-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rva/eezeeit-1] Migration of account_tax_code and account_tax_constra…
…ints
- Loading branch information
1 parent
eeba5b8
commit 221749b
Showing
18 changed files
with
299 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,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 | ||
<https://github.com/OCA/account-financial-tools/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 <[email protected]> | ||
|
||
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. |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
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,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', | ||
} |
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,4 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import account_invoice_tax | ||
from . import account_tax | ||
from . import account_tax_template |
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,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) |
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,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 !') | ||
] |
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,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() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="invoice_supplier_form" model="ir.ui.view"> | ||
<field name="name">account.invoice.supplier.form.inherit</field> | ||
<field name="model">account.invoice</field> | ||
<field name="inherit_id" ref="account.invoice_supplier_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//notebook//field[@name='tax_line_ids']//field[@name='tax_id']" position="after"> | ||
<field name="tax_code"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="invoice_form" model="ir.ui.view"> | ||
<field name="name">account.invoice.form.inherit</field> | ||
<field name="model">account.invoice</field> | ||
<field name="inherit_id" ref="account.invoice_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//notebook//field[@name='tax_line_ids']//field[@name='tax_id']" position="after"> | ||
<field name="tax_code"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="view_invoice_tax_form" model="ir.ui.view"> | ||
<field name="name">account.invoice.tax.form.inherit</field> | ||
<field name="model">account.invoice.tax</field> | ||
<field name="inherit_id" ref="account.view_invoice_tax_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="currency_id" position="after"> | ||
<field name="tax_id" options="{'no_create': True, 'no_open': True}"/> | ||
<field name="tax_code"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="view_account_tax_search" model="ir.ui.view"> | ||
<field name="name">account.tax.search</field> | ||
<field name="model">account.tax</field> | ||
<field name="inherit_id" ref="account.view_account_tax_search"/> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="attributes"> | ||
<attribute name="filter_domain">['|', '|', ('name', 'ilike', self), ('description', 'ilike', self), ('code', 'ilike', self)]</attribute> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="view_tax_tree" model="ir.ui.view"> | ||
<field name="name">account.tax.tree</field> | ||
<field name="model">account.tax</field> | ||
<field name="inherit_id" ref="account.view_tax_tree"/> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field name="code"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="view_tax_form" model="ir.ui.view"> | ||
<field name="name">account.tax.form</field> | ||
<field name="model">account.tax</field> | ||
<field name="inherit_id" ref="account.view_tax_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field name="code"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="view_account_tax_template_search" model="ir.ui.view"> | ||
<field name="name">account.tax.template.search</field> | ||
<field name="model">account.tax.template</field> | ||
<field name="inherit_id" ref="account.view_account_tax_template_search"/> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="attributes"> | ||
<attribute name="filter_domain">['|', ('name','ilike',self), ('description','ilike',self), ('code', 'ilike', self')]</attribute> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="view_account_tax_template_tree" model="ir.ui.view"> | ||
<field name="name">account.tax.template.tree</field> | ||
<field name="model">account.tax.template</field> | ||
<field name="inherit_id" ref="account.view_account_tax_template_tree"/> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field name="code"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="view_account_tax_template_form" model="ir.ui.view"> | ||
<field name="name">account.tax.template.form</field> | ||
<field name="model">account.tax.template</field> | ||
<field name="inherit_id" ref="account.view_account_tax_template_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field name="code"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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,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. |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
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,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', | ||
], | ||
} |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import account_tax |
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,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() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.