account_fiscal_position_vat_check: black, isort and others
This commit is contained in:
parent
32073277ab
commit
93efc08cfa
@ -3,16 +3,16 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Account Fiscal Position VAT Check',
|
||||
'version': '14.0.1.0.0',
|
||||
'category': 'Invoices & Payments',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Check VAT on invoice validation',
|
||||
'author': "Akretion,Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/OCA/account-financial-tools',
|
||||
'depends': ['account', 'base_vat'],
|
||||
'data': [
|
||||
'views/account_fiscal_position.xml',
|
||||
"name": "Account Fiscal Position VAT Check",
|
||||
"version": "14.0.1.0.0",
|
||||
"category": "Invoices & Payments",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Check VAT on invoice validation",
|
||||
"author": "Akretion,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/account-financial-tools",
|
||||
"depends": ["account", "base_vat"],
|
||||
"data": [
|
||||
"views/account_fiscal_position.xml",
|
||||
],
|
||||
'installable': True,
|
||||
"installable": True,
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_fiscal_position_vat_check
|
||||
# * account_fiscal_position_vat_check
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 12.0\n"
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: <>\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@ -19,25 +19,49 @@ msgid "Contact"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_fiscal_position_vat_check
|
||||
#: model:ir.model,name:account_fiscal_position_vat_check.model_account_invoice
|
||||
msgid "Invoice"
|
||||
#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_account_move__display_name
|
||||
#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_res_partner__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_fiscal_position_vat_check
|
||||
#: code:addons/account_fiscal_position_vat_check/models/partner.py:19
|
||||
#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_account_move__id
|
||||
#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_res_partner__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_fiscal_position_vat_check
|
||||
#: model:ir.model,name:account_fiscal_position_vat_check.model_account_move
|
||||
msgid "Journal Entry"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_fiscal_position_vat_check
|
||||
#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_account_move____last_update
|
||||
#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_res_partner____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_fiscal_position_vat_check
|
||||
#: code:addons/account_fiscal_position_vat_check/models/partner.py:0
|
||||
#, python-format
|
||||
msgid "Missing VAT number:"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_fiscal_position_vat_check
|
||||
#: code:addons/account_fiscal_position_vat_check/models/account_invoice.py:21
|
||||
#: code:addons/account_fiscal_position_vat_check/models/account_move.py:0
|
||||
#, python-format
|
||||
msgid "You are trying to validate a customer invoice/refund with the fiscal position '%s' that require the customer to have a VAT number. But the Customer '%s' doesn't have a VAT number in Odoo. Please add the VAT number of this Customer in Odoo and try to validate again."
|
||||
msgid ""
|
||||
"You are trying to validate a customer invoice/refund with the fiscal "
|
||||
"position '%s' that require the customer to have a VAT number. But the "
|
||||
"Customer '%s' doesn't have a VAT number in Odoo. Please add the VAT number "
|
||||
"of this Customer in Odoo and try to validate again."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_fiscal_position_vat_check
|
||||
#: code:addons/account_fiscal_position_vat_check/models/partner.py:20
|
||||
#: code:addons/account_fiscal_position_vat_check/models/partner.py:0
|
||||
#, python-format
|
||||
msgid "You have set the fiscal position '%s' that require the customer to have a VAT number, but the VAT number is missing."
|
||||
msgid ""
|
||||
"You have set the fiscal position '%s' that require customers to have a VAT "
|
||||
"number. If you plan to use this partner as a customer, you should add its "
|
||||
"VAT number."
|
||||
msgstr ""
|
||||
|
||||
|
@ -2,27 +2,33 @@
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, _
|
||||
from odoo import _, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
_inherit = "account.move"
|
||||
|
||||
def _post(self, soft=True):
|
||||
"""Check that the customer has VAT set if required by the
|
||||
fiscal position"""
|
||||
for move in self:
|
||||
if (
|
||||
move.move_type in ('out_invoice', 'out_refund') and
|
||||
move.fiscal_position_id.vat_required and
|
||||
not move.commercial_partner_id.vat):
|
||||
raise UserError(_(
|
||||
"You are trying to validate a customer invoice/refund "
|
||||
"with the fiscal position '%s' that require the customer "
|
||||
"to have a VAT number. But the Customer '%s' doesn't have "
|
||||
"a VAT number in Odoo. Please add the VAT number of this "
|
||||
"Customer in Odoo and try to validate again.") % (
|
||||
move.move_type in ("out_invoice", "out_refund")
|
||||
and move.fiscal_position_id.vat_required
|
||||
and not move.commercial_partner_id.vat
|
||||
):
|
||||
raise UserError(
|
||||
_(
|
||||
"You are trying to validate a customer invoice/refund "
|
||||
"with the fiscal position '%s' that require the customer "
|
||||
"to have a VAT number. But the Customer '%s' doesn't have "
|
||||
"a VAT number in Odoo. Please add the VAT number of this "
|
||||
"Customer in Odoo and try to validate again."
|
||||
)
|
||||
% (
|
||||
move.fiscal_position_id.display_name,
|
||||
move.commercial_partner_id.display_name))
|
||||
move.commercial_partner_id.display_name,
|
||||
)
|
||||
)
|
||||
return super()._post(soft=soft)
|
||||
|
@ -2,25 +2,27 @@
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, _
|
||||
from odoo import _, api, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
_inherit = "res.partner"
|
||||
|
||||
@api.onchange('property_account_position_id')
|
||||
@api.onchange("property_account_position_id")
|
||||
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_id
|
||||
if fp.vat_required and not self.vat:
|
||||
return {
|
||||
'warning': {
|
||||
'title': _('Missing VAT number:'),
|
||||
'message': _(
|
||||
"warning": {
|
||||
"title": _("Missing VAT number:"),
|
||||
"message": _(
|
||||
"You have set the fiscal position '%s' "
|
||||
"that require customers to have a VAT number. "
|
||||
"If you plan to use this partner as a customer, you "
|
||||
"should add its VAT number.") % fp.display_name
|
||||
"should add its VAT number."
|
||||
)
|
||||
% fp.display_name,
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2013-2020 Akretion France (https://akretion.com/)
|
||||
@author: 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="vat_required" position="attributes">
|
||||
<!-- always display that field -->
|
||||
<attribute name="attrs">{}</attribute>
|
||||
<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="vat_required" position="attributes">
|
||||
<!-- always display that field -->
|
||||
<attribute name="attrs">{}</attribute>
|
||||
</field>
|
||||
</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="vat_required" />
|
||||
</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="vat_required" />
|
||||
</field>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</record>
|
||||
</odoo>
|
||||
|
Loading…
Reference in New Issue
Block a user