Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reencuar enviament de correus erroni per limitacio de 30 al min #150

Merged
merged 8 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading