mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG] account_fiscal_position_vat_check
This commit is contained in:
@@ -31,7 +31,7 @@ on a customer that doesn't have a VAT number yet.
|
||||
|
||||
.. 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/8.0
|
||||
:target: https://runbot.odoo-community.org/runbot/92/9.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
@@ -48,6 +48,7 @@ Contributors
|
||||
------------
|
||||
|
||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# © 2016 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import account_invoice
|
||||
from . import partner
|
||||
from . import models
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# © 2016 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Account Fiscal Position VAT Check',
|
||||
'version': '8.0.0.1.2',
|
||||
'version': '9.0.1.0.0',
|
||||
'category': 'Accounting & Finance',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Check VAT on invoice validation',
|
||||
'author': "Akretion,Odoo Community Association (OCA)",
|
||||
'author': "Akretion, "
|
||||
"Tecnativa,"
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['account', 'base_vat'],
|
||||
'data': [
|
||||
'account_fiscal_position_view.xml',
|
||||
'views/account_fiscal_position_view.xml',
|
||||
],
|
||||
'installable': False,
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record id="view_account_position_form" model="ir.ui.view">
|
||||
<field name="name">customer.must.have.vat.fiscal_position_form</field>
|
||||
<field name="model">account.fiscal.position</field>
|
||||
<field name="inherit_id" ref="account.view_account_position_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="country_group_id" position="after">
|
||||
<field name="customer_must_have_vat" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_account_position_tree" model="ir.ui.view">
|
||||
<field name="name">customer.must.have.vat.fiscal_position_tree</field>
|
||||
<field name="model">account.fiscal.position</field>
|
||||
<field name="inherit_id" ref="account.view_account_position_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="after">
|
||||
<field name="customer_must_have_vat" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
7
account_fiscal_position_vat_check/models/__init__.py
Normal file
7
account_fiscal_position_vat_check/models/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# © 2016 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import account_invoice
|
||||
from . import partner
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# © 2016 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
@@ -20,13 +21,14 @@ class AccountInvoice(models.Model):
|
||||
|
||||
@api.multi
|
||||
def action_move_create(self):
|
||||
'''Check that the customer has VAT set
|
||||
if required by the fiscal position'''
|
||||
"""Check that the customer has VAT set
|
||||
if required by the fiscal position"""
|
||||
|
||||
for invoice in self:
|
||||
if (
|
||||
invoice.type in ('out_invoice', 'out_refund') and
|
||||
invoice.fiscal_position and
|
||||
invoice.fiscal_position.customer_must_have_vat and
|
||||
invoice.fiscal_position_id and
|
||||
invoice.fiscal_position_id.customer_must_have_vat and
|
||||
not invoice.partner_id.vat):
|
||||
if invoice.type == 'out_invoice':
|
||||
type_label = _('a Customer Invoice')
|
||||
@@ -41,6 +43,6 @@ class AccountInvoice(models.Model):
|
||||
"have a VAT number in OpenERP."
|
||||
"Please add the VAT number of this Customer in Odoo "
|
||||
" and try to validate again.")
|
||||
% (type_label, invoice.fiscal_position.name,
|
||||
% (type_label, invoice.fiscal_position_id.name,
|
||||
invoice.partner_id.name))
|
||||
return super(AccountInvoice, self).action_move_create()
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# © 2016 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, api, _
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="view_account_position_form" model="ir.ui.view">
|
||||
<field name="name">customer.must.have.vat.fiscal_position_form</field>
|
||||
<field name="model">account.fiscal.position</field>
|
||||
<field name="inherit_id" ref="account.view_account_position_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="country_group_id" position="after">
|
||||
<field name="customer_must_have_vat"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_position_tree" model="ir.ui.view">
|
||||
<field name="name">customer.must.have.vat.fiscal_position_tree</field>
|
||||
<field name="model">account.fiscal.position</field>
|
||||
<field name="inherit_id" ref="account.view_account_position_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="after">
|
||||
<field name="customer_must_have_vat"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user