diff --git a/account_tax_code/README.rst b/account_tax_code/README.rst new file mode 100644 index 00000000..575419a3 --- /dev/null +++ b/account_tax_code/README.rst @@ -0,0 +1,54 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +================ +account tax code +================ + +This module adds a 'code' field to taxes in order to facilitate e.g. +the tax object lookup, the synchronisation with tax templates or +the construction of tax reports. + +Installation +============ + +There is no specific installation procedure for this module. + +Configuration and Usage +======================= + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/92/10.0 + +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 smash it by providing detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Luc De Meyer + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/account_tax_code/__init__.py b/account_tax_code/__init__.py new file mode 100644 index 00000000..a0fdc10f --- /dev/null +++ b/account_tax_code/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/account_tax_code/__manifest__.py b/account_tax_code/__manifest__.py new file mode 100644 index 00000000..0dd87a95 --- /dev/null +++ b/account_tax_code/__manifest__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2018 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'account tax code', + 'version': '11.0.1.0.0', + 'category': 'Accounting & Finance', + 'summary': """ + Add 'code' field to taxes + """, + 'author': 'Noviat,' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/account-financial-tools', + 'depends': [ + 'account', + ], + 'data': [ + 'views/account_invoice.xml', + 'views/account_invoice_tax.xml', + 'views/account_tax.xml', + 'views/account_tax_template.xml', + ], + 'installable': True, + 'license': 'AGPL-3', +} diff --git a/account_tax_code/models/__init__.py b/account_tax_code/models/__init__.py new file mode 100644 index 00000000..327eb8a7 --- /dev/null +++ b/account_tax_code/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from . import account_invoice_tax +from . import account_tax +from . import account_tax_template diff --git a/account_tax_code/models/account_invoice_tax.py b/account_tax_code/models/account_invoice_tax.py new file mode 100644 index 00000000..5e293913 --- /dev/null +++ b/account_tax_code/models/account_invoice_tax.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2018 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountInvoiceTax(models.Model): + _inherit = 'account.invoice.tax' + + tax_code = fields.Char( + related='tax_id.code', readonly=True) diff --git a/account_tax_code/models/account_tax.py b/account_tax_code/models/account_tax.py new file mode 100644 index 00000000..76cefabd --- /dev/null +++ b/account_tax_code/models/account_tax.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2018 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountTax(models.Model): + _inherit = 'account.tax' + + code = fields.Char() + + _sql_constraints = [ + ('code_company_uniq', 'unique (code,company_id)', + 'The code of the Tax must be unique per company !') + ] diff --git a/account_tax_code/models/account_tax_template.py b/account_tax_code/models/account_tax_template.py new file mode 100644 index 00000000..15580907 --- /dev/null +++ b/account_tax_code/models/account_tax_template.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2018 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountTaxTemplate(models.Model): + _inherit = 'account.tax.template' + + code = fields.Char() diff --git a/account_tax_code/static/description/icon.png b/account_tax_code/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_tax_code/static/description/icon.png differ diff --git a/account_tax_code/views/account_invoice.xml b/account_tax_code/views/account_invoice.xml new file mode 100644 index 00000000..76acfda0 --- /dev/null +++ b/account_tax_code/views/account_invoice.xml @@ -0,0 +1,26 @@ + + + + + account.invoice.supplier.form.inherit + account.invoice + + + + + + + + + + account.invoice.form.inherit + account.invoice + + + + + + + + + diff --git a/account_tax_code/views/account_invoice_tax.xml b/account_tax_code/views/account_invoice_tax.xml new file mode 100644 index 00000000..f1f6cc2d --- /dev/null +++ b/account_tax_code/views/account_invoice_tax.xml @@ -0,0 +1,16 @@ + + + + + account.invoice.tax.form.inherit + account.invoice.tax + + + + + + + + + + diff --git a/account_tax_code/views/account_tax.xml b/account_tax_code/views/account_tax.xml new file mode 100644 index 00000000..501a2127 --- /dev/null +++ b/account_tax_code/views/account_tax.xml @@ -0,0 +1,37 @@ + + + + + account.tax.search + account.tax + + + + ['|', '|', ('name', 'ilike', self), ('description', 'ilike', self), ('code', 'ilike', self)] + + + + + + account.tax.tree + account.tax + + + + + + + + + + account.tax.form + account.tax + + + + + + + + + diff --git a/account_tax_code/views/account_tax_template.xml b/account_tax_code/views/account_tax_template.xml new file mode 100644 index 00000000..9e2f2667 --- /dev/null +++ b/account_tax_code/views/account_tax_template.xml @@ -0,0 +1,37 @@ + + + + + account.tax.template.search + account.tax.template + + + + ['|', ('name','ilike',self), ('description','ilike',self), ('code', 'ilike', self')] + + + + + + account.tax.template.tree + account.tax.template + + + + + + + + + + account.tax.template.form + account.tax.template + + + + + + + + + diff --git a/account_tax_constraints/README.rst b/account_tax_constraints/README.rst new file mode 100644 index 00000000..2aaf57c3 --- /dev/null +++ b/account_tax_constraints/README.rst @@ -0,0 +1,10 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +======================= +Account Tax constraints +======================= + +This module prohibits the removal of a tax when this tax +has been set on product records. diff --git a/account_tax_constraints/__init__.py b/account_tax_constraints/__init__.py new file mode 100644 index 00000000..a0fdc10f --- /dev/null +++ b/account_tax_constraints/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/account_tax_constraints/__manifest__.py b/account_tax_constraints/__manifest__.py new file mode 100644 index 00000000..5422cdd0 --- /dev/null +++ b/account_tax_constraints/__manifest__.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2018 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Account Tax constraints', + 'version': '11.0.1.0.0', + 'category': 'Accounting & Finance', + 'website': 'https://www.noviat.com', + 'author': 'Noviat', + 'license': 'AGPL-3', + 'installable': True, + 'depends': [ + 'account', + ], +} diff --git a/account_tax_constraints/models/__init__.py b/account_tax_constraints/models/__init__.py new file mode 100644 index 00000000..f8456f67 --- /dev/null +++ b/account_tax_constraints/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import account_tax diff --git a/account_tax_constraints/models/account_tax.py b/account_tax_constraints/models/account_tax.py new file mode 100644 index 00000000..ae98681c --- /dev/null +++ b/account_tax_constraints/models/account_tax.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2018 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models, _ +from odoo.exceptions import UserError + + +class AccountTax(models.Model): + _inherit = 'account.tax' + + @api.multi + def unlink(self): + for tax in self: + products = self.env['product.template'].with_context( + active_test=False).search( + ['|', ('supplier_taxes_id', '=', tax.id), + ('taxes_id', '=', tax.id)]) + if products: + product_list = [ + '%s' % x.name for x in products] + raise UserError(_( + "You cannot delete a tax that " + "has been set on product records" + "\nAs an alterative, you can disable a " + "tax via the 'active' flag." + "\n\nProduct records: %s") % product_list) + return super(AccountTax, self).unlink() diff --git a/account_tax_constraints/static/description/icon.png b/account_tax_constraints/static/description/icon.png new file mode 100644 index 00000000..32740c0c Binary files /dev/null and b/account_tax_constraints/static/description/icon.png differ