[FIX] account_peppol: allow the download of UBL files w/o eas and endpoint
Currently, users are blocked from downloading the UBL file if the partner or the company are missing Peppol EAS and Peppol Endpoint fields. The checkbox is not visible and even if it was visible, the user would see a UserError asking to fill those values. Let users download these files but show a banner warning about missing fields. closes odoo/odoo#159553 closes odoo/odoo#160035 Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com> Signed-off-by: Aliya Tastemirova (alta) <alta@odoo.com>
This commit is contained in:
@@ -823,6 +823,16 @@ msgid ""
|
||||
"The field 'Sanitized Account Number' is required on the Recipient Bank."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_edi_ubl_cii
|
||||
#. odoo-python
|
||||
#: code:addons/account_edi_ubl_cii/models/account_move_send.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The following partners are missing Peppol EAS or Peppol Endpoint field: %s. "
|
||||
"Please check those in their Accounting tab. Otherwise, the generated files "
|
||||
"will be incomplete."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_edi_ubl_cii
|
||||
#. odoo-python
|
||||
#: code:addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py:0
|
||||
@@ -842,6 +852,15 @@ msgid ""
|
||||
"been reverted."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_edi_ubl_cii
|
||||
#. odoo-python
|
||||
#: code:addons/account_edi_ubl_cii/models/account_move_send.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"This partner is missing Peppol EAS or Peppol Endpoint field. Please check "
|
||||
"those in its Accounting tab or the generated file will be incomplete."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_edi_ubl_cii
|
||||
#. odoo-python
|
||||
#: code:addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py:0
|
||||
|
||||
@@ -270,13 +270,6 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel):
|
||||
# EXTENDS account.edi.xml.ubl_21
|
||||
constraints = super()._export_invoice_constraints(invoice, vals)
|
||||
|
||||
constraints.update({
|
||||
'peppol_eas_is_set_supplier': self._check_required_fields(vals['supplier'], 'peppol_eas'),
|
||||
'peppol_eas_is_set_customer': self._check_required_fields(vals['customer'], 'peppol_eas'),
|
||||
'peppol_endpoint_is_set_supplier': self._check_required_fields(vals['supplier'], 'peppol_endpoint'),
|
||||
'peppol_endpoint_is_set_customer': self._check_required_fields(vals['customer'], 'peppol_endpoint'),
|
||||
})
|
||||
|
||||
constraints.update(
|
||||
self._invoice_constraints_peppol_en16931_ubl(invoice, vals)
|
||||
)
|
||||
|
||||
@@ -19,6 +19,14 @@ class AccountMoveSend(models.TransientModel):
|
||||
enable_ubl_cii_xml = fields.Boolean(compute='_compute_enable_ubl_cii_xml')
|
||||
checkbox_ubl_cii_label = fields.Char(compute='_compute_checkbox_ubl_cii_label')
|
||||
checkbox_ubl_cii_xml = fields.Boolean(compute='_compute_checkbox_ubl_cii_xml', store=True, readonly=False)
|
||||
ubl_partner_warning = fields.Char(
|
||||
string="Partner warning",
|
||||
compute="_compute_ubl_warnings",
|
||||
)
|
||||
show_ubl_company_warning = fields.Boolean(
|
||||
string="Company warning",
|
||||
compute="_compute_ubl_warnings",
|
||||
)
|
||||
|
||||
def _get_wizard_values(self):
|
||||
# EXTENDS 'account'
|
||||
@@ -64,6 +72,27 @@ class AccountMoveSend(models.TransientModel):
|
||||
for wizard in self:
|
||||
wizard.checkbox_ubl_cii_xml = wizard.enable_ubl_cii_xml and (wizard.checkbox_ubl_cii_xml or wizard.company_id.invoice_is_ubl_cii)
|
||||
|
||||
@api.depends('move_ids')
|
||||
def _compute_ubl_warnings(self):
|
||||
for wizard in self:
|
||||
wizard.show_ubl_company_warning = False
|
||||
wizard.ubl_partner_warning = False
|
||||
if not set(wizard.move_ids.partner_id.mapped('ubl_cii_format')) - {False, 'facturx', 'oioubl_201'}:
|
||||
return
|
||||
|
||||
wizard.show_ubl_company_warning = not (wizard.company_id.partner_id.peppol_eas and wizard.company_id.partner_id.peppol_endpoint)
|
||||
not_configured_partners = wizard.move_ids.partner_id.commercial_partner_id.filtered(
|
||||
lambda partner: not (partner.peppol_eas and partner.peppol_endpoint)
|
||||
)
|
||||
if len(not_configured_partners) == 1:
|
||||
wizard.ubl_partner_warning = _("This partner is missing Peppol EAS or Peppol Endpoint field. "
|
||||
"Please check those in its Accounting tab or the generated file will be incomplete.")
|
||||
if len(not_configured_partners) > 1:
|
||||
names = ', '.join(not_configured_partners[:5].mapped('display_name'))
|
||||
wizard.ubl_partner_warning = _("The following partners are missing Peppol EAS or Peppol Endpoint field: %s. "
|
||||
"Please check those in their Accounting tab. "
|
||||
"Otherwise, the generated files will be incomplete.", names)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# ATTACHMENTS
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@@ -6,6 +6,19 @@
|
||||
<field name="model">account.move.send</field>
|
||||
<field name="inherit_id" ref="account.account_move_send_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='warnings']" position="inside">
|
||||
<field name="show_ubl_company_warning" invisible="1"/>
|
||||
<div class="alert alert-info"
|
||||
role="alert"
|
||||
invisible="not checkbox_ubl_cii_xml or not ubl_partner_warning">
|
||||
<field name="ubl_partner_warning"/>
|
||||
</div>
|
||||
<div class="alert alert-info"
|
||||
role="alert"
|
||||
invisible="not checkbox_ubl_cii_xml or not show_ubl_company_warning">
|
||||
Please fill in Peppol EAS and Peppol Endpoint in your company form to generate a complete file.
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='advanced_options']" position="inside">
|
||||
<field name="enable_ubl_cii_xml" invisible="1"/>
|
||||
<div name="option_xml"
|
||||
|
||||
@@ -38,19 +38,6 @@ class AccountMove(models.Model):
|
||||
self.env.registry.clear_cache()
|
||||
return res
|
||||
|
||||
def _need_ubl_cii_xml(self):
|
||||
self.ensure_one()
|
||||
|
||||
res = super()._need_ubl_cii_xml()
|
||||
partner = self.partner_id.commercial_partner_id
|
||||
if partner.ubl_cii_format in {False, 'facturx', 'oioubl_201'} or self.company_id.account_peppol_proxy_state != 'active':
|
||||
return res
|
||||
if not partner.peppol_eas or not partner.peppol_endpoint:
|
||||
return False
|
||||
if partner.account_peppol_verification_label == 'not_verified':
|
||||
partner.button_account_peppol_check_partner_endpoint()
|
||||
return res and partner.account_peppol_is_endpoint_valid
|
||||
|
||||
def action_cancel_peppol_documents(self):
|
||||
# if the peppol_move_state is processing/done
|
||||
# then it means it has been already sent to peppol proxy and we can't cancel
|
||||
|
||||
@@ -45,7 +45,7 @@ class AccountMoveSend(models.TransientModel):
|
||||
@api.depends('enable_peppol')
|
||||
def _compute_checkbox_send_peppol(self):
|
||||
for wizard in self:
|
||||
wizard.checkbox_send_peppol = wizard.enable_peppol
|
||||
wizard.checkbox_send_peppol = wizard.enable_peppol and not wizard.peppol_warning
|
||||
|
||||
@api.depends('checkbox_send_peppol')
|
||||
def _compute_checkbox_ubl_cii_xml(self):
|
||||
@@ -147,7 +147,6 @@ class AccountMoveSend(models.TransientModel):
|
||||
|
||||
partner = invoice.partner_id.commercial_partner_id
|
||||
if not partner.peppol_eas or not partner.peppol_endpoint:
|
||||
# should never happen but in case it does, we need to handle it
|
||||
invoice.peppol_move_state = 'error'
|
||||
invoice_data['error'] = _('The partner is missing Peppol EAS and/or Endpoint identifier.')
|
||||
continue
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='warnings']" position="inside">
|
||||
<field name="enable_peppol" invisible="1"/>
|
||||
<div class="alert alert-warning" role="alert" invisible="not checkbox_send_peppol or not peppol_warning">
|
||||
<div class="alert alert-warning" role="alert" invisible="not checkbox_send_peppol or not peppol_warning or ubl_partner_warning">
|
||||
<!-- hiding the warning if we're already showing one through the
|
||||
UBL module to avoid showing basically the same errors at the same time -->
|
||||
<field name="peppol_warning"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user