From fcaa54939e9a4f0dd5e47cd0ccffe7aa24bd451c Mon Sep 17 00:00:00 2001 From: wan Date: Fri, 2 Apr 2021 10:33:24 +0000 Subject: [FIX] account: never set default for invoice_date For customer invoices: * do not set default date because if you prepare an invoice (and it gets a default date), then validate it the next day, the date will be wrong * set the date when posting if it wasn't set, because why not? For vendor bills: * do not set default date because you rarely encode a bill at the bill date. Forcing the user to enter it reduces risks of user error (duplicated vendor bill) * do not set it when posting, same reason. opw-2492862 Related #68368 Closes #68367 closes odoo/odoo#68689 Related: odoo/enterprise#17502 Signed-off-by: Laurent Smet --- addons/sale/tests/test_reinvoice.py | 7 ++++++- addons/sale/tests/test_sale_order.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'addons/sale') diff --git a/addons/sale/tests/test_reinvoice.py b/addons/sale/tests/test_reinvoice.py index 6ba53f7e24b..56e887fa9ce 100644 --- a/addons/sale/tests/test_reinvoice.py +++ b/addons/sale/tests/test_reinvoice.py @@ -26,7 +26,12 @@ class TestReInvoice(TestSaleCommon): 'pricelist_id': cls.company_data['default_pricelist'].id, }) - cls.AccountMove = cls.env['account.move'].with_context(default_move_type='in_invoice', mail_notrack=True, mail_create_nolog=True) + cls.AccountMove = cls.env['account.move'].with_context( + default_move_type='in_invoice', + default_invoice_date=cls.sale_order.date_order, + mail_notrack=True, + mail_create_nolog=True, + ) def test_at_cost(self): """ Test vendor bill at cost for product based on ordered and delivered quantities. """ diff --git a/addons/sale/tests/test_sale_order.py b/addons/sale/tests/test_sale_order.py index bfdfa219b0c..3a9ace87e02 100644 --- a/addons/sale/tests/test_sale_order.py +++ b/addons/sale/tests/test_sale_order.py @@ -240,6 +240,7 @@ class TestSaleOrder(TestSaleCommon): inv = self.env['account.move'].with_context(default_move_type='in_invoice').create({ 'partner_id': self.partner_a.id, + 'invoice_date': so.date_order, 'invoice_line_ids': [ (0, 0, { 'name': serv_cost.name, -- cgit v1.2.3