From a27aa23a4534593783573174f6a3af652ab37787 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 30 Dec 2022 01:19:19 +0100 Subject: [PATCH] [MIG] account_fiscal_position_partner_type: Migration to 16.0 --- .../__manifest__.py | 2 +- .../models/account_fiscal_position.py | 19 +++++++++---------- .../models/res_partner.py | 2 +- ...st_account_fiscal_position_partner_type.py | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/account_fiscal_position_partner_type/__manifest__.py b/account_fiscal_position_partner_type/__manifest__.py index e1dc166a7..347c817a7 100644 --- a/account_fiscal_position_partner_type/__manifest__.py +++ b/account_fiscal_position_partner_type/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Account Fiscal Position Partner Type", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "category": "Accounting & Finance", "website": "https://github.com/OCA/account-fiscal-rule", "author": "Sygel Technology," "Odoo Community Association (OCA)", diff --git a/account_fiscal_position_partner_type/models/account_fiscal_position.py b/account_fiscal_position_partner_type/models/account_fiscal_position.py index 2d2715e22..e907e9ac7 100644 --- a/account_fiscal_position_partner_type/models/account_fiscal_position.py +++ b/account_fiscal_position_partner_type/models/account_fiscal_position.py @@ -15,11 +15,11 @@ class AccountFiscalPosition(models.Model): ) @api.model - def search(self, args, offset=0, limit=None, order=None, count=False): + def search(self, domain, offset=0, limit=None, order=None, count=False): if self.env.context.get("fiscal_position_type"): - args = expression.AND( + domain = expression.AND( ( - args, + domain, [ ( "fiscal_position_type", @@ -30,21 +30,20 @@ def search(self, args, offset=0, limit=None, order=None, count=False): ) ) return super().search( - args, offset=offset, limit=limit, order=order, count=count + domain, offset=offset, limit=limit, order=order, count=count ) @api.model - def get_fiscal_position(self, partner_id, delivery_id=None): + def _get_fiscal_position(self, partner, delivery=None): fiscal_type = False - if partner_id: - delivery = self.env["res.partner"].browse(delivery_id or partner_id) + if partner: + delivery = delivery or partner # Only type has been configured if ( delivery.fiscal_position_type and not delivery.property_account_position_id ): fiscal_type = delivery.fiscal_position_type - fp_id = super( + return super( AccountFiscalPosition, self.with_context(fiscal_position_type=fiscal_type) - ).get_fiscal_position(partner_id=partner_id, delivery_id=delivery_id) - return fp_id + )._get_fiscal_position(partner=partner, delivery=delivery) diff --git a/account_fiscal_position_partner_type/models/res_partner.py b/account_fiscal_position_partner_type/models/res_partner.py index cca22e141..3e5b3600b 100644 --- a/account_fiscal_position_partner_type/models/res_partner.py +++ b/account_fiscal_position_partner_type/models/res_partner.py @@ -20,4 +20,4 @@ def _selection_fiscal_position_type(self): @api.model def _commercial_fields(self): - return super(ResPartner, self)._commercial_fields() + ["fiscal_position_type"] + return super()._commercial_fields() + ["fiscal_position_type"] diff --git a/account_fiscal_position_partner_type/tests/test_account_fiscal_position_partner_type.py b/account_fiscal_position_partner_type/tests/test_account_fiscal_position_partner_type.py index 1031c28ce..1b9c2faae 100644 --- a/account_fiscal_position_partner_type/tests/test_account_fiscal_position_partner_type.py +++ b/account_fiscal_position_partner_type/tests/test_account_fiscal_position_partner_type.py @@ -7,7 +7,7 @@ class TestAccountFiscalPositionPartnerType(common.TransactionCase): def setUp(self): - super(TestAccountFiscalPositionPartnerType, self).setUp() + super().setUp() # MODELS self.res_partner_model = self.env["res.partner"] self.fiscal_position_model = self.env["account.fiscal.position"]