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

fix: register poweremail_n_mails_per_batch varconf #159

Open
wants to merge 3 commits into
base: v5_backport
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion __terp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"author" : "Sharoon Thomas, Openlabs",
"website" : "http://openlabs.co.in/blog/post/poweremail/",
"category" : "Added functionality",
"depends" : ['base'],
"depends" : ['base_extended'],
"description": """
Power Email - extends the most Power ful open source ERP with email which powers the world today.

Expand All @@ -53,6 +53,7 @@
'poweremail_demo.xml'
],
"update_xml": [
'data/res_config.xml',
'security/poweremail_security.xml',
'poweremail_core_view.xml',
'wizard/wizard_poweremail_preview.xml',
Expand Down
10 changes: 10 additions & 0 deletions data/res_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
<record model="res.config" id="poweremail_n_mails_per_batch">
<field name="name">poweremail_n_mails_per_batch</field>
<field name="value">0</field>
<field name="description">Sets a limit of mails to send every time the email cron is run. 0 for no limit.</field>
</record>
</data>
</openerp>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
import logging
from oopgrade.oopgrade import load_data_records
import pooler


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

logger = logging.getLogger('openerp.migration')
logger.info("Creating pooler")
pool = pooler.get_pool(cursor.dbname)

uid = 1
irmd_o = pool.get('ir.model.data')
varconf_k = 'poweremail_n_mails_per_batch'
irmd_id = irmd_o.search(cursor, uid, [('name', '=', varconf_k)])
if not irmd_id:
varconf_o = pool.get('res.config')
varconf_id = varconf_o.search(cursor, uid, [('name', '=', varconf_k)])
if varconf_id:
varconf_v = varconf_o.get(cursor, uid, varconf_k)
varconf_o.unlink(cursor, uid, varconf_id)
load_data_records(
cursor, 'poweremail', 'data/res_config.xml', ['poweremail_n_mails_per_batch'], mode='init'
)
if varconf_id:
varconf_o.set(cursor, uid, varconf_k, varconf_v)


def down(cursor, installed_version):
pass


migrate = up