Skip to content

Commit

Permalink
[MIG] account_fiscal_position_partner_type: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoBM committed Mar 30, 2023
1 parent 62db8d1 commit 5230649
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 33 deletions.
2 changes: 1 addition & 1 deletion account_fiscal_position_partner_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
57 changes: 57 additions & 0 deletions account_fiscal_position_partner_type/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_fiscal_position_partner_type
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-03-30 07:56+0000\n"
"PO-Revision-Date: 2023-03-30 07:56+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_fiscal_position_partner_type
#: model:ir.model,name:account_fiscal_position_partner_type.model_res_company
msgid "Companies"
msgstr "Compañías"

#. module: account_fiscal_position_partner_type
#: model:ir.model.fields.selection,name:account_fiscal_position_partner_type.selection__account_fiscal_position__fiscal_position_type__b2b
msgid "Company (B2B)"
msgstr "Compañía (B2B)"

#. module: account_fiscal_position_partner_type
#: model:ir.model,name:account_fiscal_position_partner_type.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: account_fiscal_position_partner_type
#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_company__default_fiscal_position_type
msgid "Default Partner Fiscal Position Type"
msgstr "Tipo posición fiscal predeterminada"

#. module: account_fiscal_position_partner_type
#: model:ir.model.fields.selection,name:account_fiscal_position_partner_type.selection__account_fiscal_position__fiscal_position_type__b2c
msgid "End customer (B2C)"
msgstr "Consumidor final (B2C)"

#. module: account_fiscal_position_partner_type
#: model:ir.model,name:account_fiscal_position_partner_type.model_account_fiscal_position
msgid "Fiscal Position"
msgstr "Posición fiscal"

#. module: account_fiscal_position_partner_type
#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_partner__fiscal_position_type
#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_users__fiscal_position_type
msgid "Fiscal Position Type"
msgstr "Tipo posición fiscal"

#. module: account_fiscal_position_partner_type
#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_account_fiscal_position__fiscal_position_type
msgid "Type"
msgstr "Tipo"
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
2 changes: 1 addition & 1 deletion account_fiscal_position_partner_type/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,42 @@


class TestAccountFiscalPositionPartnerType(common.TransactionCase):
def setUp(self):
super(TestAccountFiscalPositionPartnerType, self).setUp()
@classmethod
def setUpClass(cls):
super().setUpClass()
# MODELS
self.res_partner_model = self.env["res.partner"]
self.fiscal_position_model = self.env["account.fiscal.position"]
cls.res_partner_model = cls.env["res.partner"]
cls.fiscal_position_model = cls.env["account.fiscal.position"]
# INSTANCES
# Company
self.company_main = self.env.ref("base.main_company")
self.company_main.default_fiscal_position_type = "b2b"
cls.company_main = cls.env.ref("base.main_company")
cls.company_main.default_fiscal_position_type = "b2b"
# Fiscal Positions
self.fiscal_position_test = self.fiscal_position_model.create(
cls.fiscal_position_test = cls.fiscal_position_model.create(
{
"name": "Test",
"auto_apply": False,
"fiscal_position_type": False,
"sequence": 1,
}
)
self.fiscal_position_empty = self.fiscal_position_model.create(
cls.fiscal_position_empty = cls.fiscal_position_model.create(
{
"name": "Empty",
"auto_apply": True,
"fiscal_position_type": False,
"sequence": 2,
}
)
self.fiscal_position_b2c = self.fiscal_position_model.create(
cls.fiscal_position_b2c = cls.fiscal_position_model.create(
{
"name": "b2c",
"auto_apply": True,
"fiscal_position_type": "b2c",
"sequence": 3,
}
)
self.fiscal_position_b2b = self.fiscal_position_model.create(
cls.fiscal_position_b2b = cls.fiscal_position_model.create(
{
"name": "b2b",
"auto_apply": True,
Expand All @@ -49,21 +50,21 @@ def setUp(self):
}
)
# Partners
self.partner_01 = self.env.ref("base.res_partner_1")
self.partner_01.write({"fiscal_position_type": False})
self.partner_02 = self.env.ref("base.res_partner_2")
self.partner_02.write({"fiscal_position_type": "b2c"})
self.partner_03 = self.env.ref("base.res_partner_3")
self.partner_03.write({"fiscal_position_type": "b2b"})
self.partner_04 = self.env.ref("base.res_partner_4")
self.partner_04.write(
cls.partner_01 = cls.env.ref("base.res_partner_1")
cls.partner_01.write({"fiscal_position_type": False})
cls.partner_02 = cls.env.ref("base.res_partner_2")
cls.partner_02.write({"fiscal_position_type": "b2c"})
cls.partner_03 = cls.env.ref("base.res_partner_3")
cls.partner_03.write({"fiscal_position_type": "b2b"})
cls.partner_04 = cls.env.ref("base.res_partner_4")
cls.partner_04.write(
{
"fiscal_position_type": "b2b",
"property_account_position_id": self.fiscal_position_test.id,
"property_account_position_id": cls.fiscal_position_test.id,
}
)
self.partner_05 = self.env.ref("base.res_partner_10")
self.partner_05.write({"fiscal_position_type": "b2b"})
cls.partner_05 = cls.env.ref("base.res_partner_10")
cls.partner_05.write({"fiscal_position_type": "b2b"})

def _invoice_sale_create(self, partner):
invoice_form = Form(
Expand Down

0 comments on commit 5230649

Please sign in to comment.