From 69baeceaf85be32eccbb63d96ead62ca6a9f9c74 Mon Sep 17 00:00:00 2001 From: Kaynnan Lemes Date: Fri, 15 Mar 2024 14:03:04 -0300 Subject: [PATCH] [ADD] l10n_br_account_service_type_by_partner: add new module --- .../README.rst | 74 +++ .../__init__.py | 1 + .../__manifest__.py | 18 + .../models/__init__.py | 5 + .../models/account_move.py | 26 ++ .../models/account_move_line.py | 22 + .../models/res_partner.py | 15 + .../models/res_partner_service_type.py | 37 ++ .../models/service_type.py | 11 + .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 1 + .../readme/USAGE.rst | 7 + .../security/ir.model.access.csv | 3 + .../static/description/icon.png | Bin 0 -> 2873 bytes .../static/description/index.html | 431 ++++++++++++++++++ .../views/res_partner_view.xml | 28 ++ .../views/service_type_view.xml | 20 + .../l10n_br_account_service_type_by_partner | 1 + .../setup.py | 6 + 19 files changed, 710 insertions(+) create mode 100644 l10n_br_account_service_type_by_partner/README.rst create mode 100644 l10n_br_account_service_type_by_partner/__init__.py create mode 100644 l10n_br_account_service_type_by_partner/__manifest__.py create mode 100644 l10n_br_account_service_type_by_partner/models/__init__.py create mode 100644 l10n_br_account_service_type_by_partner/models/account_move.py create mode 100644 l10n_br_account_service_type_by_partner/models/account_move_line.py create mode 100644 l10n_br_account_service_type_by_partner/models/res_partner.py create mode 100644 l10n_br_account_service_type_by_partner/models/res_partner_service_type.py create mode 100644 l10n_br_account_service_type_by_partner/models/service_type.py create mode 100644 l10n_br_account_service_type_by_partner/readme/CONTRIBUTORS.rst create mode 100644 l10n_br_account_service_type_by_partner/readme/DESCRIPTION.rst create mode 100644 l10n_br_account_service_type_by_partner/readme/USAGE.rst create mode 100644 l10n_br_account_service_type_by_partner/security/ir.model.access.csv create mode 100644 l10n_br_account_service_type_by_partner/static/description/icon.png create mode 100644 l10n_br_account_service_type_by_partner/static/description/index.html create mode 100644 l10n_br_account_service_type_by_partner/views/res_partner_view.xml create mode 100644 l10n_br_account_service_type_by_partner/views/service_type_view.xml create mode 120000 setup/l10n_br_account_service_type_by_partner/odoo/addons/l10n_br_account_service_type_by_partner create mode 100644 setup/l10n_br_account_service_type_by_partner/setup.py diff --git a/l10n_br_account_service_type_by_partner/README.rst b/l10n_br_account_service_type_by_partner/README.rst new file mode 100644 index 000000000000..970c6bf1ce94 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/README.rst @@ -0,0 +1,74 @@ +========================================= +Brazilian Account Service Type by Partner +========================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:77a1e6d27b13f6aed543f8a625e448d61cf693fb373faff8de4912bbfa8806b2 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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-Escodoo%2Fl10n--brazil-lightgray.png?logo=github + :target: https://github.com/Escodoo/l10n-brazil/tree/14.0/l10n_br_account_service_type_by_partner + :alt: Escodoo/l10n-brazil + +|badge1| |badge2| |badge3| + +The module enables partners to define a service type related to them for a specific product. This provides additional flexibility, allowing the service associated with a product to be determined by the partner, rather than solely relying on the service type defined for the product. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +* Navigate to Fiscal > Configurations > Service Type LC. +* Choose a service type and mark the option "can_be_selected_on_partner." +* Proceed to the partner's profile. +* Access the Fiscal tab. +* Under "Service Type," assign the chosen service type and product. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Marcel Savegnago + * Kaynnan Lemes + +Maintainers +~~~~~~~~~~~ + +This module is part of the `Escodoo/l10n-brazil `_ project on GitHub. + +You are welcome to contribute. diff --git a/l10n_br_account_service_type_by_partner/__init__.py b/l10n_br_account_service_type_by_partner/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_br_account_service_type_by_partner/__manifest__.py b/l10n_br_account_service_type_by_partner/__manifest__.py new file mode 100644 index 000000000000..3a72de3b0627 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 - TODAY, Escodoo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Brazilian Account Service Type by Partner", + "summary": """ + Brazilian Account Service Type by Partner""", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "Escodoo, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-brazil", + "depends": ["l10n_br_account"], + "data": [ + "views/res_partner_view.xml", + "views/service_type_view.xml", + "security/ir.model.access.csv", + ], +} diff --git a/l10n_br_account_service_type_by_partner/models/__init__.py b/l10n_br_account_service_type_by_partner/models/__init__.py new file mode 100644 index 000000000000..1e32e3b601e6 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/models/__init__.py @@ -0,0 +1,5 @@ +from . import service_type +from . import res_partner_service_type +from . import res_partner +from . import account_move +from . import account_move_line diff --git a/l10n_br_account_service_type_by_partner/models/account_move.py b/l10n_br_account_service_type_by_partner/models/account_move.py new file mode 100644 index 000000000000..1a379d9fde60 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/models/account_move.py @@ -0,0 +1,26 @@ +# Copyright 2024 - TODAY, Kaynnan Lemes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + +from odoo.addons.l10n_br_fiscal.constants.fiscal import FISCAL_IN + + +class AccountMove(models.Model): + _inherit = "account.move" + + @api.onchange("partner_id") + def _onchange_partner_id(self): + super()._onchange_partner_id() + if self.fiscal_operation_type == FISCAL_IN: + for line in self.invoice_line_ids: + if line.product_id: + partner_service_type = ( + line.partner_id.partner_service_type_ids.filtered( + lambda x: x.product_id == line.product_id + ) + ) + if partner_service_type: + line.service_type_id = partner_service_type.service_type_id + else: + line.service_type_id = line.product_id.service_type_id diff --git a/l10n_br_account_service_type_by_partner/models/account_move_line.py b/l10n_br_account_service_type_by_partner/models/account_move_line.py new file mode 100644 index 000000000000..ab55dbf91e2c --- /dev/null +++ b/l10n_br_account_service_type_by_partner/models/account_move_line.py @@ -0,0 +1,22 @@ +# Copyright 2024 - TODAY, Kaynnan Lemes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + +from odoo.addons.l10n_br_fiscal.constants.fiscal import FISCAL_IN + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + @api.onchange("product_id") + def _onchange_product_id_fiscal(self): + super()._onchange_product_id_fiscal() + if self.product_id and self.move_id.fiscal_operation_type == FISCAL_IN: + partner_service_type = self.partner_id.partner_service_type_ids.filtered( + lambda x: x.product_id == self.product_id + ) + if partner_service_type: + self.service_type_id = partner_service_type.service_type_id + else: + self.service_type_id = self.product_id.service_type_id diff --git a/l10n_br_account_service_type_by_partner/models/res_partner.py b/l10n_br_account_service_type_by_partner/models/res_partner.py new file mode 100644 index 000000000000..ade25427942f --- /dev/null +++ b/l10n_br_account_service_type_by_partner/models/res_partner.py @@ -0,0 +1,15 @@ +# Copyright 2024 - TODAY, Kaynnan Lemes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResPartner(models.Model): + + _inherit = "res.partner" + + partner_service_type_ids = fields.One2many( + comodel_name="res.partner.service.type", + inverse_name="partner_id", + string="Partner LC", + ) diff --git a/l10n_br_account_service_type_by_partner/models/res_partner_service_type.py b/l10n_br_account_service_type_by_partner/models/res_partner_service_type.py new file mode 100644 index 000000000000..ae2557584169 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/models/res_partner_service_type.py @@ -0,0 +1,37 @@ +# Copyright 2024 - TODAY, Kaynnan Lemes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResPartnerServiceType(models.Model): + + _name = "res.partner.service.type" + _description = "Partner Service Type" + + partner_id = fields.Many2one( + comodel_name="res.partner", + string="Partner", + ) + + service_type_id = fields.Many2one( + comodel_name="l10n_br_fiscal.service.type", + string="Fiscal Service Type", + domain="[('can_be_selected_on_partner', '=', True)]", + required=True, + ) + + product_id = fields.Many2one( + comodel_name="product.product", + string="Product", + domain="[('type', '=', 'service'), ('tax_icms_or_issqn', '=', 'issqn')]", + required=True, + ) + + _sql_constraints = [ + ( + "unique_product_service_type_partner", + "UNIQUE(product_id, partner_id)", + "A product can only have one service type per partner.", + ), + ] diff --git a/l10n_br_account_service_type_by_partner/models/service_type.py b/l10n_br_account_service_type_by_partner/models/service_type.py new file mode 100644 index 000000000000..ee35a0188c92 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/models/service_type.py @@ -0,0 +1,11 @@ +# Copyright 2024 - TODAY, Kaynnan Lemes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ServiceType(models.Model): + + _inherit = "l10n_br_fiscal.service.type" + + can_be_selected_on_partner = fields.Boolean(string="Can be selected on Partner") diff --git a/l10n_br_account_service_type_by_partner/readme/CONTRIBUTORS.rst b/l10n_br_account_service_type_by_partner/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..c7fe69086d2c --- /dev/null +++ b/l10n_br_account_service_type_by_partner/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Escodoo `_: + + * Marcel Savegnago + * Kaynnan Lemes diff --git a/l10n_br_account_service_type_by_partner/readme/DESCRIPTION.rst b/l10n_br_account_service_type_by_partner/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..da3974450525 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +The module enables partners to define a service type related to them for a specific product. This provides additional flexibility, allowing the service associated with a product to be determined by the partner, rather than solely relying on the service type defined for the product. diff --git a/l10n_br_account_service_type_by_partner/readme/USAGE.rst b/l10n_br_account_service_type_by_partner/readme/USAGE.rst new file mode 100644 index 000000000000..772a434f1dd4 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/readme/USAGE.rst @@ -0,0 +1,7 @@ +To use this module, you need to: + +* Navigate to Fiscal > Configurations > Service Type LC. +* Choose a service type and mark the option "can_be_selected_on_partner." +* Proceed to the partner's profile. +* Access the Fiscal tab. +* Under "Service Type," assign the chosen service type and product. diff --git a/l10n_br_account_service_type_by_partner/security/ir.model.access.csv b/l10n_br_account_service_type_by_partner/security/ir.model.access.csv new file mode 100644 index 000000000000..9b7ff6d2adb0 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/security/ir.model.access.csv @@ -0,0 +1,3 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"l10n_br_account_service_type_by_partner_profile_user","Fiscal Partner LC User","model_res_partner_service_type","l10n_br_fiscal.group_user",1,0,0,0 +"l10n_br_account_service_type_by_partner_profile_manager","Fiscal Partner LC for Manager","model_res_partner_service_type","l10n_br_fiscal.group_manager",1,1,1,1 diff --git a/l10n_br_account_service_type_by_partner/static/description/icon.png b/l10n_br_account_service_type_by_partner/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..12ab0051e3b9ac413f0f0016b7cff54f02fc763e GIT binary patch literal 2873 zcmV-93&!+`P)`uGecH7++*a9tqf=D4K3Mya}O@tpzNQ@yQCf@Kr zF!+nn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s@`$6_U{3>S+??hM0 zOJWkNYDUb5+iFpssh|wS7r%TpS6zECLJ0gIpfpio$BvQi5#pyFe}Q{`wvQom8v~ia zRgVooTS{lS6r>D;ZNrHuU^O2v0>bXk7=45J37f-Kl}rwLv_YC zo`+ar9as$FmK$!5y&##tw_F5a$W*n8-E#TlXD;F5OLueVjrVxyzGpb2xRbQ8a@C+$ zh;Q9+d+e?;5gjxghjO)oP?FJsF}4hhu1g#MTFduVONdVkE1hOTc8IJ|M9GsIt+j&Z z+sJbD{dKvxCUuJG5elhI>q(I({QN z2z?sv45gWOvE4eFE>qZUjkoRBK+sicvFHdR7XOOU0%|W1q%;d9)-MBq*+VWTdKUiy XXqTGI$C0NT00000NkvXXu0mjf?G|(} literal 0 HcmV?d00001 diff --git a/l10n_br_account_service_type_by_partner/static/description/index.html b/l10n_br_account_service_type_by_partner/static/description/index.html new file mode 100644 index 000000000000..55e76275b843 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/static/description/index.html @@ -0,0 +1,431 @@ + + + + + +Brazilian Account Service Type by Partner + + + +
+

Brazilian Account Service Type by Partner

+ + +

Beta License: AGPL-3 Escodoo/l10n-brazil

+

The module enables partners to define a service type related to them for a specific product. This provides additional flexibility, allowing the service associated with a product to be determined by the partner, rather than solely relying on the service type defined for the product.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  • Navigate to Fiscal > Configurations > Service Type LC.
  • +
  • Choose a service type and mark the option “can_be_selected_on_partner.”
  • +
  • Proceed to the partner’s profile.
  • +
  • Access the Fiscal tab.
  • +
  • Under “Service Type,” assign the chosen service type and product.
  • +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the Escodoo/l10n-brazil project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/l10n_br_account_service_type_by_partner/views/res_partner_view.xml b/l10n_br_account_service_type_by_partner/views/res_partner_view.xml new file mode 100644 index 000000000000..1368e4eab6c7 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/views/res_partner_view.xml @@ -0,0 +1,28 @@ + + + + + l10n_br_base.res.partner.form (in l10n_br_account_service_type_by_partner) + res.partner + + + + + + + + + + + + + + + + diff --git a/l10n_br_account_service_type_by_partner/views/service_type_view.xml b/l10n_br_account_service_type_by_partner/views/service_type_view.xml new file mode 100644 index 000000000000..555f7c6fa7c5 --- /dev/null +++ b/l10n_br_account_service_type_by_partner/views/service_type_view.xml @@ -0,0 +1,20 @@ + + + + + + l10n_br_fiscal.service.type.form (in l10n_br_account_service_type_by_partner) + l10n_br_fiscal.service.type + + + + + + + + + + diff --git a/setup/l10n_br_account_service_type_by_partner/odoo/addons/l10n_br_account_service_type_by_partner b/setup/l10n_br_account_service_type_by_partner/odoo/addons/l10n_br_account_service_type_by_partner new file mode 120000 index 000000000000..5cd30b51cabd --- /dev/null +++ b/setup/l10n_br_account_service_type_by_partner/odoo/addons/l10n_br_account_service_type_by_partner @@ -0,0 +1 @@ +../../../../l10n_br_account_service_type_by_partner \ No newline at end of file diff --git a/setup/l10n_br_account_service_type_by_partner/setup.py b/setup/l10n_br_account_service_type_by_partner/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_br_account_service_type_by_partner/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)