Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions account_fiscal_position_tax_included/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
==================================================
Account Fiscal Position - Tax Excluded to Included
==================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:72f4c03f47c69856c81e1cdd6f1043f489bb8e0d322edf5ceb1054e37364e26e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-OCA%2Faccount--fiscal--rule-lightgray.png?logo=github
:target: https://github.com/OCA/account-fiscal-rule/tree/16.0/account_fiscal_position_tax_included
: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-16-0/account-fiscal-rule-16-0-account_fiscal_position_tax_included
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-fiscal-rule&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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

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

* Tax Excl --> Tax Excl / No tax
* Tax Incl --> Tax Excl / No tax
* Tax Incl --> Tax Incl / No tax

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

* Tax Excl --> Tax Incl

**Table of contents**

.. contents::
:local:

Development
===========

This module fully overwrite the function ``_get_tax_included_unit_price_from_price`` of the model ``product.product``.

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 to smash it by providing a detailed and welcomed
`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**>`_.

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

Credits
=======

Authors
~~~~~~~

* GRAP

Contributors
~~~~~~~~~~~~

* Sylvain LE GAL <https://twitter.com/legalsylvain>

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.

.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
:target: https://github.com/legalsylvain
:alt: legalsylvain

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

|maintainer-legalsylvain|

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.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_fiscal_position_tax_included/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions account_fiscal_position_tax_included/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2019-Today Sylvain LE GAL (http://www.grap.coop)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Account Fiscal Position - Tax Excluded to Included",
"summary": "Allow to map from tax excluded to tax included",
"version": "16.0.1.0.0",
"category": "Accounting",
"author": "GRAP, Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"website": "https://github.com/OCA/account-fiscal-rule",
"license": "AGPL-3",
"depends": ["account"],
"demo": [
"demo/account_tax.xml",
"demo/account_fiscal_position.xml",
"demo/product_product.xml",
],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2019 - Today: Sylvain LE GAL (http://www.grap.coop)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record id="fiscal_position_20_excl_to_20_incl" model="account.fiscal.position">
<field name="name">20% Tax Excl. -> 20% Tax Incl.</field>
</record>

<record
id="fiscal_position_20_excl_to_20_incl_line"
model="account.fiscal.position.tax"
>
<field name="position_id" ref="fiscal_position_20_excl_to_20_incl" />
<field name="tax_src_id" ref="tax_20_tax_excl" />
<field name="tax_dest_id" ref="tax_20_tax_incl" />
</record>

<record id="fiscal_position_20_excl_to_5_excl" model="account.fiscal.position">
<field name="name">20% Tax Excl. -> 5% Tax Excl.</field>
</record>

<record
id="fiscal_position_20_excl_to_5_excl_line"
model="account.fiscal.position.tax"
>
<field name="position_id" ref="fiscal_position_20_excl_to_5_excl" />
<field name="tax_src_id" ref="tax_20_tax_excl" />
<field name="tax_dest_id" ref="tax_5_tax_excl" />
</record>

<record id="fiscal_position_20_incl_to_20_excl" model="account.fiscal.position">
<field name="name">20% Tax Incl. -> 20% Tax Excl.</field>
</record>

<record
id="fiscal_position_20_incl_to_20_excl_line"
model="account.fiscal.position.tax"
>
<field name="position_id" ref="fiscal_position_20_incl_to_20_excl" />
<field name="tax_src_id" ref="tax_20_tax_incl" />
<field name="tax_dest_id" ref="tax_20_tax_excl" />
</record>

<record id="fiscal_position_20_incl_to_5_incl" model="account.fiscal.position">
<field name="name">20% Tax Incl. -> 5% Tax Incl.</field>
</record>

<record
id="fiscal_position_20_incl_to_5_incl_line"
model="account.fiscal.position.tax"
>
<field name="position_id" ref="fiscal_position_20_incl_to_5_incl" />
<field name="tax_src_id" ref="tax_20_tax_incl" />
<field name="tax_dest_id" ref="tax_5_tax_incl" />
</record>

</odoo>
36 changes: 36 additions & 0 deletions account_fiscal_position_tax_included/demo/account_tax.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2019 - Today: Sylvain LE GAL (http://www.grap.coop)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record id="tax_5_tax_excl" model="account.tax">
<field name="name">5% Tax Excl</field>
<field name="amount_type">percent</field>
<field name="amount">5</field>
<field name="price_include" eval="False" />
</record>

<record id="tax_20_tax_excl" model="account.tax">
<field name="name">20% Tax Excl</field>
<field name="amount_type">percent</field>
<field name="amount">20</field>
<field name="price_include" eval="False" />
</record>

<record id="tax_5_tax_incl" model="account.tax">
<field name="name">5% Tax Incl</field>
<field name="amount_type">percent</field>
<field name="amount">5</field>
<field name="price_include" eval="True" />
</record>

<record id="tax_20_tax_incl" model="account.tax">
<field name="name">20% Tax Incl</field>
<field name="amount_type">percent</field>
<field name="amount">20</field>
<field name="price_include" eval="True" />
</record>

</odoo>
20 changes: 20 additions & 0 deletions account_fiscal_position_tax_included/demo/product_product.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2019 - Today: Sylvain LE GAL (http://www.grap.coop)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record id="product_20_tax_excl" model="product.product">
<field name="name">Product 20% Tax Excl. (100 Vat Excl / 120 Vat Incl)</field>
<field name="taxes_id" eval="[(4, ref('tax_20_tax_excl'))]" />
<field name="lst_price">100</field>
</record>

<record id="product_20_tax_incl" model="product.product">
<field name="name">Product 20% Tax Incl. (100 Vat Excl / 120 Vat Incl)</field>
<field name="taxes_id" eval="[(4, ref('tax_20_tax_incl'))]" />
<field name="lst_price">120</field>
</record>

</odoo>
50 changes: 50 additions & 0 deletions account_fiscal_position_tax_included/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_fiscal_position_tax_included
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-14 13:26+0000\n"
"PO-Revision-Date: 2019-11-14 13:26+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_tax_included
#: model:product.product,name:account_fiscal_position_tax_included.product_20_tax_excl
#: model:product.template,name:account_fiscal_position_tax_included.product_20_tax_excl_product_template
msgid "Product 20% Tax Excl."
msgstr "Produit TVA 20% (HT)"

#. module: account_fiscal_position_tax_included
#: model:product.product,name:account_fiscal_position_tax_included.product_20_tax_incl
#: model:product.template,name:account_fiscal_position_tax_included.product_20_tax_incl_product_template
msgid "Product 20% Tax Incl."
msgstr "Produit TVA 20% (TTC)"

#. module: account_fiscal_position_tax_included
#: model:ir.model,name:account_fiscal_position_tax_included.model_account_tax
msgid "Tax"
msgstr "Taxe"

#. module: account_fiscal_position_tax_included
#: model:product.product,uom_name:account_fiscal_position_tax_included.product_20_tax_excl
#: model:product.product,uom_name:account_fiscal_position_tax_included.product_20_tax_incl
#: model:product.template,uom_name:account_fiscal_position_tax_included.product_20_tax_excl_product_template
#: model:product.template,uom_name:account_fiscal_position_tax_included.product_20_tax_incl_product_template
msgid "Unit(s)"
msgstr "Unité(s)"

#. module: account_fiscal_position_tax_included
#: model:product.product,weight_uom_name:account_fiscal_position_tax_included.product_20_tax_excl
#: model:product.product,weight_uom_name:account_fiscal_position_tax_included.product_20_tax_incl
#: model:product.template,weight_uom_name:account_fiscal_position_tax_included.product_20_tax_excl_product_template
#: model:product.template,weight_uom_name:account_fiscal_position_tax_included.product_20_tax_incl_product_template
msgid "kg"
msgstr "kg"

1 change: 1 addition & 0 deletions account_fiscal_position_tax_included/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_product
72 changes: 72 additions & 0 deletions account_fiscal_position_tax_included/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright (C) 2019 - Today: Sylvain LE GAL (http://www.grap.coop)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class ProductProduct(models.Model):
_inherit = "product.product"

# Full Copy Paste of the original function, defined in the odoo account module.
# One single line is changed
@api.model
def _get_tax_included_unit_price_from_price(
self,
product_price_unit,
currency,
product_taxes,
fiscal_position=None,
product_taxes_after_fp=None,
is_refund_document=False,
):
if not product_taxes:
return product_price_unit

if product_taxes_after_fp is None:
if not fiscal_position:
return product_price_unit

product_taxes_after_fp = fiscal_position.map_tax(product_taxes)

flattened_taxes_after_fp = (
product_taxes_after_fp._origin.flatten_taxes_hierarchy()
)
flattened_taxes_before_fp = product_taxes._origin.flatten_taxes_hierarchy()

# <Begin of Changes>
# taxes_before_included = all(tax.price_include for tax in flattened_taxes_before_fp)
taxes_before_included = True
# </End of Changes>

if (
set(product_taxes.ids) != set(product_taxes_after_fp.ids)
and taxes_before_included
):
taxes_res = flattened_taxes_before_fp.with_context(
round=False, round_base=False
).compute_all(
product_price_unit,
quantity=1.0,
currency=currency,
product=self,
is_refund=is_refund_document,
)
product_price_unit = taxes_res["total_excluded"]

if any(tax.price_include for tax in flattened_taxes_after_fp):
taxes_res = flattened_taxes_after_fp.with_context(
round=False, round_base=False
).compute_all(
product_price_unit,
quantity=1.0,
currency=currency,
product=self,
is_refund=is_refund_document,
handle_price_include=False,
)
for tax_res in taxes_res["taxes"]:
tax = self.env["account.tax"].browse(tax_res["id"])
if tax.price_include:
product_price_unit += tax_res["amount"]

return product_price_unit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
11 changes: 11 additions & 0 deletions account_fiscal_position_tax_included/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This module extend the Odoo account module, regarding fiscal position.

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

* Tax Excl --> Tax Excl / No tax
* Tax Incl --> Tax Excl / No tax
* Tax Incl --> Tax Incl / No tax

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

* Tax Excl --> Tax Incl
1 change: 1 addition & 0 deletions account_fiscal_position_tax_included/readme/DEVELOP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module fully overwrite the function ``_get_tax_included_unit_price_from_price`` of the model ``product.product``.
Loading