[FIX] account_peppol: peppol_move_state

One flow wasn't considered in the PR that added a ready state:
- A user unchecks BIS3 XML generation and sending via Peppol in the send & print wizard
- `peppol_move_state` is set to `ready`, even though it's not possible to send it without the XML file, so it queues forever

This commit adds a `skipped` state. If the XML file is not generated, the `peppol_move_state`
is changed to `skipped` and the user needs to manually regenerate attachments to send the invoice via Peppol.
Also, the BIS3 checkbox shouldn't be deselected automatically when peppol checkbox is deselected.

Part-of: odoo/odoo#141258
This commit is contained in:
aliya
2023-11-08 14:36:26 +00:00
parent 3135699792
commit 098939b20a
4 changed files with 21 additions and 1 deletions
@@ -53,7 +53,7 @@ class AccountMoveSend(models.TransientModel):
@api.depends('enable_ubl_cii_xml')
def _compute_checkbox_ubl_cii_xml(self):
for wizard in self:
wizard.checkbox_ubl_cii_xml = wizard.enable_ubl_cii_xml and wizard.company_id.invoice_is_ubl_cii
wizard.checkbox_ubl_cii_xml = wizard.enable_ubl_cii_xml and (wizard.checkbox_ubl_cii_xml or wizard.company_id.invoice_is_ubl_cii)
# -------------------------------------------------------------------------
# ATTACHMENTS
@@ -597,6 +597,11 @@ msgstr ""
msgid "Send via PEPPOL"
msgstr ""
#. module: account_peppol
#: model:ir.model.fields.selection,name:account_peppol.selection__account_move__peppol_move_state__skipped
msgid "Skipped"
msgstr ""
#. module: account_peppol
#: model_terms:ir.ui.view,arch_db:account_peppol.res_config_settings_view_form
msgid ""
@@ -13,6 +13,7 @@ class AccountMove(models.Model):
selection=[
('ready', 'Ready to send'),
('to_send', 'Queued'),
('skipped', 'Skipped'),
('processing', 'Pending Reception'),
('canceled', 'Canceled'),
('done', 'Done'),
@@ -24,6 +25,19 @@ class AccountMove(models.Model):
)
peppol_is_demo_uuid = fields.Boolean(compute="_compute_peppol_is_demo_uuid")
@api.model
def fields_get(self, allfields=None, attributes=None):
res = super().fields_get(allfields, attributes)
# the orm_cache does not contain the new selections added in stable: clear the cache once
peppol_move_state_field = self._fields['peppol_move_state']
if ('skipped', "Skipped") not in peppol_move_state_field.get_description(self.env)['selection']:
self.env['ir.model.fields'].invalidate_model(['selection_ids'])
self.env['ir.model.fields.selection']._update_selection(
'account.move', 'peppol_move_state', peppol_move_state_field.selection)
self.env.registry.clear_cache()
return res
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
@@ -130,6 +130,7 @@ class AccountMoveSend(models.TransientModel):
xml_file = invoice.ubl_cii_xml_id.raw
filename = invoice.ubl_cii_xml_id.name
else:
invoice.peppol_move_state = 'skipped'
continue
if not invoice.partner_id.peppol_eas or not invoice.partner_id.peppol_endpoint: