-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][ADD] account_fiscal_product_rule
- Loading branch information
1 parent
8362c2f
commit 6c35545
Showing
17 changed files
with
962 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,77 @@ | ||
=========================== | ||
Account Fiscal Product Rule | ||
=========================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-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/14.0/account_fiscal_product_rule | ||
: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-14-0/account-fiscal-rule-14-0-account_fiscal_product_rule | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/251/14.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows to map tax and account depending of the product. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-fiscal-rule/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 <https://github.com/OCA/account-fiscal-rule/issues/new?body=module:%20account_fiscal_product_rule%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 | ||
~~~~~~~ | ||
|
||
* Akretion | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Sébastien Beau <sebastien.beau@akretion.com> | ||
* Chafique Delli <chafique.delli@akretion.com> | ||
|
||
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 <https://github.com/OCA/account-fiscal-rule/tree/14.0/account_fiscal_product_rule>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/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 2022 Akretion | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Account Fiscal Product Rule", | ||
"version": "14.0.1.0.0", | ||
"category": "Accounting & Finance", | ||
"author": "Akretion, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/account-fiscal-rule", | ||
"license": "AGPL-3", | ||
"depends": ["account"], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/product.xml", | ||
"views/account_fiscal_position.xml", | ||
"views/account_menuitem.xml", | ||
], | ||
"installable": True, | ||
} |
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,2 @@ | ||
from . import account_fiscal_position | ||
from . import product |
50 changes: 50 additions & 0 deletions
50
account_fiscal_product_rule/models/account_fiscal_position.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,50 @@ | ||
# Copyright 2022 Akretion France (http://www.akretion.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AccountFiscalPositionProductRule(models.Model): | ||
_name = "account.fiscal.position.product.rule" | ||
_description = "Account Fiscal Position Rule in Product" | ||
|
||
name = fields.Char(required=True) | ||
fiscal_position_id = fields.Many2one("account.fiscal.position", required=True) | ||
product_tmpl_ids = fields.Many2many("product.template") | ||
product_category_ids = fields.Many2many("product.category") | ||
account_income_id = fields.Many2one("account.account") | ||
account_expense_id = fields.Many2one("account.account") | ||
seller_tax_ids = fields.Many2many("account.tax", "account_tax_seller") | ||
supplier_tax_ids = fields.Many2many( | ||
"account.tax", | ||
"account_tax_supplier", | ||
) | ||
company_id = fields.Many2one(related="fiscal_position_id.company_id") | ||
|
||
|
||
class AccountFiscalPosition(models.Model): | ||
_inherit = "account.fiscal.position" | ||
|
||
fiscal_position_product_rule_ids = fields.One2many( | ||
"account.fiscal.position.product.rule", | ||
"fiscal_position_id", | ||
string="Product Fiscal Rules", | ||
) | ||
|
||
def map_tax(self, taxes, product=None, partner=None): | ||
# if product: | ||
# for fp in self: | ||
# if fp.fiscal_position_product_rule_ids: | ||
# fiscal_product_rules = self.env[ | ||
# "account.fiscal.position.product.rule" | ||
# ].search( | ||
# [ | ||
# ("fiscal_position_id", "=", fp.id), | ||
# "|", | ||
# ("product_tmpl_ids", "in", product.product_tmpl_id.ids), | ||
# ("product_category_ids", "in", product.categ_id.ids), | ||
# ] | ||
# ) | ||
# if fiscal_product_rules: | ||
# return | ||
return super().map_tax(taxes=taxes, product=product, partner=partner) |
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,77 @@ | ||
# Copyright 2022 Akretion France (http://www.akretion.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProductCategory(models.Model): | ||
_inherit = "product.category" | ||
|
||
fiscal_position_product_rule_ids = fields.Many2many( | ||
"account.fiscal.position.product.rule", string="Fiscal Rule" | ||
) | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
fiscal_position_product_rule_ids = fields.Many2many( | ||
"account.fiscal.position.product.rule", string="Fiscal Rule" | ||
) | ||
|
||
def get_product_accounts(self, fiscal_pos=None): | ||
for product in self: | ||
if fiscal_pos and fiscal_pos.fiscal_position_product_rule_ids: | ||
fiscal_product_rules = self.env[ | ||
"account.fiscal.position.product.rule" | ||
].search( | ||
[ | ||
("fiscal_position_id", "=", fiscal_pos.id), | ||
"|", | ||
("product_tmpl_ids", "in", product.ids), | ||
("product_category_ids", "in", product.categ_id.ids), | ||
] | ||
) | ||
if fiscal_product_rules: | ||
accounts = {} | ||
accounts["income"] = fiscal_product_rules[0].account_income_id | ||
accounts["expense"] = fiscal_product_rules[0].account_expense_id | ||
return accounts | ||
return super().get_product_accounts(fiscal_pos=fiscal_pos) | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
@api.model | ||
def _get_tax_included_unit_price( | ||
self, | ||
company, | ||
currency, | ||
document_date, | ||
document_type, | ||
is_refund_document=False, | ||
product_uom=None, | ||
product_currency=None, | ||
product_price_unit=None, | ||
product_taxes=None, | ||
fiscal_position=None, | ||
): | ||
res = super()._get_tax_included_unit_price( | ||
company=company, | ||
currency=currency, | ||
document_date=document_date, | ||
document_type=document_type, | ||
is_refund_document=is_refund_document, | ||
product_uom=product_uom, | ||
product_currency=product_currency, | ||
product_price_unit=product_price_unit, | ||
product_taxes=product_taxes, | ||
fiscal_position=fiscal_position, | ||
) | ||
# for product in self: | ||
# # Apply fiscal product rule. | ||
# if product_taxes and fiscal_position: | ||
# fiscal_position.map_tax(product_taxes, product) | ||
# return | ||
return res |
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,2 @@ | ||
* Sébastien Beau <sebastien.beau@akretion.com> | ||
* Chafique Delli <chafique.delli@akretion.com> |
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 @@ | ||
This module allows to map tax and account depending of 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,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_account_fiscal_position_product_rule,access on account.fiscal.position.product.rule,model_account_fiscal_position_product_rule,account.group_account_user,1,1,1,1 |
Oops, something went wrong.