Skip to content

Commit

Permalink
Merge pull request #150 from gisce/56739_reencuar_enviament_correus
Browse files Browse the repository at this point in the history
Reencuar enviament de correus erroni per limitacio de 30 al min
  • Loading branch information
eberloso authored May 22, 2024
2 parents b10b526 + 2392f46 commit 9a94228
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions __terp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
'poweremail_mailbox_view.xml',
'poweremail_serveraction_view.xml',
'security/ir.model.access.csv',
'poweremail_mailbox_cronjobs.xml'
],
"installable": True,
"active": False,
Expand Down
24 changes: 24 additions & 0 deletions migrations/5.0.24.5.0/post-0001_cron_rencuar_emails.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
import logging
from oopgrade.oopgrade import load_data


def up(cursor, installed_version):
if not installed_version:
return

logger = logging.getLogger('openerp.migration')

##UPATAR UN XML SENCER##
logger.info("Updating XML poweremail_mailbox_cronjobs.xml")
load_data(
cursor, 'poweremail', 'poweremail_mailbox_cronjobs.xml', idref=None, mode='update'
)
logger.info("XMLs succesfully updated.")


def down(cursor, installed_version):
pass


migrate = up
13 changes: 13 additions & 0 deletions poweremail_mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,19 @@ def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None,
return super(osv.osv, self).search(cr, uid, args, offset, limit,
order, context=context, count=count)

def _cronjob_resend_emails_error(self, cursor, uid, context=None):
if context is None:
context = {}

emails_ids = self.search(cursor, uid, [
('history', 'like', '%None%'),
('folder', '=', 'error')
], context=context)

self.write(cursor, uid, emails_ids, {'state': 'na', 'folder': 'outbox'}, context=context)
self.historise(cursor, uid, emails_ids, _("Email will be sent again"), context=context)


PoweremailMailbox()


Expand Down
19 changes: 19 additions & 0 deletions poweremail_mailbox_cronjobs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!-- Totes les accions en mode bach en un sol cron -->
<record model="ir.cron" id="ir_cron_reenviar_emails_error" forcecreate="1">
<field name="name">Reenviar emails amb error</field>
<field name="active" eval="0"/>
<field name="user_id" ref="base.user_admin"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="0"/>
<field name="nextcall" eval="time.strftime('%Y-%m-%d 00:00:00')"/>
<field name="model" eval="'poweremail.mailbox'"/>
<field name="function" eval="'_cronjob_resend_emails_error'"/>
<field name="args" eval="()"/>
</record>
</data>
</openerp>

0 comments on commit 9a94228

Please sign in to comment.