Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion account_invoice_en16931/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ def _check_invoice_type_code(self):

def _post(self, soft=True):
for move in self.filtered(lambda x: x.is_sale_document()):
move.company_id._en16931_checks()
if move.company_id.en16931_issuer:
move.company_id._en16931_checks()
errors = []
if not move.company_id.no_vat_taxes:
for line in move.invoice_line_ids.filtered(
Expand Down
8 changes: 8 additions & 0 deletions account_invoice_en16931/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ class ResCompany(models.Model):
default="facturx",
string="Default PDF Invoice Generation",
)
en16931_issuer = fields.Boolean(
string="Issues EN16931 e-Invoices",
help="Check the EN16931 configuration of this company when a customer "
"invoice is posted. Leave unchecked for companies that never emit an "
"EN16931 document: their tax configuration is then only checked when "
"such a document is actually generated. Localisation modules may set "
"this field for the companies they cover.",
)
no_vat_taxes = fields.Boolean(
compute="_compute_no_vat_taxes", string="Company has no VAT Taxes"
)
Expand Down
21 changes: 21 additions & 0 deletions account_invoice_en16931/wizards/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ResConfigSettings(models.TransientModel):
en16931_default_pdf_invoice = fields.Selection(
related="company_id.en16931_default_pdf_invoice", readonly=False
)
en16931_issuer = fields.Boolean(related="company_id.en16931_issuer", readonly=False)
no_vat_taxes = fields.Boolean(related="company_id.no_vat_taxes")
no_vat_taxes_vatex_id = fields.Many2one(
related="company_id.no_vat_taxes_vatex_id", readonly=False
Expand All @@ -22,3 +23,23 @@ class ResConfigSettings(models.TransientModel):
string="Raise Error if Saxon Validation Fails",
config_parameter="en16931.saxon_validation_blocking",
)

def button_en16931_checks(self):
"""Run the EN16931 configuration checks of the current company on demand.

_en16931_checks() raises a UserError listing what is wrong, so reaching
the end means the company is properly configured.
"""
self.ensure_one()
self.company_id._en16931_checks()
return {
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"type": "success",
"message": self.env._(
"The EN16931 configuration of company %s is valid.",
self.company_id.display_name,
),
},
}
15 changes: 15 additions & 0 deletions account_invoice_en16931/wizards/res_config_settings_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
<setting id="en16931_default_pdf_invoice">
<field name="en16931_default_pdf_invoice" class="w-100" />
</setting>
<setting
id="en16931_issuer"
help="When enabled, the EN16931 configuration of this company is checked every time a customer invoice is posted. Whether it is enabled or not, the same checks always run when an EN16931 document is generated."
>
<field name="en16931_issuer" />
<div class="mt8">
<button
name="button_en16931_checks"
type="object"
string="Check Configuration"
class="btn-link"
icon="fa-check"
/>
</div>
</setting>
<setting
id="saxon_server_url"
help="The default value for the Saxon Server URL is http://localhost:5000/transform If you need to use another URL, you can enter it below."
Expand Down
Loading