forked from OCA/l10n-brazil
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] l10n_br_account_service_type_by_partner: add new module
- Loading branch information
Showing
19 changed files
with
710 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/Escodoo/l10n-brazil/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 <https://github.com/Escodoo/l10n-brazil/issues/new?body=module:%20l10n_br_account_service_type_by_partner%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Escodoo | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Escodoo <https://www.escodoo.com.br>`_: | ||
|
||
* Marcel Savegnago <[email protected]> | ||
* Kaynnan Lemes <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `Escodoo/l10n-brazil <https://github.com/Escodoo/l10n-brazil/tree/14.0/l10n_br_account_service_type_by_partner>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
26 changes: 26 additions & 0 deletions
26
l10n_br_account_service_type_by_partner/models/account_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2024 - TODAY, Kaynnan Lemes <[email protected]> | ||
# 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 | ||
22 changes: 22 additions & 0 deletions
22
l10n_br_account_service_type_by_partner/models/account_move_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 - TODAY, Kaynnan Lemes <[email protected]> | ||
# 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 |
15 changes: 15 additions & 0 deletions
15
l10n_br_account_service_type_by_partner/models/res_partner.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024 - TODAY, Kaynnan Lemes <[email protected]> | ||
# 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", | ||
) |
37 changes: 37 additions & 0 deletions
37
l10n_br_account_service_type_by_partner/models/res_partner_service_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2024 - TODAY, Kaynnan Lemes <[email protected]> | ||
# 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.", | ||
), | ||
] |
11 changes: 11 additions & 0 deletions
11
l10n_br_account_service_type_by_partner/models/service_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 - TODAY, Kaynnan Lemes <[email protected]> | ||
# 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") |
4 changes: 4 additions & 0 deletions
4
l10n_br_account_service_type_by_partner/readme/CONTRIBUTORS.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* `Escodoo <https://www.escodoo.com.br>`_: | ||
|
||
* Marcel Savegnago <[email protected]> | ||
* Kaynnan Lemes <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
3 changes: 3 additions & 0 deletions
3
l10n_br_account_service_type_by_partner/security/ir.model.access.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.