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).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Account Fiscal Position VAT Check',
|
"name": "Account Fiscal Position VAT Check",
|
||||||
'version': '14.0.1.0.0',
|
"version": "14.0.1.0.0",
|
||||||
'category': 'Invoices & Payments',
|
"category": "Invoices & Payments",
|
||||||
'license': 'AGPL-3',
|
"license": "AGPL-3",
|
||||||
'summary': 'Check VAT on invoice validation',
|
"summary": "Check VAT on invoice validation",
|
||||||
'author': "Akretion,Odoo Community Association (OCA)",
|
"author": "Akretion,Odoo Community Association (OCA)",
|
||||||
'website': 'https://github.com/OCA/account-financial-tools',
|
"website": "https://github.com/OCA/account-financial-tools",
|
||||||
'depends': ['account', 'base_vat'],
|
"depends": ["account", "base_vat"],
|
||||||
'data': [
|
"data": [
|
||||||
'views/account_fiscal_position.xml',
|
"views/account_fiscal_position.xml",
|
||||||
],
|
],
|
||||||
'installable': True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# Translation of Odoo Server.
|
# Translation of Odoo Server.
|
||||||
# This file contains the translation of the following modules:
|
# This file contains the translation of the following modules:
|
||||||
# * account_fiscal_position_vat_check
|
# * account_fiscal_position_vat_check
|
||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 12.0\n"
|
"Project-Id-Version: Odoo Server 14.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
@ -19,25 +19,49 @@ msgid "Contact"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_fiscal_position_vat_check
|
#. module: account_fiscal_position_vat_check
|
||||||
#: model:ir.model,name:account_fiscal_position_vat_check.model_account_invoice
|
#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_account_move__display_name
|
||||||
msgid "Invoice"
|
#: model:ir.model.fields,field_description:account_fiscal_position_vat_check.field_res_partner__display_name
|
||||||
|
msgid "Display Name"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_fiscal_position_vat_check
|
#. 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
|
#, python-format
|
||||||
msgid "Missing VAT number:"
|
msgid "Missing VAT number:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_fiscal_position_vat_check
|
#. 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
|
#, 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 ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_fiscal_position_vat_check
|
#. 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
|
#, 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 ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -2,27 +2,33 @@
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# 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
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
class AccountMove(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = 'account.move'
|
_inherit = "account.move"
|
||||||
|
|
||||||
def _post(self, soft=True):
|
def _post(self, soft=True):
|
||||||
"""Check that the customer has VAT set if required by the
|
"""Check that the customer has VAT set if required by the
|
||||||
fiscal position"""
|
fiscal position"""
|
||||||
for move in self:
|
for move in self:
|
||||||
if (
|
if (
|
||||||
move.move_type in ('out_invoice', 'out_refund') and
|
move.move_type in ("out_invoice", "out_refund")
|
||||||
move.fiscal_position_id.vat_required and
|
and move.fiscal_position_id.vat_required
|
||||||
not move.commercial_partner_id.vat):
|
and not move.commercial_partner_id.vat
|
||||||
raise UserError(_(
|
):
|
||||||
"You are trying to validate a customer invoice/refund "
|
raise UserError(
|
||||||
"with the fiscal position '%s' that require the customer "
|
_(
|
||||||
"to have a VAT number. But the Customer '%s' doesn't have "
|
"You are trying to validate a customer invoice/refund "
|
||||||
"a VAT number in Odoo. Please add the VAT number of this "
|
"with the fiscal position '%s' that require the customer "
|
||||||
"Customer in Odoo and try to validate again.") % (
|
"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.fiscal_position_id.display_name,
|
||||||
move.commercial_partner_id.display_name))
|
move.commercial_partner_id.display_name,
|
||||||
|
)
|
||||||
|
)
|
||||||
return super()._post(soft=soft)
|
return super()._post(soft=soft)
|
||||||
|
|
|
@ -2,25 +2,27 @@
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# 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):
|
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):
|
def fiscal_position_change(self):
|
||||||
"""Warning if the fiscal position requires a VAT number and the
|
"""Warning if the fiscal position requires a VAT number and the
|
||||||
partner doesn't have one yet"""
|
partner doesn't have one yet"""
|
||||||
fp = self.property_account_position_id
|
fp = self.property_account_position_id
|
||||||
if fp.vat_required and not self.vat:
|
if fp.vat_required and not self.vat:
|
||||||
return {
|
return {
|
||||||
'warning': {
|
"warning": {
|
||||||
'title': _('Missing VAT number:'),
|
"title": _("Missing VAT number:"),
|
||||||
'message': _(
|
"message": _(
|
||||||
"You have set the fiscal position '%s' "
|
"You have set the fiscal position '%s' "
|
||||||
"that require customers to have a VAT number. "
|
"that require customers to have a VAT number. "
|
||||||
"If you plan to use this partner as a customer, you "
|
"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/)
|
Copyright 2013-2020 Akretion France (https://akretion.com/)
|
||||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
<record id="view_account_position_form" model="ir.ui.view">
|
||||||
|
<field name="name">customer.must.have.vat.fiscal_position_form</field>
|
||||||
<record id="view_account_position_form" model="ir.ui.view">
|
<field name="model">account.fiscal.position</field>
|
||||||
<field name="name">customer.must.have.vat.fiscal_position_form</field>
|
<field name="inherit_id" ref="account.view_account_position_form" />
|
||||||
<field name="model">account.fiscal.position</field>
|
<field name="arch" type="xml">
|
||||||
<field name="inherit_id" ref="account.view_account_position_form" />
|
<field name="vat_required" position="attributes">
|
||||||
<field name="arch" type="xml">
|
<!-- always display that field -->
|
||||||
<field name="vat_required" position="attributes">
|
<attribute name="attrs">{}</attribute>
|
||||||
<!-- always display that field -->
|
</field>
|
||||||
<attribute name="attrs">{}</attribute>
|
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</record>
|
||||||
</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>
|
||||||
<record id="view_account_position_tree" model="ir.ui.view">
|
<field name="inherit_id" ref="account.view_account_position_tree" />
|
||||||
<field name="name">customer.must.have.vat.fiscal_position_tree</field>
|
<field name="arch" type="xml">
|
||||||
<field name="model">account.fiscal.position</field>
|
<field name="name" position="after">
|
||||||
<field name="inherit_id" ref="account.view_account_position_tree" />
|
<field name="vat_required" />
|
||||||
<field name="arch" type="xml">
|
</field>
|
||||||
<field name="name" position="after">
|
|
||||||
<field name="vat_required" />
|
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</record>
|
||||||
</record>
|
|
||||||
|
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user