mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Use @api.onchange instead of on_change in view
Move description from __openerp__.py to README
This commit is contained in:
committed by
Pedro M. Baeza
parent
bc398d008a
commit
8ef89d48cb
65
account_fiscal_position_vat_check/README.rst
Normal file
65
account_fiscal_position_vat_check/README.rst
Normal file
@@ -0,0 +1,65 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
=================================
|
||||
Account Fiscal Position VAT Check
|
||||
=================================
|
||||
|
||||
With this module, when a user tries to validate a customer invoice or refund
|
||||
with a fiscal position that requires VAT, Odoo block the validation of the invoice
|
||||
if the customer doesn't have a VAT number in Odoo.
|
||||
|
||||
In the European Union (EU), when an EU company sends an invoice to
|
||||
another EU company in another country, it can invoice without VAT
|
||||
(most of the time) but the VAT number of the customer must be displayed
|
||||
on the invoice.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To configure this module, go to *Accounting > Configuration > Accounting
|
||||
> Fiscal Positions* and enable the option **Customer Must Have VAT number**
|
||||
on the relevant fiscal positions.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
On the customer form view, Odoo will display a warning when a user sets
|
||||
a fiscal position that has the option **Customer Must Have VAT number**
|
||||
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
|
||||
|
||||
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 smashing it by providing a detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
|
||||
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 https://odoo-community.org.
|
||||
@@ -1,24 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Fiscal Position VAT Check module for Odoo
|
||||
# Copyright (C) 2013-2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import account_invoice
|
||||
from . import partner
|
||||
|
||||
@@ -1,62 +1,18 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Fiscal Position VAT Check module for Odoo
|
||||
# Copyright (C) 2013-2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Account Fiscal Position VAT Check',
|
||||
'version': '8.0.0.1.1',
|
||||
'version': '8.0.0.1.2',
|
||||
'category': 'Accounting & Finance',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Check VAT on invoice validation',
|
||||
'description': """
|
||||
Check that the Customer has a VAT number on invoice validation
|
||||
==============================================================
|
||||
|
||||
This module adds an option **Customer must have VAT** on fiscal positions.
|
||||
When a user tries to validate a customer invoice or refund
|
||||
with a fiscal position that have this option, OpenERP will check that
|
||||
the customer has a VAT number.
|
||||
|
||||
If it doesn't, OpenERP will block the validation of the invoice
|
||||
and display an error message.
|
||||
|
||||
In the European Union (EU), when an EU company sends an invoice to
|
||||
another EU company in another country, it can invoice without VAT
|
||||
(most of the time) but the VAT number of the customer must be displayed
|
||||
on the invoice.
|
||||
|
||||
This module also displays a warning when a user sets
|
||||
a fiscal position with the option **Customer must have VAT** on a customer
|
||||
and this customer doesn't have a VAT number in OpenERP yet.
|
||||
|
||||
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com>
|
||||
for any help or question about this module.
|
||||
""",
|
||||
'author': "Akretion,Odoo Community Association (OCA)",
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['account', 'base_vat'],
|
||||
'data': [
|
||||
'account_fiscal_position_view.xml',
|
||||
'partner_view.xml',
|
||||
],
|
||||
'installable': False,
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2013-2014 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
|
||||
@@ -1,30 +1,12 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Fiscal Position VAT Check module for OpenERP
|
||||
# Copyright (C) 2013-2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
from openerp.exceptions import except_orm
|
||||
|
||||
|
||||
class account_fiscal_position(models.Model):
|
||||
class AccountFiscalPosition(models.Model):
|
||||
_inherit = 'account.fiscal.position'
|
||||
|
||||
customer_must_have_vat = fields.Boolean(
|
||||
@@ -33,7 +15,7 @@ class account_fiscal_position(models.Model):
|
||||
"number when the user validates a customer invoice/refund.")
|
||||
|
||||
|
||||
class account_invoice(models.Model):
|
||||
class AccountInvoice(models.Model):
|
||||
_inherit = 'account.invoice'
|
||||
|
||||
@api.multi
|
||||
@@ -61,4 +43,4 @@ class account_invoice(models.Model):
|
||||
" and try to validate again.")
|
||||
% (type_label, invoice.fiscal_position.name,
|
||||
invoice.partner_id.name))
|
||||
return super(account_invoice, self).action_move_create()
|
||||
return super(AccountInvoice, self).action_move_create()
|
||||
|
||||
@@ -1,47 +1,25 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Fiscal Position VAT Check module for Odoo
|
||||
# Copyright (C) 2013-2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, api, _
|
||||
|
||||
|
||||
class res_partner(models.Model):
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
@api.multi
|
||||
def fiscal_position_change(
|
||||
self, account_position_id, vat, customer):
|
||||
'''Warning if the fiscal position requires a VAT number and the
|
||||
partner doesn't have one yet'''
|
||||
if account_position_id and customer and not vat:
|
||||
fp = self.env['account.fiscal.position'].browse(
|
||||
account_position_id)
|
||||
if fp.customer_must_have_vat:
|
||||
return {
|
||||
'warning': {
|
||||
'title': _('Missing VAT number:'),
|
||||
'message': _(
|
||||
"You have set the fiscal position '%s' "
|
||||
"that require the customer to have a VAT number, "
|
||||
"but the VAT number is missing.") % fp.name
|
||||
}
|
||||
@api.onchange('property_account_position')
|
||||
def fiscal_position_change(self):
|
||||
"""Warning if the fiscal position requires a VAT number and the
|
||||
partner doesn't have one yet"""
|
||||
fp = self.property_account_position
|
||||
if fp.customer_must_have_vat and self.customer and not self.vat:
|
||||
return {
|
||||
'warning': {
|
||||
'title': _('Missing VAT number:'),
|
||||
'message': _(
|
||||
"You have set the fiscal position '%s' "
|
||||
"that require the customer to have a VAT number, "
|
||||
"but the VAT number is missing.") % fp.name
|
||||
}
|
||||
return True
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2013-2014 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record id="view_partner_property_form" model="ir.ui.view">
|
||||
<field name="name">customer.must.have.vat.fiscal_position_form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="account.view_partner_property_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="property_account_position" position="attributes">
|
||||
<attribute name="on_change">fiscal_position_change(property_account_position, vat, customer)</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user