From e4818b6821f46b3bd4312307c84fc419920aa09e Mon Sep 17 00:00:00 2001 From: Julien Van Roy Date: Wed, 8 Dec 2021 09:21:38 +0000 Subject: [PATCH] [IMP] account: Invoice / Bill Outstanding Debit / credit improvement This commit: 1) fixes the customer invoice/vendor bill outstanding debit/credit warning anchor link 2) improves the customer invoice/vendor bill outstanding section 3) fixes the customer invoice/vendor bill outstanding debit/credit warning messages when viewing an account move reversal 4) modifies the order of the 'invoice lines' tab for mobile view 1) The anchor link did not work when pointing to a field (the id of a field is not propagated into the DOM). Hence,the target field is put inside a div with the correct id. 2) The outstanding section is placed to the right, below the amount due and next to the description for clarity purpose. The 'Add' button is turned into a secondary button (s.t. it is more noticeable). Each entry name is now a link to to the corresponding account move. 3) The warning messages are modified because they were not consistent and confusing when viewing an account move reversal. 4) Previously, the order on the 'invoice lines' tab was: narration>total>widget, now it is: total>widget>narration task-2669132 closes odoo/odoo#78550 Signed-off-by: Laurent Smet --- addons/account/models/account_move.py | 3 +- addons/account/static/src/css/account.css | 31 ++++++++++---- .../static/src/js/account_payment_field.js | 19 +++++---- .../static/src/xml/account_payment.xml | 25 ++++++++--- addons/account/views/account_move_views.xml | 42 ++++++++++++------- 5 files changed, 83 insertions(+), 37 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 181b2eff61e..5479949a2d4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1607,7 +1607,8 @@ class AccountMove(models.Model): 'move_id': line.move_id.id, 'position': move.currency_id.position, 'digits': [69, move.currency_id.decimal_places], - 'payment_date': fields.Date.to_string(line.date), + 'date': fields.Date.to_string(line.date), + 'account_payment_id': line.payment_id.id, }) if not payments_widget_vals['content']: diff --git a/addons/account/static/src/css/account.css b/addons/account/static/src/css/account.css index 486b8225bfa..84f2a2c0863 100644 --- a/addons/account/static/src/css/account.css +++ b/addons/account/static/src/css/account.css @@ -27,16 +27,31 @@ .oe_invoice_outstanding_credits_debits { clear: both; float: right; - min-width: 350px; -} - -@media (max-width: 767.98px) { - .oe_invoice_outstanding_credits_debits { - min-width: initial; - width: 100%; - } + min-width: 260px; + padding-top: 20px; } .oe_account_terms { flex: auto !important; } + +@media (max-width: 991.98px) { + /* The purpose is to put the narration below the totals in the tab 'Invoice Lines' + instead of above for the mobile view */ + .o_form_view .oe_invoice_lines_tab { + display: flex; + flex-direction: column-reverse; + } + + .o_form_view .oe_invoice_lines_tab .oe_invoice_outstanding_credits_debits { + min-width: initial; + width: 50%; + } +} + +@media (max-width: 767.98px) { + .o_form_view .oe_invoice_lines_tab .oe_invoice_outstanding_credits_debits { + min-width: initial; + width: 100%; + } +} diff --git a/addons/account/static/src/js/account_payment_field.js b/addons/account/static/src/js/account_payment_field.js index fa56d1a1858..8fe3a9bc568 100644 --- a/addons/account/static/src/js/account_payment_field.js +++ b/addons/account/static/src/js/account_payment_field.js @@ -12,6 +12,7 @@ var _t = core._t; var ShowPaymentLineWidget = AbstractField.extend({ events: _.extend({ 'click .outstanding_credit_assign': '_onOutstandingCreditAssign', + 'click .open_account_move': '_onOpenPaymentOrMove', }, AbstractField.prototype.events), supportedFieldTypes: ['char'], @@ -36,6 +37,7 @@ var ShowPaymentLineWidget = AbstractField.extend({ * @override */ _render: function() { + this.viewAlreadyOpened = false; var self = this; var info = JSON.parse(this.value); if (!info) { @@ -62,7 +64,7 @@ var ShowPaymentLineWidget = AbstractField.extend({ var $content = $(QWeb.render('PaymentPopOver', content)); var unreconcile_button = $content.filter('.js_unreconcile_payment').on('click', self._onRemoveMoveReconcile.bind(self)); - $content.filter('.js_open_payment').on('click', self._onOpenPayment.bind(self)); + $content.filter('.js_open_payment').on('click', self._onOpenPaymentOrMove.bind(self)); return $content; }, html: true, @@ -85,23 +87,26 @@ var ShowPaymentLineWidget = AbstractField.extend({ * @override * @param {MouseEvent} event */ - _onOpenPayment: function (event) { + _onOpenPaymentOrMove: function (event) { var paymentId = parseInt($(event.target).attr('payment-id')); var moveId = parseInt($(event.target).attr('move-id')); - var res_model; + var resModel; var id; if (paymentId !== undefined && !isNaN(paymentId)){ - res_model = "account.payment"; + resModel = "account.payment"; id = paymentId; } else if (moveId !== undefined && !isNaN(moveId)){ - res_model = "account.move"; + resModel = "account.move"; id = moveId; } //Open form view of account.move with id = move_id - if (res_model && id) { + //viewAlreadyopened is a flag to prevent the user from clicking on another account.move/account.payment + //while the first one he clicked on is loading + if (!this.viewAlreadyOpened && resModel && id) { + this.viewAlreadyOpened = true; this.do_action({ type: 'ir.actions.act_window', - res_model: res_model, + res_model: resModel, res_id: id, views: [[false, 'form']], target: 'current' diff --git a/addons/account/static/src/xml/account_payment.xml b/addons/account/static/src/xml/account_payment.xml index c752f838123..01670e5b25d 100644 --- a/addons/account/static/src/xml/account_payment.xml +++ b/addons/account/static/src/xml/account_payment.xml @@ -6,7 +6,7 @@
- +
@@ -14,15 +14,28 @@ - - +
- Add + Add -
+
+ - + Paid on @@ -73,7 +86,7 @@
Payment Journal: Journal: ()
diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 52c398aa599..97a1a9da2b8 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -653,14 +653,24 @@
+ +