Skip to content

Commit

Permalink
[14.0][IMP] l10n_it_fatturapa_pec: no server draft on max pec error c…
Browse files Browse the repository at this point in the history
…ount

Implementa OCA#3554
  • Loading branch information
FrancescoBallerini committed Sep 2, 2023
1 parent 7213f0d commit f01f7de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion l10n_it_fatturapa_pec/models/fetchmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def _default_e_inv_notify_partner_ids(self):

last_pec_error_message = fields.Text("Last PEC Error Message", readonly=True)
pec_error_count = fields.Integer("PEC error count", readonly=True)
lock_on_max_pec_error_count = fields.Boolean(
default=True,
help="Put server in 'draft' state if max PEC error count reaches "
"'fetchmail.pec.max.retry' system parameter's value.",
)
e_inv_notify_partner_ids = fields.Many2many(
"res.partner",
string="Contacts to notify",
Expand Down Expand Up @@ -131,7 +136,10 @@ def fetch_mail(self):
max_retry = self.env["ir.config_parameter"].get_param(
"fetchmail.pec.max.retry"
)
if server.pec_error_count > int(max_retry):
if (
server.pec_error_count > int(max_retry)
and server.lock_on_max_pec_error_count
):
# Setting to draft prevents new e-invoices to
# be sent via PEC.
# Resetting server state only after N fails.
Expand Down
6 changes: 6 additions & 0 deletions l10n_it_fatturapa_pec/views/fetchmail_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
</group>
</page>
</notebook>
<xpath expr="//page[@name='advanced_options']/group" position="inside">
<field
name="lock_on_max_pec_error_count"
string="Lock server on max PEC error count"
/>
</xpath>
<xpath expr="//notebook/page[1]/group[1]/group[3]" position="attributes">
<!-- Hiding, because it would not be considered. See 'fetch_mail' override -->
<attribute
Expand Down

0 comments on commit f01f7de

Please sign in to comment.