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}"/>
- +