Skip to content

Commit aa8d9b7

Browse files
committed
[MIG] account_fiscal_position_tax_included. From 12.0 to 16.0
1 parent 0af0a18 commit aa8d9b7

File tree

16 files changed

+796
-170
lines changed

16 files changed

+796
-170
lines changed

account_fiscal_position_tax_included/README.rst

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,53 @@ Account Fiscal Position - Tax Excluded to Included
1010
!! source digest: sha256:72f4c03f47c69856c81e1cdd6f1043f489bb8e0d322edf5ceb1054e37364e26e
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
13-
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1414
:target: https://odoo-community.org/page/development-status
15-
:alt: Alpha
15+
:alt: Beta
1616
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
19-
.. |badge3| image:: https://img.shields.io/badge/github-grap%2Fgrap--odoo--incubator-lightgray.png?logo=github
20-
:target: https://github.com/grap/grap-odoo-incubator/tree/12.0/account_fiscal_position_tax_included
21-
:alt: grap/grap-odoo-incubator
22-
23-
|badge1| |badge2| |badge3|
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--fiscal--rule-lightgray.png?logo=github
20+
:target: https://github.com/OCA/account-fiscal-rule/tree/16.0/account_fiscal_position_tax_included
21+
:alt: OCA/account-fiscal-rule
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/account-fiscal-rule-16-0/account-fiscal-rule-16-0-account_fiscal_position_tax_included
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-fiscal-rule&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
2430

2531
This module extend the Odoo account module, regarding fiscal position.
2632

2733
By default, it is only possible to realize such tax mapping :
2834

2935
* Tax Excl --> Tax Excl / No tax
3036
* Tax Incl --> Tax Excl / No tax
37+
* Tax Incl --> Tax Incl / No tax
3138

3239
This module allows to realize such mapping and fixes incorrect computation.
3340

3441
* Tax Excl --> Tax Incl
35-
* Tax Incl --> Tax Incl
36-
37-
.. IMPORTANT::
38-
This is an alpha version, the data model and design can change at any time without warning.
39-
Only for development or testing purpose, do not use in production.
40-
`More details on development status <https://odoo-community.org/page/development-status>`_
4142

4243
**Table of contents**
4344

4445
.. contents::
4546
:local:
4647

47-
Known issues / Roadmap
48-
======================
49-
50-
legalsylvain 2021-12-06:
51-
52-
I'm not very confortable to have such patch in an external module.
48+
Development
49+
===========
5350

54-
* When migrating to V16, check if this module is still necessary, or
55-
open an issue.
51+
This module fully overwrite the function ``_get_tax_included_unit_price_from_price`` of the model ``product.product``.
5652

5753
Bug Tracker
5854
===========
5955

60-
Bugs are tracked on `GitHub Issues <https://github.com/grap/grap-odoo-incubator/issues>`_.
56+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-fiscal-rule/issues>`_.
6157
In case of trouble, please check there if your issue has already been reported.
6258
If you spotted it first, help us to smash it by providing a detailed and welcomed
63-
`feedback <https://github.com/grap/grap-odoo-incubator/issues/new?body=module:%20account_fiscal_position_tax_included%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
59+
`feedback <https://github.com/OCA/account-fiscal-rule/issues/new?body=module:%20account_fiscal_position_tax_included%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
6460

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

@@ -80,14 +76,24 @@ Contributors
8076
Maintainers
8177
~~~~~~~~~~~
8278

79+
This module is maintained by the OCA.
80+
81+
.. image:: https://odoo-community.org/logo.png
82+
:alt: Odoo Community Association
83+
:target: https://odoo-community.org
84+
85+
OCA, or the Odoo Community Association, is a nonprofit organization whose
86+
mission is to support the collaborative development of Odoo features and
87+
promote its widespread use.
88+
8389
.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
8490
:target: https://github.com/legalsylvain
8591
:alt: legalsylvain
8692

87-
Current maintainer:
93+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
8894

8995
|maintainer-legalsylvain|
9096

91-
This module is part of the `grap/grap-odoo-incubator <https://github.com/grap/grap-odoo-incubator/tree/12.0/account_fiscal_position_tax_included>`_ project on GitHub.
97+
This module is part of the `OCA/account-fiscal-rule <https://github.com/OCA/account-fiscal-rule/tree/16.0/account_fiscal_position_tax_included>`_ project on GitHub.
9298

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

account_fiscal_position_tax_included/__manifest__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
# Copyright (C) 2015-Today GRAP (http://www.grap.coop)
2-
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
1+
# Copyright (C) 2019-Today Sylvain LE GAL (http://www.grap.coop)
32
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
43

54
{
65
"name": "Account Fiscal Position - Tax Excluded to Included",
76
"summary": "Allow to map from tax excluded to tax included",
8-
"version": "12.0.1.1.3",
7+
"version": "16.0.1.0.0",
98
"category": "Accounting",
10-
"author": "GRAP",
9+
"author": "GRAP, Odoo Community Association (OCA)",
1110
"maintainers": ["legalsylvain"],
12-
"development_status": "Alpha",
13-
"website": "https://github.com/grap/grap-odoo-incubator",
11+
"website": "https://github.com/OCA/account-fiscal-rule",
1412
"license": "AGPL-3",
1513
"depends": ["account"],
1614
"demo": [
Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22
<!--
3-
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
4-
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
Copyright (C) 2019 - Today: Sylvain LE GAL (http://www.grap.coop)
54
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
65
-->
76
<odoo>
@@ -10,20 +9,52 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
109
<field name="name">20% Tax Excl. -> 20% Tax Incl.</field>
1110
</record>
1211

13-
<record id="fiscal_position_20_excl_to_20_incl_line" model="account.fiscal.position.tax">
14-
<field name="position_id" ref="fiscal_position_20_excl_to_20_incl"/>
12+
<record
13+
id="fiscal_position_20_excl_to_20_incl_line"
14+
model="account.fiscal.position.tax"
15+
>
16+
<field name="position_id" ref="fiscal_position_20_excl_to_20_incl" />
1517
<field name="tax_src_id" ref="tax_20_tax_excl" />
1618
<field name="tax_dest_id" ref="tax_20_tax_incl" />
1719
</record>
1820

21+
<record id="fiscal_position_20_excl_to_5_excl" model="account.fiscal.position">
22+
<field name="name">20% Tax Excl. -> 5% Tax Excl.</field>
23+
</record>
24+
25+
<record
26+
id="fiscal_position_20_excl_to_5_excl_line"
27+
model="account.fiscal.position.tax"
28+
>
29+
<field name="position_id" ref="fiscal_position_20_excl_to_5_excl" />
30+
<field name="tax_src_id" ref="tax_20_tax_excl" />
31+
<field name="tax_dest_id" ref="tax_5_tax_excl" />
32+
</record>
33+
1934
<record id="fiscal_position_20_incl_to_20_excl" model="account.fiscal.position">
2035
<field name="name">20% Tax Incl. -> 20% Tax Excl.</field>
2136
</record>
2237

23-
<record id="fiscal_position_20_incl_to_20_excl_line" model="account.fiscal.position.tax">
24-
<field name="position_id" ref="fiscal_position_20_incl_to_20_excl"/>
38+
<record
39+
id="fiscal_position_20_incl_to_20_excl_line"
40+
model="account.fiscal.position.tax"
41+
>
42+
<field name="position_id" ref="fiscal_position_20_incl_to_20_excl" />
2543
<field name="tax_src_id" ref="tax_20_tax_incl" />
2644
<field name="tax_dest_id" ref="tax_20_tax_excl" />
2745
</record>
2846

47+
<record id="fiscal_position_20_incl_to_5_incl" model="account.fiscal.position">
48+
<field name="name">20% Tax Incl. -> 5% Tax Incl.</field>
49+
</record>
50+
51+
<record
52+
id="fiscal_position_20_incl_to_5_incl_line"
53+
model="account.fiscal.position.tax"
54+
>
55+
<field name="position_id" ref="fiscal_position_20_incl_to_5_incl" />
56+
<field name="tax_src_id" ref="tax_20_tax_incl" />
57+
<field name="tax_dest_id" ref="tax_5_tax_incl" />
58+
</record>
59+
2960
</odoo>
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22
<!--
3-
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
4-
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
Copyright (C) 2019 - Today: Sylvain LE GAL (http://www.grap.coop)
54
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
65
-->
76
<odoo>
87

8+
<record id="tax_5_tax_excl" model="account.tax">
9+
<field name="name">5% Tax Excl</field>
10+
<field name="amount_type">percent</field>
11+
<field name="amount">5</field>
12+
<field name="price_include" eval="False" />
13+
</record>
14+
915
<record id="tax_20_tax_excl" model="account.tax">
1016
<field name="name">20% Tax Excl</field>
1117
<field name="amount_type">percent</field>
1218
<field name="amount">20</field>
13-
<field name="price_include" eval="False"/>
19+
<field name="price_include" eval="False" />
20+
</record>
21+
22+
<record id="tax_5_tax_incl" model="account.tax">
23+
<field name="name">5% Tax Incl</field>
24+
<field name="amount_type">percent</field>
25+
<field name="amount">5</field>
26+
<field name="price_include" eval="True" />
1427
</record>
1528

1629
<record id="tax_20_tax_incl" model="account.tax">
1730
<field name="name">20% Tax Incl</field>
1831
<field name="amount_type">percent</field>
1932
<field name="amount">20</field>
20-
<field name="price_include" eval="True"/>
33+
<field name="price_include" eval="True" />
2134
</record>
2235

2336
</odoo>
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22
<!--
3-
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
4-
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
Copyright (C) 2019 - Today: Sylvain LE GAL (http://www.grap.coop)
54
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
65
-->
76
<odoo>
87

98
<record id="product_20_tax_excl" model="product.product">
10-
<field name="name">Product 20% Tax Excl.</field>
11-
<field name="uom_id" ref="uom.product_uom_unit"/>
12-
<field name="categ_id" ref="product.product_category_all"/>
13-
<field name="taxes_id" eval="[(4, ref('tax_20_tax_excl'))]"/>
9+
<field name="name">Product 20% Tax Excl. (100 Vat Excl / 120 Vat Incl)</field>
10+
<field name="taxes_id" eval="[(4, ref('tax_20_tax_excl'))]" />
11+
<field name="lst_price">100</field>
1412
</record>
1513

1614
<record id="product_20_tax_incl" model="product.product">
17-
<field name="name">Product 20% Tax Incl.</field>
18-
<field name="uom_id" ref="uom.product_uom_unit"/>
19-
<field name="categ_id" ref="product.product_category_all"/>
20-
<field name="taxes_id" eval="[(4, ref('tax_20_tax_incl'))]"/>
15+
<field name="name">Product 20% Tax Incl. (100 Vat Excl / 120 Vat Incl)</field>
16+
<field name="taxes_id" eval="[(4, ref('tax_20_tax_incl'))]" />
17+
<field name="lst_price">120</field>
2118
</record>
2219

2320
</odoo>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from . import account_invoice
2-
from . import account_tax
1+
# from . import product_product

account_fiscal_position_tax_included/models/account_invoice.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

account_fiscal_position_tax_included/models/account_tax.py

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright (C) 2019 - Today: Sylvain LE GAL (http://www.grap.coop)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import api, models
5+
6+
7+
class ProductProduct(models.Model):
8+
_inherit = "product.product"
9+
10+
# Full Copy Paste of the original function, defined in the odoo account module.
11+
# One single line is changed
12+
@api.model
13+
def _get_tax_included_unit_price_from_price(
14+
self,
15+
product_price_unit,
16+
currency,
17+
product_taxes,
18+
fiscal_position=None,
19+
product_taxes_after_fp=None,
20+
is_refund_document=False,
21+
):
22+
if not product_taxes:
23+
return product_price_unit
24+
25+
if product_taxes_after_fp is None:
26+
if not fiscal_position:
27+
return product_price_unit
28+
29+
product_taxes_after_fp = fiscal_position.map_tax(product_taxes)
30+
31+
flattened_taxes_after_fp = (
32+
product_taxes_after_fp._origin.flatten_taxes_hierarchy()
33+
)
34+
flattened_taxes_before_fp = product_taxes._origin.flatten_taxes_hierarchy()
35+
36+
# <Begin of Changes>
37+
# taxes_before_included = all(tax.price_include for tax in flattened_taxes_before_fp)
38+
taxes_before_included = True
39+
# </End of Changes>
40+
41+
if (
42+
set(product_taxes.ids) != set(product_taxes_after_fp.ids)
43+
and taxes_before_included
44+
):
45+
taxes_res = flattened_taxes_before_fp.with_context(
46+
round=False, round_base=False
47+
).compute_all(
48+
product_price_unit,
49+
quantity=1.0,
50+
currency=currency,
51+
product=self,
52+
is_refund=is_refund_document,
53+
)
54+
product_price_unit = taxes_res["total_excluded"]
55+
56+
if any(tax.price_include for tax in flattened_taxes_after_fp):
57+
taxes_res = flattened_taxes_after_fp.with_context(
58+
round=False, round_base=False
59+
).compute_all(
60+
product_price_unit,
61+
quantity=1.0,
62+
currency=currency,
63+
product=self,
64+
is_refund=is_refund_document,
65+
handle_price_include=False,
66+
)
67+
for tax_res in taxes_res["taxes"]:
68+
tax = self.env["account.tax"].browse(tax_res["id"])
69+
if tax.price_include:
70+
product_price_unit += tax_res["amount"]
71+
72+
return product_price_unit

account_fiscal_position_tax_included/readme/DESCRIPTION.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ By default, it is only possible to realize such tax mapping :
44

55
* Tax Excl --> Tax Excl / No tax
66
* Tax Incl --> Tax Excl / No tax
7+
* Tax Incl --> Tax Incl / No tax
78

89
This module allows to realize such mapping and fixes incorrect computation.
910

1011
* Tax Excl --> Tax Incl
11-
* Tax Incl --> Tax Incl

0 commit comments

Comments
 (0)