From e9b807366c0b22823ce27020e884d38c50a3d77a Mon Sep 17 00:00:00 2001 From: william Date: Fri, 21 Oct 2022 14:29:29 +0000 Subject: [PATCH] [FIX] account: import invoice with tax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The import feature is using a `=` as the operator. To reproduce: Import a file like this ``` partner_id,journal_id,currency_id,date,invoice_line_ids/account,invoice_line_ids/name,invoice_line_ids/quantity,invoice_line_ids/price_unit,invoice_line_ids/taxes Publiroute,Customer invoices,EUR,18/06/2021,700000,Prof services 05/2021,1,100,21% ``` In this case, the ORM would look for a tax with the name equal to `2%1` instead of `21%`. This of course valid for any other way of using the equality operator in the domain. closes odoo/odoo#104764 X-original-commit: af46d8a567215a07b18d00f7d513681d385a8e7b Signed-off-by: Julien Castiaux Signed-off-by: William André (wan) --- addons/account/models/account_tax.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py index 2fbeb99bb84..7439f3aee04 100644 --- a/addons/account/models/account_tax.py +++ b/addons/account/models/account_tax.py @@ -193,12 +193,14 @@ class AccountTax(models.Model): return '%'.join(list(name)) @api.model - def name_search(self, name='', args=None, operator='ilike', limit=100): - return super().name_search(name=AccountTax._parse_name_search(name), args=args, operator=operator, limit=limit) + def _name_search(self, name='', args=None, operator='ilike', limit=100, name_get_uid=None): + if operator in ("ilike", "like"): + name = AccountTax._parse_name_search(name) + return super()._name_search(name, args, operator, limit, name_get_uid) def _search_name(self, operator, value): if operator not in ("ilike", "like") or not isinstance(value, str): - return super()._search_name(operator, value) + return [('name', operator, value)] return [('name', operator, AccountTax._parse_name_search(value))] def _check_repartition_lines(self, lines):