diff --git a/account_fiscal_position_partner_type/README.rst b/account_fiscal_position_partner_type/README.rst new file mode 100644 index 000000000..d0491e6c8 --- /dev/null +++ b/account_fiscal_position_partner_type/README.rst @@ -0,0 +1,100 @@ +==================================== +Account Fiscal Position Partner Type +==================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--fiscal--rule-lightgray.png?logo=github + :target: https://github.com/OCA/account-fiscal-rule/tree/15.0/account_fiscal_position_partner_type + :alt: OCA/account-fiscal-rule +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-fiscal-rule-15-0/account-fiscal-rule-15-0-account_fiscal_position_partner_type + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/93/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the concept of type applied to fiscal positions and partners. The idea is to categorize them for not applying fiscal positions that doesn't belong to the same type. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +User can configure the default value according to the system company going to: + +* Settings/Users & Companies/Companies. +* Changing the value of the "Default Partner Fiscal Position Type" field. + +Usage +===== + +Create a new partner and define the "Fiscal Position Type" field. + +Create a new Fiscal Position, with the following configuration: + +* 'Detect Automatically' -> checked. +* 'Fiscal Position Type' + +Create a new Sale/Invoice and select the partner. Remember that the system recalculates the fiscal position according to the shipping address. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Sygel Technology + +Contributors +~~~~~~~~~~~~ + +* `Sygel `_: + + * Harald Panten + * Valentin Vinagre + +* `Tecnativa `_: + + * Pedro M. Baeza + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/account-fiscal-rule `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_fiscal_position_partner_type/__init__.py b/account_fiscal_position_partner_type/__init__.py new file mode 100644 index 000000000..bfcf34154 --- /dev/null +++ b/account_fiscal_position_partner_type/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 Valentin Vinagre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/account_fiscal_position_partner_type/__manifest__.py b/account_fiscal_position_partner_type/__manifest__.py new file mode 100644 index 000000000..347c817a7 --- /dev/null +++ b/account_fiscal_position_partner_type/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2021 Valentín Vinagre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Fiscal Position Partner Type", + "version": "16.0.1.0.0", + "category": "Accounting & Finance", + "website": "https://github.com/OCA/account-fiscal-rule", + "author": "Sygel Technology," "Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "development_status": "Production/Stable", + "depends": ["account"], + "data": [ + "views/res_company.xml", + "views/res_partner.xml", + "views/account_fiscal_position.xml", + ], +} diff --git a/account_fiscal_position_partner_type/i18n/account_fiscal_position_partner_type.pot b/account_fiscal_position_partner_type/i18n/account_fiscal_position_partner_type.pot new file mode 100644 index 000000000..a14450fa7 --- /dev/null +++ b/account_fiscal_position_partner_type/i18n/account_fiscal_position_partner_type.pot @@ -0,0 +1,55 @@ +# 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 15.0\n" +"Report-Msgid-Bugs-To: \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 "" + +#. 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 "" + +#. module: account_fiscal_position_partner_type +#: model:ir.model,name:account_fiscal_position_partner_type.model_res_partner +msgid "Contact" +msgstr "" + +#. 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 "" + +#. 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 "" + +#. module: account_fiscal_position_partner_type +#: model:ir.model,name:account_fiscal_position_partner_type.model_account_fiscal_position +msgid "Fiscal Position" +msgstr "" + +#. 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 "" + +#. 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 "" diff --git a/account_fiscal_position_partner_type/i18n/es.po b/account_fiscal_position_partner_type/i18n/es.po new file mode 100644 index 000000000..e088bc87b --- /dev/null +++ b/account_fiscal_position_partner_type/i18n/es.po @@ -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 cliente por defecto" + +#. 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" diff --git a/account_fiscal_position_partner_type/i18n/pt_PT.po b/account_fiscal_position_partner_type/i18n/pt_PT.po new file mode 100644 index 000000000..03b387ba5 --- /dev/null +++ b/account_fiscal_position_partner_type/i18n/pt_PT.po @@ -0,0 +1,79 @@ +# 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 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-08-16 21:49+0000\n" +"Last-Translator: Daniel Reis \n" +"Language-Team: none\n" +"Language: pt_PT\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: account_fiscal_position_partner_type +#: model:ir.model,name:account_fiscal_position_partner_type.model_res_company +msgid "Companies" +msgstr "Empresas" + +#. 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 "Empresa (B2B)" + +#. module: account_fiscal_position_partner_type +#: model:ir.model,name:account_fiscal_position_partner_type.model_res_partner +msgid "Contact" +msgstr "Contato" + +#. 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 "Posição Fiscal Predefinida para Parceiros" + +#. module: account_fiscal_position_partner_type +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_account_fiscal_position__display_name +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_company__display_name +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_partner__display_name +msgid "Display Name" +msgstr "Nome Apresentado" + +#. 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 "Client 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 "Posição 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 de Posição Fiscal" + +#. module: account_fiscal_position_partner_type +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_account_fiscal_position__id +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_company__id +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_partner__id +msgid "ID" +msgstr "ID" + +#. module: account_fiscal_position_partner_type +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_account_fiscal_position____last_update +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_company____last_update +#: model:ir.model.fields,field_description:account_fiscal_position_partner_type.field_res_partner____last_update +msgid "Last Modified on" +msgstr "Última Modificação em" + +#. 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" diff --git a/account_fiscal_position_partner_type/models/__init__.py b/account_fiscal_position_partner_type/models/__init__.py new file mode 100644 index 000000000..2c2df46f7 --- /dev/null +++ b/account_fiscal_position_partner_type/models/__init__.py @@ -0,0 +1,6 @@ +# Copyright 2021 Valentin Vinagre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import res_company +from . import res_partner +from . import account_fiscal_position diff --git a/account_fiscal_position_partner_type/models/account_fiscal_position.py b/account_fiscal_position_partner_type/models/account_fiscal_position.py new file mode 100644 index 000000000..e907e9ac7 --- /dev/null +++ b/account_fiscal_position_partner_type/models/account_fiscal_position.py @@ -0,0 +1,49 @@ +# Copyright 2021 Valentin Vinagre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models +from odoo.osv import expression + + +class AccountFiscalPosition(models.Model): + _inherit = "account.fiscal.position" + + fiscal_position_type = fields.Selection( + selection=[("b2c", "End customer (B2C)"), ("b2b", "Company (B2B)")], + string="Type", + default=lambda self: self.env.company.default_fiscal_position_type, + ) + + @api.model + def search(self, domain, offset=0, limit=None, order=None, count=False): + if self.env.context.get("fiscal_position_type"): + domain = expression.AND( + ( + domain, + [ + ( + "fiscal_position_type", + "=", + self.env.context["fiscal_position_type"], + ) + ], + ) + ) + return super().search( + domain, offset=offset, limit=limit, order=order, count=count + ) + + @api.model + def _get_fiscal_position(self, partner, delivery=None): + fiscal_type = False + 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 + return super( + AccountFiscalPosition, self.with_context(fiscal_position_type=fiscal_type) + )._get_fiscal_position(partner=partner, delivery=delivery) diff --git a/account_fiscal_position_partner_type/models/res_company.py b/account_fiscal_position_partner_type/models/res_company.py new file mode 100644 index 000000000..d5d082860 --- /dev/null +++ b/account_fiscal_position_partner_type/models/res_company.py @@ -0,0 +1,19 @@ +# Copyright 2021 Valentin Vinagre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + default_fiscal_position_type = fields.Selection( + selection="_selection_fiscal_position_type", + string="Default Partner Fiscal Position Type", + ) + + def _selection_fiscal_position_type(self): + field = "fiscal_position_type" + return self.env["account.fiscal.position"].fields_get(allfields=[field])[field][ + "selection" + ] diff --git a/account_fiscal_position_partner_type/models/res_partner.py b/account_fiscal_position_partner_type/models/res_partner.py new file mode 100644 index 000000000..3e5b3600b --- /dev/null +++ b/account_fiscal_position_partner_type/models/res_partner.py @@ -0,0 +1,23 @@ +# Copyright 2021 Valentin Vinagre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + fiscal_position_type = fields.Selection( + selection="_selection_fiscal_position_type", + default=lambda self: self.env.company.default_fiscal_position_type, + ) + + def _selection_fiscal_position_type(self): + field = "fiscal_position_type" + return self.env["account.fiscal.position"].fields_get(allfields=[field])[field][ + "selection" + ] + + @api.model + def _commercial_fields(self): + return super()._commercial_fields() + ["fiscal_position_type"] diff --git a/account_fiscal_position_partner_type/readme/CONFIGURE.rst b/account_fiscal_position_partner_type/readme/CONFIGURE.rst new file mode 100644 index 000000000..a3f8c16de --- /dev/null +++ b/account_fiscal_position_partner_type/readme/CONFIGURE.rst @@ -0,0 +1,4 @@ +User can configure the default value according to the system company going to: + +* Settings/Users & Companies/Companies. +* Changing the value of the "Default Partner Fiscal Position Type" field. diff --git a/account_fiscal_position_partner_type/readme/CONTRIBUTORS.rst b/account_fiscal_position_partner_type/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..6c2153127 --- /dev/null +++ b/account_fiscal_position_partner_type/readme/CONTRIBUTORS.rst @@ -0,0 +1,8 @@ +* `Sygel `_: + + * Harald Panten + * Valentin Vinagre + +* `Tecnativa `_: + + * Pedro M. Baeza diff --git a/account_fiscal_position_partner_type/readme/DESCRIPTION.rst b/account_fiscal_position_partner_type/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6b7a103fc --- /dev/null +++ b/account_fiscal_position_partner_type/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds the concept of type applied to fiscal positions and partners. The idea is to categorize them for not applying fiscal positions that doesn't belong to the same type. diff --git a/account_fiscal_position_partner_type/readme/USAGE.rst b/account_fiscal_position_partner_type/readme/USAGE.rst new file mode 100644 index 000000000..180b91076 --- /dev/null +++ b/account_fiscal_position_partner_type/readme/USAGE.rst @@ -0,0 +1,8 @@ +Create a new partner and define the "Fiscal Position Type" field. + +Create a new Fiscal Position, with the following configuration: + +* 'Detect Automatically' -> checked. +* 'Fiscal Position Type' + +Create a new Sale/Invoice and select the partner. Remember that the system recalculates the fiscal position according to the shipping address. diff --git a/account_fiscal_position_partner_type/static/description/icon.png b/account_fiscal_position_partner_type/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_fiscal_position_partner_type/static/description/icon.png differ diff --git a/account_fiscal_position_partner_type/static/description/index.html b/account_fiscal_position_partner_type/static/description/index.html new file mode 100644 index 000000000..bb5ae5a80 --- /dev/null +++ b/account_fiscal_position_partner_type/static/description/index.html @@ -0,0 +1,453 @@ + + + + + + +Account Fiscal Position Partner Type + + + +
+

Account Fiscal Position Partner Type

+ + +

Production/Stable License: AGPL-3 OCA/account-fiscal-rule Translate me on Weblate Try me on Runbot

+

This module adds the concept of type applied to fiscal positions and partners. The idea is to categorize them for not applying fiscal positions that doesn’t belong to the same type.

+

Table of contents

+ +
+

Configuration

+

User can configure the default value according to the system company going to:

+
    +
  • Settings/Users & Companies/Companies.
  • +
  • Changing the value of the “Default Partner Fiscal Position Type” field.
  • +
+
+
+

Usage

+

Create a new partner and define the “Fiscal Position Type” field.

+

Create a new Fiscal Position, with the following configuration:

+
    +
  • ‘Detect Automatically’ -> checked.
  • +
  • ‘Fiscal Position Type’
  • +
+

Create a new Sale/Invoice and select the partner. Remember that the system recalculates the fiscal position according to the shipping address.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Sygel Technology
  • +
+
+
+

Contributors

+
    +
  • Sygel:

    +
    +
      +
    • Harald Panten
    • +
    • Valentin Vinagre
    • +
    +
    +
  • +
  • Tecnativa:

    +
    +
      +
    • Pedro M. Baeza
    • +
    +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/account-fiscal-rule project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_fiscal_position_partner_type/tests/__init__.py b/account_fiscal_position_partner_type/tests/__init__.py new file mode 100644 index 000000000..d486e3a9e --- /dev/null +++ b/account_fiscal_position_partner_type/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 Valentin Vinagre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_account_fiscal_position_partner_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 new file mode 100644 index 000000000..b1c14c92c --- /dev/null +++ b/account_fiscal_position_partner_type/tests/test_account_fiscal_position_partner_type.py @@ -0,0 +1,110 @@ +# Copyright 2021 Valentin Vinagre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields +from odoo.tests import Form, common + + +class TestAccountFiscalPositionPartnerType(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + # MODELS + cls.res_partner_model = cls.env["res.partner"] + cls.fiscal_position_model = cls.env["account.fiscal.position"] + # INSTANCES + # Company + cls.company_main = cls.env.ref("base.main_company") + cls.company_main.default_fiscal_position_type = "b2b" + # Fiscal Positions + cls.fiscal_position_test = cls.fiscal_position_model.create( + { + "name": "Test", + "auto_apply": False, + "fiscal_position_type": False, + "sequence": 1, + } + ) + cls.fiscal_position_empty = cls.fiscal_position_model.create( + { + "name": "Empty", + "auto_apply": True, + "fiscal_position_type": False, + "sequence": 2, + } + ) + cls.fiscal_position_b2c = cls.fiscal_position_model.create( + { + "name": "b2c", + "auto_apply": True, + "fiscal_position_type": "b2c", + "sequence": 3, + } + ) + cls.fiscal_position_b2b = cls.fiscal_position_model.create( + { + "name": "b2b", + "auto_apply": True, + "fiscal_position_type": "b2b", + "sequence": 4, + } + ) + # Partners + 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": cls.fiscal_position_test.id, + } + ) + 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( + self.env["account.move"].with_context( + default_move_type="out_invoice", default_company_id=self.company_main.id + ) + ) + invoice_form.invoice_date = fields.Date.today() + invoice_form.partner_id = partner + invoice = invoice_form.save() + + invoice._onchange_partner_id() + return invoice + + def test_01(self): + partner_id = self.res_partner_model.create({"name": "fiscal position test"}) + self.assertEqual(partner_id.fiscal_position_type, "b2b") + fiscal_position_id = self.fiscal_position_model.create( + {"name": "fiscal position test", "auto_apply": True} + ) + self.assertEqual(fiscal_position_id.fiscal_position_type, "b2b") + + def test_02(self): + invoice_01 = self._invoice_sale_create(self.partner_01) + self.assertEqual(invoice_01.fiscal_position_id, self.fiscal_position_empty) + invoice_02 = self._invoice_sale_create(self.partner_02) + self.assertEqual(invoice_02.fiscal_position_id, self.fiscal_position_b2c) + invoice_03 = self._invoice_sale_create(self.partner_03) + self.assertEqual(invoice_03.fiscal_position_id, self.fiscal_position_b2b) + invoice_04 = self._invoice_sale_create(self.partner_04) + self.assertEqual(invoice_04.fiscal_position_id, self.fiscal_position_test) + + def test_03(self): + fiscal_position_b2b_country = self.fiscal_position_model.create( + { + "name": "b2b with country", + "auto_apply": True, + "fiscal_position_type": "b2b", + "country_id": self.env.ref("base.us").id, + } + ) + invoice_05 = self._invoice_sale_create(self.partner_05) + self.assertEqual(invoice_05.fiscal_position_id, fiscal_position_b2b_country) diff --git a/account_fiscal_position_partner_type/views/account_fiscal_position.xml b/account_fiscal_position_partner_type/views/account_fiscal_position.xml new file mode 100644 index 000000000..ce1277310 --- /dev/null +++ b/account_fiscal_position_partner_type/views/account_fiscal_position.xml @@ -0,0 +1,20 @@ + + + + + view.account.position.form.fiscal.position.type + account.fiscal.position + + + + + + + + diff --git a/account_fiscal_position_partner_type/views/res_company.xml b/account_fiscal_position_partner_type/views/res_company.xml new file mode 100644 index 000000000..4e951a94c --- /dev/null +++ b/account_fiscal_position_partner_type/views/res_company.xml @@ -0,0 +1,17 @@ + + + + + view.company.form.fiscal.position.type + res.company + + + + + + + + diff --git a/account_fiscal_position_partner_type/views/res_partner.xml b/account_fiscal_position_partner_type/views/res_partner.xml new file mode 100644 index 000000000..1c899c618 --- /dev/null +++ b/account_fiscal_position_partner_type/views/res_partner.xml @@ -0,0 +1,20 @@ + + + + + view.partner.form.fiscal.position.type + res.partner + + + + + + + + diff --git a/setup/account_fiscal_position_partner_type/odoo/addons/account_fiscal_position_partner_type b/setup/account_fiscal_position_partner_type/odoo/addons/account_fiscal_position_partner_type new file mode 120000 index 000000000..4534e32db --- /dev/null +++ b/setup/account_fiscal_position_partner_type/odoo/addons/account_fiscal_position_partner_type @@ -0,0 +1 @@ +../../../../account_fiscal_position_partner_type \ No newline at end of file diff --git a/setup/account_fiscal_position_partner_type/setup.py b/setup/account_fiscal_position_partner_type/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_fiscal_position_partner_type/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)