Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Peppol

Entity: account.move

Compute Method: _compute_peppol_move_state

View 17.0 View 20.0
Inputs Method Outputs
  • company_id
  • company_id.account_peppol_proxy_state
  • commercial_partner_id
  • commercial_partner_id.account_peppol_is_endpoint_valid
  • state
  • move_type
  • peppol_move_state
  • peppol_response_ids
  • company_id.peppol_can_send
  • commercial_partner_id.peppol_verification_state
  • peppol_is_sent
for move in self:
-             if all([
-                 move.company_id.account_peppol_proxy_state in ('active', 'sender'),
-                 move.commercial_partner_id.account_peppol_is_endpoint_valid,
+             if valid_statuses := move.peppol_response_ids.filtered(lambda r: r.peppol_state == 'done').mapped('response_code'):
+                 if 'RE' in valid_statuses:
+                     move.peppol_move_state = 'RE'
+                 elif any(status in {'AP', 'PD'} for status in valid_statuses):
+                     move.peppol_move_state = 'AP'
+                 else:
+                     move.peppol_move_state = 'AB'
+             elif all([
+                 move.company_id.peppol_can_send,
+                 move.commercial_partner_id.peppol_verification_state == 'valid',
                move.state == 'posted',
-                 move.move_type in ('out_invoice', 'out_refund', 'out_receipt'),
+                 move.is_sale_document(include_receipts=True),
                not move.peppol_move_state,
            ]):
                move.peppol_move_state = 'ready'
            elif (
                move.state == 'draft'
                and move.is_sale_document(include_receipts=True)
-                 and move.peppol_move_state not in ('processing', 'done')
+                 and not move.peppol_is_sent
            ):
                move.peppol_move_state = False
            else:
                move.peppol_move_state = move.peppol_move_state
  • peppol_move_state

Back to entity