From 3764914c8616bf59d299e6279cc6fc93321cdacb Mon Sep 17 00:00:00 2001 From: hupo-odoo Date: Fri, 13 Jan 2023 11:07:30 +0000 Subject: [PATCH] [IMP] account : invoice layout improvement Modifies the invoice layout according to the mockup provided in the task. This enables to remove the blank space that occured in the middle of the invoices Add the possibility to add the total amount of an invoice in words. This feature can be enabled by activating a boolean setting in Accounting settings. Task: 3097097 Pr: 107714 Part-of: odoo/odoo#107714 --- addons/account/__manifest__.py | 6 + addons/account/models/account_move.py | 17 ++- addons/account/models/company.py | 1 + addons/account/models/res_config_settings.py | 5 + .../account/static/src/css/report_invoice.css | 18 +++ addons/account/static/src/img/Odoo_logo_O.svg | 4 + addons/account/views/report_invoice.xml | 140 ++++++++++-------- .../views/res_config_settings_views.xml | 3 + 8 files changed, 127 insertions(+), 67 deletions(-) create mode 100644 addons/account/static/src/css/report_invoice.css create mode 100644 addons/account/static/src/img/Odoo_logo_O.svg diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py index 77bd19a7810..c05398c9339 100644 --- a/addons/account/__manifest__.py +++ b/addons/account/__manifest__.py @@ -105,6 +105,12 @@ You could use this simplified accounting in case you work with an (external) acc 'account/static/tests/helpers/*.js', 'account/static/tests/*.js', ], + 'web.report_assets_common': [ + 'account/static/src/css/report_invoice.css', + ], + 'web.report_assets_pdf': [ + 'account/static/src/css/report_invoice.css', + ], }, 'license': 'LGPL-3', } diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 91140923a2c..cf6525f33cf 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -449,6 +449,10 @@ class AccountMove(models.Model): copy=False, tracking=True, ) + amount_total_words = fields.Char( + string="Amount total in words", + compute="_compute_amount_total_words", + ) # === Reverse feature fields === # reversed_entry_id = fields.Many2one( @@ -1425,12 +1429,17 @@ class AccountMove(models.Model): @api.depends('company_id') def _compute_display_qr_code(self): - for record in self: - record.display_qr_code = ( - record.move_type in ('out_invoice', 'out_receipt', 'in_invoice', 'in_receipt') - and record.company_id.qr_code + for move in self: + move.display_qr_code = ( + move.move_type in ('out_invoice', 'out_receipt', 'in_invoice', 'in_receipt') + and move.company_id.qr_code ) + @api.depends('amount_total', 'currency_id') + def _compute_amount_total_words(self): + for move in self: + move.amount_total_words = move.currency_id.amount_to_text(move.amount_total).replace(',', '') + # ------------------------------------------------------------------------- # INVERSE METHODS # ------------------------------------------------------------------------- diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 49122b4a247..e01a5fe67d1 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -102,6 +102,7 @@ class ResCompany(models.Model): invoice_is_email = fields.Boolean('Email by default', default=True) invoice_is_print = fields.Boolean('Print by default', default=True) + display_invoice_amount_total_words = fields.Boolean(string='Total amount of invoice in letters') account_use_credit_limit = fields.Boolean( string='Sales Credit Limit', help='Enable the use of credit limit on partners.') diff --git a/addons/account/models/res_config_settings.py b/addons/account/models/res_config_settings.py index cbbe11a1bc4..c32636fb0bf 100644 --- a/addons/account/models/res_config_settings.py +++ b/addons/account/models/res_config_settings.py @@ -133,6 +133,11 @@ class ResConfigSettings(models.TransientModel): readonly=False) terms_type = fields.Selection( related='company_id.terms_type', readonly=False) + display_invoice_amount_total_words = fields.Boolean( + string="Total amount of invoice in letters", + related='company_id.display_invoice_amount_total_words', + readonly=False + ) preview_ready = fields.Boolean(string="Display preview button", compute='_compute_terms_preview') use_invoice_terms = fields.Boolean( diff --git a/addons/account/static/src/css/report_invoice.css b/addons/account/static/src/css/report_invoice.css new file mode 100644 index 00000000000..7abb185c986 --- /dev/null +++ b/addons/account/static/src/css/report_invoice.css @@ -0,0 +1,18 @@ +#payment_terms_note_id > p { + margin-bottom: 0 !important; +} + +.avoid-page-break-inside { + page-break-inside: avoid; +} + +.justify-text { + text-align:justify; + text-justify:inter-word; +} + +#qrcode_odoo_logo { + -webkit-transform:translate(-50%,-50%); + height:18%; + width:18%; +} diff --git a/addons/account/static/src/img/Odoo_logo_O.svg b/addons/account/static/src/img/Odoo_logo_O.svg new file mode 100644 index 00000000000..e85050776ce --- /dev/null +++ b/addons/account/static/src/img/Odoo_logo_O.svg @@ -0,0 +1,4 @@ + + + + diff --git a/addons/account/views/report_invoice.xml b/addons/account/views/report_invoice.xml index 586b3f20229..4d6b904d8df 100644 --- a/addons/account/views/report_invoice.xml +++ b/addons/account/views/report_invoice.xml @@ -49,7 +49,7 @@
-
+

Invoice Draft Invoice @@ -61,28 +61,27 @@ Vendor Bill

- -
-
+
+
Invoice Date: Credit Note Date: Receipt Date: Date:

-
+
Due Date:

-
+
Source:

-
+
Customer Code:

-
+
Reference:

@@ -163,11 +162,11 @@ - -
-
-
- + +
+
+
+
@@ -194,64 +193,79 @@ - -
-
+ +
+
+

+ Total amount in words:
+ +

+
-

- Please use the following communication for your payment : -

- -
- -
-
- - - due if paid before - - - - - - - - - Installment of - - due on - - ( +
+
+

+ +

+
+ +
+
+ +
+
+ if paid before - ) - -
- - - + t-out="payment_term_details[0].get('discount_amount_currency')"/> due if paid before + +
+ +
+ - Installment of + + due on + + ( + if paid before + ) + +
+
+
+
+
+
+
+

+ Payment Communication: +

+
+
+
+ +

+ + +

+
+
+

Scan this QR Code to
pay with your mobile

-
- -
- -
-

- -

-

- Incoterm: - -

-
- -

- Scan me with your banking app.

- + +

+ +
+

+ Incoterm: -

diff --git a/addons/account/views/res_config_settings_views.xml b/addons/account/views/res_config_settings_views.xml index cd2455dd88e..b0bccbc29a6 100644 --- a/addons/account/views/res_config_settings_views.xml +++ b/addons/account/views/res_config_settings_views.xml @@ -177,6 +177,9 @@
+ + +