Skip to content

Commit

Permalink
[rva/eezeeit-1] Migration of account_tax_code and account_tax_constra…
Browse files Browse the repository at this point in the history
…ints
  • Loading branch information
rudyeezee-it committed Jun 6, 2018
1 parent eeba5b8 commit 221749b
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 0 deletions.
54 changes: 54 additions & 0 deletions account_tax_code/README.rst
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.
2 changes: 2 additions & 0 deletions account_tax_code/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
26 changes: 26 additions & 0 deletions account_tax_code/__manifest__.py
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',
}
4 changes: 4 additions & 0 deletions account_tax_code/models/__init__.py
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
12 changes: 12 additions & 0 deletions account_tax_code/models/account_invoice_tax.py
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)
16 changes: 16 additions & 0 deletions account_tax_code/models/account_tax.py
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 !')
]
11 changes: 11 additions & 0 deletions account_tax_code/models/account_tax_template.py
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()
Binary file added account_tax_code/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions account_tax_code/views/account_invoice.xml
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>
16 changes: 16 additions & 0 deletions account_tax_code/views/account_invoice_tax.xml
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>
37 changes: 37 additions & 0 deletions account_tax_code/views/account_tax.xml
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>
37 changes: 37 additions & 0 deletions account_tax_code/views/account_tax_template.xml
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>
10 changes: 10 additions & 0 deletions account_tax_constraints/README.rst
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.
2 changes: 2 additions & 0 deletions account_tax_constraints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
16 changes: 16 additions & 0 deletions account_tax_constraints/__manifest__.py
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',
],
}
2 changes: 2 additions & 0 deletions account_tax_constraints/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import account_tax
28 changes: 28 additions & 0 deletions account_tax_constraints/models/account_tax.py
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.

0 comments on commit 221749b

Please sign in to comment.