diff --git a/account_tax_repartition_line_tax_group_account/README.rst b/account_tax_repartition_line_tax_group_account/README.rst new file mode 100644 index 000000000..b2ef45ec3 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/README.rst @@ -0,0 +1,94 @@ +============================================== +Account Tax Repartition Line Tax Group Account +============================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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--financial--tools-lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-tools/tree/13.0/account_tax_repartition_line_tax_group_account + :alt: OCA/account-financial-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-tools-13-0/account-financial-tools-13-0-account_tax_repartition_line_tax_group_account + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/92/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to set up an account in tax repartition lines +based on a default account set up in the tax group. + +Some countries like the US use tax integrations such as Tax Cloud, Tax Jar, etc.. +that create taxes as a result of an API call to those applications. In those +cases a default account for tax should be proposed for those new taxes. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Go to the tax group and change the field 'Default account to use in repartition lines'. + +Usage +===== + +#. Go to *Invocing/Accounting > Configuration > Taxes* +#. Create a new tax and make sure that it references the tax group + that you have configured with a default account. +#. Upon saving the tax you should see a tax being populated in the sections + 'Repartition for invoices' and 'Repartition for credit notes'. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* ForgeFlow + + * Jordi Ballester Alomar + +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-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_tax_repartition_line_tax_group_account/__init__.py b/account_tax_repartition_line_tax_group_account/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_tax_repartition_line_tax_group_account/__manifest__.py b/account_tax_repartition_line_tax_group_account/__manifest__.py new file mode 100644 index 000000000..68379b22b --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2020 ForgeFlow, S.L. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +{ + "name": "Account Tax Repartition Line Tax Group Account", + "summary": "Set a default account from tax group to tax repartition lines", + "version": "13.0.1.0.0", + "category": "Accounting", + "website": "https://github.com/OCA/account-financial-tools", + "author": "ForgeFlow," "Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": ["account"], + "data": ["views/account_tax_group_views.xml"], +} diff --git a/account_tax_repartition_line_tax_group_account/models/__init__.py b/account_tax_repartition_line_tax_group_account/models/__init__.py new file mode 100644 index 000000000..30f5cd56d --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_tax_group +from . import account_tax_repartition_line diff --git a/account_tax_repartition_line_tax_group_account/models/account_tax_group.py b/account_tax_repartition_line_tax_group_account/models/account_tax_group.py new file mode 100644 index 000000000..f3818d488 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/models/account_tax_group.py @@ -0,0 +1,14 @@ +# Copyright 2020 ForgeFlow, S.L. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class AccountTaxGroup(models.Model): + _inherit = "account.tax.group" + + property_repartition_line_account_id = fields.Many2one( + "account.account", + company_dependent=True, + string="Default account to use in repartition lines", + ) diff --git a/account_tax_repartition_line_tax_group_account/models/account_tax_repartition_line.py b/account_tax_repartition_line_tax_group_account/models/account_tax_repartition_line.py new file mode 100644 index 000000000..89edc375c --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/models/account_tax_repartition_line.py @@ -0,0 +1,24 @@ +# Copyright 2020 ForgeFlow, S.L. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import api, models + + +class AccountTaxRepartitionLine(models.Model): + _inherit = "account.tax.repartition.line" + + @api.model + def create(self, vals): + account_id = vals.get("account_id", "") + invoice_tax_id = vals.get("invoice_tax_id", "") + refund_tax_id = vals.get("refund_tax_id", "") + repartition_type = vals.get("repartition_type", "") + tax_id = invoice_tax_id or refund_tax_id + if not account_id and tax_id and repartition_type == "tax": + tax = self.env["account.tax"].browse(tax_id) + def_acc = tax.tax_group_id.with_context( + force_company=tax.company_id.id + ).property_repartition_line_account_id + if def_acc: + vals["account_id"] = def_acc.id + return super(AccountTaxRepartitionLine, self).create(vals) diff --git a/account_tax_repartition_line_tax_group_account/readme/CONFIGURE.rst b/account_tax_repartition_line_tax_group_account/readme/CONFIGURE.rst new file mode 100644 index 000000000..20fd035d9 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/readme/CONFIGURE.rst @@ -0,0 +1 @@ +Go to the tax group and change the field 'Default account to use in repartition lines'. diff --git a/account_tax_repartition_line_tax_group_account/readme/CONTRIBUTORS.rst b/account_tax_repartition_line_tax_group_account/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..5c942494e --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* ForgeFlow + + * Jordi Ballester Alomar diff --git a/account_tax_repartition_line_tax_group_account/readme/DESCRIPTION.rst b/account_tax_repartition_line_tax_group_account/readme/DESCRIPTION.rst new file mode 100644 index 000000000..c5e0750c2 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module allows to set up an account in tax repartition lines +based on a default account set up in the tax group. + +Some countries like the US use tax integrations such as Tax Cloud, Tax Jar, etc.. +that create taxes as a result of an API call to those applications. In those +cases a default account for tax should be proposed for those new taxes. diff --git a/account_tax_repartition_line_tax_group_account/readme/USAGE.rst b/account_tax_repartition_line_tax_group_account/readme/USAGE.rst new file mode 100644 index 000000000..f49b1de85 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/readme/USAGE.rst @@ -0,0 +1,5 @@ +#. Go to *Invocing/Accounting > Configuration > Taxes* +#. Create a new tax and make sure that it references the tax group + that you have configured with a default account. +#. Upon saving the tax you should see a tax being populated in the sections + 'Repartition for invoices' and 'Repartition for credit notes'. diff --git a/account_tax_repartition_line_tax_group_account/static/description/icon.png b/account_tax_repartition_line_tax_group_account/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_tax_repartition_line_tax_group_account/static/description/icon.png differ diff --git a/account_tax_repartition_line_tax_group_account/static/description/index.html b/account_tax_repartition_line_tax_group_account/static/description/index.html new file mode 100644 index 000000000..e2d5a9cc7 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/static/description/index.html @@ -0,0 +1,442 @@ + + + + + + +Account Tax Repartition Line Tax Group Account + + + +
+

Account Tax Repartition Line Tax Group Account

+ + +

Beta License: LGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

This module allows to set up an account in tax repartition lines +based on a default account set up in the tax group.

+

Some countries like the US use tax integrations such as Tax Cloud, Tax Jar, etc.. +that create taxes as a result of an API call to those applications. In those +cases a default account for tax should be proposed for those new taxes.

+

Table of contents

+ +
+

Configuration

+

Go to the tax group and change the field ‘Default account to use in repartition lines’.

+
+
+

Usage

+
    +
  1. Go to Invocing/Accounting > Configuration > Taxes
  2. +
  3. Create a new tax and make sure that it references the tax group +that you have configured with a default account.
  4. +
  5. Upon saving the tax you should see a tax being populated in the sections +‘Repartition for invoices’ and ‘Repartition for credit notes’.
  6. +
+
+
+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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-financial-tools project on GitHub.

+

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

+
+
+
+ + diff --git a/account_tax_repartition_line_tax_group_account/tests/__init__.py b/account_tax_repartition_line_tax_group_account/tests/__init__.py new file mode 100644 index 000000000..71ce3c262 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 ForgeFlow, S.L. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from . import test_account_tax_repartition_line_tax_group_account diff --git a/account_tax_repartition_line_tax_group_account/tests/test_account_tax_repartition_line_tax_group_account.py b/account_tax_repartition_line_tax_group_account/tests/test_account_tax_repartition_line_tax_group_account.py new file mode 100644 index 000000000..2fb3e1c76 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/tests/test_account_tax_repartition_line_tax_group_account.py @@ -0,0 +1,52 @@ +# Copyright 2020 ForgeFlow, S.L. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +import odoo.tests.common as common + + +class TestAccountTaxRepartitionLineTaxGroupAccount(common.TransactionCase): + def setUp(self): + super().setUp() + res_users_account_manager = self.env.ref("account.group_account_manager") + partner_manager = self.env.ref("base.group_partner_manager") + self.env.user.write( + {"groups_id": [(6, 0, [res_users_account_manager.id, partner_manager.id])]} + ) + self.sales_tax_account = self.env["account.account"].create( + { + "code": "sales_tax", + "name": "sales_tax", + "user_type_id": self.env.ref( + "account.data_account_type_current_liabilities" + ).id, + "reconcile": False, + } + ) + self.sales_tax_group = self.env["account.tax.group"].create( + { + "name": "Sales Tax Group", + "property_repartition_line_account_id": self.sales_tax_account.id, + } + ) + + def test_default_account(self): + + tax = self.env["account.tax"].create( + { + "name": "sales tax", + "type_tax_use": "sale", + "amount_type": "percent", + "amount": 5.00, + "tax_exigibility": "on_invoice", + "tax_group_id": self.sales_tax_group.id, + } + ) + irls = tax.mapped("invoice_repartition_line_ids") + irl_accs = irls.filtered(lambda rl: rl.repartition_type == "tax").mapped( + "account_id" + ) + self.assertEqual(irl_accs[0], self.sales_tax_account) + rrls = tax.mapped("refund_repartition_line_ids") + rrl_accs = rrls.filtered(lambda rl: rl.repartition_type == "tax").mapped( + "account_id" + ) + self.assertEqual(rrl_accs[0], self.sales_tax_account) diff --git a/account_tax_repartition_line_tax_group_account/views/account_tax_group_views.xml b/account_tax_repartition_line_tax_group_account/views/account_tax_group_views.xml new file mode 100644 index 000000000..c11dc0608 --- /dev/null +++ b/account_tax_repartition_line_tax_group_account/views/account_tax_group_views.xml @@ -0,0 +1,13 @@ + + + + account.tax.group.tree + account.tax.group + + + + + + + + diff --git a/setup/account_tax_repartition_line_tax_group_account/odoo/addons/account_tax_repartition_line_tax_group_account b/setup/account_tax_repartition_line_tax_group_account/odoo/addons/account_tax_repartition_line_tax_group_account new file mode 120000 index 000000000..d28babd55 --- /dev/null +++ b/setup/account_tax_repartition_line_tax_group_account/odoo/addons/account_tax_repartition_line_tax_group_account @@ -0,0 +1 @@ +../../../../account_tax_repartition_line_tax_group_account \ No newline at end of file diff --git a/setup/account_tax_repartition_line_tax_group_account/setup.py b/setup/account_tax_repartition_line_tax_group_account/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_tax_repartition_line_tax_group_account/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)