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}"/>
-
+
@@ -1207,6 +1208,7 @@
attrs="{'readonly': [('state', '!=', 'draft')]}"/>
+
Due Date:
+
Source:
diff --git a/addons/l10n_hu/models/__init__.py b/addons/l10n_hu/models/__init__.py
index d062ef8937b..ef9d8cfa373 100644
--- a/addons/l10n_hu/models/__init__.py
+++ b/addons/l10n_hu/models/__init__.py
@@ -1,2 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import template_hu
+from . import account_move
diff --git a/addons/l10n_hu/models/account_move.py b/addons/l10n_hu/models/account_move.py
new file mode 100644
index 00000000000..b7e7e5e17aa
--- /dev/null
+++ b/addons/l10n_hu/models/account_move.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from odoo import api, models
+
+
+class AccountMove(models.Model):
+ _inherit = 'account.move'
+
+ @api.depends('country_code', 'move_type')
+ def _compute_show_delivery_date(self):
+ # EXTENDS 'account'
+ super()._compute_show_delivery_date()
+ for move in self:
+ if move.country_code == 'HU':
+ move.show_delivery_date = move.is_sale_document()
+
+ def _post(self, soft=True):
+ res = super()._post(soft)
+ for move in self:
+ if move.country_code == 'HU' and move.is_sale_document() and not move.delivery_date:
+ move.delivery_date = move.invoice_date
+ return res
diff --git a/addons/l10n_hu/models/template_hu.py b/addons/l10n_hu/models/template_hu.py
index f204ccdcf2b..010275f301c 100644
--- a/addons/l10n_hu/models/template_hu.py
+++ b/addons/l10n_hu/models/template_hu.py
@@ -23,6 +23,7 @@ class AccountChartTemplate(models.AbstractModel):
return {
self.env.company.id: {
'account_fiscal_country_id': 'base.hu',
+ 'tax_calculation_rounding_method': 'round_globally',
'bank_account_code_prefix': '384',
'cash_account_code_prefix': '381',
'transfer_account_code_prefix': '389',
diff --git a/addons/l10n_sa/__manifest__.py b/addons/l10n_sa/__manifest__.py
index 60ed2132d41..da693204ff0 100644
--- a/addons/l10n_sa/__manifest__.py
+++ b/addons/l10n_sa/__manifest__.py
@@ -17,7 +17,6 @@ Odoo Arabic localization for most Saudi Arabia.
'data': [
'data/account_data.xml',
'data/account_tax_report_data.xml',
- 'views/view_move_form.xml',
'views/report_invoice.xml',
],
'demo': [
diff --git a/addons/l10n_sa/models/account_move.py b/addons/l10n_sa/models/account_move.py
index 26f450790c9..149f20fb65f 100644
--- a/addons/l10n_sa/models/account_move.py
+++ b/addons/l10n_sa/models/account_move.py
@@ -10,17 +10,16 @@ from odoo.tools import float_repr
class AccountMove(models.Model):
_inherit = 'account.move'
- l10n_sa_delivery_date = fields.Date(string='Delivery Date', default=fields.Date.context_today, copy=False,
- readonly=True, states={'draft': [('readonly', False)]},
- help="In case of multiple deliveries, you should take the date of the latest one. ")
- l10n_sa_show_delivery_date = fields.Boolean(compute='_compute_show_delivery_date')
l10n_sa_qr_code_str = fields.Char(string='Zatka QR Code', compute='_compute_qr_code_str')
l10n_sa_confirmation_datetime = fields.Datetime(string='Confirmation Date', readonly=True, copy=False)
@api.depends('country_code', 'move_type')
def _compute_show_delivery_date(self):
+ # EXTENDS 'account'
+ super()._compute_show_delivery_date()
for move in self:
- move.l10n_sa_show_delivery_date = move.country_code == 'SA' and move.move_type in ('out_invoice', 'out_refund')
+ if move.country_code == 'SA':
+ move.show_delivery_date = move.is_sale_document()
@api.depends('amount_total_signed', 'amount_tax_signed', 'l10n_sa_confirmation_datetime', 'company_id', 'company_id.vat')
def _compute_qr_code_str(self):
@@ -49,11 +48,10 @@ class AccountMove(models.Model):
def _post(self, soft=True):
res = super()._post(soft)
- for record in self:
- if record.country_code == 'SA' and record.move_type in ('out_invoice', 'out_refund'):
- if not record.l10n_sa_show_delivery_date:
- raise UserError(_('Delivery Date cannot be empty'))
- self.write({
- 'l10n_sa_confirmation_datetime': fields.Datetime.now()
- })
+ for move in self:
+ if move.country_code == 'SA' and move.is_sale_document():
+ vals = {'l10n_sa_confirmation_datetime': fields.Datetime.now()}
+ if not move.delivery_date:
+ vals['delivery_date'] = move.invoice_date
+ move.write(vals)
return res
diff --git a/addons/l10n_sa/views/report_invoice.xml b/addons/l10n_sa/views/report_invoice.xml
index 47c0509c4d0..60fcec78eef 100644
--- a/addons/l10n_sa/views/report_invoice.xml
+++ b/addons/l10n_sa/views/report_invoice.xml
@@ -3,14 +3,14 @@
-
+
Delivery Date:
-
+
:
diff --git a/addons/l10n_sa/views/view_move_form.xml b/addons/l10n_sa/views/view_move_form.xml
deleted file mode 100644
index ced3c984c9b..00000000000
--- a/addons/l10n_sa/views/view_move_form.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- account.move.deliver_date
- account.move
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py b/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py
index de627c482b1..02b607b79d8 100644
--- a/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py
+++ b/addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py
@@ -91,7 +91,7 @@ class AccountEdiXmlUBL21Zatca(models.AbstractModel):
def _get_delivery_vals_list(self, invoice):
""" Override to include/update values specific to ZATCA's UBL 2.1 specs """
shipping_address = invoice.partner_shipping_id
- return [{'actual_delivery_date': invoice.l10n_sa_delivery_date,
+ return [{'actual_delivery_date': invoice.delivery_date or invoice.invoice_date,
'delivery_address_vals': self._get_partner_address_vals(shipping_address) if shipping_address else {},}]
def _get_partner_party_identification_vals_list(self, partner):
diff --git a/addons/sale_stock/models/account_move.py b/addons/sale_stock/models/account_move.py
index 7bf34ae2174..99e07f2caa2 100644
--- a/addons/sale_stock/models/account_move.py
+++ b/addons/sale_stock/models/account_move.py
@@ -3,7 +3,7 @@
from collections import defaultdict
-from odoo import fields, models
+from odoo import models, api
from odoo.tools import float_is_zero, float_compare
from odoo.tools.misc import formatLang
@@ -107,6 +107,17 @@ class AccountMove(models.Model):
return res
+ @api.depends('line_ids.sale_line_ids.order_id')
+ def _compute_delivery_date(self):
+ # EXTENDS 'account'
+ super()._compute_delivery_date()
+ for move in self:
+ sale_order_effective_date = list(filter(None, move.line_ids.sale_line_ids.order_id.mapped('effective_date')))
+ effective_date_res = max(sale_order_effective_date) if sale_order_effective_date else False
+ # if multiple sale order we take the bigger effective_date
+ if effective_date_res:
+ move.delivery_date = effective_date_res
+
class AccountMoveLine(models.Model):
_inherit = "account.move.line"