From 9a713ee70d31b63e6d863748941ba596ca2c5ac2 Mon Sep 17 00:00:00 2001 From: "Achraf (abz)" Date: Wed, 30 Nov 2022 15:17:45 +0000 Subject: [PATCH] [FIX] account,purchase,sale: Export fail when dict passed to write function A `TypeError` traceback that occurs in `xlsxwriter.worksheet._write` was caught by Sentry. The problem is that there is a binary field which is used by `account` module as a compute field with a python `dict`. https://github.com/odoo/odoo/blob/76a640d05a350840bdde1c88bd052251aabd6b12/addons/account/models/account_move.py#L426-L431 https://github.com/odoo/odoo/blob/a542cb3b3d1232f0e2dec58a220a4b35fb76cc7f/addons/l10n_cl/models/account_move.py#L148-L163 Variables of type dict were not supported by the exporter, the solution is to use a fix already made before in 16.0 (https://github.com/odoo/odoo/pull/105043) by making `tax_totals` non-exportable opw-3086746 closes odoo/odoo#107386 X-original-commit: f1ad538ba2a45b510b3dda792e39bc7593ba81b5 Signed-off-by: Olivier Colson (oco) Signed-off-by: Achraf --- addons/account/models/account_move.py | 1 + addons/purchase/models/purchase.py | 2 +- addons/sale/models/sale_order.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 0d7d1424290..b7b3e4ed8d6 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -428,6 +428,7 @@ class AccountMove(models.Model): compute='_compute_tax_totals', inverse='_inverse_tax_totals', help='Edit Tax amounts if you encounter rounding issues.', + exportable=False, ) payment_state = fields.Selection( selection=[ diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 78e630018cb..a52d492895b 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -110,7 +110,7 @@ class PurchaseOrder(models.Model): date_calendar_start = fields.Datetime(compute='_compute_date_calendar_start', readonly=True, store=True) amount_untaxed = fields.Monetary(string='Untaxed Amount', store=True, readonly=True, compute='_amount_all', tracking=True) - tax_totals = fields.Binary(compute='_compute_tax_totals') + tax_totals = fields.Binary(compute='_compute_tax_totals', exportable=False) amount_tax = fields.Monetary(string='Taxes', store=True, readonly=True, compute='_amount_all') amount_total = fields.Monetary(string='Total', store=True, readonly=True, compute='_amount_all') diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index 77595b4064c..274de8bd492 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -276,7 +276,7 @@ class SaleOrder(models.Model): compute='_compute_tax_country_id', # Avoid access error on fiscal position when reading a sale order with company != user.company_ids compute_sudo=True) # used to filter available taxes depending on the fiscal country and position - tax_totals = fields.Binary(compute='_compute_tax_totals') + tax_totals = fields.Binary(compute='_compute_tax_totals', exportable=False) terms_type = fields.Selection(related='company_id.terms_type') type_name = fields.Char(string="Type Name", compute='_compute_type_name')