From 7b60ffaec4e1718ec6be1973ede77e880c9d2e22 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Mon, 6 Sep 2021 15:09:56 +0000 Subject: [PATCH] [FIX] account: accrued SO/PO process * the cache_invalidate() was invalidating the changes made in the wizard as well, make it impossible to set any value other than the default one, even though the preview entry was updated accordingly. That also prevented to simply validate the wizard as the accrual account was required but reset anytime we changed its value. * the preview_data field was incorrectly set as Binary while the widget only supports Text Part-of: odoo/odoo#76037 --- addons/account/wizard/accrued_orders.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/wizard/accrued_orders.py b/addons/account/wizard/accrued_orders.py index 69c0aa73821..f40139c8b1a 100644 --- a/addons/account/wizard/accrued_orders.py +++ b/addons/account/wizard/accrued_orders.py @@ -52,7 +52,7 @@ class AccruedExpenseRevenue(models.TransientModel): check_company=True, domain=_get_account_domain, ) - preview_data = fields.Binary(compute='_compute_preview_data') + preview_data = fields.Text(compute='_compute_preview_data') display_amount = fields.Boolean(compute='_compute_display_amount') @api.depends('date', 'amount') @@ -126,6 +126,7 @@ class AccruedExpenseRevenue(models.TransientModel): raise UserError(_('Entries can only be created for a single company at a time.')) orders_with_entries = [] + fnames = [] for order in orders: total_balance = 0.0 total_amount_currency = 0.0 @@ -164,16 +165,18 @@ class AccruedExpenseRevenue(models.TransientModel): account = order_line.product_id.property_account_expense_id or order_line.product_id.categ_id.property_account_expense_categ_id amount = self.company_id.currency_id.round(order_line.qty_to_invoice * order_line.price_unit / rate) amount_currency = order_line.currency_id.round(order_line.qty_to_invoice * order_line.price_unit) + fnames = ['qty_to_invoice', 'qty_received', 'qty_invoiced', 'invoice_lines'] else: account = order_line.product_id.property_account_income_id or order_line.product_id.categ_id.property_account_income_categ_id amount = self.company_id.currency_id.round(order_line.untaxed_amount_to_invoice / rate) amount_currency = order_line.untaxed_amount_to_invoice + fnames = ['qty_to_invoice', 'untaxed_amount_to_invoice', 'qty_invoiced', 'qty_delivered', 'invoice_lines'] inc_exp_accounts[account]['amount'] += amount inc_exp_accounts[account]['amount_currency'] += amount_currency total_balance += amount total_amount_currency += amount_currency # must invalidate cache or o can mess when _create_invoices().action_post() of original order after this - self.invalidate_cache() + order.order_line.invalidate_cache(fnames=fnames) if not self.company_id.currency_id.is_zero(total_balance): orders_with_entries.append(order)