From a5801a12b5ecd0cd6f3beb0854a65e69a8f962d1 Mon Sep 17 00:00:00 2001 From: det Date: Tue, 7 Mar 2023 13:28:23 +0000 Subject: [PATCH] [IMP] l10n_hu, l10n_sa, account: delivery date + hu brush up In this pr, we have improved the l10n_hu localization by adding a Tax rounding (global) by default. Also, a lot of localization will need a delivery date on invoices. We added a field in account that can be overridden if needed. In this pr, we did an override on l10n_sa and l10n_hu. When creating a sale order and that the effective date is fill, we take this value for the delivery date. The delivery date field will always be displayed in the other info tab, and if there is a delivery data, the field is also display in the header of the form view. Exception for l10n_sa and l10n_hu where the delivery date is always present. Also for l10n_sa company there was a problem with the vat number, it was not in the right format. Task-id: 3191530 Part-of: odoo/odoo#116643 --- addons/account/demo/account_demo.py | 6 +++++ addons/account/models/account_move.py | 17 ++++++++++++++ addons/account/views/account_move_views.xml | 4 +++- addons/account/views/report_invoice.xml | 4 ++++ addons/l10n_hu/models/__init__.py | 1 + addons/l10n_hu/models/account_move.py | 22 +++++++++++++++++++ addons/l10n_hu/models/template_hu.py | 1 + addons/l10n_sa/__manifest__.py | 1 - addons/l10n_sa/models/account_move.py | 22 +++++++++---------- addons/l10n_sa/views/report_invoice.xml | 4 ++-- addons/l10n_sa/views/view_move_form.xml | 15 ------------- .../models/account_edi_xml_ubl_21_zatca.py | 2 +- addons/sale_stock/models/account_move.py | 13 ++++++++++- 13 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 addons/l10n_hu/models/account_move.py delete mode 100644 addons/l10n_sa/views/view_move_form.xml diff --git a/addons/account/demo/account_demo.py b/addons/account/demo/account_demo.py index 4e9facb2635..febd0e41f64 100644 --- a/addons/account/demo/account_demo.py +++ b/addons/account/demo/account_demo.py @@ -66,6 +66,7 @@ class AccountChartTemplate(models.AbstractModel): 'invoice_user_id': 'base.user_demo', 'invoice_payment_term_id': 'account.account_payment_term_end_following_month', 'invoice_date': time.strftime('%Y-%m-01'), + 'delivery_date': time.strftime('%Y-%m-01'), 'invoice_line_ids': [ Command.create({'product_id': 'product.consu_delivery_02', 'quantity': 5}), Command.create({'product_id': 'product.consu_delivery_03', 'quantity': 5}), @@ -76,6 +77,7 @@ class AccountChartTemplate(models.AbstractModel): 'partner_id': 'base.res_partner_2', 'invoice_user_id': False, 'invoice_date': time.strftime('%Y-%m-08'), + 'delivery_date': time.strftime('%Y-%m-08'), 'invoice_line_ids': [ Command.create({'product_id': 'product.consu_delivery_03', 'quantity': 5}), Command.create({'product_id': 'product.consu_delivery_01', 'quantity': 20}), @@ -86,6 +88,7 @@ class AccountChartTemplate(models.AbstractModel): 'partner_id': 'base.res_partner_2', 'invoice_user_id': False, 'invoice_date': time.strftime('%Y-%m-08'), + 'delivery_date': time.strftime('%Y-%m-08'), 'invoice_line_ids': [ Command.create({'product_id': 'product.consu_delivery_01', 'quantity': 5}), Command.create({'product_id': 'product.consu_delivery_03', 'quantity': 5}), @@ -97,6 +100,7 @@ class AccountChartTemplate(models.AbstractModel): 'invoice_user_id': 'base.user_demo', 'invoice_payment_term_id': 'account.account_payment_term_immediate', 'invoice_date': (fields.Date.today() + timedelta(days=-15)).strftime('%Y-%m-%d'), + 'delivery_date': (fields.Date.today() + timedelta(days=-15)).strftime('%Y-%m-%d'), 'invoice_line_ids': [ Command.create({'product_id': 'product.consu_delivery_02', 'quantity': 5}), Command.create({'product_id': 'product.consu_delivery_03', 'quantity': 5}), @@ -108,6 +112,7 @@ class AccountChartTemplate(models.AbstractModel): 'invoice_user_id': 'base.user_demo', 'invoice_payment_term_id': 'account.account_payment_term_end_following_month', 'invoice_date': time.strftime('%Y-%m-01'), + 'delivery_date': time.strftime('%Y-%m-01'), 'invoice_line_ids': [ Command.create({'product_id': 'product.product_delivery_01', 'price_unit': 10.0, 'quantity': 1}), Command.create({'product_id': 'product.product_order_01', 'price_unit': 4.0, 'quantity': 5}), @@ -123,6 +128,7 @@ class AccountChartTemplate(models.AbstractModel): 'partner_id': 'base.res_partner_12', 'invoice_user_id': False, 'invoice_date': fifteen_months_ago.strftime("%Y-%m-17"), + 'delivery_date': fifteen_months_ago.strftime("%Y-%m-17"), 'invoice_line_ids': [ Command.create({'name': 'Redeem Reference Number: PO02529', 'quantity': 1, 'price_unit': 541.10, 'tax_ids': self.env.company.account_purchase_tax_id.ids}), diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 8cdc03995a5..f4575f2f42f 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -286,6 +286,15 @@ class AccountMove(models.Model): index=True, copy=False, ) + delivery_date = fields.Date( + string='Delivery Date', + copy=False, + readonly=True, + store=True, + compute='_compute_delivery_date', + states={'draft': [('readonly', False)]}, + ) + show_delivery_date = fields.Boolean(compute='_compute_show_delivery_date') invoice_payment_term_id = fields.Many2one( comodel_name='account.payment.term', string='Payment Terms', @@ -842,6 +851,14 @@ class AccountMove(models.Model): default=False, ) or move.invoice_date_due or today + def _compute_delivery_date(self): + pass + + @api.depends('delivery_date') + def _compute_show_delivery_date(self): + for move in self: + move.show_delivery_date = move.delivery_date and move.is_sale_document() + @api.depends('journal_id', 'statement_line_id') def _compute_currency_id(self): for invoice in self: diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 584c264f6eb..95f8b7217eb 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -758,6 +758,7 @@ +
@@ -845,7 +846,7 @@ placeholder="Payment Terms" options="{'no_quick_create':True}"/>
- +