diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py index 522f7ca5ee9..fb08a1befc3 100644 --- a/addons/account/__manifest__.py +++ b/addons/account/__manifest__.py @@ -108,6 +108,7 @@ You could use this simplified accounting in case you work with an (external) acc 'account/static/src/js/tours/account.js', 'account/static/src/js/bills_upload.js', 'account/static/src/js/account_selection.js', + 'account/static/src/js/open_move_widget.js', ], 'web.assets_frontend': [ 'account/static/src/js/account_portal_sidebar.js', diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 06573243196..0954e379559 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2223,15 +2223,7 @@ class AccountMove(models.Model): def name_get(self): result = [] for move in self: - if self._context.get('name_groupby'): - name = '**%s**, %s' % (format_date(self.env, move.date), move._get_move_display_name()) - if move.ref: - name += ' (%s)' % move.ref - if move.partner_id.name: - name += ' - %s' % move.partner_id.name - else: - name = move._get_move_display_name(show_ref=True) - result.append((move.id, name)) + result.append((move.id, move._get_move_display_name(show_ref=True))) return result # ------------------------------------------------------------------------- @@ -3525,7 +3517,7 @@ class AccountMoveLine(models.Model): index=True, required=True, readonly=True, auto_join=True, ondelete="cascade", check_company=True, help="The move of this entry line.") - move_name = fields.Char(string='Number', related='move_id.name', store=True, index='trigram') + move_name = fields.Char(string='Number', related='move_id.name', store=True, index='btree') date = fields.Date(related='move_id.date', store=True, readonly=True, index=True, copy=False, group_operator='min') ref = fields.Char(related='move_id.ref', store=True, copy=False, index='trigram', readonly=True) parent_state = fields.Selection(related='move_id.state', store=True, readonly=True) @@ -3534,6 +3526,7 @@ class AccountMoveLine(models.Model): company_currency_id = fields.Many2one(related='company_id.currency_id', string='Company Currency', readonly=True, store=True, help='Utility field to express amount currency') + is_same_currency = fields.Boolean(compute='_compute_same_currency') is_storno = fields.Boolean( related='move_id.is_storno', string='Company Storno Accounting', @@ -3640,6 +3633,7 @@ class AccountMoveLine(models.Model): matched_credit_ids = fields.One2many('account.partial.reconcile', 'debit_move_id', string='Matched Credits', help='Credit journal items that are matched with this journal item.', readonly=True) matching_number = fields.Char(string="Matching #", compute='_compute_matching_number', store=True, help="Matching number for this line, 'P' if it is only partially reconcile, or the name of the full reconcile if it exists.") + is_account_reconcile = fields.Boolean(related='account_id.reconcile', string='Account Reconcile', help='Technical field for the matching link widget') # ==== Analytic fields ==== analytic_line_ids = fields.One2many('account.analytic.line', 'move_id', string='Analytic lines') @@ -4388,6 +4382,11 @@ class AccountMoveLine(models.Model): record.tax_audit = audit_str + @api.depends('currency_id', 'company_currency_id') + def _compute_same_currency(self): + for record in self: + record.is_same_currency = record.currency_id == record.company_currency_id + # ------------------------------------------------------------------------- # CONSTRAINT METHODS # ------------------------------------------------------------------------- @@ -5884,13 +5883,22 @@ class AccountMoveLine(models.Model): return action def open_move(self): - return { - 'type': 'ir.actions.act_window', - 'res_model': 'account.move', - 'view_mode': 'form', - 'res_id': self.move_id.id, - 'views': [(False, 'form')], - } + if self.payment_id: + return { + 'type': 'ir.actions.act_window', + 'res_model': 'account.payment', + 'view_mode': 'form', + 'res_id': self.payment_id.id, + 'views': [(False, 'form')], + } + else: + return { + 'type': 'ir.actions.act_window', + 'res_model': 'account.move', + 'view_mode': 'form', + 'res_id': self.move_id.id, + 'views': [(False, 'form')], + } def action_automatic_entry(self): diff --git a/addons/account/static/src/js/open_move_widget.js b/addons/account/static/src/js/open_move_widget.js new file mode 100644 index 00000000000..78901317e68 --- /dev/null +++ b/addons/account/static/src/js/open_move_widget.js @@ -0,0 +1,23 @@ +/** @odoo-module **/ +import fieldRegistry from 'web.field_registry'; +import { FieldChar } from 'web.basic_fields'; + +const OpenMoveWidget = FieldChar.extend({ + template: 'account.OpenMoveTemplate', + events: Object.assign({}, FieldChar.prototype.events, { + 'click': '_onOpenMove', + }), + _onOpenMove: function(ev) { + ev.preventDefault(); + ev.stopPropagation(); + var self = this; + this._rpc({ + model: 'account.move.line', + method: 'open_move', + args: [this.res_id], + }).then(function (actionData){ + return self.do_action(actionData); + }); + }, +}); +fieldRegistry.add('open_move_widget', OpenMoveWidget); diff --git a/addons/account/static/src/xml/grouped_view_widget.xml b/addons/account/static/src/xml/grouped_view_widget.xml index 6852c036290..b187277418e 100644 --- a/addons/account/static/src/xml/grouped_view_widget.xml +++ b/addons/account/static/src/xml/grouped_view_widget.xml @@ -33,4 +33,8 @@ + + + + diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 09fe23a2f66..f2c6088a1c1 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -150,100 +150,40 @@ account.move.line - + - - + + - - - + + + - - - + + + + - - + + + + + + + + + + - - - - - - - -