From 489196ee763b2e242aa89269504e6d1ce8447bf7 Mon Sep 17 00:00:00 2001
From: "Chirag Dodiya (OpenERP Trainee)"
Date: Tue, 11 Jun 2013 17:43:10 +0530
Subject: [PATCH 001/175] Added selection field into company, set font
dynamically to all para style in header
bzr revid: chiragdd7@gmail.com-20130611121310-35ogs0ler806hkov
---
openerp/addons/base/res/res_company.py | 43 +++++++++++++++++++-
openerp/addons/base/res/res_company_view.xml | 3 ++
openerp/report/render/rml2pdf/customfonts.py | 1 +
openerp/report/render/rml2pdf/trml2pdf.py | 15 ++++++-
4 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 02dfefe1e38..6705a893910 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -20,7 +20,7 @@
##############################################################################
import os
-
+import re
import openerp
from openerp import SUPERUSER_ID, tools
from openerp.osv import fields, osv
@@ -28,6 +28,25 @@ from openerp.tools.translate import _
from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools import image_resize_image
+_select_font=[ ('DejaVu Sans',"DejaVu Sans"),
+ ('DejaVu Sans Bold',"DejaVu Sans Bold"),
+ ('DejaVu Sans Oblique',"DejaVu Sans Oblique"),
+ ('DejaVu Sans BoldOblique',"DejaVu Sans BoldOblique"),
+ ('Liberation Serif',"Liberation Serif"),
+ ('Liberation Serif Bold',"Liberation Serif Bold"),
+ ('Liberation Serif Italic',"Liberation Serif Italic"),
+ ('Liberation Serif BoldItalic',"Liberation Serif BoldItalic"),
+ ('Liberation Serif',"Liberation Serif"),
+ ('Liberation Serif Bold',"Liberation Serif Bold"),
+ ('Liberation Serif Italic',"Liberation Serif Italic"),
+ ('Liberation Serif BoldItalic',"Liberation Serif BoldItalic"),
+ ('FreeMono',"FreeMono"),
+ ('FreeMono Bold',"FreeMono Bold"),
+ ('FreeMono Oblique',"FreeMono Oblique"),
+ ('FreeMono BoldOblique',"FreeMono BoldOblique"),
+ ('Sun-ExtA',"Sun-ExtA")
+]
+
class multi_company_default(osv.osv):
"""
Manage multi company default value
@@ -108,7 +127,7 @@ class res_company(osv.osv):
size = (180, None)
result[record.id] = image_resize_image(record.partner_id.image, size)
return result
-
+
def _get_companies_from_partner(self, cr, uid, ids, context=None):
return self.pool['res.company'].search(cr, uid, [('partner_id', 'in', ids)], context=context)
@@ -147,6 +166,7 @@ class res_company(osv.osv):
'vat': fields.related('partner_id', 'vat', string="Tax ID", type="char", size=32),
'company_registry': fields.char('Company Registry', size=64),
'paper_format': fields.selection([('a4', 'A4'), ('us_letter', 'US Letter')], "Paper Format", required=True),
+ 'font': fields.selection(_select_font, "Select Font"),
}
_sql_constraints = [
('name_uniq', 'unique (name)', 'The company name must be unique !')
@@ -178,6 +198,25 @@ class res_company(osv.osv):
if state_id:
return {'value':{'country_id': self.pool.get('res.country.state').browse(cr, uid, state_id, context).country_id.id }}
return {}
+
+ def onchange_font_name(self, cr, uid, ids, font, context=None):
+ """
+ To change default header style of all and drawstring.
+ """
+ def _change_header(header,font):
+ """
+ Replace default fontname use in header and setfont tag
+ """
+ default_para = re.sub('fontName.?=.?".*"', 'fontName="%s"'% font,header)
+ return re.sub('("%s"\g<3>'% font,default_para)
+ if not ids: return {}
+ data = self.browse(cr, uid, ids[0], context=context)
+ return {'value':{
+ 'rml_header': _change_header(data.rml_header,font),
+ 'rml_header2':_change_header(data.rml_header2,font),
+ 'rml_header3':_change_header(data.rml_header3,font)
+ }}
+
def on_change_country(self, cr, uid, ids, country_id, context=None):
res = {'domain': {'state_id': []}}
currency_id = self._get_euro(cr, uid, context=context)
diff --git a/openerp/addons/base/res/res_company_view.xml b/openerp/addons/base/res/res_company_view.xml
index b261f80822b..57b487cace1 100644
--- a/openerp/addons/base/res/res_company_view.xml
+++ b/openerp/addons/base/res/res_company_view.xml
@@ -83,6 +83,9 @@
+
+
+
diff --git a/openerp/report/render/rml2pdf/customfonts.py b/openerp/report/render/rml2pdf/customfonts.py
index 85874f2b82f..cb5b3d69e0b 100644
--- a/openerp/report/render/rml2pdf/customfonts.py
+++ b/openerp/report/render/rml2pdf/customfonts.py
@@ -28,6 +28,7 @@ from reportlab import rl_config
from openerp.tools import config
+#.apidoc title: TTF Font Table
"""This module allows the mapping of some system-available TTF fonts to
the reportlab engine.
diff --git a/openerp/report/render/rml2pdf/trml2pdf.py b/openerp/report/render/rml2pdf/trml2pdf.py
index 243cc02a0b3..2052b128ad9 100644
--- a/openerp/report/render/rml2pdf/trml2pdf.py
+++ b/openerp/report/render/rml2pdf/trml2pdf.py
@@ -160,7 +160,7 @@ class _rml_styles(object,):
for style in node.findall('paraStyle'):
sname = style.get('name')
self.styles[sname] = self._para_style_update(style)
- if sname in self.default_style:
+ if self.default_style.has_key(sname):
for key, value in self.styles[sname].items():
setattr(self.default_style[sname], key, value)
else:
@@ -277,11 +277,24 @@ class _rml_doc(object):
fname = font.get('fontFile').encode('ascii')
if name not in pdfmetrics._fonts:
pdfmetrics.registerFont(TTFont(name, fname))
+ #by default, we map the fontName to each style (bold, italic, bold and italic), so that
+ #if there isn't any font defined for one of these style (via a font family), the system
+ #will fallback on the normal font.
addMapping(name, 0, 0, name) #normal
addMapping(name, 0, 1, name) #italic
addMapping(name, 1, 0, name) #bold
addMapping(name, 1, 1, name) #italic and bold
+ #if registerFontFamily is defined, we register the mapping of the fontName to use for each style.
+ for font_family in node.findall('registerFontFamily'):
+ family_name = font_family.get('normal').encode('ascii')
+ if font_family.get('italic'):
+ addMapping(family_name, 0, 1, font_family.get('italic').encode('ascii'))
+ if font_family.get('bold'):
+ addMapping(family_name, 1, 0, font_family.get('bold').encode('ascii'))
+ if font_family.get('boldItalic'):
+ addMapping(family_name, 1, 1, font_family.get('boldItalic').encode('ascii'))
+
def setTTFontMapping(self,face, fontname, filename, mode='all'):
from reportlab.lib.fonts import addMapping
from reportlab.pdfbase import pdfmetrics
From 3398bd14021b7fbbff5b92b4cc93b80081817783 Mon Sep 17 00:00:00 2001
From: "Chirag Dodiya (OpenERP Trainee)"
Date: Wed, 12 Jun 2013 12:37:28 +0530
Subject: [PATCH 002/175] [IMP]Changed In Parastyle
bzr revid: chiragdd7@gmail.com-20130612070728-yk4t52kpczdtt7bq
---
openerp/addons/base/res/res_company.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 6705a893910..7611af4862c 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -357,7 +357,7 @@ class res_company(osv.osv):
-
+
From 72604e8b121ec715791eefbf8ad0fdc6f3064b3a Mon Sep 17 00:00:00 2001
From: "Chirag Dodiya (OpenERP Trainee)"
Date: Wed, 12 Jun 2013 19:02:27 +0530
Subject: [PATCH 003/175] [IMP] Improved Code as per Review suggestion
bzr revid: chiragdd7@gmail.com-20130612133227-xjf0d22bnwk4eota
---
openerp/addons/base/res/res_company.py | 25 ++++++++++----------
openerp/addons/base/res/res_company_view.xml | 2 +-
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 7611af4862c..be5225a9282 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -199,22 +199,20 @@ class res_company(osv.osv):
return {'value':{'country_id': self.pool.get('res.country.state').browse(cr, uid, state_id, context).country_id.id }}
return {}
- def onchange_font_name(self, cr, uid, ids, font, context=None):
- """
- To change default header style of all and drawstring.
- """
+ def onchange_font_name(self, cr, uid, ids, font, rml_header, rml_header2, rml_header3, context=None):
+
+ """ To change default header style of all and drawstring. """
+
def _change_header(header,font):
- """
- Replace default fontname use in header and setfont tag
- """
+
+ """ Replace default fontname use in header and setfont tag """
+
default_para = re.sub('fontName.?=.?".*"', 'fontName="%s"'% font,header)
return re.sub('("%s"\g<3>'% font,default_para)
- if not ids: return {}
- data = self.browse(cr, uid, ids[0], context=context)
return {'value':{
- 'rml_header': _change_header(data.rml_header,font),
- 'rml_header2':_change_header(data.rml_header2,font),
- 'rml_header3':_change_header(data.rml_header3,font)
+ 'rml_header': _change_header(rml_header,font),
+ 'rml_header2':_change_header(rml_header2,font),
+ 'rml_header3':_change_header(rml_header3,font)
}}
def on_change_country(self, cr, uid, ids, country_id, context=None):
@@ -413,7 +411,8 @@ class res_company(osv.osv):
'rml_header':_get_header,
'rml_header2': _header2,
'rml_header3': _header3,
- 'logo':_get_logo
+ 'logo':_get_logo,
+ 'font':'DejaVu Sans'
}
_constraints = [
diff --git a/openerp/addons/base/res/res_company_view.xml b/openerp/addons/base/res/res_company_view.xml
index 57b487cace1..bf117e2c8c1 100644
--- a/openerp/addons/base/res/res_company_view.xml
+++ b/openerp/addons/base/res/res_company_view.xml
@@ -84,7 +84,7 @@
-
+
From ce8fb2e1b73d2672927936f2e1eb69217bc1f61d Mon Sep 17 00:00:00 2001
From: "Chirag Dodiya (OpenERP Trainee)"
Date: Tue, 18 Jun 2013 15:06:55 +0530
Subject: [PATCH 004/175] [IMP] Puted help as per review suggestion
bzr revid: chiragdd7@gmail.com-20130618093655-tnwc1jkbnz5hi1b1
---
openerp/addons/base/res/res_company.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 233e9727c4d..9780f13cf55 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -166,7 +166,7 @@ class res_company(osv.osv):
'vat': fields.related('partner_id', 'vat', string="Tax ID", type="char", size=32),
'company_registry': fields.char('Company Registry', size=64),
'paper_format': fields.selection([('a4', 'A4'), ('us_letter', 'US Letter')], "Paper Format", required=True),
- 'font': fields.selection(_select_font, "Select Font"),
+ 'font': fields.selection(_select_font, "Select Font",help="Set your favorite font into company header"),
}
_sql_constraints = [
('name_uniq', 'unique (name)', 'The company name must be unique !')
@@ -200,11 +200,9 @@ class res_company(osv.osv):
return {}
def onchange_font_name(self, cr, uid, ids, font, rml_header, rml_header2, rml_header3, context=None):
-
""" To change default header style of all and drawstring. """
def _change_header(header,font):
-
""" Replace default fontname use in header and setfont tag """
default_para = re.sub('fontName.?=.?".*"', 'fontName="%s"'% font,header)
From 3cf3519e82efe735f5228bc83bced6366ec895af Mon Sep 17 00:00:00 2001
From: Darshan Kalola
Date: Wed, 24 Jul 2013 19:15:48 +0530
Subject: [PATCH 005/175] [IMP]improve help of setting/configuration menus
bzr revid: darshankalola@gmail.com-20130724134548-jmgot5zt3xpcx1ct
---
addons/account/res_config.py | 36 +++++++-------
addons/base_setup/res_config.py | 21 ++++----
addons/crm/res_config.py | 4 +-
addons/hr_recruitment/res_config.py | 8 ++--
addons/hr_timesheet_sheet/res_config.py | 4 +-
addons/knowledge/res_config.py | 14 +++---
addons/marketing/res_config.py | 14 +++---
addons/mrp/res_config.py | 64 ++++++++++++-------------
addons/project/res_config.py | 34 ++++++-------
addons/purchase/res_config.py | 28 +++++------
addons/sale/res_config.py | 42 ++++++++--------
addons/sale_stock/res_config.py | 8 ++--
addons/stock/res_config.py | 26 +++++-----
13 files changed, 151 insertions(+), 152 deletions(-)
diff --git a/addons/account/res_config.py b/addons/account/res_config.py
index 89d238b16e9..edb34f54be2 100644
--- a/addons/account/res_config.py
+++ b/addons/account/res_config.py
@@ -81,31 +81,31 @@ class account_config_settings(osv.osv_memory):
'purchase_refund_sequence_next': fields.related('purchase_refund_journal_id', 'sequence_id', 'number_next', type='integer', string='Next supplier credit note number'),
'module_account_check_writing': fields.boolean('Pay your suppliers by check',
- help="""This allows you to check writing and printing.
- This installs the module account_check_writing."""),
+ help='This allows you to check writing and printing.\n'
+ 'This installs the module account_check_writing.'),
'module_account_accountant': fields.boolean('Full accounting features: journals, legal statements, chart of accounts, etc.',
help="""If you do not check this box, you will be able to do invoicing & payments, but not accounting (Journal Items, Chart of Accounts, ...)"""),
'module_account_asset': fields.boolean('Assets management',
- help="""This allows you to manage the assets owned by a company or a person.
- It keeps track of the depreciation occurred on those assets, and creates account move for those depreciation lines.
- This installs the module account_asset. If you do not check this box, you will be able to do invoicing & payments,
- but not accounting (Journal Items, Chart of Accounts, ...)"""),
+ help='This allows you to manage the assets owned by a company or a person.\n'
+ 'It keeps track of the depreciation occurred on those assets, and creates account move for those depreciation lines.\n'
+ 'This installs the module account_asset. If you do not check this box, you will be able to do invoicing & payments, '
+ 'but not accounting (Journal Items, Chart of Accounts, ...)'),
'module_account_budget': fields.boolean('Budget management',
- help="""This allows accountants to manage analytic and crossovered budgets.
- Once the master budgets and the budgets are defined,
- the project managers can set the planned amount on each analytic account.
- This installs the module account_budget."""),
+ help='This allows accountants to manage analytic and crossovered budgets. '
+ 'Once the master budgets and the budgets are defined, '
+ 'the project managers can set the planned amount on each analytic account.\n'
+ 'This installs the module account_budget.'),
'module_account_payment': fields.boolean('Manage payment orders',
- help="""This allows you to create and manage your payment orders, with purposes to
- * serve as base for an easy plug-in of various automated payment mechanisms, and
- * provide a more efficient way to manage invoice payments.
- This installs the module account_payment."""),
+ help='This allows you to create and manage your payment orders, with purposes to \n'
+ '* serve as base for an easy plug-in of various automated payment mechanisms, and \n'
+ '* provide a more efficient way to manage invoice payments.\n'
+ 'This installs the module account_payment.' ),
'module_account_voucher': fields.boolean('Manage customer payments',
- help="""This includes all the basic requirements of voucher entries for bank, cash, sales, purchase, expense, contra, etc.
- This installs the module account_voucher."""),
+ help='This includes all the basic requirements of voucher entries for bank, cash, sales, purchase, expense, contra, etc.\n'
+ 'This installs the module account_voucher.'),
'module_account_followup': fields.boolean('Manage customer payment follow-ups',
- help="""This allows to automate letters for unpaid invoices, with multi-level recalls.
- This installs the module account_followup."""),
+ help='This allows to automate letters for unpaid invoices, with multi-level recalls.\n'
+ 'This installs the module account_followup.'),
'group_proforma_invoices': fields.boolean('Allow pro-forma invoices',
implied_group='account.group_proforma_invoices',
help="Allows you to put invoices in pro-forma state."),
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index 6b8578bbf47..82828e5f30d 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -64,18 +64,17 @@ class sale_config_settings(osv.osv_memory):
'module_crm': fields.boolean('CRM'),
'module_sale' : fields.boolean('SALE'),
'module_plugin_thunderbird': fields.boolean('Enable Thunderbird plug-in',
- help="""The plugin allows you archive email and its attachments to the selected
- OpenERP objects. You can select a partner, or a lead and
- attach the selected mail as a .eml file in
- the attachment of a selected record. You can create documents for CRM Lead,
- Partner from the selected emails.
- This installs the module plugin_thunderbird."""),
+ help='The plugin allows you archive email and its attachments to the selected '
+ 'OpenERP objects. You can select a partner, or a lead and '
+ 'attach the selected mail as a .eml file in '
+ 'the attachment of a selected record. You can create documents for CRM Lead, '
+ 'Partner from the selected emails.\n'
+ 'This installs the module plugin_thunderbird.'),
'module_plugin_outlook': fields.boolean('Enable Outlook plug-in',
- help="""The Outlook plugin allows you to select an object that you would like to add
- to your email and its attachments from MS Outlook. You can select a partner,
- or a lead object and archive a selected
- email into an OpenERP mail message with attachments.
- This installs the module plugin_outlook."""),
+ help='The Outlook plugin allows you to select an object that you would like to add '
+ 'to your email and its attachments from MS Outlook. You can select a partner, '
+ 'or a lead object and archive a selected email into an OpenERP mail message with attachments.\n'
+ 'This installs the module plugin_outlook.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/res_config.py b/addons/crm/res_config.py
index ea37c24fe06..622af04ef75 100644
--- a/addons/crm/res_config.py
+++ b/addons/crm/res_config.py
@@ -58,8 +58,8 @@ class crm_configuration(osv.TransientModel):
implied_group='crm.group_fund_raising',
help="""Allows you to trace and manage your activities for fund raising."""),
'module_crm_claim': fields.boolean("Manage Customer Claims",
- help="""Allows you to track your customers/suppliers claims and grievances.
- This installs the module crm_claim."""),
+ help='Allows you to track your customers/suppliers claims and grievances.\n'
+ 'This installs the module crm_claim.'),
'module_crm_helpdesk': fields.boolean("Manage Helpdesk and Support",
help="""Allows you to communicate with Customer, process Customer query, and provide better help and support. This installs the module crm_helpdesk."""),
'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams",
diff --git a/addons/hr_recruitment/res_config.py b/addons/hr_recruitment/res_config.py
index ac53bf74ff3..a15ae541e7f 100644
--- a/addons/hr_recruitment/res_config.py
+++ b/addons/hr_recruitment/res_config.py
@@ -27,11 +27,11 @@ class hr_applicant_settings(osv.osv_memory):
_columns = {
'module_document_ftp': fields.boolean('Allow the automatic indexation of resumes',
- help="""Manage your CV's and motivation letter related to all applicants.
- This installs the module document_ftp. This will install the knowledge management module in order to allow you to search using specific keywords through the content of all documents (PDF, .DOCx...)"""),
+ help='Manage your CV\'s and motivation letter related to all applicants.\n'
+ 'This installs the module document_ftp. This will install the knowledge management module in order to allow you to search using specific keywords through the content of all documents (PDF, .DOCx...)'),
'fetchmail_applicants': fields.boolean('Create applicants from an incoming email account',
fetchmail_model='hr.applicant', fetchmail_name='Incoming HR Applications',
- help ="""Allow applicants to send their job application to an email address (jobs@mycompany.com),
- and create automatically application documents in the system."""),
+ help ='Allow applicants to send their job application to an email address (jobs@mycompany.com), '
+ 'and create automatically application documents in the system.'),
}
diff --git a/addons/hr_timesheet_sheet/res_config.py b/addons/hr_timesheet_sheet/res_config.py
index e767b4da8fa..f3ef5b8496a 100644
--- a/addons/hr_timesheet_sheet/res_config.py
+++ b/addons/hr_timesheet_sheet/res_config.py
@@ -28,8 +28,8 @@ class hr_timesheet_settings(osv.osv_memory):
'timesheet_range': fields.selection([('day','Day'),('week','Week'),('month','Month')],
'Validate timesheets every', help="Periodicity on which you validate your timesheets."),
'timesheet_max_difference': fields.float('Allow a difference of time between timesheets and attendances of (in hours)',
- help="""Allowed difference in hours between the sign in/out and the timesheet
- computation for one sheet. Set this to 0 if you do not want any control."""),
+ help='Allowed difference in hours between the sign in/out and the timesheet '
+ 'computation for one sheet. Set this to 0 if you do not want any control.'),
}
def get_default_timesheet(self, cr, uid, fields, context=None):
diff --git a/addons/knowledge/res_config.py b/addons/knowledge/res_config.py
index fddbb5ebdc3..fd033772133 100644
--- a/addons/knowledge/res_config.py
+++ b/addons/knowledge/res_config.py
@@ -28,15 +28,15 @@ class knowledge_config_settings(osv.osv_memory):
'module_document_page': fields.boolean('Create static web pages',
help="""This installs the module document_page."""),
'module_document': fields.boolean('Manage documents',
- help="""This is a complete document management system, with: user authentication,
- full document search (but pptx and docx are not supported), and a document dashboard.
- This installs the module document."""),
+ help='This is a complete document management system, with: user authentication, '
+ 'full document search (but pptx and docx are not supported), and a document dashboard.\n'
+ 'This installs the module document.'),
'module_document_ftp': fields.boolean('Share repositories (FTP)',
- help="""Access your documents in OpenERP through an FTP interface.
- This installs the module document_ftp."""),
+ help='Access your documents in OpenERP through an FTP interface.\n'
+ 'This installs the module document_ftp.'),
'module_document_webdav': fields.boolean('Share repositories (WebDAV)',
- help="""Access your documents in OpenERP through WebDAV.
- This installs the module document_webdav."""),
+ help='Access your documents in OpenERP through WebDAV.\n'
+ 'This installs the module document_webdav.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/marketing/res_config.py b/addons/marketing/res_config.py
index 3c161c4d0d6..3d8eaf71fe6 100644
--- a/addons/marketing/res_config.py
+++ b/addons/marketing/res_config.py
@@ -26,15 +26,15 @@ class marketing_config_settings(osv.osv_memory):
_inherit = 'res.config.settings'
_columns = {
'module_marketing_campaign': fields.boolean('Marketing campaigns',
- help="""Provides leads automation through marketing campaigns.
- Campaigns can in fact be defined on any resource, not just CRM leads.
- This installs the module marketing_campaign."""),
+ help='Provides leads automation through marketing campaigns. '
+ 'Campaigns can in fact be defined on any resource, not just CRM leads.\n'
+ 'This installs the module marketing_campaign.'),
'module_marketing_campaign_crm_demo': fields.boolean('Demo data for marketing campaigns',
- help="""Installs demo data like leads, campaigns and segments for Marketing Campaigns.
- This installs the module marketing_campaign_crm_demo."""),
+ help='Installs demo data like leads, campaigns and segments for Marketing Campaigns.\n'
+ 'This installs the module marketing_campaign_crm_demo.'),
'module_crm_profiling': fields.boolean('Track customer profile to focus your campaigns',
- help="""Allows users to perform segmentation within partners.
- This installs the module crm_profiling."""),
+ help='Allows users to perform segmentation within partners.\n'
+ 'This installs the module crm_profiling.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/res_config.py b/addons/mrp/res_config.py
index 22a14addcd1..7f54999e15b 100644
--- a/addons/mrp/res_config.py
+++ b/addons/mrp/res_config.py
@@ -28,48 +28,48 @@ class mrp_config_settings(osv.osv_memory):
_columns = {
'module_mrp_repair': fields.boolean("Manage repairs of products ",
- help="""Allows to manage all product repairs.
- * Add/remove products in the reparation
- * Impact for stocks
- * Invoicing (products and/or services)
- * Warranty concept
- * Repair quotation report
- * Notes for the technician and for the final customer.
- This installs the module mrp_repair."""),
+ help='Allows to manage all product repairs.\n'
+ '* Add/remove products in the reparation\n'
+ '* Impact for stocks\n'
+ '* Invoicing (products and/or services)\n'
+ '* Warranty concept\n'
+ '* Repair quotation report\n'
+ '* Notes for the technician and for the final customer.\n'
+ 'This installs the module mrp_repair.'),
'module_mrp_operations': fields.boolean("Allow detailed planning of work order",
- help="""This allows to add state, date_start,date_stop in production order operation lines (in the "Work Centers" tab).
- This installs the module mrp_operations."""),
+ help='This allows to add state, date_start,date_stop in production order operation lines (in the "Work Centers" tab).\n'
+ 'This installs the module mrp_operations.'),
'module_mrp_byproduct': fields.boolean("Produce several products from one manufacturing order",
- help="""You can configure by-products in the bill of material.
- Without this module: A + B + C -> D.
- With this module: A + B + C -> D + E.
- This installs the module mrp_byproduct."""),
+ help='You can configure by-products in the bill of material.\n'
+ 'Without this module: A + B + C -> D.\n'
+ 'With this module: A + B + C -> D + E.\n'
+ 'This installs the module mrp_byproduct.'),
'module_mrp_jit': fields.boolean("Generate procurement in real time",
- help="""This allows Just In Time computation of procurement orders.
- All procurement orders will be processed immediately, which could in some
- cases entail a small performance impact.
- This installs the module mrp_jit."""),
+ help='This allows Just In Time computation of procurement orders.\n'
+ 'All procurement orders will be processed immediately, which could in some '
+ 'cases entail a small performance impact.\n'
+ 'This installs the module mrp_jit.'),
'module_stock_no_autopicking': fields.boolean("Manage manual picking to fulfill manufacturing orders ",
- help="""This module allows an intermediate picking process to provide raw materials to production orders.
- For example to manage production made by your suppliers (sub-contracting).
- To achieve this, set the assembled product which is sub-contracted to "No Auto-Picking"
- and put the location of the supplier in the routing of the assembly operation.
- This installs the module stock_no_autopicking."""),
+ help='This module allows an intermediate picking process to provide raw materials to production orders.\n'
+ 'For example to manage production made by your suppliers (sub-contracting).\n'
+ 'To achieve this, set the assembled product which is sub-contracted to "No Auto-Picking" '
+ 'and put the location of the supplier in the routing of the assembly operation.\n'
+ 'This installs the module stock_no_autopicking.'),
'group_mrp_routings': fields.boolean("Manage routings and work orders ",
implied_group='mrp.group_mrp_routings',
- help="""Routings allow you to create and manage the manufacturing operations that should be followed
- within your work centers in order to produce a product. They are attached to bills of materials
- that will define the required raw materials."""),
+ help='Routings allow you to create and manage the manufacturing operations that should be followed '
+ 'within your work centers in order to produce a product. They are attached to bills of materials '
+ 'that will define the required raw materials.'),
'group_mrp_properties': fields.boolean("Allow several bill of materials per products using properties",
implied_group='product.group_mrp_properties',
help="""The selection of the right Bill of Material to use will depend on the properties specified on the sales order and the Bill of Material."""),
'module_product_manufacturer': fields.boolean("Define manufacturers on products ",
- help="""This allows you to define the following for a product:
- * Manufacturer
- * Manufacturer Product Name
- * Manufacturer Product Code
- * Product Attributes.
- This installs the module product_manufacturer."""),
+ help='This allows you to define the following for a product:\n'
+ '* Manufacturer\n'
+ '* Manufacturer Product Name\n'
+ '* Manufacturer Product Code\n'
+ '* Product Attributes.\n'
+ 'This installs the module product_manufacturer.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project/res_config.py b/addons/project/res_config.py
index ddf98582ef3..a8b8af3b90b 100644
--- a/addons/project/res_config.py
+++ b/addons/project/res_config.py
@@ -28,30 +28,30 @@ class project_configuration(osv.osv_memory):
_columns = {
'module_project_mrp': fields.boolean('Generate tasks from sale orders',
- help ="""This feature automatically creates project tasks from service products in sale orders.
- More precisely, tasks are created for procurement lines with product of type 'Service',
- procurement method 'Make to Order', and supply method 'Manufacture'.
- This installs the module project_mrp."""),
+ help ='This feature automatically creates project tasks from service products in sale orders. '
+ 'More precisely, tasks are created for procurement lines with product of type \'Service\', '
+ 'procurement method \'Make to Order\', and supply method \'Manufacture\'.\n'
+ 'This installs the module project_mrp.'),
'module_pad': fields.boolean("Use integrated collaborative note pads on task",
- help="""Lets the company customize which Pad installation should be used to link to new pads
- (for example: http://ietherpad.com/).
- This installs the module pad."""),
+ help='Lets the company customize which Pad installation should be used to link to new pads '
+ '(for example: http://ietherpad.com/).\n'
+ 'This installs the module pad.'),
'module_project_timesheet': fields.boolean("Record timesheet lines per tasks",
- help="""This allows you to transfer the entries under tasks defined for Project Management to
- the timesheet line entries for particular date and user, with the effect of creating,
- editing and deleting either ways.
- This installs the module project_timesheet."""),
+ help='This allows you to transfer the entries under tasks defined for Project Management to '
+ 'the timesheet line entries for particular date and user, with the effect of creating, '
+ 'editing and deleting either ways.\n'
+ 'This installs the module project_timesheet.'),
'module_project_long_term': fields.boolean("Manage resources planning on gantt view",
- help="""A long term project management module that tracks planning, scheduling, and resource allocation.
- This installs the module project_long_term."""),
+ help='A long term project management module that tracks planning, scheduling, and resource allocation.\n'
+ 'This installs the module project_long_term.'),
'module_project_issue': fields.boolean("Track issues and bugs",
- help="""Provides management of issues/bugs in projects.
- This installs the module project_issue."""),
+ help='Provides management of issues/bugs in projects.\n'
+ 'This installs the module project_issue.'),
'time_unit': fields.many2one('product.uom', 'Working time unit', required=True,
help="""This will set the unit of measure used in projects and tasks."""),
'module_project_issue_sheet': fields.boolean("Invoice working time on issues",
- help="""Provides timesheet support for the issues/bugs management in project.
- This installs the module project_issue_sheet."""),
+ help='Provides timesheet support for the issues/bugs management in project.\n'
+ 'This installs the module project_issue_sheet.'),
'group_tasks_work_on_tasks': fields.boolean("Log work activities on tasks",
implied_group='project.group_tasks_work_on_tasks',
help="Allows you to compute work on tasks."),
diff --git a/addons/purchase/res_config.py b/addons/purchase/res_config.py
index f5f2dfcdda5..930ee5f9f29 100644
--- a/addons/purchase/res_config.py
+++ b/addons/purchase/res_config.py
@@ -34,8 +34,8 @@ class purchase_config_settings(osv.osv_memory):
], 'Default invoicing control method', required=True, default_model='purchase.order'),
'group_purchase_pricelist':fields.boolean("Manage pricelist per supplier",
implied_group='product.group_purchase_pricelist',
- help="""Allows to manage different prices based on rules per category of Supplier.
- Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
+ help='Allows to manage different prices based on rules per category of Supplier.\n'
+ 'Example: 10% for retailers, promotion of 5 EUR on this product, etc.'),
'group_uom':fields.boolean("Manage different units of measure for products",
implied_group='product.group_uom',
help="""Allows you to select and maintain different units of measure for products."""),
@@ -43,19 +43,19 @@ class purchase_config_settings(osv.osv_memory):
implied_group='product.group_costing_method',
help="""Allows you to compute product cost price based on average cost."""),
'module_warning': fields.boolean("Alerts by products or supplier",
- help="""Allow to configure notification on products and trigger them when a user wants to purchase a given product or a given supplier.
-Example: Product: this product is deprecated, do not purchase more than 5.
- Supplier: don't forget to ask for an express delivery."""),
+ help='Allow to configure notification on products and trigger them when a user wants to purchase a given product or a given supplier.\n'
+ 'Example: Product: this product is deprecated, do not purchase more than 5.\n'
+ 'Supplier: don\'t forget to ask for an express delivery.'),
'module_purchase_double_validation': fields.boolean("Force two levels of approvals",
- help="""Provide a double validation mechanism for purchases exceeding minimum amount.
- This installs the module purchase_double_validation."""),
+ help='Provide a double validation mechanism for purchases exceeding minimum amount.\n'
+ 'This installs the module purchase_double_validation.'),
'module_purchase_requisition': fields.boolean("Manage purchase requisitions",
- help="""Purchase Requisitions are used when you want to request quotations from several suppliers for a given set of products.
- You can configure per product if you directly do a Request for Quotation
- to one supplier or if you want a purchase requisition to negotiate with several suppliers."""),
+ help='Purchase Requisitions are used when you want to request quotations from several suppliers for a given set of products.\n'
+ 'You can configure per product if you directly do a Request for Quotation '
+ 'to one supplier or if you want a purchase requisition to negotiate with several suppliers.'),
'module_purchase_analytic_plans': fields.boolean('Use multiple analytic accounts on purchase orders',
- help ="""Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.
- This installs the module purchase_analytic_plans."""),
+ help ='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
+ 'This installs the module purchase_analytic_plans.'),
'group_analytic_account_for_purchases': fields.boolean('Analytic accounting for purchases',
implied_group='purchase.group_analytic_accounting',
help="Allows you to specify an analytic account on purchase orders."),
@@ -77,8 +77,8 @@ class account_config_settings(osv.osv_memory):
_inherit = 'account.config.settings'
_columns = {
'module_purchase_analytic_plans': fields.boolean('Use multiple analytic accounts on orders',
- help ="""Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.
- This installs the module purchase_analytic_plans."""),
+ help ='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
+ 'This installs the module purchase_analytic_plans.'),
'group_analytic_account_for_purchases': fields.boolean('Analytic accounting for purchases',
implied_group='purchase.group_analytic_accounting',
help="Allows you to specify an analytic account on purchase orders."),
diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py
index bfbaa5f0a6f..d570dfc8183 100644
--- a/addons/sale/res_config.py
+++ b/addons/sale/res_config.py
@@ -34,15 +34,15 @@ class sale_configuration(osv.osv_memory):
implied_group='sale.group_invoice_so_lines',
help="To allow your salesman to make invoices for sales order lines using the menu 'Lines to Invoice'."),
'timesheet': fields.boolean('Prepare invoices based on timesheets',
- help = """For modifying account analytic view to show important data to project manager of services companies.
- You can also view the report of account analytic summary user-wise as well as month wise.
- This installs the module account_analytic_analysis."""),
+ help = 'For modifying account analytic view to show important data to project manager of services companies.'
+ 'You can also view the report of account analytic summary user-wise as well as month wise.\n'
+ 'This installs the module account_analytic_analysis.'),
'module_account_analytic_analysis': fields.boolean('Use contracts management',
- help = """Allows to define your customer contracts conditions: invoicing
- method (fixed price, on timesheet, advance invoice), the exact pricing
- (650€/day for a developer), the duration (one year support contract).
- You will be able to follow the progress of the contract and invoice automatically.
- It installs the account_analytic_analysis module."""),
+ help = 'Allows to define your customer contracts conditions: invoicing '
+ 'method (fixed price, on timesheet, advance invoice), the exact pricing '
+ '(650€/day for a developer), the duration (one year support contract).\n'
+ 'You will be able to follow the progress of the contract and invoice automatically.\n'
+ 'It installs the account_analytic_analysis module.'),
'time_unit': fields.many2one('product.uom', 'The default working time unit for services is'),
'group_sale_pricelist':fields.boolean("Use pricelists to adapt your price per customers",
implied_group='product.group_sale_pricelist',
@@ -58,22 +58,22 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
implied_group='product.group_product_variant',
help="""Allow to manage several variants per product. As an example, if you sell T-Shirts, for the same "Linux T-Shirt", you may have variants on sizes or colors; S, M, L, XL, XXL."""),
'module_warning': fields.boolean("Allow configuring alerts by customer or products",
- help="""Allow to configure notification on products and trigger them when a user wants to sell a given product or a given customer.
-Example: Product: this product is deprecated, do not purchase more than 5.
- Supplier: don't forget to ask for an express delivery."""),
+ help='Allow to configure notification on products and trigger them when a user wants to sell a given product or a given customer.\n'
+ 'Example: Product: this product is deprecated, do not purchase more than 5.\n'
+ 'Supplier: don\'t forget to ask for an express delivery.'),
'module_sale_margin': fields.boolean("Display margins on sales orders",
- help="""This adds the 'Margin' on sales order.
- This gives the profitability by calculating the difference between the Unit Price and Cost Price.
- This installs the module sale_margin."""),
+ help='This adds the \'Margin\' on sales order.\n'
+ 'This gives the profitability by calculating the difference between the Unit Price and Cost Price.\n'
+ 'This installs the module sale_margin.'),
'module_sale_journal': fields.boolean("Allow batch invoicing of delivery orders through journals",
- help="""Allows you to categorize your sales and deliveries (picking lists) between different journals,
- and perform batch operations on journals.
- This installs the module sale_journal."""),
+ help='Allows you to categorize your sales and deliveries (picking lists) between different journals, '
+ 'and perform batch operations on journals.\n'
+ 'This installs the module sale_journal.'),
'module_analytic_user_function': fields.boolean("One employee can have different roles per contract",
- help="""Allows you to define what is the default function of a specific user on a given account.
- This is mostly used when a user encodes his timesheet. The values are retrieved and the fields are auto-filled.
- But the possibility to change these values is still available.
- This installs the module analytic_user_function."""),
+ help='Allows you to define what is the default function of a specific user on a given account.\n'
+ 'This is mostly used when a user encodes his timesheet. The values are retrieved and the fields are auto-filled. '
+ 'But the possibility to change these values is still available.\n'
+ 'This installs the module analytic_user_function.'),
'module_project': fields.boolean("Project"),
'module_sale_stock': fields.boolean("Trigger delivery orders automatically from sales orders",
help="""Allows you to Make Quotation, Sale Order using different Order policy and Manage Related Stock.
diff --git a/addons/sale_stock/res_config.py b/addons/sale_stock/res_config.py
index 4c3b92f1d33..ae81989aa52 100644
--- a/addons/sale_stock/res_config.py
+++ b/addons/sale_stock/res_config.py
@@ -33,10 +33,10 @@ class sale_configuration(osv.osv_memory):
implied_group='sale_stock.group_invoice_deli_orders',
help="To allow your salesman to make invoices for Delivery Orders using the menu 'Deliveries to Invoice'."),
'task_work': fields.boolean("Prepare invoices based on task's activities",
- help="""Lets you transfer the entries under tasks defined for Project Management to
- the Timesheet line entries for particular date and particular user with the effect of creating, editing and deleting either ways
- and to automatically creates project tasks from procurement lines.
- This installs the modules project_timesheet and project_mrp."""),
+ help='Lets you transfer the entries under tasks defined for Project Management to '
+ 'the Timesheet line entries for particular date and particular user with the effect of creating, editing and deleting either ways '
+ 'and to automatically creates project tasks from procurement lines.\n'
+ 'This installs the modules project_timesheet and project_mrp.'),
'default_order_policy': fields.selection(
[('manual', 'Invoice based on sales orders'), ('picking', 'Invoice based on deliveries')],
'The default invoicing method is', default_model='sale.order',
diff --git a/addons/stock/res_config.py b/addons/stock/res_config.py
index d0b0563875c..4da23389214 100644
--- a/addons/stock/res_config.py
+++ b/addons/stock/res_config.py
@@ -27,12 +27,12 @@ class stock_config_settings(osv.osv_memory):
_columns = {
'module_claim_from_delivery': fields.boolean("Allow claim on deliveries",
- help="""Adds a Claim link to the delivery order.
- This installs the module claim_from_delivery."""),
+ help='Adds a Claim link to the delivery order.\n'
+ 'This installs the module claim_from_delivery.'),
'module_stock_invoice_directly': fields.boolean("Create and open the invoice when the user finish a delivery order",
- help="""This allows to automatically launch the invoicing wizard if the delivery is
- to be invoiced when you send or deliver goods.
- This installs the module stock_invoice_directly."""),
+ help='This allows to automatically launch the invoicing wizard if the delivery is '
+ 'to be invoiced when you send or deliver goods.\n'
+ 'This installs the module stock_invoice_directly.'),
'module_product_expiry': fields.boolean("Expiry date on serial numbers",
help="""Track different dates on products and serial numbers.
The following dates can be tracked:
@@ -42,17 +42,17 @@ The following dates can be tracked:
- alert date.
This installs the module product_expiry."""),
'module_stock_location': fields.boolean("Create push/pull logistic rules",
- help="""Provide push and pull inventory flows. Typical uses of this feature are:
- manage product manufacturing chains, manage default locations per product,
- define routes within your warehouse according to business needs, etc.
- This installs the module stock_location."""),
+ help='Provide push and pull inventory flows. Typical uses of this feature are: '
+ 'manage product manufacturing chains, manage default locations per product, '
+ 'define routes within your warehouse according to business needs, etc.\n'
+ 'This installs the module stock_location.'),
'group_uom': fields.boolean("Manage different units of measure for products",
implied_group='product.group_uom',
help="""Allows you to select and maintain different units of measure for products."""),
'group_uos': fields.boolean("Invoice products in a different unit of measure than the sales order",
implied_group='product.group_uos',
- help="""Allows you to sell units of a product, but invoice based on a different unit of measure.
- For instance, you can sell pieces of meat that you invoice based on their weight."""),
+ help='Allows you to sell units of a product, but invoice based on a different unit of measure.\n'
+ 'For instance, you can sell pieces of meat that you invoice based on their weight.'),
'group_stock_packaging': fields.boolean("Allow to define several packaging methods on products",
implied_group='product.group_stock_packaging',
help="""Allows you to create and manage your packaging dimensions and types you want to be maintained in your system."""),
@@ -67,8 +67,8 @@ This installs the module product_expiry."""),
help="""Allows to configure inventory valuations on products and product categories."""),
'group_stock_multiple_locations': fields.boolean("Manage multiple locations and warehouses",
implied_group='stock.group_locations',
- help="""This allows to configure and use multiple stock locations and warehouses,
- instead of having a single default one."""),
+ help='This allows to configure and use multiple stock locations and warehouses, '
+ 'instead of having a single default one.'),
'decimal_precision': fields.integer('Decimal precision on weight', help="As an example, a decimal precision of 2 will allow weights like: 9.99 kg, whereas a decimal precision of 4 will allow weights like: 0.0231 kg."),
}
From c0a72b34914436bcee627d829ac7e89f3cac87f9 Mon Sep 17 00:00:00 2001
From: Darshan Kalola
Date: Thu, 25 Jul 2013 11:44:42 +0530
Subject: [PATCH 006/175] [IMP]improve help of sales and General-setting menus
in setting/configuration
bzr revid: darshankalola@gmail.com-20130725061442-kchwc3eattox148j
---
addons/base_setup/res_config.py | 4 ++--
addons/sale/res_config.py | 4 ++--
addons/sale_stock/res_config.py | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index 82828e5f30d..c7f6d4245ec 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -26,8 +26,8 @@ class base_config_settings(osv.osv_memory):
_inherit = 'res.config.settings'
_columns = {
'module_multi_company': fields.boolean('Manage multiple companies',
- help="""Work in multi-company environments, with appropriate security access between companies.
- This installs the module multi_company."""),
+ help='Work in multi-company environments, with appropriate security access between companies.\n'
+ 'This installs the module multi_company.'),
'module_share': fields.boolean('Allow documents sharing',
help="""Share or embbed any screen of openerp."""),
'module_portal': fields.boolean('Activate the customer portal',
diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py
index d570dfc8183..fe81a7cc6d8 100644
--- a/addons/sale/res_config.py
+++ b/addons/sale/res_config.py
@@ -76,8 +76,8 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
'This installs the module analytic_user_function.'),
'module_project': fields.boolean("Project"),
'module_sale_stock': fields.boolean("Trigger delivery orders automatically from sales orders",
- help="""Allows you to Make Quotation, Sale Order using different Order policy and Manage Related Stock.
- This installs the module sale_stock."""),
+ help='Allows you to Make Quotation, Sale Order using different Order policy and Manage Related Stock.\n'
+ 'This installs the module sale_stock.'),
}
def default_get(self, cr, uid, fields, context=None):
diff --git a/addons/sale_stock/res_config.py b/addons/sale_stock/res_config.py
index ae81989aa52..76cfbcb6fd3 100644
--- a/addons/sale_stock/res_config.py
+++ b/addons/sale_stock/res_config.py
@@ -42,9 +42,9 @@ class sale_configuration(osv.osv_memory):
'The default invoicing method is', default_model='sale.order',
help="You can generate invoices based on sales orders or based on shippings."),
'module_delivery': fields.boolean('Allow adding shipping costs',
- help ="""Allows you to add delivery methods in sales orders and delivery orders.
- You can define your own carrier and delivery grids for prices.
- This installs the module delivery."""),
+ help ='Allows you to add delivery methods in sales orders and delivery orders.\n'
+ 'You can define your own carrier and delivery grids for prices.\n'
+ 'This installs the module delivery.'),
'default_picking_policy' : fields.boolean("Deliver all at once when all products are available.",
help = "Sales order by default will be configured to deliver all products at once instead of delivering each product when it is available. This may have an impact on the shipping price."),
'group_mrp_properties': fields.boolean('Product properties on order lines',
From 497ba7dab96a15c965e1e2824d9111772a98210b Mon Sep 17 00:00:00 2001
From: "Mansi Kariya (OpenERP Trainee)"
Date: Tue, 30 Jul 2013 17:17:45 +0530
Subject: [PATCH 007/175] [IMP] purchases Configuration menus location and name
changed
bzr revid: mansi.mk.179@gmail.com-20130730114745-o2xzb0h63ze29stq
---
addons/purchase/purchase_view.xml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index dffe1ed54ff..0463527461e 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -14,9 +14,6 @@
-
Pricelist Versions
@@ -36,14 +33,18 @@
+
+
+
-
From d1e7ad9be6f01644567df0fb8d0e68e6c40aff5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 6 Aug 2013 17:10:18 +0200
Subject: [PATCH 008/175] [IMP] tools: added a regex for bounce email addresses
bzr revid: tde@openerp.com-20130806151018-0uom07dbr8b7ycb3
---
openerp/tools/mail.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py
index 5970ce47040..36a4c1610c4 100644
--- a/openerp/tools/mail.py
+++ b/openerp/tools/mail.py
@@ -297,6 +297,11 @@ command_re = re.compile("^Set-([a-z]+) *: *(.+)$", re.I + re.UNICODE)
# group(1) = the record ID ; group(2) = the model (if any) ; group(3) = the domain
reference_re = re.compile("<.*-open(?:object|erp)-(\\d+)(?:-([\w.]+))?.*@(.*)>", re.UNICODE)
+# Bounce regex
+# Typical form of bounce is bounce-128-crm.lead-34@domain
+# group(1) = the mail ID; group(2) = the model (if any); group(3) = the record ID
+bounce_re = re.compile("[\w]+-(\d+)-?([\w.]+)?-?(\d+)?", re.UNICODE)
+
def generate_tracking_message_id(res_id):
"""Returns a string that can be used in the Message-ID RFC822 header field
From 38a534dee0bf15a56a97874a01172cb67cd6b94a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 6 Aug 2013 17:11:43 +0200
Subject: [PATCH 009/175] [IMP] mail: first implementation of tracking and
bounce management. Added 2 fields on mail_mail to count read/bounce. Added
bounce alias bounce-mail_id-model-res_id. Added message_receive_bounce method
that try to incremetn message_bounce field.
bzr revid: tde@openerp.com-20130806151143-7dw6xlj8n7mh0nqe
---
addons/crm/crm_lead.py | 2 +
addons/crm/crm_lead_view.xml | 1 +
addons/mail/controllers/main.py | 21 ++++++---
addons/mail/data/mail_data.xml | 6 +++
addons/mail/mail_mail.py | 83 ++++++++++++++++++++++++---------
addons/mail/mail_mail_view.xml | 40 ++++++++++------
addons/mail/mail_thread.py | 28 +++++++++++
7 files changed, 136 insertions(+), 45 deletions(-)
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index c0f003f9792..52987de00e1 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -273,6 +273,8 @@ class crm_lead(format_address, osv.osv):
selection=crm.AVAILABLE_STATES, string="Status", readonly=True,
help='The Status is set to \'Draft\', when a case is created. If the case is in progress the Status is set to \'Open\'. When the case is over, the Status is set to \'Done\'. If the case needs to be reviewed then the Status is set to \'Pending\'.'),
+ # Messaging and marketing
+ 'message_bounce': fields.integer('Bounce'),
# Only used for type opportunity
'probability': fields.float('Success Rate (%)',group_operator="avg"),
'planned_revenue': fields.float('Expected Revenue', track_visibility='always'),
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index aa5aac76b9d..113355eea83 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -182,6 +182,7 @@
+
diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py
index ef3a60987d6..27373c34add 100644
--- a/addons/mail/controllers/main.py
+++ b/addons/mail/controllers/main.py
@@ -1,17 +1,17 @@
import base64
+import psycopg2
import openerp
from openerp import SUPERUSER_ID
-import openerp.addons.web.http as oeweb
+import openerp.addons.web.http as http
from openerp.addons.web.controllers.main import content_disposition
+from openerp.addons.web.http import request
-#----------------------------------------------------------
-# Controller
-#----------------------------------------------------------
-class MailController(oeweb.Controller):
+
+class MailController(http.Controller):
_cp_path = '/mail'
- @oeweb.httprequest
+ @http.httprequest
def download_attachment(self, req, model, id, method, attachment_id, **kw):
Model = req.session.model(model)
res = getattr(Model, method)(int(id), int(attachment_id))
@@ -24,7 +24,7 @@ class MailController(oeweb.Controller):
('Content-Disposition', content_disposition(filename, req))])
return req.not_found()
- @oeweb.jsonrequest
+ @http.jsonrequest
def receive(self, req):
""" End-point to receive mail from an external SMTP server. """
dbs = req.jsonrequest.get('databases')
@@ -38,3 +38,10 @@ class MailController(oeweb.Controller):
except psycopg2.Error:
pass
return True
+
+ @http.route('/mail/track//blank.gif', type='http', auth='admin')
+ def track_read_email(self, mail_id):
+ """ Email tracking. """
+ mail_mail = request.registry.get('mail.mail')
+ mail_mail.set_opened(request.cr, request.uid, [mail_id])
+ return False
diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml
index 4e935e4aa88..8ba92a8205c 100644
--- a/addons/mail/data/mail_data.xml
+++ b/addons/mail/data/mail_data.xml
@@ -46,6 +46,12 @@
catchall
+
+
+ mail.bounce.alias
+ bounce
+
+
Discussions
diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py
index bf76216e7e4..5548608aeeb 100644
--- a/addons/mail/mail_mail.py
+++ b/addons/mail/mail_mail.py
@@ -61,15 +61,16 @@ class mail_mail(osv.Model):
# Auto-detected based on create() - if 'mail_message_id' was passed then this mail is a notification
# and during unlink() we will not cascade delete the parent and its attachments
'notification': fields.boolean('Is Notification',
- help='Mail has been created to notify people of an existing mail.message')
+ help='Mail has been created to notify people of an existing mail.message'),
+ # Bounce and tracking
+ 'opened': fields.integer(
+ 'Opened',
+ help='Number of times this email has been seen, using the OpenERP tracking.'),
+ 'replied': fields.integer(
+ 'Reply Received',
+ help='If checked, a reply to this email has been received.'),
}
- def _get_default_from(self, cr, uid, context=None):
- """ Kept for compatibility
- TDE TODO: remove me in 8.0
- """
- return self.pool['mail.message']._get_default_from(cr, uid, context=context)
-
_defaults = {
'state': 'outgoing',
}
@@ -158,6 +159,18 @@ class mail_mail(osv.Model):
def cancel(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
+ def set_opened(self, cr, uid, ids, context=None):
+ """ Increment opened counter """
+ for mail in self.browse(cr, uid, ids, context=context):
+ self.write(cr, uid, [mail.id], {'opened': (mail.opened + 1)}, context=context)
+ return True
+
+ def set_replied(self, cr, uid, ids, context=None):
+ """ Increment replied counter """
+ for mail in self.browse(cr, uid, ids, context=context):
+ self.write(cr, uid, [mail.id], {'replied': (mail.replied + 1)}, context=context)
+ return True
+
def process_email_queue(self, cr, uid, ids=None, context=None):
"""Send immediately queued messages, committing after each
message is sent - this is not transactional and should
@@ -226,13 +239,22 @@ class mail_mail(osv.Model):
}
if mail.notification:
fragment.update({
- 'message_id': mail.mail_message_id.id,
- })
+ 'message_id': mail.mail_message_id.id,
+ })
url = urljoin(base_url, "?%s#%s" % (urlencode(query), urlencode(fragment)))
return _("""Access your messages and documents in OpenERP""") % url
else:
return None
+ def _get_tracking_url(self, cr, uid, mail, partner=None, context=None):
+ if not mail.auto_delete:
+ base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
+ track_url = urljoin(base_url, 'mail/track/%d/blank.gif' % mail.id)
+ print base_url, track_url
+ return '' % track_url
+ else:
+ return ''
+
def send_get_mail_subject(self, cr, uid, mail, force=False, partner=None, context=None):
""" If subject is void and record_name defined: ' posted on '
@@ -257,8 +279,11 @@ class mail_mail(osv.Model):
# generate footer
link = self._get_partner_access_link(cr, uid, mail, partner, context=context)
+ tracking_url = self._get_tracking_url(cr, uid, mail, partner, context=context)
if link:
body = tools.append_content_to_html(body, link, plaintext=False, container_tag='div')
+ if tracking_url:
+ body = tools.append_content_to_html(body, tracking_url, plaintext=False, container_tag='div')
return body
def send_get_email_dict(self, cr, uid, mail, partner=None, context=None):
@@ -319,25 +344,37 @@ class mail_mail(osv.Model):
email_list.append(self.send_get_email_dict(cr, uid, mail, context=context))
for partner in mail.recipient_ids:
email_list.append(self.send_get_email_dict(cr, uid, mail, partner=partner, context=context))
+ # headers
+ headers = {}
+ bounce_alias = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.bounce.alias", context=context)
+ catchall_domain = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.catchall.domain", context=context)
+ if bounce_alias and catchall_domain:
+ if mail.model and mail.res_id:
+ headers['Return-Path'] = '%s-%d-%s-%d@%s' % (bounce_alias, mail.id, mail.model, mail.res_id, catchall_domain)
+ else:
+ headers['Return-Path'] = '%s-%d@%s' % (bounce_alias, mail.id, catchall_domain)
# build an RFC2822 email.message.Message object and send it without queuing
+ res = None
for email in email_list:
msg = ir_mail_server.build_email(
- email_from = mail.email_from,
- email_to = email.get('email_to'),
- subject = email.get('subject'),
- body = email.get('body'),
- body_alternative = email.get('body_alternative'),
- email_cc = tools.email_split(mail.email_cc),
- reply_to = mail.reply_to,
- attachments = attachments,
- message_id = mail.message_id,
- references = mail.references,
- object_id = mail.res_id and ('%s-%s' % (mail.res_id, mail.model)),
- subtype = 'html',
- subtype_alternative = 'plain')
+ email_from=mail.email_from,
+ email_to=email.get('email_to'),
+ subject=email.get('subject'),
+ body=email.get('body'),
+ body_alternative=email.get('body_alternative'),
+ email_cc=tools.email_split(mail.email_cc),
+ reply_to=mail.reply_to,
+ attachments=attachments,
+ message_id=mail.message_id,
+ references=mail.references,
+ object_id=mail.res_id and ('%s-%s' % (mail.res_id, mail.model)),
+ subtype='html',
+ subtype_alternative='plain',
+ headers=headers)
res = ir_mail_server.send_email(cr, uid, msg,
- mail_server_id=mail.mail_server_id.id, context=context)
+ mail_server_id=mail.mail_server_id.id,
+ context=context)
if res:
mail.write({'state': 'sent', 'message_id': res})
mail_sent = True
diff --git a/addons/mail/mail_mail_view.xml b/addons/mail/mail_mail_view.xml
index f3728d4653a..3901a192225 100644
--- a/addons/mail/mail_mail_view.xml
+++ b/addons/mail/mail_mail_view.xml
@@ -14,7 +14,7 @@
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 306e5fd5905..89a9a4694b6 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -772,6 +772,7 @@ class mail_thread(osv.AbstractModel):
"""
assert isinstance(message, Message), 'message must be an email.message.Message at this point'
fallback_model = model
+ bounce_alias = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.bounce.alias", context=context)
# Get email.message.Message variables for future processing
message_id = message.get('Message-Id')
@@ -780,6 +781,24 @@ class mail_thread(osv.AbstractModel):
references = decode_header(message, 'References')
in_reply_to = decode_header(message, 'In-Reply-To')
+ # 0. Verify whether this is a bounced email (wrong destination,...) -> use it to collect data, such as dead leads
+ if bounce_alias in email_to:
+ bounce_match = tools.bounce_re.search(email_to)
+ if bounce_match:
+ bounced_mail_id = bounce_match.group(1)
+ if self.pool['mail.mail'].exists(cr, uid, bounced_mail_id):
+ mail = self.pool['mail.mail'].browse(cr, uid, bounced_mail_id, context=context)
+ bounced_model = mail.model
+ bounced_thread_id = mail.res_id
+ else:
+ bounced_model = bounce_match.group(2)
+ bounced_thread_id = int(bounce_match.group(3)) if bounce_match.group(3) else 0
+ _logger.info('Routing mail from %s to %s with Message-Id %s: bounced mail from mail %s, model: %s, thread_id: %s',
+ email_from, email_to, message_id, bounced_mail_id, bounced_model, bounced_thread_id)
+ if bounced_model and bounced_model in self.pool and hasattr(self.pool[bounced_model], 'message_receive_bounce'):
+ self.pool[bounced_model].message_receive_bounce(cr, uid, [bounced_thread_id], mail_id=bounced_mail_id, context=context)
+ return []
+
# 1. Verify if this is a reply to an existing thread
thread_references = references or in_reply_to
ref_match = thread_references and tools.reference_re.search(thread_references)
@@ -1018,6 +1037,15 @@ class mail_thread(osv.AbstractModel):
self.write(cr, uid, ids, update_vals, context=context)
return True
+ def message_receive_bounce(self, cr, uid, ids, mail_id=None, context=None):
+ """Called by ``message_process`` when a bounce email (such as Undelivered
+ Mail Returned to Sender) is received for an existing thread. The default
+ behavior is to check is an integer ``message_bounce`` column exists.
+ If it is the case, its content is incremented. """
+ if self._all_columns.get('message_bounce'):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.write(cr, uid, [obj.id], {'message_bounce': obj.message_bounce + 1}, context=context)
+
def _message_extract_payload(self, message, save_original=False):
"""Extract body as HTML and attachments from the mail message"""
attachments = []
From fd100054ccdb4cedcb2411bdf38a7388338ea814 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Wed, 7 Aug 2013 15:01:18 +0200
Subject: [PATCH 010/175] [FIX] mail_mail: fixed reply_to computation (before
create was leading to a wrong message_id to the embedded mail_message);
mail_thread; fixed private discussion not going through the route checking;
improved replying through mailgateway now incrementing the replied field of
mail_mail.
bzr revid: tde@openerp.com-20130807130118-yggvmontssofxt0q
---
addons/mail/mail_mail.py | 11 +++++++++--
addons/mail/mail_thread.py | 18 ++++++++++++------
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py
index 5548608aeeb..130e63deefd 100644
--- a/addons/mail/mail_mail.py
+++ b/addons/mail/mail_mail.py
@@ -140,10 +140,17 @@ class mail_mail(osv.Model):
# notification field: if not set, set if mail comes from an existing mail.message
if 'notification' not in values and values.get('mail_message_id'):
values['notification'] = True
+ mail_id = super(mail_mail, self).create(cr, uid, values, context=context)
+
# reply_to: if not set, set with default values that require creation values
+ # but delegate after creation because of mail_message.message_id automatic
+ # creation using existence of reply_to
if not values.get('reply_to'):
- values['reply_to'] = self._get_reply_to(cr, uid, values, context=context)
- return super(mail_mail, self).create(cr, uid, values, context=context)
+ reply_to = self._get_reply_to(cr, uid, values, context=context)
+ if reply_to:
+ self.write(cr, uid, [mail_id], {'reply_to': reply_to}, context=context)
+
+ return mail_id
def unlink(self, cr, uid, ids, context=None):
# cascade-delete the parent message for all mails that are not created for a notification
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 89a9a4694b6..f03f1239bd8 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -706,7 +706,7 @@ class mail_thread(osv.AbstractModel):
return ()
# New Document: check model accepts the mailgateway
- if not thread_id and not hasattr(model_pool, 'message_new'):
+ if not thread_id and model and not hasattr(model_pool, 'message_new'):
if assert_model:
assert hasattr(model_pool, 'message_new'), 'Model %s does not accept document creation, crashing' % model
_warn('model %s does not accept document creation, skipping' % model)
@@ -817,16 +817,16 @@ class mail_thread(osv.AbstractModel):
# 2. Reply to a private message
if in_reply_to:
- message_ids = self.pool.get('mail.message').search(cr, uid, [
+ mail_message_ids = self.pool.get('mail.message').search(cr, uid, [
('message_id', '=', in_reply_to),
'!', ('message_id', 'ilike', 'reply_to')
], limit=1, context=context)
- if message_ids:
- message = self.pool.get('mail.message').browse(cr, uid, message_ids[0], context=context)
+ if mail_message_ids:
+ mail_message = self.pool.get('mail.message').browse(cr, uid, mail_message_ids[0], context=context)
_logger.info('Routing mail from %s to %s with Message-Id %s: direct reply to a private message: %s, custom_values: %s, uid: %s',
- email_from, email_to, message_id, message.id, custom_values, uid)
+ email_from, email_to, message_id, mail_message.id, custom_values, uid)
route = self.message_route_verify(cr, uid, message, message_dict,
- (message.model, message.res_id, custom_values, uid, None),
+ (mail_message.model, mail_message.res_id, custom_values, uid, None),
update_author=True, assert_model=True, create_fallback=True, context=context)
return route and [route] or []
@@ -1415,6 +1415,12 @@ class mail_thread(osv.AbstractModel):
parent_id = message_ids and message_ids[0] or False
# we want to set a parent: force to set the parent_id to the oldest ancestor, to avoid having more than 1 level of thread
elif parent_id:
+ # update original mail_mail if exists
+ if type == 'email':
+ mail_mail_ids = self.pool['mail.mail'].search(cr, SUPERUSER_ID, [('mail_message_id', '=', parent_id)], context=context)
+ for mail in self.pool['mail.mail'].browse(cr, SUPERUSER_ID, mail_mail_ids, context=context):
+ self.pool['mail.mail'].write(cr, SUPERUSER_ID, [mail.id], {'replied': mail.replied + 1}, context=context)
+
message_ids = mail_message.search(cr, SUPERUSER_ID, [('id', '=', parent_id), ('parent_id', '!=', False)], context=context)
# avoid loops when finding ancestors
processed_list = []
From 33fd9e01d6f50d7d6a3e379fd8544bb069a5d21d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Wed, 7 Aug 2013 15:03:34 +0200
Subject: [PATCH 011/175] [ADD] mass_mailing: added module for mass mailign
campaigns. First draft of new module : simple mass mailing campaign model,
linked to emails, compute some statistics mail.compose.message updated to the
mass mailing campaigns in mass mail mode
bzr revid: tde@openerp.com-20130807130334-nwd34fgsz4lc6lt1
---
addons/mass_mailing/__init__.py | 24 ++++++
addons/mass_mailing/__openerp__.py | 39 +++++++++
addons/mass_mailing/mail_mail.py | 35 ++++++++
addons/mass_mailing/mail_mail_view.xml | 18 ++++
addons/mass_mailing/mass_mailing.py | 84 +++++++++++++++++++
addons/mass_mailing/mass_mailing_view.xml | 48 +++++++++++
.../mass_mailing/security/ir.model.access.csv | 3 +
addons/mass_mailing/wizard/__init__.py | 22 +++++
.../wizard/mail_compose_message.py | 51 +++++++++++
.../wizard/mail_compose_message_view.xml | 20 +++++
10 files changed, 344 insertions(+)
create mode 100644 addons/mass_mailing/__init__.py
create mode 100644 addons/mass_mailing/__openerp__.py
create mode 100644 addons/mass_mailing/mail_mail.py
create mode 100644 addons/mass_mailing/mail_mail_view.xml
create mode 100644 addons/mass_mailing/mass_mailing.py
create mode 100644 addons/mass_mailing/mass_mailing_view.xml
create mode 100644 addons/mass_mailing/security/ir.model.access.csv
create mode 100644 addons/mass_mailing/wizard/__init__.py
create mode 100644 addons/mass_mailing/wizard/mail_compose_message.py
create mode 100644 addons/mass_mailing/wizard/mail_compose_message_view.xml
diff --git a/addons/mass_mailing/__init__.py b/addons/mass_mailing/__init__.py
new file mode 100644
index 00000000000..37f3850306a
--- /dev/null
+++ b/addons/mass_mailing/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013-today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+import mass_mailing
+import mail_mail
+import wizard
diff --git a/addons/mass_mailing/__openerp__.py b/addons/mass_mailing/__openerp__.py
new file mode 100644
index 00000000000..e6fbb42e886
--- /dev/null
+++ b/addons/mass_mailing/__openerp__.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013-today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+{
+ 'name': 'Mass Mailing Campaigns',
+ 'version': '1.0',
+ 'author': 'OpenERP',
+ 'website': 'http://www.openerp.com',
+ 'category': 'Marketing',
+ 'depends': ['mail', 'email_template'],
+ 'description': """TODO""",
+ 'data': [
+ 'mass_mailing_view.xml',
+ 'mail_mail_view.xml',
+ 'wizard/mail_compose_message_view.xml',
+ 'security/ir.model.access.csv',
+ ],
+ 'demo': [],
+ 'installable': True,
+ 'auto_install': False,
+}
diff --git a/addons/mass_mailing/mail_mail.py b/addons/mass_mailing/mail_mail.py
new file mode 100644
index 00000000000..d7f46446b56
--- /dev/null
+++ b/addons/mass_mailing/mail_mail.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013-today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+
+
+class MailMail(osv.Model):
+ """Add the mass mailing campaign data to mail"""
+ _name = 'mail.mail'
+ _inherit = ['mail.mail']
+
+ _columns = {
+ 'mass_mailing_campaign_id': fields.many2one(
+ 'mail.mass_mailing.campaign', 'Mass Mailing Campaign',
+ ondelete='set null',
+ ),
+ }
diff --git a/addons/mass_mailing/mail_mail_view.xml b/addons/mass_mailing/mail_mail_view.xml
new file mode 100644
index 00000000000..dd66aede66f
--- /dev/null
+++ b/addons/mass_mailing/mail_mail_view.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ mail.mail.form.mass_mailing
+ mail.mail
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py
new file mode 100644
index 00000000000..91392759b0e
--- /dev/null
+++ b/addons/mass_mailing/mass_mailing.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013-today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+
+
+class MassMailingCampaign(osv.Model):
+ """Model of mass mailing campaigns.
+ """
+ _name = "mail.mass_mailing.campaign"
+ _description = 'Mass Mailing Campaign'
+
+ def _get_statistics(self, cr, uid, ids, name, arg, context=None):
+ """ Compute statistics of the mass mailing campaign """
+ results = dict.fromkeys(ids, False)
+ for campaign in self.browse(cr, uid, ids, context=context):
+ if not campaign.mail_ids:
+ results[campaign.id] = {
+ 'sent': 0,
+ 'opened_ratio': 0.0,
+ 'replied_ratio': 0.0,
+ 'bounce_ratio': 0.0,
+ }
+ continue
+ results[campaign.id] = {
+ 'sent': len(campaign.mail_ids),
+ 'opened_ratio': len([mail for mail in campaign.mail_ids if mail.opened]) * 1.0 / len(campaign.mail_ids),
+ 'replied_ratio': len([mail for mail in campaign.mail_ids if mail.replied]) * 1.0 / len(campaign.mail_ids),
+ 'bounce_ratio': 0.0,
+ }
+ return results
+
+ _columns = {
+ 'name': fields.char(
+ 'Campaign Name', required=True,
+ ),
+ 'template_id': fields.many2one(
+ 'email.template', 'Email Template',
+ ondelete='set null',
+ ),
+ 'mail_ids': fields.one2many(
+ 'mail.mail', 'mass_mailing_campaign_id',
+ 'Send Emails',
+ ),
+ # stat fields
+ 'sent': fields.function(
+ _get_statistics,
+ string='Sent Emails',
+ type='integer', multi='_get_statistics'
+ ),
+ 'opened_ratio': fields.function(
+ _get_statistics,
+ string='Opened Ratio',
+ type='float', multi='_get_statistics',
+ ),
+ 'replied_ratio': fields.function(
+ _get_statistics,
+ string='Replied Ratio',
+ type='float', multi='_get_statistics'
+ ),
+ 'bounce_ratio': fields.function(
+ _get_statistics,
+ string='Bounce Ratio',
+ type='float', multi='_get_statistics'
+ ),
+ }
diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml
new file mode 100644
index 00000000000..bc28827343d
--- /dev/null
+++ b/addons/mass_mailing/mass_mailing_view.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+ mail.mass_mailing.campaign.tree
+ mail.mass_mailing.campaign
+ 10
+
+
+
+
+
+
+
+
+ mail.mass_mailing.campaign.form
+ mail.mass_mailing.campaign
+
+
+
+
+
+
+ Mass Mailing Campaigns
+ mail.mass_mailing.campaign
+ form
+ tree,form
+
+
+
+
+
+
+
diff --git a/addons/mass_mailing/security/ir.model.access.csv b/addons/mass_mailing/security/ir.model.access.csv
new file mode 100644
index 00000000000..af6eaa7bb06
--- /dev/null
+++ b/addons/mass_mailing/security/ir.model.access.csv
@@ -0,0 +1,3 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_mass_mailing_campaign,mail.mass_mailing.campaign.template,model_mail_mass_mailing_campaign,,1,1,1,0
+access_mass_mailing_campaign_system,mail.mass_mailing.campaign.system,model_mail_mass_mailing_campaign,base.group_system,1,1,1,1
diff --git a/addons/mass_mailing/wizard/__init__.py b/addons/mass_mailing/wizard/__init__.py
new file mode 100644
index 00000000000..155849362cd
--- /dev/null
+++ b/addons/mass_mailing/wizard/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013-today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+import mail_compose_message
diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py
new file mode 100644
index 00000000000..2f74ef2c732
--- /dev/null
+++ b/addons/mass_mailing/wizard/mail_compose_message.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013-today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+
+
+class MailComposeMessage(osv.TransientModel):
+ """Add concept of mass mailing campaign to the mail.compose.message wizard
+ """
+ _inherit = 'mail.compose.message'
+
+ _columns = {
+ 'mass_mail_campaign_id': fields.many2one(
+ 'mail.mass_mailing.campaign', 'Mass mailing campaign'
+ ),
+ }
+
+ def onchange_mass_mail_campaign_id(self, cr, uid, ids, mass_mail_campaign_id, context=None):
+ values = {}
+ if mass_mail_campaign_id:
+ campaign = self.pool['mail.mass_mailing.campaign'].browse(cr, uid, mass_mail_campaign_id, context=context)
+ if campaign and campaign.template_id:
+ values['template_id'] = campaign.template_id.id
+ return {'value': values}
+
+ def render_message(self, cr, uid, wizard, res_id, context=None):
+ """ Override method that generated the mail content by adding the mass
+ mailing campaign, when doing pure email mass mailing. """
+ res = super(MailComposeMessage, self).render_message(cr, uid, wizard, res_id, context=context)
+ print res, wizard.mass_mail_campaign_id
+ if wizard.composition_mode == 'mass_mail' and wizard.mass_mail_campaign_id: # TODO: which kind of mass mailing ?
+ res['mass_mailing_campaign_id'] = wizard.mass_mail_campaign_id.id
+ return res
diff --git a/addons/mass_mailing/wizard/mail_compose_message_view.xml b/addons/mass_mailing/wizard/mail_compose_message_view.xml
new file mode 100644
index 00000000000..bc5f1a9eb6a
--- /dev/null
+++ b/addons/mass_mailing/wizard/mail_compose_message_view.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+ mail.compose.message.form.mass_mailing
+ mail.compose.message
+
+
+
+
+
+
+
+
+
+
From 70d2a3859240498816682418ab173dd9af89c4ac Mon Sep 17 00:00:00 2001
From: "Mansi Kariya (OpenERP Trainee)"
Date: Mon, 12 Aug 2013 14:43:21 +0530
Subject: [PATCH 012/175] [IMP] Optimized code
bzr revid: mansi.mk.179@gmail.com-20130812091321-o6ql1csd9sq78vs7
---
addons/purchase/purchase_view.xml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index 0463527461e..ab32eb0372f 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -33,14 +33,13 @@
-
+ action="product.product_pricelist_action_for_purchase" id="menu_product_pricelist_action2_purchase"
+ parent="menu_purchase_config_pricelist" sequence="1" groups="product.group_purchase_pricelist" />
+
+
+
+
+
+
+
+
From 3a67d7dc992963c27a993010ab355cc3b6d88a78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 26 Aug 2013 11:56:00 +0200
Subject: [PATCH 015/175] [FIX] crm: fixed a bug introduced when merging trunk
bzr revid: tde@openerp.com-20130826095600-bgvdzah9nwb2vu0l
---
addons/crm/crm_lead_view.xml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index acbec848da0..da3d91491b4 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -173,8 +173,7 @@
-
+ widget="selection"/>
From b35a44f66d947b03542b8eb3899fcd3adcf476ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 27 Aug 2013 15:30:58 +0200
Subject: [PATCH 016/175] [IMP] mail_mail, mail_message: various improvements
to try to improve message creation time Replaced some read by browse Moved
get_reply_to from mail_mail to mail_message Hint: specifying email_from,
reply_to help to enhance computation time
[REF] mail: cleaned some tests, renamed a file, moved mail_group tests into a dedicated file
bzr revid: tde@openerp.com-20130827133058-ko0g0ib0f0jihmdk
---
addons/email_template/tests/test_mail.py | 4 +-
addons/mail/mail_mail.py | 70 +------
addons/mail/mail_message.py | 99 +++++++---
addons/mail/tests/__init__.py | 3 +-
.../tests/{test_mail_base.py => common.py} | 58 +++++-
addons/mail/tests/test_invite.py | 4 +-
addons/mail/tests/test_mail_features.py | 4 +-
addons/mail/tests/test_mail_gateway.py | 174 +----------------
addons/mail/tests/test_mail_group.py | 71 +++++++
addons/mail/tests/test_mail_message.py | 179 +++++++++++++-----
addons/mail/tests/test_message_read.py | 4 +-
addons/portal/tests/test_portal.py | 4 +-
addons/project/tests/test_project_base.py | 4 +-
13 files changed, 346 insertions(+), 332 deletions(-)
rename addons/mail/tests/{test_mail_base.py => common.py} (66%)
create mode 100644 addons/mail/tests/test_mail_group.py
diff --git a/addons/email_template/tests/test_mail.py b/addons/email_template/tests/test_mail.py
index d5feea9ebc4..adb550aa617 100644
--- a/addons/email_template/tests/test_mail.py
+++ b/addons/email_template/tests/test_mail.py
@@ -20,10 +20,10 @@
##############################################################################
import base64
-from openerp.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.addons.mail.tests.common import TestMail
-class test_message_compose(TestMailBase):
+class test_message_compose(TestMail):
def setUp(self):
super(test_message_compose, self).setUp()
diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py
index f3cf5ce9e57..e5cb2b56eb3 100644
--- a/addons/mail/mail_mail.py
+++ b/addons/mail/mail_mail.py
@@ -82,74 +82,11 @@ class mail_mail(osv.Model):
context = dict(context, default_type=None)
return super(mail_mail, self).default_get(cr, uid, fields, context=context)
- def _get_reply_to(self, cr, uid, values, context=None):
- """ Return a specific reply_to: alias of the document through message_get_reply_to
- or take the email_from
- """
- # if value specified: directly return it
- if values.get('reply_to'):
- return values.get('reply_to')
- format_name = True # whether to use a 'Followers of Pigs catchall alias
- if not email_reply_to:
- catchall_alias = ir_config_parameter.get_param(cr, uid, "mail.catchall.alias", context=context)
- if catchall_domain and catchall_alias:
- email_reply_to = '%s@%s' % (catchall_alias, catchall_domain)
-
- # still no reply_to -> reply_to will be the email_from
- if not email_reply_to and email_from:
- email_reply_to = email_from
-
- # format 'Document name '
- if email_reply_to and model and res_id and format_name:
- emails = tools.email_split(email_reply_to)
- if emails:
- email_reply_to = emails[0]
- document_name = self.pool[model].name_get(cr, SUPERUSER_ID, [res_id], context=context)[0]
- if document_name:
- # sanitize document name
- sanitized_doc_name = re.sub(r'[^\w+.]+', '-', document_name[1])
- # generate reply to
- email_reply_to = _('"Followers of %s" <%s>') % (sanitized_doc_name, email_reply_to)
-
- return email_reply_to
-
def create(self, cr, uid, values, context=None):
# notification field: if not set, set if mail comes from an existing mail.message
if 'notification' not in values and values.get('mail_message_id'):
values['notification'] = True
- mail_id = super(mail_mail, self).create(cr, uid, values, context=context)
-
- # reply_to: if not set, set with default values that require creation values
- # but delegate after creation because of mail_message.message_id automatic
- # creation using existence of reply_to
- if not values.get('reply_to'):
- reply_to = self._get_reply_to(cr, uid, values, context=context)
- if reply_to:
- self.write(cr, uid, [mail_id], {'reply_to': reply_to}, context=context)
- return mail_id
+ return super(mail_mail, self).create(cr, uid, values, context=context)
def unlink(self, cr, uid, ids, context=None):
# cascade-delete the parent message for all mails that are not created for a notification
@@ -226,11 +163,6 @@ class mail_mail(osv.Model):
# mail_mail formatting, tools and send mechanism
#------------------------------------------------------
- # TODO in 8.0(+): maybe factorize this to enable in modules link generation
- # independently of mail_mail model
- # TODO in 8.0(+): factorize doc name sanitized and 'Followers of ...' formatting
- # because it begins to appear everywhere
-
def _get_partner_access_link(self, cr, uid, mail, partner=None, context=None):
""" Generate URLs for links in mails:
- partner is an user and has read access to the document: direct link to document with model, res_id
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index bcb66433964..d63025b0912 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -20,6 +20,8 @@
##############################################################################
import logging
+import re
+
from openerp import tools
from email.header import decode_header
@@ -87,6 +89,7 @@ class mail_message(osv.Model):
def _get_record_name(self, cr, uid, ids, name, arg, context=None):
""" Return the related document name, using name_get. It is done using
SUPERUSER_ID, to be sure to have the record name correctly stored. """
+ # return dict.fromkeys(ids, False)
# TDE note: regroup by model/ids, to have less queries to perform
result = dict.fromkeys(ids, False)
for message in self.read(cr, uid, ids, ['model', 'res_id'], context=context):
@@ -206,11 +209,11 @@ class mail_message(osv.Model):
raise osv.except_osv(_('Invalid Action!'), _("Unable to send email, please configure the sender's email address or alias."))
def _get_default_author(self, cr, uid, context=None):
- return self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0]
+ return self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context).partner_id.id
_defaults = {
'type': 'email',
- 'date': lambda *a: fields.datetime.now(),
+ 'date': fields.datetime.now(),
'author_id': lambda self, cr, uid, ctx=None: self._get_default_author(cr, uid, ctx),
'body': '',
'email_from': lambda self, cr, uid, ctx=None: self._get_default_from(cr, uid, ctx),
@@ -645,7 +648,8 @@ class mail_message(osv.Model):
elif not ids:
return ids
- pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'])['partner_id'][0]
+ # pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'])['partner_id'][0]
+ pid = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context).partner_id.id
author_ids, partner_ids, allowed_ids = set([]), set([]), set([])
model_ids = {}
@@ -705,7 +709,7 @@ class mail_message(osv.Model):
ids = [ids]
not_obj = self.pool.get('mail.notification')
fol_obj = self.pool.get('mail.followers')
- partner_id = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=None)['partner_id'][0]
+ partner_id = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=None).partner_id.id
# Read mail_message.ids to have their values
message_values = dict.fromkeys(ids)
@@ -774,17 +778,66 @@ class mail_message(osv.Model):
_('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % \
(self._description, operation))
+ def _get_reply_to(self, cr, uid, values, context=None):
+ """ Return a specific reply_to: alias of the document through message_get_reply_to
+ or take the email_from
+ """
+ email_reply_to = None
+
+ ir_config_parameter = self.pool.get("ir.config_parameter")
+ catchall_domain = ir_config_parameter.get_param(cr, uid, "mail.catchall.domain", context=context)
+
+ # model, res_id, email_from: comes from values OR related message
+ model, res_id, email_from = values.get('model'), values.get('res_id'), values.get('email_from')
+
+ # if model and res_id: try to use ``message_get_reply_to`` that returns the document alias
+ if not email_reply_to and model and res_id and catchall_domain and hasattr(self.pool[model], 'message_get_reply_to'):
+ email_reply_to = self.pool[model].message_get_reply_to(cr, uid, [res_id], context=context)[0]
+ # no alias reply_to -> catchall alias
+ if not email_reply_to and catchall_domain:
+ catchall_alias = ir_config_parameter.get_param(cr, uid, "mail.catchall.alias", context=context)
+ if catchall_alias:
+ email_reply_to = '%s@%s' % (catchall_alias, catchall_domain)
+ # still no reply_to -> reply_to will be the email_from
+ if not email_reply_to and email_from:
+ email_reply_to = email_from
+
+ # format 'Document name '
+ if email_reply_to and model and res_id:
+ emails = tools.email_split(email_reply_to)
+ if emails:
+ email_reply_to = emails[0]
+ document_name = self.pool[model].name_get(cr, SUPERUSER_ID, [res_id], context=context)[0]
+ if document_name:
+ # sanitize document name
+ sanitized_doc_name = re.sub(r'[^\w+.]+', '-', document_name[1])
+ # generate reply to
+ email_reply_to = _('"Followers of %s" <%s>') % (sanitized_doc_name, email_reply_to)
+
+ return email_reply_to
+
+ def _get_message_id(self, cr, uid, values, context=None):
+ message_id = None
+ if not values.get('message_id') and values.get('reply_to'):
+ message_id = tools.generate_tracking_message_id('reply_to')
+ elif not values.get('message_id') and values.get('res_id') and values.get('model'):
+ message_id = tools.generate_tracking_message_id('%(res_id)s-%(model)s' % values)
+ elif not values.get('message_id'):
+ message_id = tools.generate_tracking_message_id('private')
+ return message_id
+
def create(self, cr, uid, values, context=None):
if context is None:
context = {}
default_starred = context.pop('default_starred', False)
- # generate message_id, to redirect answers to the right discussion thread
- if not values.get('message_id') and values.get('reply_to'):
- values['message_id'] = tools.generate_tracking_message_id('reply_to')
- elif not values.get('message_id') and values.get('res_id') and values.get('model'):
- values['message_id'] = tools.generate_tracking_message_id('%(res_id)s-%(model)s' % values)
- elif not values.get('message_id'):
- values['message_id'] = tools.generate_tracking_message_id('private')
+
+ if not values.get('email_from'): # needed to compute reply_to
+ values['email_from'] = self._get_default_from(cr, uid, context=context)
+ if not values.get('message_id'):
+ values['message_id'] = self._get_message_id(cr, uid, values, context=context)
+ if not values.get('reply_to'):
+ values['reply_to'] = self._get_reply_to(cr, uid, values, context=context)
+
newid = super(mail_message, self).create(cr, uid, values, context)
self._notify(cr, uid, newid, context=context,
force_send=context.get('mail_notify_force_send', True),
@@ -914,26 +967,28 @@ class mail_message(osv.Model):
if message.subtype_id and message.model and message.res_id:
fol_obj = self.pool.get("mail.followers")
# browse as SUPERUSER because rules could restrict the search results
- fol_ids = fol_obj.search(cr, SUPERUSER_ID, [
- ('res_model', '=', message.model),
- ('res_id', '=', message.res_id),
- ('subtype_ids', 'in', message.subtype_id.id)
+ fol_ids = fol_obj.search(
+ cr, SUPERUSER_ID, [
+ ('res_model', '=', message.model),
+ ('res_id', '=', message.res_id),
+ ('subtype_ids', 'in', message.subtype_id.id)
], context=context)
- partners_to_notify |= set(fo.partner_id for fo in fol_obj.browse(cr, SUPERUSER_ID, fol_ids, context=context))
+ partners_to_notify |= set(fo.partner_id.id for fo in fol_obj.browse(cr, SUPERUSER_ID, fol_ids, context=context))
# remove me from notified partners, unless the message is written on my own wall
if message.subtype_id and message.author_id and message.model == "res.partner" and message.res_id == message.author_id.id:
- partners_to_notify |= set([message.author_id])
+ partners_to_notify |= set([message.author_id.id])
elif message.author_id:
- partners_to_notify -= set([message.author_id])
+ partners_to_notify -= set([message.author_id.id])
# all partner_ids of the mail.message have to be notified regardless of the above (even the author if explicitly added!)
if message.partner_ids:
- partners_to_notify |= set(message.partner_ids)
+ partners_to_notify |= set([p.id for p in message.partner_ids])
# notify
- if partners_to_notify:
- notification_obj._notify(cr, uid, newid, partners_to_notify=[p.id for p in partners_to_notify], context=context,
- force_send=force_send, user_signature=user_signature)
+ notification_obj._notify(
+ cr, uid, newid, partners_to_notify=list(partners_to_notify), context=context,
+ force_send=force_send, user_signature=user_signature
+ )
message.refresh()
# An error appear when a user receive a notification without notifying
diff --git a/addons/mail/tests/__init__.py b/addons/mail/tests/__init__.py
index ff1080b0580..242beb60bf1 100644
--- a/addons/mail/tests/__init__.py
+++ b/addons/mail/tests/__init__.py
@@ -19,9 +19,10 @@
#
##############################################################################
-from . import test_mail_message, test_mail_features, test_mail_gateway, test_message_read, test_invite
+from . import test_mail_group, test_mail_message, test_mail_features, test_mail_gateway, test_message_read, test_invite
checks = [
+ test_mail_group,
test_mail_message,
test_mail_features,
test_mail_gateway,
diff --git a/addons/mail/tests/test_mail_base.py b/addons/mail/tests/common.py
similarity index 66%
rename from addons/mail/tests/test_mail_base.py
rename to addons/mail/tests/common.py
index b0f9f72b6f7..68a329e043a 100644
--- a/addons/mail/tests/test_mail_base.py
+++ b/addons/mail/tests/common.py
@@ -22,7 +22,7 @@
from openerp.tests import common
-class TestMailBase(common.TransactionCase):
+class TestMail(common.TransactionCase):
def _mock_smtp_gateway(self, *args, **kwargs):
return args[2]['Message-Id']
@@ -39,7 +39,7 @@ class TestMailBase(common.TransactionCase):
return self._build_email(*args, **kwargs)
def setUp(self):
- super(TestMailBase, self).setUp()
+ super(TestMail, self).setUp()
cr, uid = self.cr, self.uid
# Install mock SMTP gateway
@@ -68,12 +68,46 @@ class TestMailBase(common.TransactionCase):
group_employee_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user')
self.group_employee_id = group_employee_ref and group_employee_ref[1] or False
+ # Partner Data
+
+ # User Data: employee, noone
+ self.user_employee_id = self.res_users.create(cr, uid, {
+ 'name': 'Ernest Employee',
+ 'login': 'ernest',
+ 'alias_name': 'ernest',
+ 'email': 'e.e@example.com',
+ 'signature': '--\nErnest',
+ 'notification_email_send': 'comment',
+ 'groups_id': [(6, 0, [self.group_employee_id])]
+ }, {'no_reset_password': True})
+ self.user_noone_id = self.res_users.create(cr, uid, {
+ 'name': 'Noemie NoOne',
+ 'login': 'noemie',
+ 'alias_name': 'noemie',
+ 'email': 'n.n@example.com',
+ 'signature': '--\nNoemie',
+ 'notification_email_send': 'comment',
+ 'groups_id': [(6, 0, [])]
+ }, {'no_reset_password': True})
+
# Test users to use through the various tests
self.res_users.write(cr, uid, uid, {'name': 'Administrator'})
- self.user_raoul_id = self.res_users.create(cr, uid,
- {'name': 'Raoul Grosbedon', 'signature': 'SignRaoul', 'email': 'raoul@raoul.fr', 'login': 'raoul', 'alias_name': 'raoul', 'groups_id': [(6, 0, [self.group_employee_id])]})
- self.user_bert_id = self.res_users.create(cr, uid,
- {'name': 'Bert Tartignole', 'signature': 'SignBert', 'email': 'bert@bert.fr', 'login': 'bert', 'alias_name': 'bert', 'groups_id': [(6, 0, [])]})
+ self.user_raoul_id = self.res_users.create(cr, uid, {
+ 'name': 'Raoul Grosbedon',
+ 'signature': 'SignRaoul',
+ 'email': 'raoul@raoul.fr',
+ 'login': 'raoul',
+ 'alias_name': 'raoul',
+ 'groups_id': [(6, 0, [self.group_employee_id])]
+ })
+ self.user_bert_id = self.res_users.create(cr, uid, {
+ 'name': 'Bert Tartignole',
+ 'signature': 'SignBert',
+ 'email': 'bert@bert.fr',
+ 'login': 'bert',
+ 'alias_name': 'bert',
+ 'groups_id': [(6, 0, [])]
+ })
self.user_raoul = self.res_users.browse(cr, uid, self.user_raoul_id)
self.user_bert = self.res_users.browse(cr, uid, self.user_bert_id)
self.user_admin = self.res_users.browse(cr, uid, uid)
@@ -82,13 +116,19 @@ class TestMailBase(common.TransactionCase):
self.partner_bert_id = self.user_bert.partner_id.id
# Test 'pigs' group to use through the various tests
- self.group_pigs_id = self.mail_group.create(cr, uid,
+ self.group_pigs_id = self.mail_group.create(
+ cr, uid,
{'name': 'Pigs', 'description': 'Fans of Pigs, unite !', 'alias_name': 'group+pigs'},
- {'mail_create_nolog': True})
+ {'mail_create_nolog': True}
+ )
self.group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id)
+ # Test mail.group: public to provide access to everyone
+ self.group_jobs_id = self.mail_group.create(cr, uid, {'name': 'Jobs', 'public': 'public'})
+ # Test mail.group: private to restrict access
+ self.group_priv_id = self.mail_group.create(cr, uid, {'name': 'Private', 'public': 'private'})
def tearDown(self):
# Remove mocks
self.registry('ir.mail_server').build_email = self._build_email
self.registry('ir.mail_server').send_email = self._send_email
- super(TestMailBase, self).tearDown()
+ super(TestMail, self).tearDown()
diff --git a/addons/mail/tests/test_invite.py b/addons/mail/tests/test_invite.py
index faa9fd55793..c4484d254bb 100644
--- a/addons/mail/tests/test_invite.py
+++ b/addons/mail/tests/test_invite.py
@@ -19,10 +19,10 @@
#
##############################################################################
-from openerp.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.addons.mail.tests.common import TestMail
-class test_invite(TestMailBase):
+class test_invite(TestMail):
def test_00_basic_invite(self):
cr, uid = self.cr, self.uid
diff --git a/addons/mail/tests/test_mail_features.py b/addons/mail/tests/test_mail_features.py
index e9563e19246..970f07f519e 100644
--- a/addons/mail/tests/test_mail_features.py
+++ b/addons/mail/tests/test_mail_features.py
@@ -21,12 +21,12 @@
from openerp.addons.mail.mail_mail import mail_mail
from openerp.addons.mail.mail_thread import mail_thread
-from openerp.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.addons.mail.tests.common import TestMail
from openerp.tools import mute_logger, email_split
from openerp.tools.mail import html_sanitize
-class test_mail(TestMailBase):
+class test_mail(TestMail):
def test_000_alias_setup(self):
""" Test basic mail.alias setup works, before trying to use them for routing """
diff --git a/addons/mail/tests/test_mail_gateway.py b/addons/mail/tests/test_mail_gateway.py
index 3fd8ebd3101..b2a1c3250aa 100644
--- a/addons/mail/tests/test_mail_gateway.py
+++ b/addons/mail/tests/test_mail_gateway.py
@@ -19,7 +19,7 @@
#
##############################################################################
-from openerp.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.addons.mail.tests.common import TestMail
from openerp.tools import mute_logger
MAIL_TEMPLATE = """Return-Path:
@@ -143,173 +143,9 @@ dGVzdAo=
--089e01536c4ed4d17204e49b8e96--"""
-class TestMailgateway(TestMailBase):
+class TestMailgateway(TestMail):
- def test_00_partner_find_from_email(self):
- """ Tests designed for partner fetch based on emails. """
- cr, uid, user_raoul, group_pigs = self.cr, self.uid, self.user_raoul, self.group_pigs
-
- # --------------------------------------------------
- # Data creation
- # --------------------------------------------------
- # 1 - Partner ARaoul
- p_a_id = self.res_partner.create(cr, uid, {'name': 'ARaoul', 'email': 'test@test.fr'})
-
- # --------------------------------------------------
- # CASE1: without object
- # --------------------------------------------------
-
- # Do: find partner with email -> first partner should be found
- partner_info = self.mail_thread.message_partner_info_from_emails(cr, uid, None, ['Maybe Raoul '], link_mail=False)[0]
- self.assertEqual(partner_info['full_name'], 'Maybe Raoul ',
- 'mail_thread: message_partner_info_from_emails did not handle email')
- self.assertEqual(partner_info['partner_id'], p_a_id,
- 'mail_thread: message_partner_info_from_emails wrong partner found')
-
- # Data: add some data about partners
- # 2 - User BRaoul
- p_b_id = self.res_partner.create(cr, uid, {'name': 'BRaoul', 'email': 'test@test.fr', 'user_ids': [(4, user_raoul.id)]})
-
- # Do: find partner with email -> first user should be found
- partner_info = self.mail_thread.message_partner_info_from_emails(cr, uid, None, ['Maybe Raoul '], link_mail=False)[0]
- self.assertEqual(partner_info['partner_id'], p_b_id,
- 'mail_thread: message_partner_info_from_emails wrong partner found')
-
- # --------------------------------------------------
- # CASE1: with object
- # --------------------------------------------------
-
- # Do: find partner in group where there is a follower with the email -> should be taken
- self.mail_group.message_subscribe(cr, uid, [group_pigs.id], [p_b_id])
- partner_info = self.mail_group.message_partner_info_from_emails(cr, uid, group_pigs.id, ['Maybe Raoul '], link_mail=False)[0]
- self.assertEqual(partner_info['partner_id'], p_b_id,
- 'mail_thread: message_partner_info_from_emails wrong partner found')
-
- def test_05_mail_message_mail_mail(self):
- """ Tests designed for testing email values based on mail.message, aliases, ... """
- cr, uid, user_raoul_id = self.cr, self.uid, self.user_raoul_id
-
- # Data: update + generic variables
- reply_to1 = '_reply_to1@example.com'
- reply_to2 = '_reply_to2@example.com'
- email_from1 = 'from@example.com'
- alias_domain = 'schlouby.fr'
- raoul_from = 'Raoul Grosbedon '
- raoul_from_alias = 'Raoul Grosbedon '
- raoul_reply = '"Followers of Pigs" '
- raoul_reply_alias = '"Followers of Pigs" '
- # Data: remove alias_domain to see emails with alias
- param_ids = self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.domain')])
- self.registry('ir.config_parameter').unlink(cr, uid, param_ids)
-
- # Do: free message; specified values > default values
- msg_id = self.mail_message.create(cr, user_raoul_id, {'reply_to': reply_to1, 'email_from': email_from1})
- msg = self.mail_message.browse(cr, user_raoul_id, msg_id)
- # Test: message content
- self.assertIn('reply_to', msg.message_id,
- 'mail_message: message_id should be specific to a mail_message with a given reply_to')
- self.assertEqual(msg.reply_to, reply_to1,
- 'mail_message: incorrect reply_to: should come from values')
- self.assertEqual(msg.email_from, email_from1,
- 'mail_message: incorrect email_from: should come from values')
- # Do: create a mail_mail with the previous mail_message
- mail_id = self.mail_mail.create(cr, user_raoul_id, {'mail_message_id': msg_id, 'state': 'cancel'})
- mail = self.mail_mail.browse(cr, user_raoul_id, mail_id)
- # Test: mail_mail content
- self.assertEqual(mail.reply_to, reply_to1,
- 'mail_mail: incorrect reply_to: should come from mail.message')
- self.assertEqual(mail.email_from, email_from1,
- 'mail_mail: incorrect email_from: should come from mail.message')
- # Do: create a mail_mail with the previous mail_message + specified reply_to
- mail_id = self.mail_mail.create(cr, user_raoul_id, {'mail_message_id': msg_id, 'state': 'cancel', 'reply_to': reply_to2})
- mail = self.mail_mail.browse(cr, user_raoul_id, mail_id)
- # Test: mail_mail content
- self.assertEqual(mail.reply_to, reply_to2,
- 'mail_mail: incorrect reply_to: should come from values')
- self.assertEqual(mail.email_from, email_from1,
- 'mail_mail: incorrect email_from: should come from mail.message')
-
- # Do: mail_message attached to a document
- msg_id = self.mail_message.create(cr, user_raoul_id, {'model': 'mail.group', 'res_id': self.group_pigs_id})
- msg = self.mail_message.browse(cr, user_raoul_id, msg_id)
- # Test: message content
- self.assertIn('mail.group', msg.message_id,
- 'mail_message: message_id should contain model')
- self.assertIn('%s' % self.group_pigs_id, msg.message_id,
- 'mail_message: message_id should contain res_id')
- self.assertFalse(msg.reply_to,
- 'mail_message: incorrect reply_to: should not be generated if not specified')
- self.assertEqual(msg.email_from, raoul_from,
- 'mail_message: incorrect email_from: should be Raoul')
- # Do: create a mail_mail based on the previous mail_message
- mail_id = self.mail_mail.create(cr, user_raoul_id, {'mail_message_id': msg_id, 'state': 'cancel'})
- mail = self.mail_mail.browse(cr, user_raoul_id, mail_id)
- # Test: mail_mail content
- self.assertEqual(mail.reply_to, raoul_reply,
- 'mail_mail: incorrect reply_to: should be Raoul')
-
- # Data: set catchall domain
- self.registry('ir.config_parameter').set_param(cr, uid, 'mail.catchall.domain', alias_domain)
- self.registry('ir.config_parameter').unlink(cr, uid, self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.alias')]))
-
- # Update message
- self.mail_message.write(cr, user_raoul_id, [msg_id], {'email_from': False, 'reply_to': False})
- msg.refresh()
- # Do: create a mail_mail based on the previous mail_message
- mail_id = self.mail_mail.create(cr, user_raoul_id, {'mail_message_id': msg_id, 'state': 'cancel'})
- mail = self.mail_mail.browse(cr, user_raoul_id, mail_id)
- # Test: mail_mail content
- self.assertEqual(mail.reply_to, raoul_reply_alias,
- 'mail_mail: incorrect reply_to: should be Pigs alias')
-
- # Update message: test alias on email_from
- msg_id = self.mail_message.create(cr, user_raoul_id, {})
- msg = self.mail_message.browse(cr, user_raoul_id, msg_id)
- # Do: create a mail_mail based on the previous mail_message
- mail_id = self.mail_mail.create(cr, user_raoul_id, {'mail_message_id': msg_id, 'state': 'cancel'})
- mail = self.mail_mail.browse(cr, user_raoul_id, mail_id)
- # Test: mail_mail content
- self.assertEqual(mail.reply_to, raoul_from_alias,
- 'mail_mail: incorrect reply_to: should be message email_from using Raoul alias')
-
- # Update message
- self.mail_message.write(cr, user_raoul_id, [msg_id], {'res_id': False, 'email_from': 'someone@schlouby.fr', 'reply_to': False})
- msg.refresh()
- # Do: create a mail_mail based on the previous mail_message
- mail_id = self.mail_mail.create(cr, user_raoul_id, {'mail_message_id': msg_id, 'state': 'cancel'})
- mail = self.mail_mail.browse(cr, user_raoul_id, mail_id)
- # Test: mail_mail content
- self.assertEqual(mail.reply_to, msg.email_from,
- 'mail_mail: incorrect reply_to: should be message email_from')
-
- # Data: set catchall alias
- self.registry('ir.config_parameter').set_param(self.cr, self.uid, 'mail.catchall.alias', 'gateway')
-
- # Update message
- self.mail_message.write(cr, uid, [msg_id], {'email_from': False, 'reply_to': False})
- msg.refresh()
- # Do: create a mail_mail based on the previous mail_message
- mail_id = self.mail_mail.create(cr, uid, {'mail_message_id': msg_id, 'state': 'cancel'})
- mail = self.mail_mail.browse(cr, uid, mail_id)
- # Test: mail_mail Content-Type
- self.assertEqual(mail.reply_to, 'gateway@schlouby.fr',
- 'mail_mail: reply_to should equal the catchall email alias')
-
- # Do: create a mail_mail
- mail_id = self.mail_mail.create(cr, uid, {'state': 'cancel'})
- mail = self.mail_mail.browse(cr, uid, mail_id)
- # Test: mail_mail content
- self.assertEqual(mail.reply_to, 'gateway@schlouby.fr',
- 'mail_mail: reply_to should equal the catchall email alias')
-
- # Do: create a mail_mail
- mail_id = self.mail_mail.create(cr, uid, {'state': 'cancel', 'reply_to': 'someone@example.com'})
- mail = self.mail_mail.browse(cr, uid, mail_id)
- # Test: mail_mail content
- self.assertEqual(mail.reply_to, 'someone@example.com',
- 'mail_mail: reply_to should equal the rpely_to given to create')
-
- def test_09_message_parse(self):
+ def test_00_message_parse(self):
""" Testing incoming emails parsing """
cr, uid = self.cr, self.uid
@@ -738,9 +574,7 @@ class TestMailgateway(TestMailBase):
'message_post: private discussion: incorrect notified recipients')
self.assertEqual(msg.model, False,
'message_post: private discussion: context key "thread_model" not correctly ignored when having no res_id')
- # Test: message reply_to and message-id
- self.assertFalse(msg.reply_to,
- 'message_post: private discussion: initial message should not have any reply_to specified')
+ # Test: message-id
self.assertIn('openerp-private', msg.message_id,
'message_post: private discussion: message-id should contain the private keyword')
diff --git a/addons/mail/tests/test_mail_group.py b/addons/mail/tests/test_mail_group.py
new file mode 100644
index 00000000000..c1512441b13
--- /dev/null
+++ b/addons/mail/tests/test_mail_group.py
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Business Applications
+# Copyright (c) 2012-TODAY OpenERP S.A.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp.addons.mail.tests.common import TestMail
+from openerp.osv.orm import except_orm
+from openerp.tools import mute_logger
+
+
+class TestMailGroup(TestMail):
+
+ @mute_logger('openerp.addons.base.ir.ir_model', 'openerp.osv.orm')
+ def test_00_mail_group_access_rights(self):
+ """ Testing mail_group access rights and basic mail_thread features """
+ cr, uid, user_noone_id, user_employee_id = self.cr, self.uid, self.user_noone_id, self.user_employee_id
+
+ # Do: Bert reads Jobs -> ok, public
+ self.mail_group.read(cr, user_noone_id, [self.group_jobs_id])
+ # Do: Bert read Pigs -> ko, restricted to employees
+ with self.assertRaises(except_orm):
+ self.mail_group.read(cr, user_noone_id, [self.group_pigs_id])
+ # Do: Raoul read Pigs -> ok, belong to employees
+ self.mail_group.read(cr, user_employee_id, [self.group_pigs_id])
+
+ # Do: Bert creates a group -> ko, no access rights
+ with self.assertRaises(except_orm):
+ self.mail_group.create(cr, user_noone_id, {'name': 'Test'})
+ # Do: Raoul creates a restricted group -> ok
+ new_group_id = self.mail_group.create(cr, user_employee_id, {'name': 'Test'})
+ # Do: Bert added in followers, read -> ok, in followers
+ self.mail_group.message_subscribe_users(cr, uid, [new_group_id], [user_noone_id])
+ self.mail_group.read(cr, user_noone_id, [new_group_id])
+
+ # Do: Raoul reads Priv -> ko, private
+ with self.assertRaises(except_orm):
+ self.mail_group.read(cr, user_employee_id, [self.group_priv_id])
+ # Do: Raoul added in follower, read -> ok, in followers
+ self.mail_group.message_subscribe_users(cr, uid, [self.group_priv_id], [user_employee_id])
+ self.mail_group.read(cr, user_employee_id, [self.group_priv_id])
+
+ # Do: Raoul write on Jobs -> ok
+ self.mail_group.write(cr, user_employee_id, [self.group_priv_id], {'name': 'modified'})
+ # Do: Bert cannot write on Private -> ko (read but no write)
+ with self.assertRaises(except_orm):
+ self.mail_group.write(cr, user_noone_id, [self.group_priv_id], {'name': 're-modified'})
+ # Test: Bert cannot unlink the group
+ with self.assertRaises(except_orm):
+ self.mail_group.unlink(cr, user_noone_id, [self.group_priv_id])
+ # Do: Raoul unlinks the group, there are no followers and messages left
+ self.mail_group.unlink(cr, user_employee_id, [self.group_priv_id])
+ fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_priv_id)])
+ self.assertFalse(fol_ids, 'unlinked document should not have any followers left')
+ msg_ids = self.mail_message.search(cr, uid, [('model', '=', 'mail.group'), ('res_id', '=', self.group_priv_id)])
+ self.assertFalse(msg_ids, 'unlinked document should not have any followers left')
diff --git a/addons/mail/tests/test_mail_message.py b/addons/mail/tests/test_mail_message.py
index f422219000c..5dc5e9e247d 100644
--- a/addons/mail/tests/test_mail_message.py
+++ b/addons/mail/tests/test_mail_message.py
@@ -19,66 +19,147 @@
#
##############################################################################
-from openerp.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.addons.mail.tests.common import TestMail
from openerp.osv.orm import except_orm
from openerp.tools import mute_logger
-class test_mail_access_rights(TestMailBase):
+class TestMailMail(TestMail):
- def setUp(self):
- super(test_mail_access_rights, self).setUp()
- cr, uid = self.cr, self.uid
+ def test_00_partner_find_from_email(self):
+ """ Tests designed for partner fetch based on emails. """
+ cr, uid, user_raoul, group_pigs = self.cr, self.uid, self.user_raoul, self.group_pigs
- # Test mail.group: public to provide access to everyone
- self.group_jobs_id = self.mail_group.create(cr, uid, {'name': 'Jobs', 'public': 'public'})
- # Test mail.group: private to restrict access
- self.group_priv_id = self.mail_group.create(cr, uid, {'name': 'Private', 'public': 'private'})
+ # --------------------------------------------------
+ # Data creation
+ # --------------------------------------------------
+ # 1 - Partner ARaoul
+ p_a_id = self.res_partner.create(cr, uid, {'name': 'ARaoul', 'email': 'test@test.fr'})
- @mute_logger('openerp.addons.base.ir.ir_model', 'openerp.osv.orm')
- def test_00_mail_group_access_rights(self):
- """ Testing mail_group access rights and basic mail_thread features """
- cr, uid, user_bert_id, user_raoul_id = self.cr, self.uid, self.user_bert_id, self.user_raoul_id
+ # --------------------------------------------------
+ # CASE1: without object
+ # --------------------------------------------------
- # Do: Bert reads Jobs -> ok, public
- self.mail_group.read(cr, user_bert_id, [self.group_jobs_id])
- # Do: Bert read Pigs -> ko, restricted to employees
- self.assertRaises(except_orm, self.mail_group.read,
- cr, user_bert_id, [self.group_pigs_id])
- # Do: Raoul read Pigs -> ok, belong to employees
- self.mail_group.read(cr, user_raoul_id, [self.group_pigs_id])
+ # Do: find partner with email -> first partner should be found
+ partner_info = self.mail_thread.message_partner_info_from_emails(cr, uid, None, ['Maybe Raoul '], link_mail=False)[0]
+ self.assertEqual(partner_info['full_name'], 'Maybe Raoul ',
+ 'mail_thread: message_partner_info_from_emails did not handle email')
+ self.assertEqual(partner_info['partner_id'], p_a_id,
+ 'mail_thread: message_partner_info_from_emails wrong partner found')
- # Do: Bert creates a group -> ko, no access rights
- self.assertRaises(except_orm, self.mail_group.create,
- cr, user_bert_id, {'name': 'Test'})
- # Do: Raoul creates a restricted group -> ok
- new_group_id = self.mail_group.create(cr, user_raoul_id, {'name': 'Test'})
- # Do: Bert added in followers, read -> ok, in followers
- self.mail_group.message_subscribe_users(cr, uid, [new_group_id], [user_bert_id])
- self.mail_group.read(cr, user_bert_id, [new_group_id])
+ # Data: add some data about partners
+ # 2 - User BRaoul
+ p_b_id = self.res_partner.create(cr, uid, {'name': 'BRaoul', 'email': 'test@test.fr', 'user_ids': [(4, user_raoul.id)]})
- # Do: Raoul reads Priv -> ko, private
- self.assertRaises(except_orm, self.mail_group.read,
- cr, user_raoul_id, [self.group_priv_id])
- # Do: Raoul added in follower, read -> ok, in followers
- self.mail_group.message_subscribe_users(cr, uid, [self.group_priv_id], [user_raoul_id])
- self.mail_group.read(cr, user_raoul_id, [self.group_priv_id])
+ # Do: find partner with email -> first user should be found
+ partner_info = self.mail_thread.message_partner_info_from_emails(cr, uid, None, ['Maybe Raoul '], link_mail=False)[0]
+ self.assertEqual(partner_info['partner_id'], p_b_id,
+ 'mail_thread: message_partner_info_from_emails wrong partner found')
- # Do: Raoul write on Jobs -> ok
- self.mail_group.write(cr, user_raoul_id, [self.group_priv_id], {'name': 'modified'})
- # Do: Bert cannot write on Private -> ko (read but no write)
- self.assertRaises(except_orm, self.mail_group.write,
- cr, user_bert_id, [self.group_priv_id], {'name': 're-modified'})
- # Test: Bert cannot unlink the group
- self.assertRaises(except_orm,
- self.mail_group.unlink,
- cr, user_bert_id, [self.group_priv_id])
- # Do: Raoul unlinks the group, there are no followers and messages left
- self.mail_group.unlink(cr, user_raoul_id, [self.group_priv_id])
- fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_priv_id)])
- self.assertFalse(fol_ids, 'unlinked document should not have any followers left')
- msg_ids = self.mail_message.search(cr, uid, [('model', '=', 'mail.group'), ('res_id', '=', self.group_priv_id)])
- self.assertFalse(msg_ids, 'unlinked document should not have any followers left')
+ # --------------------------------------------------
+ # CASE1: with object
+ # --------------------------------------------------
+
+ # Do: find partner in group where there is a follower with the email -> should be taken
+ self.mail_group.message_subscribe(cr, uid, [group_pigs.id], [p_b_id])
+ partner_info = self.mail_group.message_partner_info_from_emails(cr, uid, group_pigs.id, ['Maybe Raoul '], link_mail=False)[0]
+ self.assertEqual(partner_info['partner_id'], p_b_id,
+ 'mail_thread: message_partner_info_from_emails wrong partner found')
+
+
+class TestMailMessage(TestMail):
+
+ def test_00_mail_message_values(self):
+ """ Tests designed for testing email values based on mail.message, aliases, ... """
+ cr, uid, user_raoul_id = self.cr, self.uid, self.user_raoul_id
+
+ # Data: update + generic variables
+ reply_to1 = '_reply_to1@example.com'
+ reply_to2 = '_reply_to2@example.com'
+ email_from1 = 'from@example.com'
+ alias_domain = 'schlouby.fr'
+ raoul_from = 'Raoul Grosbedon '
+ raoul_from_alias = 'Raoul Grosbedon '
+ raoul_reply = '"Followers of Pigs" '
+ raoul_reply_alias = '"Followers of Pigs" '
+
+ # --------------------------------------------------
+ # Case1: without alias_domain
+ # --------------------------------------------------
+ param_ids = self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.domain')])
+ self.registry('ir.config_parameter').unlink(cr, uid, param_ids)
+
+ # Do: free message; specified values > default values
+ msg_id = self.mail_message.create(cr, user_raoul_id, {'reply_to': reply_to1, 'email_from': email_from1})
+ msg = self.mail_message.browse(cr, user_raoul_id, msg_id)
+ # Test: message content
+ self.assertIn('reply_to', msg.message_id,
+ 'mail_message: message_id should be specific to a mail_message with a given reply_to')
+ self.assertEqual(msg.reply_to, reply_to1,
+ 'mail_message: incorrect reply_to: should come from values')
+ self.assertEqual(msg.email_from, email_from1,
+ 'mail_message: incorrect email_from: should come from values')
+
+ # Do: create a mail_mail with the previous mail_message + specified reply_to
+ mail_id = self.mail_mail.create(cr, user_raoul_id, {'mail_message_id': msg_id, 'state': 'cancel', 'reply_to': reply_to2})
+ mail = self.mail_mail.browse(cr, user_raoul_id, mail_id)
+ # Test: mail_mail content
+ self.assertEqual(mail.reply_to, reply_to2,
+ 'mail_mail: incorrect reply_to: should come from values')
+ self.assertEqual(mail.email_from, email_from1,
+ 'mail_mail: incorrect email_from: should come from mail.message')
+
+ # Do: mail_message attached to a document
+ msg_id = self.mail_message.create(cr, user_raoul_id, {'model': 'mail.group', 'res_id': self.group_pigs_id})
+ msg = self.mail_message.browse(cr, user_raoul_id, msg_id)
+ # Test: message content
+ self.assertIn('mail.group', msg.message_id,
+ 'mail_message: message_id should contain model')
+ self.assertIn('%s' % self.group_pigs_id, msg.message_id,
+ 'mail_message: message_id should contain res_id')
+ self.assertEqual(msg.reply_to, raoul_reply,
+ 'mail_message: incorrect reply_to: should be Raoul')
+ self.assertEqual(msg.email_from, raoul_from,
+ 'mail_message: incorrect email_from: should be Raoul')
+
+ # --------------------------------------------------
+ # Case2: with alias_domain, without catchall alias
+ # --------------------------------------------------
+ self.registry('ir.config_parameter').set_param(cr, uid, 'mail.catchall.domain', alias_domain)
+ self.registry('ir.config_parameter').unlink(cr, uid, self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.alias')]))
+
+ # Update message
+ msg_id = self.mail_message.create(cr, user_raoul_id, {'model': 'mail.group', 'res_id': self.group_pigs_id})
+ msg = self.mail_message.browse(cr, user_raoul_id, msg_id)
+ # Test: generated reply_to
+ self.assertEqual(msg.reply_to, raoul_reply_alias,
+ 'mail_mail: incorrect reply_to: should be Pigs alias')
+
+ # Update message: test alias on email_from
+ msg_id = self.mail_message.create(cr, user_raoul_id, {})
+ msg = self.mail_message.browse(cr, user_raoul_id, msg_id)
+ # Test: generated reply_to
+ self.assertEqual(msg.reply_to, raoul_from_alias,
+ 'mail_mail: incorrect reply_to: should be message email_from using Raoul alias')
+
+ # --------------------------------------------------
+ # Case2: with alias_domain and catchall alias
+ # --------------------------------------------------
+ self.registry('ir.config_parameter').set_param(self.cr, self.uid, 'mail.catchall.alias', 'gateway')
+
+ # Update message
+ msg_id = self.mail_message.create(cr, user_raoul_id, {})
+ msg = self.mail_message.browse(cr, user_raoul_id, msg_id)
+ # Test: generated reply_to
+ self.assertEqual(msg.reply_to, 'gateway@schlouby.fr',
+ 'mail_mail: reply_to should equal the catchall email alias')
+
+ # Do: create a mail_mail
+ mail_id = self.mail_mail.create(cr, uid, {'state': 'cancel', 'reply_to': 'someone@example.com'})
+ mail = self.mail_mail.browse(cr, uid, mail_id)
+ # Test: mail_mail content
+ self.assertEqual(mail.reply_to, 'someone@example.com',
+ 'mail_mail: reply_to should equal the rpely_to given to create')
@mute_logger('openerp.addons.base.ir.ir_model', 'openerp.osv.orm')
def test_10_mail_message_search_access_rights(self):
diff --git a/addons/mail/tests/test_message_read.py b/addons/mail/tests/test_message_read.py
index a4ff3685788..c02e9a32278 100644
--- a/addons/mail/tests/test_message_read.py
+++ b/addons/mail/tests/test_message_read.py
@@ -19,10 +19,10 @@
#
##############################################################################
-from openerp.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.addons.mail.tests.common import TestMail
-class test_mail_access_rights(TestMailBase):
+class test_mail_access_rights(TestMail):
def test_00_message_read(self):
""" Tests for message_read and expandables. """
diff --git a/addons/portal/tests/test_portal.py b/addons/portal/tests/test_portal.py
index e2b66e65af6..4d301458365 100644
--- a/addons/portal/tests/test_portal.py
+++ b/addons/portal/tests/test_portal.py
@@ -19,12 +19,12 @@
#
##############################################################################
-from openerp.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.addons.mail.tests.common import TestMail
from openerp.osv.orm import except_orm
from openerp.tools.misc import mute_logger
-class test_portal(TestMailBase):
+class test_portal(TestMail):
def setUp(self):
super(test_portal, self).setUp()
diff --git a/addons/project/tests/test_project_base.py b/addons/project/tests/test_project_base.py
index f82561766fe..70f8b59812f 100644
--- a/addons/project/tests/test_project_base.py
+++ b/addons/project/tests/test_project_base.py
@@ -19,10 +19,10 @@
#
##############################################################################
-from openerp.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.addons.mail.tests.common import TestMail
-class TestProjectBase(TestMailBase):
+class TestProjectBase(TestMail):
def setUp(self):
super(TestProjectBase, self).setUp()
From 4779df339eb8d7790cb7c6ac61d32f4d1d193f43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 27 Aug 2013 17:38:40 +0200
Subject: [PATCH 017/175] [REF] mail_followers: cleaned notify methods,
lessening the number of queries.
bzr revid: tde@openerp.com-20130827153840-fo9s2lc35fvld3fb
---
addons/mail/mail_followers.py | 118 +++++++++++++++++-----------------
addons/mail/mail_message.py | 1 -
2 files changed, 60 insertions(+), 59 deletions(-)
diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py
index ac350810aa6..0059df90530 100644
--- a/addons/mail/mail_followers.py
+++ b/addons/mail/mail_followers.py
@@ -77,7 +77,7 @@ class mail_notification(osv.Model):
if not cr.fetchone():
cr.execute('CREATE INDEX mail_notification_partner_id_read_starred_message_id ON mail_notification (partner_id, read, starred, message_id)')
- def get_partners_to_notify(self, cr, uid, message, partners_to_notify=None, context=None):
+ def get_partners_to_email(self, cr, uid, ids, message, context=None):
""" Return the list of partners to notify, based on their preferences.
:param browse_record message: mail.message to notify
@@ -85,13 +85,10 @@ class mail_notification(osv.Model):
the notifications to process
"""
notify_pids = []
- for notification in message.notification_ids:
+ for notification in self.browse(cr, uid, ids, context=context):
if notification.read:
continue
partner = notification.partner_id
- # If partners_to_notify specified: restrict to them
- if partners_to_notify is not None and partner.id not in partners_to_notify:
- continue
# Do not send to partners without email address defined
if not partner.email:
continue
@@ -143,14 +140,62 @@ class mail_notification(osv.Model):
company = user.company_id.name
sent_by = _('Sent by %(company)s using %(openerp)s.')
signature_company = '%s' % (sent_by % {
- 'company': company,
- 'openerp': "OpenERP"
- })
+ 'company': company,
+ 'openerp': "OpenERP"
+ })
footer = tools.append_content_to_html(footer, signature_company, plaintext=False, container_tag='div')
return footer
- def _notify(self, cr, uid, msg_id, partners_to_notify=None, context=None,
+ def update_message_notification(self, cr, uid, ids, message_id, partner_ids, context=None):
+ existing_pids = set()
+ new_pids = set()
+ new_notif_ids = []
+
+ for notification in self.browse(cr, uid, ids, context=context):
+ existing_pids.add(notification.partner_id.id)
+
+ # update existing notifications
+ self.write(cr, uid, ids, {'read': False}, context=context)
+
+ # create new notifications
+ new_pids = set(partner_ids) - existing_pids
+ for new_pid in new_pids:
+ new_notif_ids.append(self.create(cr, uid, {'message_id': message_id, 'partner_id': new_pid, 'read': False}, context=context))
+ return new_notif_ids
+
+ def _notify_email(self, cr, uid, ids, message_id, force_send=False, user_signature=True, context=None):
+ message = self.pool['mail.message'].browse(cr, SUPERUSER_ID, message_id, context=context)
+
+ # compute partners
+ email_pids = self.get_partners_to_email(cr, uid, ids, message, context=None)
+ if not email_pids:
+ return True
+
+ # compute email body (signature, company data)
+ body_html = message.body
+ user_id = message.author_id and message.author_id.user_ids and message.author_id.user_ids[0] and message.author_id.user_ids[0].id or None
+ if user_signature:
+ signature_company = self.get_signature_footer(cr, uid, user_id, res_model=message.model, res_id=message.res_id, context=context)
+ body_html = tools.append_content_to_html(body_html, signature_company, plaintext=False, container_tag='div')
+
+ # compute email references
+ references = message.parent_id.message_id if message.parent_id else False
+
+ # create email values
+ mail_values = {
+ 'mail_message_id': message.id,
+ 'auto_delete': True,
+ 'body_html': body_html,
+ 'recipient_ids': [(4, id) for id in email_pids],
+ 'references': references,
+ }
+ email_notif_id = self.pool.get('mail.mail').create(cr, uid, mail_values, context=context)
+ if force_send:
+ self.pool.get('mail.mail').send(cr, uid, [email_notif_id], context=context)
+ return True
+
+ def _notify(self, cr, uid, message_id, partners_to_notify=None, context=None,
force_send=False, user_signature=True):
""" Send by email the notification depending on the user preferences
@@ -162,57 +207,14 @@ class mail_notification(osv.Model):
:param bool user_signature: if True, the generated mail.mail body is
the body of the related mail.message with the author's signature
"""
- if context is None:
- context = {}
- mail_message_obj = self.pool.get('mail.message')
+ notif_ids = self.search(cr, SUPERUSER_ID, [('message_id', '=', message_id), ('partner_id', 'in', partners_to_notify)], context=context)
- # optional list of partners to notify: subscribe them if not already done or update the notification
- if partners_to_notify:
- notifications_to_update = []
- notified_partners = []
- notif_ids = self.search(cr, SUPERUSER_ID, [('message_id', '=', msg_id), ('partner_id', 'in', partners_to_notify)], context=context)
- for notification in self.browse(cr, SUPERUSER_ID, notif_ids, context=context):
- notified_partners.append(notification.partner_id.id)
- notifications_to_update.append(notification.id)
- partners_to_notify = filter(lambda item: item not in notified_partners, partners_to_notify)
- if notifications_to_update:
- self.write(cr, SUPERUSER_ID, notifications_to_update, {'read': False}, context=context)
- mail_message_obj.write(cr, uid, msg_id, {'notified_partner_ids': [(4, id) for id in partners_to_notify]}, context=context)
+ # update or create notifications
+ new_notif_ids = self.update_message_notification(cr, SUPERUSER_ID, notif_ids, message_id, partners_to_notify, context=context)
# mail_notify_noemail (do not send email) or no partner_ids: do not send, return
- if context.get('mail_notify_noemail'):
+ if context and context.get('mail_notify_noemail'):
return True
+
# browse as SUPERUSER_ID because of access to res_partner not necessarily allowed
- msg = self.pool.get('mail.message').browse(cr, SUPERUSER_ID, msg_id, context=context)
- notify_partner_ids = self.get_partners_to_notify(cr, uid, msg, partners_to_notify=partners_to_notify, context=context)
- if not notify_partner_ids:
- return True
-
- # add the context in the email
- # TDE FIXME: commented, to be improved in a future branch
- # quote_context = self.pool.get('mail.message').message_quote_context(cr, uid, msg_id, context=context)
-
- # add signature
- body_html = msg.body
- user_id = msg.author_id and msg.author_id.user_ids and msg.author_id.user_ids[0] and msg.author_id.user_ids[0].id or None
- if user_signature:
- signature_company = self.get_signature_footer(cr, uid, user_id, res_model=msg.model, res_id=msg.res_id, context=context)
- body_html = tools.append_content_to_html(body_html, signature_company, plaintext=False, container_tag='div')
-
- references = False
- if msg.parent_id:
- references = msg.parent_id.message_id
-
- mail_values = {
- 'mail_message_id': msg.id,
- 'auto_delete': True,
- 'body_html': body_html,
- 'recipient_ids': [(4, id) for id in notify_partner_ids],
- 'references': references,
- }
- mail_mail = self.pool.get('mail.mail')
- email_notif_id = mail_mail.create(cr, uid, mail_values, context=context)
-
- if force_send:
- mail_mail.send(cr, uid, [email_notif_id], context=context)
- return True
+ self._notify_email(cr, SUPERUSER_ID, new_notif_ids, message_id, force_send, user_signature, context=context)
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index d63025b0912..e3a1ae93342 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -89,7 +89,6 @@ class mail_message(osv.Model):
def _get_record_name(self, cr, uid, ids, name, arg, context=None):
""" Return the related document name, using name_get. It is done using
SUPERUSER_ID, to be sure to have the record name correctly stored. """
- # return dict.fromkeys(ids, False)
# TDE note: regroup by model/ids, to have less queries to perform
result = dict.fromkeys(ids, False)
for message in self.read(cr, uid, ids, ['model', 'res_id'], context=context):
From 0dfe3a2e677aad8a4c03e215a81787f299707d98 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 27 Aug 2013 18:18:01 +0200
Subject: [PATCH 018/175] [FIX] crm: fixed regression in merge_notify, due to a
cleaning in opportunities merging a few months ago
bzr revid: tde@openerp.com-20130827161801-d8i11n5uq7n4v9r8
---
addons/crm/crm_lead.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 6e8e966f5b0..9d17526c19f 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -636,7 +636,7 @@ class crm_lead(format_address, osv.osv):
# Merge notifications about loss of information
opportunities = [highest]
opportunities.extend(opportunities_rest)
- self._merge_notify(cr, uid, highest, opportunities, context=context)
+ self._merge_notify(cr, uid, highest.id, opportunities, context=context)
# Check if the stage is in the stages of the sales team. If not, assign the stage with the lowest sequence
if merged_data.get('section_id'):
section_stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('section_ids', 'in', merged_data['section_id']), ('type', '=', merged_data.get('type'))], order='sequence', context=context)
From eaf07ae5c45be7ee3e55bf405556aa50d8a59091 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Wed, 28 Aug 2013 16:08:45 +0200
Subject: [PATCH 019/175] [FIX] mail_message: fixed reply_to and email_from
computation in create: take also False values, only undefined values trigger
the default one
bzr revid: tde@openerp.com-20130828140845-uuv8ouoto4q7g96j
---
addons/mail/mail_message.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index e3a1ae93342..ef3b70bed13 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -91,6 +91,7 @@ class mail_message(osv.Model):
SUPERUSER_ID, to be sure to have the record name correctly stored. """
# TDE note: regroup by model/ids, to have less queries to perform
result = dict.fromkeys(ids, False)
+ # return result
for message in self.read(cr, uid, ids, ['model', 'res_id'], context=context):
if not message.get('model') or not message.get('res_id') or message['model'] not in self.pool:
continue
@@ -830,11 +831,11 @@ class mail_message(osv.Model):
context = {}
default_starred = context.pop('default_starred', False)
- if not values.get('email_from'): # needed to compute reply_to
+ if 'email_from' not in values: # needed to compute reply_to
values['email_from'] = self._get_default_from(cr, uid, context=context)
if not values.get('message_id'):
values['message_id'] = self._get_message_id(cr, uid, values, context=context)
- if not values.get('reply_to'):
+ if 'reply_to' not in values:
values['reply_to'] = self._get_reply_to(cr, uid, values, context=context)
newid = super(mail_message, self).create(cr, uid, values, context)
From 9ef46123a6c7c7dc1c136bbfcf9eb522cc4cf78c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Wed, 28 Aug 2013 16:09:29 +0200
Subject: [PATCH 020/175] [IMP] mail.compose.message, email.template: rendering
is now done in batch.
Also refactored send_mail in mail.compose.message in order to be able to override
mail values without having to intefere with the send_mail behavior.
bzr revid: tde@openerp.com-20130828140929-xe9hbmbo6jxgs9mh
---
addons/email_template/email_template.py | 197 +++++++++++-------
.../wizard/mail_compose_message.py | 69 +++---
addons/mail/wizard/mail_compose_message.py | 184 ++++++++++------
3 files changed, 272 insertions(+), 178 deletions(-)
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py
index 2e3405ed079..2e1c52d0ef9 100644
--- a/addons/email_template/email_template.py
+++ b/addons/email_template/email_template.py
@@ -67,7 +67,7 @@ class email_template(osv.osv):
_description = 'Email Templates'
_order = 'name'
- def render_template(self, cr, uid, template, model, res_id, context=None):
+ def render_template_batch(self, cr, uid, template, model, res_ids, context=None):
"""Render the given template text, replace mako expressions ``${expr}``
with the result of evaluating these expressions with
an evaluation context containing:
@@ -79,46 +79,60 @@ class email_template(osv.osv):
:param str template: the template text to render
:param str model: model name of the document record this mail is related to.
- :param int res_id: id of the document record this mail is related to.
+ :param int res_ids: list of ids of document records those mails are related to.
"""
- if not template:
- return u""
if context is None:
context = {}
- try:
- template = tools.ustr(template)
- record = None
- if res_id:
- record = self.pool[model].browse(cr, uid, res_id, context=context)
- user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
- variables = {
- 'object': record,
- 'user': user,
- 'ctx': context, # context kw would clash with mako internals
- }
- result = mako_template_env.from_string(template).render(variables)
- if result == u"False":
- result = u""
- return result
- except Exception:
- _logger.exception("failed to render mako template value %r", template)
- return u""
+ results = dict.fromkeys(res_ids, u"")
- def get_email_template(self, cr, uid, template_id=False, record_id=None, context=None):
+ # try to load the template
+ try:
+ template = mako_template_env.from_string(tools.ustr(template))
+ except Exception:
+ _logger.exception("Failed to load template %r", template)
+ return results
+
+ # prepare template variables
+ user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
+ records = self.pool[model].browse(cr, uid, res_ids, context=context) or [None]
+ variables = {
+ 'user': user,
+ 'ctx': context, # context kw would clash with mako internals
+ }
+ for record in records:
+ res_id = record.id if record else None
+ variables['object'] = record
+ try:
+ render_result = template.render(variables)
+ except Exception:
+ _logger.exception("Failed to render template %r using values %r" % (template, variables))
+ render_result = u""
+ if render_result == u"False":
+ render_result = u""
+ results[res_id] = render_result
+ return results
+
+ def get_email_template_batch(self, cr, uid, template_id=False, res_ids=None, context=None):
if context is None:
context = {}
+ if res_ids is None:
+ res_ids = [None]
+ results = dict.fromkeys(res_ids, False)
+
if not template_id:
- return False
+ return results
template = self.browse(cr, uid, template_id, context)
- lang = self.render_template(cr, uid, template.lang, template.model, record_id, context)
- if lang:
- # Use translated template if necessary
- ctx = context.copy()
- ctx['lang'] = lang
- template = self.browse(cr, uid, template.id, ctx)
- else:
- template = self.browse(cr, uid, int(template_id), context)
- return template
+ langs = self.render_template_batch(cr, uid, template.lang, template.model, res_ids, context)
+ for res_id, lang in langs.iteritems():
+ if lang:
+ # Use translated template if necessary
+ ctx = context.copy()
+ ctx['lang'] = lang
+ template = self.browse(cr, uid, template.id, ctx)
+ else:
+ template = self.browse(cr, uid, int(template_id), context)
+ results[res_id] = template
+ return results
def onchange_model_id(self, cr, uid, ids, model_id, context=None):
mod_name = False
@@ -300,64 +314,75 @@ class email_template(osv.osv):
})
return {'value': result}
- def generate_email(self, cr, uid, template_id, res_id, context=None):
- """Generates an email from the template for given (model, res_id) pair.
+ def generate_email_batch(self, cr, uid, template_id, res_ids, context=None, fields=None):
+ """Generates an email from the template for given the given model based on
+ records given by res_ids.
- :param template_id: id of the template to render.
- :param res_id: id of the record to use for rendering the template (model
- is taken from template definition)
- :returns: a dict containing all relevant fields for creating a new
- mail.mail entry, with one extra key ``attachments``, in the
- format expected by :py:meth:`mail_thread.message_post`.
+ :param template_id: id of the template to render.
+ :param res_id: id of the record to use for rendering the template (model
+ is taken from template definition)
+ :returns: a dict containing all relevant fields for creating a new
+ mail.mail entry, with one extra key ``attachments``, in the
+ format expected by :py:meth:`mail_thread.message_post`.
"""
if context is None:
context = {}
+ if fields is None:
+ fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to']
+
report_xml_pool = self.pool.get('ir.actions.report.xml')
- template = self.get_email_template(cr, uid, template_id, res_id, context)
- values = {}
- for field in ['subject', 'body_html', 'email_from',
- 'email_to', 'partner_to', 'email_cc', 'reply_to']:
- values[field] = self.render_template(cr, uid, getattr(template, field),
- template.model, res_id, context=context) \
- or False
- if template.user_signature:
- signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature
- values['body_html'] = tools.append_content_to_html(values['body_html'], signature)
+ res_ids_to_templates = self.get_email_template_batch(cr, uid, template_id, res_ids, context)
- if values['body_html']:
- values['body'] = tools.html_sanitize(values['body_html'])
+ # templates: res_id -> template; template -> res_ids
+ templates_to_res_ids = {}
+ for res_id, template in res_ids_to_templates.iteritems():
+ templates_to_res_ids.setdefault(template, []).append(res_id)
- values.update(mail_server_id=template.mail_server_id.id or False,
- auto_delete=template.auto_delete,
- model=template.model,
- res_id=res_id or False)
+ results = dict()
+ for template, template_res_ids in templates_to_res_ids.iteritems():
+ # generate fields value for all res_ids linked to the current template
+ for field in ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to']:
+ generated_field_values = self.render_template_batch(cr, uid, getattr(template, field), template.model, template_res_ids, context=context)
+ for res_id, field_value in generated_field_values.iteritems():
+ results.setdefault(res_id, dict())[field] = field_value
+ # update values for all res_ids
+ for res_id in template_res_ids:
+ values = results[res_id]
+ if template.user_signature:
+ signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature
+ values['body_html'] = tools.append_content_to_html(values['body_html'], signature)
+ if values['body_html']:
+ values['body'] = tools.html_sanitize(values['body_html'])
+ values.update(
+ mail_server_id=template.mail_server_id.id or False,
+ auto_delete=template.auto_delete,
+ model=template.model,
+ res_id=res_id or False,
+ attachment_ids=[attach.id for attach in template.attachment_ids],
+ )
- attachments = []
- # Add report in attachments
- if template.report_template:
- report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context)
- report_service = report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name
- # Ensure report is rendered using template's language
- ctx = context.copy()
- if template.lang:
- ctx['lang'] = self.render_template(cr, uid, template.lang, template.model, res_id, context)
- result, format = openerp.report.render_report(cr, uid, [res_id], report_service, {'model': template.model}, ctx)
- result = base64.b64encode(result)
- if not report_name:
- report_name = 'report.' + report_service
- ext = "." + format
- if not report_name.endswith(ext):
- report_name += ext
- attachments.append((report_name, result))
+ # Add report in attachments
+ if template.report_template:
+ for res_id in template_res_ids:
+ attachments = []
+ report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context)
+ report_service = report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name
+ # Ensure report is rendered using template's language
+ ctx = context.copy()
+ if template.lang:
+ ctx['lang'] = self.render_template_batch(cr, uid, template.lang, template.model, res_id, context) # take 0 ?
+ result, format = openerp.report.render_report(cr, uid, [res_id], report_service, {'model': template.model}, ctx)
+ result = base64.b64encode(result)
+ if not report_name:
+ report_name = 'report.' + report_service
+ ext = "." + format
+ if not report_name.endswith(ext):
+ report_name += ext
+ attachments.append((report_name, result))
- attachment_ids = []
- # Add template attachments
- for attach in template.attachment_ids:
- attachment_ids.append(attach.id)
+ values['attachments'] = attachments
- values['attachments'] = attachments
- values['attachment_ids'] = attachment_ids
- return values
+ return results
def send_mail(self, cr, uid, template_id, res_id, force_send=False, raise_exception=False, context=None):
"""Generates a new mail message for the given template and record,
@@ -404,4 +429,14 @@ class email_template(osv.osv):
mail_mail.send(cr, uid, [msg_id], raise_exception=raise_exception, context=context)
return msg_id
+ # Compatibility method
+ def render_template(self, cr, uid, template, model, res_id, context=None):
+ return self.render_template_batch(cr, uid, template, model, [res_id], context)[res_id]
+
+ def get_email_template(self, cr, uid, template_id=False, record_id=None, context=None):
+ return self.get_email_template_batch(cr, uid, template_id, [record_id], context)[record_id]
+
+ def generate_email(self, cr, uid, template_id, res_id, context=None):
+ return self.generate_email_batch(cr, uid, template_id, [res_id], context)[res_id]
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py
index 0aab765efbf..bae7a0d8f9c 100644
--- a/addons/email_template/wizard/mail_compose_message.py
+++ b/addons/email_template/wizard/mail_compose_message.py
@@ -62,6 +62,7 @@ class mail_compose_message(osv.TransientModel):
for wizard in self.browse(cr, uid, ids, context=context):
if wizard.template_id:
wizard_context['mail_notify_user_signature'] = False # template user_signature is added when generating body_html
+ wizard_context['mail_auto_delete'] = wizard.template_id.auto_delete # mass mailing: use template auto_delete value -> note, for emails mass mailing only
if not wizard.attachment_ids or wizard.composition_mode == 'mass_mail' or not wizard.template_id:
continue
new_attachment_ids = []
@@ -81,7 +82,7 @@ class mail_compose_message(osv.TransientModel):
template_values = self.pool.get('email.template').read(cr, uid, template_id, fields, context)
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
elif template_id:
- values = self.generate_email_for_composer(cr, uid, template_id, res_id, context=context)
+ values = self.generate_email_for_composer_batch(cr, uid, template_id, [res_id], context=context)[res_id]
# transform attachments into attachment_ids; not attached to the document because this will
# be done further in the posting process, allowing to clean database if email not send
values['attachment_ids'] = values.pop('attachment_ids', [])
@@ -147,45 +148,55 @@ class mail_compose_message(osv.TransientModel):
partner_ids.append(int(partner_id))
return partner_ids
- def generate_email_for_composer(self, cr, uid, template_id, res_id, context=None):
+ def generate_email_for_composer_batch(self, cr, uid, template_id, res_ids, context=None):
""" Call email_template.generate_email(), get fields relevant for
mail.compose.message, transform email_cc and email_to into partner_ids """
- template_values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
# filter template values
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'attachments', 'mail_server_id']
- values = dict((field, template_values[field]) for field in fields if template_values.get(field))
- values['body'] = values.pop('body_html', '')
+ values = dict.fromkeys(res_ids, False)
- # transform email_to, email_cc into partner_ids
- ctx = dict((k, v) for k, v in (context or {}).items() if not k.startswith('default_'))
- partner_ids = self._get_or_create_partners_from_values(cr, uid, values, context=ctx)
- # legacy template behavior: void values do not erase existing values and the
- # related key is removed from the values dict
- if partner_ids:
- values['partner_ids'] = list(partner_ids)
+ template_values = self.pool.get('email.template').generate_email_batch(cr, uid, template_id, res_ids, context=context)
+ for res_id in res_ids:
+ res_id_values = dict((field, template_values[res_id][field]) for field in fields if template_values[res_id].get(field))
+ res_id_values['body'] = res_id_values.pop('body_html', '')
+ # transform email_to, email_cc into partner_ids
+ ctx = dict((k, v) for k, v in (context or {}).items() if not k.startswith('default_'))
+ partner_ids = self._get_or_create_partners_from_values(cr, uid, res_id_values, context=ctx)
+ # legacy template behavior: void values do not erase existing values and the
+ # related key is removed from the values dict
+ if partner_ids:
+ res_id_values['partner_ids'] = list(partner_ids)
+
+ values[res_id] = res_id_values
return values
- def render_message(self, cr, uid, wizard, res_id, context=None):
+ def render_message_batch(self, cr, uid, wizard, res_ids, context=None):
""" Override to handle templates. """
- # generate the composer email
+ # generate template-based values
if wizard.template_id:
- values = self.generate_email_for_composer(cr, uid, wizard.template_id.id, res_id, context=context)
+ template_values = self.generate_email_for_composer_batch(cr, uid, wizard.template_id.id, res_ids, context=context)
else:
- values = {}
- # remove attachments as they should not be rendered
- values.pop('attachment_ids', None)
- # get values to return
- email_dict = super(mail_compose_message, self).render_message(cr, uid, wizard, res_id, context)
- # those values are not managed; they are readonly
- email_dict.pop('email_to', None)
- email_dict.pop('email_cc', None)
- email_dict.pop('partner_to', None)
- # update template values by wizard values
- values.update(email_dict)
- return values
+ template_values = dict.fromkeys(res_ids, dict())
+ # generate composer values
+ composer_values = super(mail_compose_message, self).render_message_batch(cr, uid, wizard, res_ids, context)
- def render_template(self, cr, uid, template, model, res_id, context=None):
- return self.pool.get('email.template').render_template(cr, uid, template, model, res_id, context=context)
+ for res_id in res_ids:
+ # remove attachments from template values as they should not be rendered
+ template_values[res_id].pop('attachment_ids', None)
+ # remove some keys from composer that are readonly
+ composer_values[res_id].pop('email_to', None)
+ composer_values[res_id].pop('email_cc', None)
+ composer_values[res_id].pop('partner_to', None)
+ # update template values by composer values
+ template_values[res_id].update(composer_values[res_id])
+ return template_values
+
+ def render_template_batch(self, cr, uid, template, model, res_ids, context=None):
+ return self.pool.get('email.template').render_template_batch(cr, uid, template, model, res_ids, context=context)
+
+ # Compatibility methods
+ def generate_email_for_composer(self, cr, uid, template_id, res_id, context=None):
+ return self.generate_email_for_composer_batch(cr, uid, template_id, [res_id], context)[res_id]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 6ab1f0e81ff..34c3db4de9b 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -233,7 +233,11 @@ class mail_compose_message(osv.TransientModel):
email(s), rendering any template patterns on the fly if needed. """
if context is None:
context = {}
- ir_attachment_obj = self.pool.get('ir.attachment')
+ # clean the context (hint: mass mailing sets some default values that
+ # could be wrongly interpreted by mail_mail)
+ context.pop('default_email_to', None)
+ context.pop('default_partner_ids', None)
+
active_ids = context.get('active_ids')
is_log = context.get('mail_compose_log', False)
@@ -252,43 +256,11 @@ class mail_compose_message(osv.TransientModel):
else:
res_ids = [wizard.res_id]
- for res_id in res_ids:
- # mail.message values, according to the wizard options
- post_values = {
- 'subject': wizard.subject,
- 'body': wizard.body,
- 'parent_id': wizard.parent_id and wizard.parent_id.id,
- 'partner_ids': [partner.id for partner in wizard.partner_ids],
- 'attachment_ids': [attach.id for attach in wizard.attachment_ids],
- }
- # mass mailing: render and override default values
- if mass_mail_mode and wizard.model:
- email_dict = self.render_message(cr, uid, wizard, res_id, context=context)
- post_values['partner_ids'] += email_dict.pop('partner_ids', [])
- post_values['attachments'] = email_dict.pop('attachments', [])
- attachment_ids = []
- for attach_id in post_values.pop('attachment_ids'):
- new_attach_id = ir_attachment_obj.copy(cr, uid, attach_id, {'res_model': self._name, 'res_id': wizard.id}, context=context)
- attachment_ids.append(new_attach_id)
- post_values['attachment_ids'] = attachment_ids
- # email_from: mass mailing only can specify another email_from
- if email_dict.get('email_from'):
- post_values['email_from'] = email_dict.pop('email_from')
- # replies redirection: mass mailing only
- if not wizard.same_thread:
- post_values['reply_to'] = email_dict.pop('reply_to')
- else:
- email_dict.pop('reply_to')
- post_values.update(email_dict)
- # clean the context (hint: mass mailing sets some default values that
- # could be wrongly interpreted by mail_mail)
- context.pop('default_email_to', None)
- context.pop('default_partner_ids', None)
- # post the message
+ all_mail_values = self.get_mail_values(cr, uid, wizard, res_ids, context=context)
+
+ for res_id, mail_values in all_mail_values.iteritems():
if mass_mail_mode and not wizard.post:
- post_values['body_html'] = post_values.get('body', '')
- post_values['recipient_ids'] = [(4, id) for id in post_values.pop('partner_ids', [])]
- self.pool.get('mail.mail').create(cr, uid, post_values, context=context)
+ self.pool.get('mail.mail').create(cr, uid, mail_values, context=context)
else:
subtype = 'mail.mt_comment'
if is_log: # log a note: subtype is False
@@ -297,46 +269,122 @@ class mail_compose_message(osv.TransientModel):
if not wizard.notify:
subtype = False
context = dict(context,
- mail_notify_force_send=False, # do not send emails directly but use the queue instead
- mail_create_nosubscribe=True) # add context key to avoid subscribing the author
- active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype=subtype, context=context, **post_values)
+ mail_notify_force_send=False, # do not send emails directly but use the queue instead
+ mail_create_nosubscribe=True) # add context key to avoid subscribing the author
+ active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype=subtype, context=context, **mail_values)
return {'type': 'ir.actions.act_window_close'}
- def render_message(self, cr, uid, wizard, res_id, context=None):
- """ Generate an email from the template for given (wizard.model, res_id)
- pair. This method is meant to be inherited by email_template that
- will produce a more complete dictionary. """
- return {
- 'subject': self.render_template(cr, uid, wizard.subject, wizard.model, res_id, context),
- 'body': self.render_template(cr, uid, wizard.body, wizard.model, res_id, context),
- 'email_from': self.render_template(cr, uid, wizard.email_from, wizard.model, res_id, context),
- 'reply_to': self.render_template(cr, uid, wizard.reply_to, wizard.model, res_id, context),
- }
+ def get_mail_values(self, cr, uid, wizard, res_ids, context=None):
+ """Generate the values that will be used by send_mail to create mail_messages
+ or mail_mails. """
+ results = dict.fromkeys(res_ids, False)
+ mass_mail_mode = wizard.composition_mode == 'mass_mail'
- def render_template(self, cr, uid, template, model, res_id, context=None):
+ # render all template-based value at once
+ if mass_mail_mode and wizard.model:
+ rendered_values = self.render_message_batch(cr, uid, wizard, res_ids, context=context)
+
+ for res_id in res_ids:
+ # static wizard (mail.message) values
+ mail_values = {
+ 'subject': wizard.subject,
+ 'body': wizard.body,
+ 'parent_id': wizard.parent_id and wizard.parent_id.id,
+ 'partner_ids': [partner.id for partner in wizard.partner_ids],
+ 'attachment_ids': [attach.id for attach in wizard.attachment_ids],
+ }
+ # mass mailing: rendering override wizard static values
+ if mass_mail_mode and wizard.model:
+ email_dict = rendered_values[res_id]
+ mail_values['partner_ids'] += email_dict.pop('partner_ids', [])
+ mail_values['attachments'] = email_dict.pop('attachments', [])
+ attachment_ids = []
+ for attach_id in mail_values.pop('attachment_ids'):
+ new_attach_id = self.pool.get('ir.attachment').copy(cr, uid, attach_id, {'res_model': self._name, 'res_id': wizard.id}, context=context)
+ attachment_ids.append(new_attach_id)
+ mail_values['attachment_ids'] = attachment_ids
+ # email_from: mass mailing only can specify another email_from
+ if email_dict.get('email_from'):
+ mail_values['email_from'] = email_dict.pop('email_from')
+ # replies redirection: mass mailing only
+ if not wizard.same_thread:
+ mail_values['reply_to'] = email_dict.pop('reply_to')
+ else:
+ email_dict.pop('reply_to')
+ mail_values.update(email_dict)
+ # mass mailing without post: mail_mail values
+ if mass_mail_mode and not wizard.post:
+ if 'mail_auto_delete' in context:
+ mail_values['auto_delete'] = context.get('mail_auto_delete')
+ mail_values['body_html'] = mail_values.get('body', '')
+ mail_values['recipient_ids'] = [(4, id) for id in mail_values.pop('partner_ids', [])]
+ results[res_id] = mail_values
+ return results
+
+ def render_message_batch(self, cr, uid, wizard, res_ids, context=None):
+ """Generate template-based values of wizard, for the document records given
+ by res_ids. This method is meant to be inherited by email_template that
+ will produce a more complete dictionary, using Jinja2 templates.
+
+ Each template is generated for all res_ids, allowing to parse the template
+ once, and render it multiple times. This is useful for mass mailing where
+ template rendering represent a significant part of the process.
+
+ :param browse wizard: current mail.compose.message browse record
+ :param list res_ids: list of record ids
+
+ :return dict results: for each res_id, the generated template values for
+ subject, body, email_from and reply_to
+ """
+ subjects = self.render_template_batch(cr, uid, wizard.subject, wizard.model, res_ids, context)
+ bodies = self.render_template_batch(cr, uid, wizard.body, wizard.model, res_ids, context)
+ emails_from = self.render_template_batch(cr, uid, wizard.email_from, wizard.model, res_ids, context)
+ replies_to = self.render_template_batch(cr, uid, wizard.reply_to, wizard.model, res_ids, context)
+
+ results = dict.fromkeys(res_ids, False)
+ for res_id in res_ids:
+ results[res_id] = {
+ 'subject': subjects[res_id],
+ 'body': bodies[res_id],
+ 'email_from': emails_from[res_id],
+ 'reply_to': replies_to[res_id],
+ }
+ return results
+
+ def render_template_batch(self, cr, uid, template, model, res_ids, context=None):
""" Render the given template text, replace mako-like expressions ``${expr}``
- with the result of evaluating these expressions with an evaluation context
- containing:
+ with the result of evaluating these expressions with an evaluation context
+ containing:
- * ``user``: browse_record of the current user
- * ``object``: browse_record of the document record this mail is
- related to
- * ``context``: the context passed to the mail composition wizard
+ * ``user``: browse_record of the current user
+ * ``object``: browse_record of the document record this mail is
+ related to
+ * ``context``: the context passed to the mail composition wizard
- :param str template: the template text to render
- :param str model: model name of the document record this mail is related to.
- :param int res_id: id of the document record this mail is related to.
+ :param str template: the template text to render
+ :param str model: model name of the document record this mail is related to
+ :param list res_ids: list of record ids
"""
if context is None:
context = {}
+ results = dict.fromkeys(res_ids, False)
- def merge(match):
- exp = str(match.group()[2:-1]).strip()
- result = eval(exp, {
- 'user': self.pool.get('res.users').browse(cr, uid, uid, context=context),
- 'object': self.pool[model].browse(cr, uid, res_id, context=context),
- 'context': dict(context), # copy context to prevent side-effects of eval
+ for res_id in res_ids:
+ def merge(match):
+ exp = str(match.group()[2:-1]).strip()
+ result = eval(exp, {
+ 'user': self.pool.get('res.users').browse(cr, uid, uid, context=context),
+ 'object': self.pool[model].browse(cr, uid, res_id, context=context),
+ 'context': dict(context), # copy context to prevent side-effects of eval
})
- return result and tools.ustr(result) or ''
- return template and EXPRESSION_PATTERN.sub(merge, template)
+ return result and tools.ustr(result) or ''
+ results[res_id] = template and EXPRESSION_PATTERN.sub(merge, template)
+ return results
+
+ # Compatibility methods
+ def render_template(self, cr, uid, template, model, res_id, context=None):
+ return self.render_template_batch(cr, uid, template, model, [res_id], context)[res_id]
+
+ def render_message(self, cr, uid, wizard, res_id, context=None):
+ return self.render_message_batch(cr, uid, wizard, [res_id], context)[res_id]
From 14a855f297a02765bf8ae1adc13bdb57750560f2 Mon Sep 17 00:00:00 2001
From: "Atul Patel (OpenERP)"
Date: Wed, 28 Aug 2013 20:31:05 +0530
Subject: [PATCH 021/175] [FIX]: Remove onchange from xml part.
bzr revid: atp@tinyerp.com-20130828150105-ylwdzki1viq9n8kl
---
addons/base_setup/res_config_view.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/base_setup/res_config_view.xml b/addons/base_setup/res_config_view.xml
index cc290f59156..8004d444ed9 100644
--- a/addons/base_setup/res_config_view.xml
+++ b/addons/base_setup/res_config_view.xml
@@ -94,7 +94,7 @@
-
+
From f70313103a082044d21e4b2290348bfe4d398bc3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Thu, 29 Aug 2013 12:09:32 +0200
Subject: [PATCH 022/175] [IMP] mail_message: cleaned search view
bzr revid: tde@openerp.com-20130829100932-xrh11khzghwxzyuf
---
addons/mail/mail_message_view.xml | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/addons/mail/mail_message_view.xml b/addons/mail/mail_message_view.xml
index e4442e366e3..e2d1deb028b 100644
--- a/addons/mail/mail_message_view.xml
+++ b/addons/mail/mail_message_view.xml
@@ -56,7 +56,8 @@
25
-
+
+
@@ -66,23 +67,13 @@
-
-
-
-
-
+
+
+
From e0ceeb8214f7c821498569e6a76f423e37eea927 Mon Sep 17 00:00:00 2001
From: "Mehul Mehta (OpenERP)"
Date: Thu, 29 Aug 2013 21:52:42 +0800
Subject: [PATCH 023/175] [IMP]in general setting for select dynamic font and
set a font for company header and footer
bzr revid: mme@tinyerp.com-20130829135242-ov2b3v1yvbtvliv2
---
addons/base_setup/res_config.py | 26 ++++++++------------------
addons/base_setup/res_config_view.xml | 2 +-
2 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index 753c063ed34..bbaa6713c82 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -21,24 +21,14 @@
from openerp.osv import fields, osv
import re
+import matplotlib.font_manager
-_select_font=[ ('DejaVu Sans',"DejaVu Sans"),
- ('DejaVu Sans Bold',"DejaVu Sans Bold"),
- ('DejaVu Sans Oblique',"DejaVu Sans Oblique"),
- ('DejaVu Sans BoldOblique',"DejaVu Sans BoldOblique"),
- ('Liberation Serif',"Liberation Serif"),
- ('Liberation Serif Bold',"Liberation Serif Bold"),
- ('Liberation Serif Italic',"Liberation Serif Italic"),
- ('Liberation Serif BoldItalic',"Liberation Serif BoldItalic"),
- ('Liberation Serif',"Liberation Serif"),
- ('Liberation Serif Bold',"Liberation Serif Bold"),
- ('Liberation Serif Italic',"Liberation Serif Italic"),
- ('Liberation Serif BoldItalic',"Liberation Serif BoldItalic"),
- ('FreeMono',"FreeMono"),
- ('FreeMono Bold',"FreeMono Bold"),
- ('FreeMono Oblique',"FreeMono Oblique"),
- ('FreeMono BoldOblique',"FreeMono BoldOblique"),
-]
+_lst_font=[]
+for i in matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf'):
+ m=re.sub('(.*/)','', i)
+ n=m.strip('.ttf')
+ n=n.replace('-',' ')
+ _lst_font.append((n,n))
class base_config_settings(osv.osv_memory):
_name = 'base.config.settings'
@@ -57,7 +47,7 @@ class base_config_settings(osv.osv_memory):
'module_base_import': fields.boolean("Allow users to import data from CSV files"),
'module_google_drive': fields.boolean('Attach Google documents to any record',
help="""This installs the module google_docs."""),
- 'font': fields.selection(_select_font, "Select Font",help="Set your favorite font into company header"),
+ 'font': fields.selection(_lst_font, "Select Font",help="Set your favorite font into company header"),
}
def open_company(self, cr, uid, ids, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context)
diff --git a/addons/base_setup/res_config_view.xml b/addons/base_setup/res_config_view.xml
index 8004d444ed9..e9be52c66d8 100644
--- a/addons/base_setup/res_config_view.xml
+++ b/addons/base_setup/res_config_view.xml
@@ -91,7 +91,7 @@
-
+
From 80da7ddd6029e4d29684c9b15ea79defe45f8d0f Mon Sep 17 00:00:00 2001
From: "Darshan Kalola (OpenERP)"
Date: Fri, 30 Aug 2013 15:15:12 +0530
Subject: [PATCH 024/175] [IMP]Add - before the the sentence This installs the
module in help
bzr revid: dka@tinyerp.com-20130830094512-n3nqjtt1g0w8m94v
---
addons/account/res_config.py | 12 ++++++------
addons/base_setup/res_config.py | 6 +++---
addons/crm/res_config.py | 2 +-
addons/hr_recruitment/res_config.py | 2 +-
addons/knowledge/res_config.py | 6 +++---
addons/marketing/res_config.py | 6 +++---
addons/mrp/res_config.py | 12 ++++++------
addons/project/res_config.py | 12 ++++++------
addons/purchase/res_config.py | 6 +++---
addons/sale/res_config.py | 12 ++++++------
addons/sale_stock/res_config.py | 4 ++--
addons/stock/res_config.py | 6 +++---
12 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/addons/account/res_config.py b/addons/account/res_config.py
index 1d79fa0ae11..9349818a47e 100644
--- a/addons/account/res_config.py
+++ b/addons/account/res_config.py
@@ -82,30 +82,30 @@ class account_config_settings(osv.osv_memory):
'module_account_check_writing': fields.boolean('Pay your suppliers by check',
help='This allows you to check writing and printing.\n'
- 'This installs the module account_check_writing.'),
+ '-This installs the module account_check_writing.'),
'module_account_accountant': fields.boolean('Full accounting features: journals, legal statements, chart of accounts, etc.',
help="""If you do not check this box, you will be able to do invoicing & payments, but not accounting (Journal Items, Chart of Accounts, ...)"""),
'module_account_asset': fields.boolean('Assets management',
help='This allows you to manage the assets owned by a company or a person.\n'
'It keeps track of the depreciation occurred on those assets, and creates account move for those depreciation lines.\n'
- 'This installs the module account_asset. If you do not check this box, you will be able to do invoicing & payments, '
+ '-This installs the module account_asset. If you do not check this box, you will be able to do invoicing & payments, '
'but not accounting (Journal Items, Chart of Accounts, ...)'),
'module_account_budget': fields.boolean('Budget management',
help='This allows accountants to manage analytic and crossovered budgets. '
'Once the master budgets and the budgets are defined, '
'the project managers can set the planned amount on each analytic account.\n'
- 'This installs the module account_budget.'),
+ '-This installs the module account_budget.'),
'module_account_payment': fields.boolean('Manage payment orders',
help='This allows you to create and manage your payment orders, with purposes to \n'
'* serve as base for an easy plug-in of various automated payment mechanisms, and \n'
'* provide a more efficient way to manage invoice payments.\n'
- 'This installs the module account_payment.' ),
+ '-This installs the module account_payment.' ),
'module_account_voucher': fields.boolean('Manage customer payments',
help='This includes all the basic requirements of voucher entries for bank, cash, sales, purchase, expense, contra, etc.\n'
- 'This installs the module account_voucher.'),
+ '-This installs the module account_voucher.'),
'module_account_followup': fields.boolean('Manage customer payment follow-ups',
help='This allows to automate letters for unpaid invoices, with multi-level recalls.\n'
- 'This installs the module account_followup.'),
+ '-This installs the module account_followup.'),
'group_proforma_invoices': fields.boolean('Allow pro-forma invoices',
implied_group='account.group_proforma_invoices',
help="Allows you to put invoices in pro-forma state."),
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index c7f6d4245ec..42e17d9c704 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -27,7 +27,7 @@ class base_config_settings(osv.osv_memory):
_columns = {
'module_multi_company': fields.boolean('Manage multiple companies',
help='Work in multi-company environments, with appropriate security access between companies.\n'
- 'This installs the module multi_company.'),
+ '-This installs the module multi_company.'),
'module_share': fields.boolean('Allow documents sharing',
help="""Share or embbed any screen of openerp."""),
'module_portal': fields.boolean('Activate the customer portal',
@@ -69,12 +69,12 @@ class sale_config_settings(osv.osv_memory):
'attach the selected mail as a .eml file in '
'the attachment of a selected record. You can create documents for CRM Lead, '
'Partner from the selected emails.\n'
- 'This installs the module plugin_thunderbird.'),
+ '-This installs the module plugin_thunderbird.'),
'module_plugin_outlook': fields.boolean('Enable Outlook plug-in',
help='The Outlook plugin allows you to select an object that you would like to add '
'to your email and its attachments from MS Outlook. You can select a partner, '
'or a lead object and archive a selected email into an OpenERP mail message with attachments.\n'
- 'This installs the module plugin_outlook.'),
+ '-This installs the module plugin_outlook.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/res_config.py b/addons/crm/res_config.py
index 622af04ef75..d572e50059a 100644
--- a/addons/crm/res_config.py
+++ b/addons/crm/res_config.py
@@ -59,7 +59,7 @@ class crm_configuration(osv.TransientModel):
help="""Allows you to trace and manage your activities for fund raising."""),
'module_crm_claim': fields.boolean("Manage Customer Claims",
help='Allows you to track your customers/suppliers claims and grievances.\n'
- 'This installs the module crm_claim.'),
+ '-This installs the module crm_claim.'),
'module_crm_helpdesk': fields.boolean("Manage Helpdesk and Support",
help="""Allows you to communicate with Customer, process Customer query, and provide better help and support. This installs the module crm_helpdesk."""),
'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams",
diff --git a/addons/hr_recruitment/res_config.py b/addons/hr_recruitment/res_config.py
index a15ae541e7f..53fd01546ec 100644
--- a/addons/hr_recruitment/res_config.py
+++ b/addons/hr_recruitment/res_config.py
@@ -28,7 +28,7 @@ class hr_applicant_settings(osv.osv_memory):
_columns = {
'module_document_ftp': fields.boolean('Allow the automatic indexation of resumes',
help='Manage your CV\'s and motivation letter related to all applicants.\n'
- 'This installs the module document_ftp. This will install the knowledge management module in order to allow you to search using specific keywords through the content of all documents (PDF, .DOCx...)'),
+ '-This installs the module document_ftp. This will install the knowledge management module in order to allow you to search using specific keywords through the content of all documents (PDF, .DOCx...)'),
'fetchmail_applicants': fields.boolean('Create applicants from an incoming email account',
fetchmail_model='hr.applicant', fetchmail_name='Incoming HR Applications',
help ='Allow applicants to send their job application to an email address (jobs@mycompany.com), '
diff --git a/addons/knowledge/res_config.py b/addons/knowledge/res_config.py
index fd033772133..0800cd84856 100644
--- a/addons/knowledge/res_config.py
+++ b/addons/knowledge/res_config.py
@@ -30,13 +30,13 @@ class knowledge_config_settings(osv.osv_memory):
'module_document': fields.boolean('Manage documents',
help='This is a complete document management system, with: user authentication, '
'full document search (but pptx and docx are not supported), and a document dashboard.\n'
- 'This installs the module document.'),
+ '-This installs the module document.'),
'module_document_ftp': fields.boolean('Share repositories (FTP)',
help='Access your documents in OpenERP through an FTP interface.\n'
- 'This installs the module document_ftp.'),
+ '-This installs the module document_ftp.'),
'module_document_webdav': fields.boolean('Share repositories (WebDAV)',
help='Access your documents in OpenERP through WebDAV.\n'
- 'This installs the module document_webdav.'),
+ '-This installs the module document_webdav.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/marketing/res_config.py b/addons/marketing/res_config.py
index 3d8eaf71fe6..b0a0679d68e 100644
--- a/addons/marketing/res_config.py
+++ b/addons/marketing/res_config.py
@@ -28,13 +28,13 @@ class marketing_config_settings(osv.osv_memory):
'module_marketing_campaign': fields.boolean('Marketing campaigns',
help='Provides leads automation through marketing campaigns. '
'Campaigns can in fact be defined on any resource, not just CRM leads.\n'
- 'This installs the module marketing_campaign.'),
+ '-This installs the module marketing_campaign.'),
'module_marketing_campaign_crm_demo': fields.boolean('Demo data for marketing campaigns',
help='Installs demo data like leads, campaigns and segments for Marketing Campaigns.\n'
- 'This installs the module marketing_campaign_crm_demo.'),
+ '-This installs the module marketing_campaign_crm_demo.'),
'module_crm_profiling': fields.boolean('Track customer profile to focus your campaigns',
help='Allows users to perform segmentation within partners.\n'
- 'This installs the module crm_profiling.'),
+ '-This installs the module crm_profiling.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/res_config.py b/addons/mrp/res_config.py
index 7f54999e15b..45a3ce41cf6 100644
--- a/addons/mrp/res_config.py
+++ b/addons/mrp/res_config.py
@@ -35,26 +35,26 @@ class mrp_config_settings(osv.osv_memory):
'* Warranty concept\n'
'* Repair quotation report\n'
'* Notes for the technician and for the final customer.\n'
- 'This installs the module mrp_repair.'),
+ '-This installs the module mrp_repair.'),
'module_mrp_operations': fields.boolean("Allow detailed planning of work order",
help='This allows to add state, date_start,date_stop in production order operation lines (in the "Work Centers" tab).\n'
- 'This installs the module mrp_operations.'),
+ '-This installs the module mrp_operations.'),
'module_mrp_byproduct': fields.boolean("Produce several products from one manufacturing order",
help='You can configure by-products in the bill of material.\n'
'Without this module: A + B + C -> D.\n'
'With this module: A + B + C -> D + E.\n'
- 'This installs the module mrp_byproduct.'),
+ '-This installs the module mrp_byproduct.'),
'module_mrp_jit': fields.boolean("Generate procurement in real time",
help='This allows Just In Time computation of procurement orders.\n'
'All procurement orders will be processed immediately, which could in some '
'cases entail a small performance impact.\n'
- 'This installs the module mrp_jit.'),
+ '-This installs the module mrp_jit.'),
'module_stock_no_autopicking': fields.boolean("Manage manual picking to fulfill manufacturing orders ",
help='This module allows an intermediate picking process to provide raw materials to production orders.\n'
'For example to manage production made by your suppliers (sub-contracting).\n'
'To achieve this, set the assembled product which is sub-contracted to "No Auto-Picking" '
'and put the location of the supplier in the routing of the assembly operation.\n'
- 'This installs the module stock_no_autopicking.'),
+ '-This installs the module stock_no_autopicking.'),
'group_mrp_routings': fields.boolean("Manage routings and work orders ",
implied_group='mrp.group_mrp_routings',
help='Routings allow you to create and manage the manufacturing operations that should be followed '
@@ -69,7 +69,7 @@ class mrp_config_settings(osv.osv_memory):
'* Manufacturer Product Name\n'
'* Manufacturer Product Code\n'
'* Product Attributes.\n'
- 'This installs the module product_manufacturer.'),
+ '-This installs the module product_manufacturer.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project/res_config.py b/addons/project/res_config.py
index a8b8af3b90b..78b05144208 100644
--- a/addons/project/res_config.py
+++ b/addons/project/res_config.py
@@ -31,27 +31,27 @@ class project_configuration(osv.osv_memory):
help ='This feature automatically creates project tasks from service products in sale orders. '
'More precisely, tasks are created for procurement lines with product of type \'Service\', '
'procurement method \'Make to Order\', and supply method \'Manufacture\'.\n'
- 'This installs the module project_mrp.'),
+ '-This installs the module project_mrp.'),
'module_pad': fields.boolean("Use integrated collaborative note pads on task",
help='Lets the company customize which Pad installation should be used to link to new pads '
'(for example: http://ietherpad.com/).\n'
- 'This installs the module pad.'),
+ '-This installs the module pad.'),
'module_project_timesheet': fields.boolean("Record timesheet lines per tasks",
help='This allows you to transfer the entries under tasks defined for Project Management to '
'the timesheet line entries for particular date and user, with the effect of creating, '
'editing and deleting either ways.\n'
- 'This installs the module project_timesheet.'),
+ '-This installs the module project_timesheet.'),
'module_project_long_term': fields.boolean("Manage resources planning on gantt view",
help='A long term project management module that tracks planning, scheduling, and resource allocation.\n'
- 'This installs the module project_long_term.'),
+ '-This installs the module project_long_term.'),
'module_project_issue': fields.boolean("Track issues and bugs",
help='Provides management of issues/bugs in projects.\n'
- 'This installs the module project_issue.'),
+ '-This installs the module project_issue.'),
'time_unit': fields.many2one('product.uom', 'Working time unit', required=True,
help="""This will set the unit of measure used in projects and tasks."""),
'module_project_issue_sheet': fields.boolean("Invoice working time on issues",
help='Provides timesheet support for the issues/bugs management in project.\n'
- 'This installs the module project_issue_sheet.'),
+ '-This installs the module project_issue_sheet.'),
'group_tasks_work_on_tasks': fields.boolean("Log work activities on tasks",
implied_group='project.group_tasks_work_on_tasks',
help="Allows you to compute work on tasks."),
diff --git a/addons/purchase/res_config.py b/addons/purchase/res_config.py
index 930ee5f9f29..82b07a839d2 100644
--- a/addons/purchase/res_config.py
+++ b/addons/purchase/res_config.py
@@ -48,14 +48,14 @@ class purchase_config_settings(osv.osv_memory):
'Supplier: don\'t forget to ask for an express delivery.'),
'module_purchase_double_validation': fields.boolean("Force two levels of approvals",
help='Provide a double validation mechanism for purchases exceeding minimum amount.\n'
- 'This installs the module purchase_double_validation.'),
+ '-This installs the module purchase_double_validation.'),
'module_purchase_requisition': fields.boolean("Manage purchase requisitions",
help='Purchase Requisitions are used when you want to request quotations from several suppliers for a given set of products.\n'
'You can configure per product if you directly do a Request for Quotation '
'to one supplier or if you want a purchase requisition to negotiate with several suppliers.'),
'module_purchase_analytic_plans': fields.boolean('Use multiple analytic accounts on purchase orders',
help ='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
- 'This installs the module purchase_analytic_plans.'),
+ '-This installs the module purchase_analytic_plans.'),
'group_analytic_account_for_purchases': fields.boolean('Analytic accounting for purchases',
implied_group='purchase.group_analytic_accounting',
help="Allows you to specify an analytic account on purchase orders."),
@@ -78,7 +78,7 @@ class account_config_settings(osv.osv_memory):
_columns = {
'module_purchase_analytic_plans': fields.boolean('Use multiple analytic accounts on orders',
help ='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
- 'This installs the module purchase_analytic_plans.'),
+ '-This installs the module purchase_analytic_plans.'),
'group_analytic_account_for_purchases': fields.boolean('Analytic accounting for purchases',
implied_group='purchase.group_analytic_accounting',
help="Allows you to specify an analytic account on purchase orders."),
diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py
index fe81a7cc6d8..7c080d8168f 100644
--- a/addons/sale/res_config.py
+++ b/addons/sale/res_config.py
@@ -36,13 +36,13 @@ class sale_configuration(osv.osv_memory):
'timesheet': fields.boolean('Prepare invoices based on timesheets',
help = 'For modifying account analytic view to show important data to project manager of services companies.'
'You can also view the report of account analytic summary user-wise as well as month wise.\n'
- 'This installs the module account_analytic_analysis.'),
+ '-This installs the module account_analytic_analysis.'),
'module_account_analytic_analysis': fields.boolean('Use contracts management',
help = 'Allows to define your customer contracts conditions: invoicing '
'method (fixed price, on timesheet, advance invoice), the exact pricing '
'(650€/day for a developer), the duration (one year support contract).\n'
'You will be able to follow the progress of the contract and invoice automatically.\n'
- 'It installs the account_analytic_analysis module.'),
+ '-It installs the account_analytic_analysis module.'),
'time_unit': fields.many2one('product.uom', 'The default working time unit for services is'),
'group_sale_pricelist':fields.boolean("Use pricelists to adapt your price per customers",
implied_group='product.group_sale_pricelist',
@@ -64,20 +64,20 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
'module_sale_margin': fields.boolean("Display margins on sales orders",
help='This adds the \'Margin\' on sales order.\n'
'This gives the profitability by calculating the difference between the Unit Price and Cost Price.\n'
- 'This installs the module sale_margin.'),
+ '-This installs the module sale_margin.'),
'module_sale_journal': fields.boolean("Allow batch invoicing of delivery orders through journals",
help='Allows you to categorize your sales and deliveries (picking lists) between different journals, '
'and perform batch operations on journals.\n'
- 'This installs the module sale_journal.'),
+ '-This installs the module sale_journal.'),
'module_analytic_user_function': fields.boolean("One employee can have different roles per contract",
help='Allows you to define what is the default function of a specific user on a given account.\n'
'This is mostly used when a user encodes his timesheet. The values are retrieved and the fields are auto-filled. '
'But the possibility to change these values is still available.\n'
- 'This installs the module analytic_user_function.'),
+ '-This installs the module analytic_user_function.'),
'module_project': fields.boolean("Project"),
'module_sale_stock': fields.boolean("Trigger delivery orders automatically from sales orders",
help='Allows you to Make Quotation, Sale Order using different Order policy and Manage Related Stock.\n'
- 'This installs the module sale_stock.'),
+ '-This installs the module sale_stock.'),
}
def default_get(self, cr, uid, fields, context=None):
diff --git a/addons/sale_stock/res_config.py b/addons/sale_stock/res_config.py
index 76cfbcb6fd3..01871bf6f1d 100644
--- a/addons/sale_stock/res_config.py
+++ b/addons/sale_stock/res_config.py
@@ -36,7 +36,7 @@ class sale_configuration(osv.osv_memory):
help='Lets you transfer the entries under tasks defined for Project Management to '
'the Timesheet line entries for particular date and particular user with the effect of creating, editing and deleting either ways '
'and to automatically creates project tasks from procurement lines.\n'
- 'This installs the modules project_timesheet and project_mrp.'),
+ '-This installs the modules project_timesheet and project_mrp.'),
'default_order_policy': fields.selection(
[('manual', 'Invoice based on sales orders'), ('picking', 'Invoice based on deliveries')],
'The default invoicing method is', default_model='sale.order',
@@ -44,7 +44,7 @@ class sale_configuration(osv.osv_memory):
'module_delivery': fields.boolean('Allow adding shipping costs',
help ='Allows you to add delivery methods in sales orders and delivery orders.\n'
'You can define your own carrier and delivery grids for prices.\n'
- 'This installs the module delivery.'),
+ '-This installs the module delivery.'),
'default_picking_policy' : fields.boolean("Deliver all at once when all products are available.",
help = "Sales order by default will be configured to deliver all products at once instead of delivering each product when it is available. This may have an impact on the shipping price."),
'group_mrp_properties': fields.boolean('Product properties on order lines',
diff --git a/addons/stock/res_config.py b/addons/stock/res_config.py
index 4da23389214..1ce5d9d25fa 100644
--- a/addons/stock/res_config.py
+++ b/addons/stock/res_config.py
@@ -28,11 +28,11 @@ class stock_config_settings(osv.osv_memory):
_columns = {
'module_claim_from_delivery': fields.boolean("Allow claim on deliveries",
help='Adds a Claim link to the delivery order.\n'
- 'This installs the module claim_from_delivery.'),
+ '-This installs the module claim_from_delivery.'),
'module_stock_invoice_directly': fields.boolean("Create and open the invoice when the user finish a delivery order",
help='This allows to automatically launch the invoicing wizard if the delivery is '
'to be invoiced when you send or deliver goods.\n'
- 'This installs the module stock_invoice_directly.'),
+ '-This installs the module stock_invoice_directly.'),
'module_product_expiry': fields.boolean("Expiry date on serial numbers",
help="""Track different dates on products and serial numbers.
The following dates can be tracked:
@@ -45,7 +45,7 @@ This installs the module product_expiry."""),
help='Provide push and pull inventory flows. Typical uses of this feature are: '
'manage product manufacturing chains, manage default locations per product, '
'define routes within your warehouse according to business needs, etc.\n'
- 'This installs the module stock_location.'),
+ '-This installs the module stock_location.'),
'group_uom': fields.boolean("Manage different units of measure for products",
implied_group='product.group_uom',
help="""Allows you to select and maintain different units of measure for products."""),
From b3e6145e048b9eefebc6f3d297cecda54269fe0c Mon Sep 17 00:00:00 2001
From: "Darshan Kalola (OpenERP)"
Date: Fri, 30 Aug 2013 16:15:24 +0530
Subject: [PATCH 025/175] [IMP]improve help in setting/configuration/sales
bzr revid: dka@tinyerp.com-20130830104524-pbxm2p32n1widzqd
---
addons/crm/res_config.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/addons/crm/res_config.py b/addons/crm/res_config.py
index d572e50059a..c7ad5fb3d7e 100644
--- a/addons/crm/res_config.py
+++ b/addons/crm/res_config.py
@@ -61,7 +61,8 @@ class crm_configuration(osv.TransientModel):
help='Allows you to track your customers/suppliers claims and grievances.\n'
'-This installs the module crm_claim.'),
'module_crm_helpdesk': fields.boolean("Manage Helpdesk and Support",
- help="""Allows you to communicate with Customer, process Customer query, and provide better help and support. This installs the module crm_helpdesk."""),
+ help='Allows you to communicate with Customer, process Customer query, and provide better help and support.\n'
+ '-This installs the module crm_helpdesk.'),
'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams",
implied_group='base.group_multi_salesteams',
help="""Allows you to use Sales Teams to manage your leads and opportunities."""),
From 7acb2f3105d61ae668e6bd2042be789d965e2e10 Mon Sep 17 00:00:00 2001
From: "Mehul Mehta (OpenERP)"
Date: Mon, 2 Sep 2013 21:08:40 +0800
Subject: [PATCH 026/175] [IMP]view a dynaemic font in general setting for
select font and set a font for company header and footer
bzr revid: mme@tinyerp.com-20130902130840-pvtegpqlpxkip46k
---
addons/base_setup/res_config.py | 52 +++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 6 deletions(-)
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index bbaa6713c82..b9d3280e49e 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -21,14 +21,54 @@
from openerp.osv import fields, osv
import re
-import matplotlib.font_manager
+import os
+import platform
+from reportlab import rl_config
+from openerp.tools import config
_lst_font=[]
-for i in matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf'):
- m=re.sub('(.*/)','', i)
- n=m.strip('.ttf')
- n=n.replace('-',' ')
- _lst_font.append((n,n))
+TTFSearchPath_Linux = [
+ '/usr/share/fonts/truetype', # SuSE
+ '/usr/share/fonts/dejavu', '/usr/share/fonts/liberation', # Fedora, RHEL
+ '/usr/share/fonts/truetype/*', # Ubuntu,
+ '/usr/share/fonts/TTF/*', # at Mandriva/Mageia
+ '/usr/share/fonts/TTF', # Arch Linux
+ ]
+
+TTFSearchPath_Windows = [
+ 'c:/winnt/fonts',
+ 'c:/windows/fonts'
+ ]
+
+TTFSearchPath_Darwin = [
+ '~/Library/Fonts',
+ '/Library/Fonts',
+ '/Network/Library/Fonts',
+ '/System/Library/Fonts',
+ ]
+
+TTFSearchPathMap = {
+ 'Darwin': TTFSearchPath_Darwin,
+ 'Windows': TTFSearchPath_Windows,
+ 'Linux': TTFSearchPath_Linux,
+}
+searchpath = []
+
+if config.get('fonts_search_path'):
+ searchpath += map(str.strip, config.get('fonts_search_path').split(','))
+
+local_platform = platform.system()
+if local_platform in TTFSearchPathMap:
+ searchpath += TTFSearchPathMap[local_platform]
+
+searchpath += rl_config.TTFSearchPath
+for dirglob in searchpath:
+ if os.path.isdir(dirglob):
+ for file in os.listdir('/'+dirglob):
+ if os.path.isfile('/'+dirglob+'/'+file):
+ font=file.strip('.ttf')
+ font=font.replace('-',' ')
+ _lst_font.append((font,font))
class base_config_settings(osv.osv_memory):
_name = 'base.config.settings'
From 903ca548c7ec709d905b7b1ff20c93678dcab2e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 3 Sep 2013 16:59:36 +0200
Subject: [PATCH 027/175] [IMP] mass_mailing: added kanban views for
mass_mailing, implemented segment for campaigns. Moved sparkline and gauge
widgets to web.
Segment: template, date, mails.
Campaign: grouped statistics.
bzr revid: tde@openerp.com-20130903145936-nwy250w1suxmtbl3
---
addons/crm/__openerp__.py | 1 -
.../static/lib/sparkline/jquery.sparkline.js | 3047 -----------------
addons/crm/static/src/js/crm_case_section.js | 23 -
addons/mail/mail_mail.py | 31 +-
addons/mail/mail_thread.py | 3 +-
addons/mail/tests/__init__.py | 3 +-
addons/mass_mailing/__openerp__.py | 6 +
addons/mass_mailing/mail_mail.py | 10 +-
addons/mass_mailing/mail_mail_view.xml | 1 +
addons/mass_mailing/mass_mailing.py | 174 +-
addons/mass_mailing/mass_mailing_demo.xml | 81 +
addons/mass_mailing/mass_mailing_view.xml | 175 +-
.../static/src/css/mass_mailing.css | 54 +
addons/sale_crm/__openerp__.py | 1 -
addons/sale_crm/sale_crm_view.xml | 4 +-
addons/sale_crm/static/lib/justgage.js | 883 -----
addons/sale_crm/static/src/js/sale_crm.js | 108 -
17 files changed, 495 insertions(+), 4110 deletions(-)
delete mode 100644 addons/crm/static/lib/sparkline/jquery.sparkline.js
create mode 100644 addons/mass_mailing/mass_mailing_demo.xml
create mode 100644 addons/mass_mailing/static/src/css/mass_mailing.css
delete mode 100644 addons/sale_crm/static/lib/justgage.js
delete mode 100644 addons/sale_crm/static/src/js/sale_crm.js
diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py
index 1b4ba191b82..ae9da7ade08 100644
--- a/addons/crm/__openerp__.py
+++ b/addons/crm/__openerp__.py
@@ -121,7 +121,6 @@ Dashboard for CRM will include:
'static/src/css/crm.css'
],
'js': [
- 'static/lib/sparkline/jquery.sparkline.js',
'static/src/js/crm_case_section.js',
],
'installable': True,
diff --git a/addons/crm/static/lib/sparkline/jquery.sparkline.js b/addons/crm/static/lib/sparkline/jquery.sparkline.js
deleted file mode 100644
index c003923e03b..00000000000
--- a/addons/crm/static/lib/sparkline/jquery.sparkline.js
+++ /dev/null
@@ -1,3047 +0,0 @@
-/**
-*
-* jquery.sparkline.js
-*
-* v2.1.1
-* (c) Splunk, Inc
-* Contact: Gareth Watts (gareth@splunk.com)
-* http://omnipotent.net/jquery.sparkline/
-*
-* Generates inline sparkline charts from data supplied either to the method
-* or inline in HTML
-*
-* Compatible with Internet Explorer 6.0+ and modern browsers equipped with the canvas tag
-* (Firefox 2.0+, Safari, Opera, etc)
-*
-* License: New BSD License
-*
-* Copyright (c) 2012, Splunk Inc.
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification,
-* are permitted provided that the following conditions are met:
-*
-* * Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the documentation
-* and/or other materials provided with the distribution.
-* * Neither the name of Splunk Inc nor the names of its contributors may
-* be used to endorse or promote products derived from this software without
-* specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
-* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*
-* Usage:
-* $(selector).sparkline(values, options)
-*
-* If values is undefined or set to 'html' then the data values are read from the specified tag:
-*
Sparkline: 1,4,6,6,8,5,3,5
-* $('.sparkline').sparkline();
-* There must be no spaces in the enclosed data set
-*
-* Otherwise values must be an array of numbers or null values
-*
Sparkline: This text replaced if the browser is compatible
-* $('#sparkline1').sparkline([1,4,6,6,8,5,3,5])
-* $('#sparkline2').sparkline([1,4,6,null,null,5,3,5])
-*
-* Values can also be specified in an HTML comment, or as a values attribute:
-*
Sparkline:
-*
Sparkline:
-* $('.sparkline').sparkline();
-*
-* For line charts, x values can also be specified:
-*
Sparkline: 1:1,2.7:4,3.4:6,5:6,6:8,8.7:5,9:3,10:5
-* $('#sparkline1').sparkline([ [1,1], [2.7,4], [3.4,6], [5,6], [6,8], [8.7,5], [9,3], [10,5] ])
-*
-* By default, options should be passed in as teh second argument to the sparkline function:
-* $('.sparkline').sparkline([1,2,3,4], {type: 'bar'})
-*
-* Options can also be set by passing them on the tag itself. This feature is disabled by default though
-* as there's a slight performance overhead:
-* $('.sparkline').sparkline([1,2,3,4], {enableTagOptions: true})
-*
Sparkline: loading
-* Prefix all options supplied as tag attribute with "spark" (configurable by setting tagOptionPrefix)
-*
-* Supported options:
-* lineColor - Color of the line used for the chart
-* fillColor - Color used to fill in the chart - Set to '' or false for a transparent chart
-* width - Width of the chart - Defaults to 3 times the number of values in pixels
-* height - Height of the chart - Defaults to the height of the containing element
-* chartRangeMin - Specify the minimum value to use for the Y range of the chart - Defaults to the minimum value supplied
-* chartRangeMax - Specify the maximum value to use for the Y range of the chart - Defaults to the maximum value supplied
-* chartRangeClip - Clip out of range values to the max/min specified by chartRangeMin and chartRangeMax
-* chartRangeMinX - Specify the minimum value to use for the X range of the chart - Defaults to the minimum value supplied
-* chartRangeMaxX - Specify the maximum value to use for the X range of the chart - Defaults to the maximum value supplied
-* composite - If true then don't erase any existing chart attached to the tag, but draw
-* another chart over the top - Note that width and height are ignored if an
-* existing chart is detected.
-* tagValuesAttribute - Name of tag attribute to check for data values - Defaults to 'values'
-* enableTagOptions - Whether to check tags for sparkline options
-* tagOptionPrefix - Prefix used for options supplied as tag attributes - Defaults to 'spark'
-* disableHiddenCheck - If set to true, then the plugin will assume that charts will never be drawn into a
-* hidden dom element, avoding a browser reflow
-* disableInteraction - If set to true then all mouseover/click interaction behaviour will be disabled,
-* making the plugin perform much like it did in 1.x
-* disableTooltips - If set to true then tooltips will be disabled - Defaults to false (tooltips enabled)
-* disableHighlight - If set to true then highlighting of selected chart elements on mouseover will be disabled
-* defaults to false (highlights enabled)
-* highlightLighten - Factor to lighten/darken highlighted chart values by - Defaults to 1.4 for a 40% increase
-* tooltipContainer - Specify which DOM element the tooltip should be rendered into - defaults to document.body
-* tooltipClassname - Optional CSS classname to apply to tooltips - If not specified then a default style will be applied
-* tooltipOffsetX - How many pixels away from the mouse pointer to render the tooltip on the X axis
-* tooltipOffsetY - How many pixels away from the mouse pointer to render the tooltip on the r axis
-* tooltipFormatter - Optional callback that allows you to override the HTML displayed in the tooltip
-* callback is given arguments of (sparkline, options, fields)
-* tooltipChartTitle - If specified then the tooltip uses the string specified by this setting as a title
-* tooltipFormat - A format string or SPFormat object (or an array thereof for multiple entries)
-* to control the format of the tooltip
-* tooltipPrefix - A string to prepend to each field displayed in a tooltip
-* tooltipSuffix - A string to append to each field displayed in a tooltip
-* tooltipSkipNull - If true then null values will not have a tooltip displayed (defaults to true)
-* tooltipValueLookups - An object or range map to map field values to tooltip strings
-* (eg. to map -1 to "Lost", 0 to "Draw", and 1 to "Win")
-* numberFormatter - Optional callback for formatting numbers in tooltips
-* numberDigitGroupSep - Character to use for group separator in numbers "1,234" - Defaults to ","
-* numberDecimalMark - Character to use for the decimal point when formatting numbers - Defaults to "."
-* numberDigitGroupCount - Number of digits between group separator - Defaults to 3
-*
-* There are 7 types of sparkline, selected by supplying a "type" option of 'line' (default),
-* 'bar', 'tristate', 'bullet', 'discrete', 'pie' or 'box'
-* line - Line chart. Options:
-* spotColor - Set to '' to not end each line in a circular spot
-* minSpotColor - If set, color of spot at minimum value
-* maxSpotColor - If set, color of spot at maximum value
-* spotRadius - Radius in pixels
-* lineWidth - Width of line in pixels
-* normalRangeMin
-* normalRangeMax - If set draws a filled horizontal bar between these two values marking the "normal"
-* or expected range of values
-* normalRangeColor - Color to use for the above bar
-* drawNormalOnTop - Draw the normal range above the chart fill color if true
-* defaultPixelsPerValue - Defaults to 3 pixels of width for each value in the chart
-* highlightSpotColor - The color to use for drawing a highlight spot on mouseover - Set to null to disable
-* highlightLineColor - The color to use for drawing a highlight line on mouseover - Set to null to disable
-* valueSpots - Specify which points to draw spots on, and in which color. Accepts a range map
-*
-* bar - Bar chart. Options:
-* barColor - Color of bars for postive values
-* negBarColor - Color of bars for negative values
-* zeroColor - Color of bars with zero values
-* nullColor - Color of bars with null values - Defaults to omitting the bar entirely
-* barWidth - Width of bars in pixels
-* colorMap - Optional mappnig of values to colors to override the *BarColor values above
-* can be an Array of values to control the color of individual bars or a range map
-* to specify colors for individual ranges of values
-* barSpacing - Gap between bars in pixels
-* zeroAxis - Centers the y-axis around zero if true
-*
-* tristate - Charts values of win (>0), lose (<0) or draw (=0)
-* posBarColor - Color of win values
-* negBarColor - Color of lose values
-* zeroBarColor - Color of draw values
-* barWidth - Width of bars in pixels
-* barSpacing - Gap between bars in pixels
-* colorMap - Optional mappnig of values to colors to override the *BarColor values above
-* can be an Array of values to control the color of individual bars or a range map
-* to specify colors for individual ranges of values
-*
-* discrete - Options:
-* lineHeight - Height of each line in pixels - Defaults to 30% of the graph height
-* thesholdValue - Values less than this value will be drawn using thresholdColor instead of lineColor
-* thresholdColor
-*
-* bullet - Values for bullet graphs msut be in the order: target, performance, range1, range2, range3, ...
-* options:
-* targetColor - The color of the vertical target marker
-* targetWidth - The width of the target marker in pixels
-* performanceColor - The color of the performance measure horizontal bar
-* rangeColors - Colors to use for each qualitative range background color
-*
-* pie - Pie chart. Options:
-* sliceColors - An array of colors to use for pie slices
-* offset - Angle in degrees to offset the first slice - Try -90 or +90
-* borderWidth - Width of border to draw around the pie chart, in pixels - Defaults to 0 (no border)
-* borderColor - Color to use for the pie chart border - Defaults to #000
-*
-* box - Box plot. Options:
-* raw - Set to true to supply pre-computed plot points as values
-* values should be: low_outlier, low_whisker, q1, median, q3, high_whisker, high_outlier
-* When set to false you can supply any number of values and the box plot will
-* be computed for you. Default is false.
-* showOutliers - Set to true (default) to display outliers as circles
-* outlierIQR - Interquartile range used to determine outliers. Default 1.5
-* boxLineColor - Outline color of the box
-* boxFillColor - Fill color for the box
-* whiskerColor - Line color used for whiskers
-* outlierLineColor - Outline color of outlier circles
-* outlierFillColor - Fill color of the outlier circles
-* spotRadius - Radius of outlier circles
-* medianColor - Line color of the median line
-* target - Draw a target cross hair at the supplied value (default undefined)
-*
-*
-*
-* Examples:
-* $('#sparkline1').sparkline(myvalues, { lineColor: '#f00', fillColor: false });
-* $('.barsparks').sparkline('html', { type:'bar', height:'40px', barWidth:5 });
-* $('#tristate').sparkline([1,1,-1,1,0,0,-1], { type:'tristate' }):
-* $('#discrete').sparkline([1,3,4,5,5,3,4,5], { type:'discrete' });
-* $('#bullet').sparkline([10,12,12,9,7], { type:'bullet' });
-* $('#pie').sparkline([1,1,2], { type:'pie' });
-*/
-
-/*jslint regexp: true, browser: true, jquery: true, white: true, nomen: false, plusplus: false, maxerr: 500, indent: 4 */
-
-(function(factory) {
- if(typeof define === 'function' && define.amd) {
- define(['jquery'], factory);
- }
- else {
- factory(jQuery);
- }
-}
-(function($) {
- 'use strict';
-
- var UNSET_OPTION = {},
- getDefaults, createClass, SPFormat, clipval, quartile, normalizeValue, normalizeValues,
- remove, isNumber, all, sum, addCSS, ensureArray, formatNumber, RangeMap,
- MouseHandler, Tooltip, barHighlightMixin,
- line, bar, tristate, discrete, bullet, pie, box, defaultStyles, initStyles,
- VShape, VCanvas_base, VCanvas_canvas, VCanvas_vml, pending, shapeCount = 0;
-
- /**
- * Default configuration settings
- */
- getDefaults = function () {
- return {
- // Settings common to most/all chart types
- common: {
- type: 'line',
- lineColor: '#00f',
- fillColor: '#cdf',
- defaultPixelsPerValue: 3,
- width: 'auto',
- height: 'auto',
- composite: false,
- tagValuesAttribute: 'values',
- tagOptionsPrefix: 'spark',
- enableTagOptions: false,
- enableHighlight: true,
- highlightLighten: 1.4,
- tooltipSkipNull: true,
- tooltipPrefix: '',
- tooltipSuffix: '',
- disableHiddenCheck: false,
- numberFormatter: false,
- numberDigitGroupCount: 3,
- numberDigitGroupSep: ',',
- numberDecimalMark: '.',
- disableTooltips: false,
- disableInteraction: false
- },
- // Defaults for line charts
- line: {
- spotColor: '#f80',
- highlightSpotColor: '#5f5',
- highlightLineColor: '#f22',
- spotRadius: 1.5,
- minSpotColor: '#f80',
- maxSpotColor: '#f80',
- lineWidth: 1,
- normalRangeMin: undefined,
- normalRangeMax: undefined,
- normalRangeColor: '#ccc',
- drawNormalOnTop: false,
- chartRangeMin: undefined,
- chartRangeMax: undefined,
- chartRangeMinX: undefined,
- chartRangeMaxX: undefined,
- tooltipFormat: new SPFormat('● {{prefix}}{{y}}{{suffix}}')
- },
- // Defaults for bar charts
- bar: {
- barColor: '#3366cc',
- negBarColor: '#f44',
- stackedBarColor: ['#3366cc', '#dc3912', '#ff9900', '#109618', '#66aa00',
- '#dd4477', '#0099c6', '#990099'],
- zeroColor: undefined,
- nullColor: undefined,
- zeroAxis: true,
- barWidth: 4,
- barSpacing: 1,
- chartRangeMax: undefined,
- chartRangeMin: undefined,
- chartRangeClip: false,
- colorMap: undefined,
- tooltipFormat: new SPFormat('● {{prefix}}{{value}}{{suffix}}')
- },
- // Defaults for tristate charts
- tristate: {
- barWidth: 4,
- barSpacing: 1,
- posBarColor: '#6f6',
- negBarColor: '#f44',
- zeroBarColor: '#999',
- colorMap: {},
- tooltipFormat: new SPFormat('● {{value:map}}'),
- tooltipValueLookups: { map: { '-1': 'Loss', '0': 'Draw', '1': 'Win' } }
- },
- // Defaults for discrete charts
- discrete: {
- lineHeight: 'auto',
- thresholdColor: undefined,
- thresholdValue: 0,
- chartRangeMax: undefined,
- chartRangeMin: undefined,
- chartRangeClip: false,
- tooltipFormat: new SPFormat('{{prefix}}{{value}}{{suffix}}')
- },
- // Defaults for bullet charts
- bullet: {
- targetColor: '#f33',
- targetWidth: 3, // width of the target bar in pixels
- performanceColor: '#33f',
- rangeColors: ['#d3dafe', '#a8b6ff', '#7f94ff'],
- base: undefined, // set this to a number to change the base start number
- tooltipFormat: new SPFormat('{{fieldkey:fields}} - {{value}}'),
- tooltipValueLookups: { fields: {r: 'Range', p: 'Performance', t: 'Target'} }
- },
- // Defaults for pie charts
- pie: {
- offset: 0,
- sliceColors: ['#3366cc', '#dc3912', '#ff9900', '#109618', '#66aa00',
- '#dd4477', '#0099c6', '#990099'],
- borderWidth: 0,
- borderColor: '#000',
- tooltipFormat: new SPFormat('● {{value}} ({{percent.1}}%)')
- },
- // Defaults for box plots
- box: {
- raw: false,
- boxLineColor: '#000',
- boxFillColor: '#cdf',
- whiskerColor: '#000',
- outlierLineColor: '#333',
- outlierFillColor: '#fff',
- medianColor: '#f00',
- showOutliers: true,
- outlierIQR: 1.5,
- spotRadius: 1.5,
- target: undefined,
- targetColor: '#4a2',
- chartRangeMax: undefined,
- chartRangeMin: undefined,
- tooltipFormat: new SPFormat('{{field:fields}}: {{value}}'),
- tooltipFormatFieldlistKey: 'field',
- tooltipValueLookups: { fields: { lq: 'Lower Quartile', med: 'Median',
- uq: 'Upper Quartile', lo: 'Left Outlier', ro: 'Right Outlier',
- lw: 'Left Whisker', rw: 'Right Whisker'} }
- }
- };
- };
-
- // You can have tooltips use a css class other than jqstooltip by specifying tooltipClassname
- defaultStyles = '.jqstooltip { ' +
- 'position: absolute;' +
- 'left: 0px;' +
- 'top: 0px;' +
- 'visibility: hidden;' +
- 'background: rgb(0, 0, 0) transparent;' +
- 'background-color: rgba(0,0,0,0.6);' +
- 'filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);' +
- '-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";' +
- 'color: white;' +
- 'font: 10px arial, san serif;' +
- 'text-align: left;' +
- 'white-space: nowrap;' +
- 'padding: 5px;' +
- 'border: 1px solid white;' +
- 'z-index: 10000;' +
- '}' +
- '.jqsfield { ' +
- 'color: white;' +
- 'font: 10px arial, san serif;' +
- 'text-align: left;' +
- '}';
-
- /**
- * Utilities
- */
-
- createClass = function (/* [baseclass, [mixin, ...]], definition */) {
- var Class, args;
- Class = function () {
- this.init.apply(this, arguments);
- };
- if (arguments.length > 1) {
- if (arguments[0]) {
- Class.prototype = $.extend(new arguments[0](), arguments[arguments.length - 1]);
- Class._super = arguments[0].prototype;
- } else {
- Class.prototype = arguments[arguments.length - 1];
- }
- if (arguments.length > 2) {
- args = Array.prototype.slice.call(arguments, 1, -1);
- args.unshift(Class.prototype);
- $.extend.apply($, args);
- }
- } else {
- Class.prototype = arguments[0];
- }
- Class.prototype.cls = Class;
- return Class;
- };
-
- /**
- * Wraps a format string for tooltips
- * {{x}}
- * {{x.2}
- * {{x:months}}
- */
- $.SPFormatClass = SPFormat = createClass({
- fre: /\{\{([\w.]+?)(:(.+?))?\}\}/g,
- precre: /(\w+)\.(\d+)/,
-
- init: function (format, fclass) {
- this.format = format;
- this.fclass = fclass;
- },
-
- render: function (fieldset, lookups, options) {
- var self = this,
- fields = fieldset,
- match, token, lookupkey, fieldvalue, prec;
- return this.format.replace(this.fre, function () {
- var lookup;
- token = arguments[1];
- lookupkey = arguments[3];
- match = self.precre.exec(token);
- if (match) {
- prec = match[2];
- token = match[1];
- } else {
- prec = false;
- }
- fieldvalue = fields[token];
- if (fieldvalue === undefined) {
- return '';
- }
- if (lookupkey && lookups && lookups[lookupkey]) {
- lookup = lookups[lookupkey];
- if (lookup.get) { // RangeMap
- return lookups[lookupkey].get(fieldvalue) || fieldvalue;
- } else {
- return lookups[lookupkey][fieldvalue] || fieldvalue;
- }
- }
- if (isNumber(fieldvalue)) {
- if (options.get('numberFormatter')) {
- fieldvalue = options.get('numberFormatter')(fieldvalue);
- } else {
- fieldvalue = formatNumber(fieldvalue, prec,
- options.get('numberDigitGroupCount'),
- options.get('numberDigitGroupSep'),
- options.get('numberDecimalMark'));
- }
- }
- return fieldvalue;
- });
- }
- });
-
- // convience method to avoid needing the new operator
- $.spformat = function(format, fclass) {
- return new SPFormat(format, fclass);
- };
-
- clipval = function (val, min, max) {
- if (val < min) {
- return min;
- }
- if (val > max) {
- return max;
- }
- return val;
- };
-
- quartile = function (values, q) {
- var vl;
- if (q === 2) {
- vl = Math.floor(values.length / 2);
- return values.length % 2 ? values[vl] : (values[vl-1] + values[vl]) / 2;
- } else {
- if (values.length % 2 ) { // odd
- vl = (values.length * q + q) / 4;
- return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl-1];
- } else { //even
- vl = (values.length * q + 2) / 4;
- return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl-1];
-
- }
- }
- };
-
- normalizeValue = function (val) {
- var nf;
- switch (val) {
- case 'undefined':
- val = undefined;
- break;
- case 'null':
- val = null;
- break;
- case 'true':
- val = true;
- break;
- case 'false':
- val = false;
- break;
- default:
- nf = parseFloat(val);
- if (val == nf) {
- val = nf;
- }
- }
- return val;
- };
-
- normalizeValues = function (vals) {
- var i, result = [];
- for (i = vals.length; i--;) {
- result[i] = normalizeValue(vals[i]);
- }
- return result;
- };
-
- remove = function (vals, filter) {
- var i, vl, result = [];
- for (i = 0, vl = vals.length; i < vl; i++) {
- if (vals[i] !== filter) {
- result.push(vals[i]);
- }
- }
- return result;
- };
-
- isNumber = function (num) {
- return !isNaN(parseFloat(num)) && isFinite(num);
- };
-
- formatNumber = function (num, prec, groupsize, groupsep, decsep) {
- var p, i;
- num = (prec === false ? parseFloat(num).toString() : num.toFixed(prec)).split('');
- p = (p = $.inArray('.', num)) < 0 ? num.length : p;
- if (p < num.length) {
- num[p] = decsep;
- }
- for (i = p - groupsize; i > 0; i -= groupsize) {
- num.splice(i, 0, groupsep);
- }
- return num.join('');
- };
-
- // determine if all values of an array match a value
- // returns true if the array is empty
- all = function (val, arr, ignoreNull) {
- var i;
- for (i = arr.length; i--; ) {
- if (ignoreNull && arr[i] === null) continue;
- if (arr[i] !== val) {
- return false;
- }
- }
- return true;
- };
-
- // sums the numeric values in an array, ignoring other values
- sum = function (vals) {
- var total = 0, i;
- for (i = vals.length; i--;) {
- total += typeof vals[i] === 'number' ? vals[i] : 0;
- }
- return total;
- };
-
- ensureArray = function (val) {
- return $.isArray(val) ? val : [val];
- };
-
- // http://paulirish.com/2008/bookmarklet-inject-new-css-rules/
- addCSS = function(css) {
- var tag;
- //if ('\v' == 'v') /* ie only */ {
- if (document.createStyleSheet) {
- document.createStyleSheet().cssText = css;
- } else {
- tag = document.createElement('style');
- tag.type = 'text/css';
- document.getElementsByTagName('head')[0].appendChild(tag);
- tag[(typeof document.body.style.WebkitAppearance == 'string') /* webkit only */ ? 'innerText' : 'innerHTML'] = css;
- }
- };
-
- // Provide a cross-browser interface to a few simple drawing primitives
- $.fn.simpledraw = function (width, height, useExisting, interact) {
- var target, mhandler;
- if (useExisting && (target = this.data('_jqs_vcanvas'))) {
- return target;
- }
- if (width === undefined) {
- width = $(this).innerWidth();
- }
- if (height === undefined) {
- height = $(this).innerHeight();
- }
- if ($.fn.sparkline.hasCanvas) {
- target = new VCanvas_canvas(width, height, this, interact);
- } else if ($.fn.sparkline.hasVML) {
- target = new VCanvas_vml(width, height, this);
- } else {
- return false;
- }
- mhandler = $(this).data('_jqs_mhandler');
- if (mhandler) {
- mhandler.registerCanvas(target);
- }
- return target;
- };
-
- $.fn.cleardraw = function () {
- var target = this.data('_jqs_vcanvas');
- if (target) {
- target.reset();
- }
- };
-
- $.RangeMapClass = RangeMap = createClass({
- init: function (map) {
- var key, range, rangelist = [];
- for (key in map) {
- if (map.hasOwnProperty(key) && typeof key === 'string' && key.indexOf(':') > -1) {
- range = key.split(':');
- range[0] = range[0].length === 0 ? -Infinity : parseFloat(range[0]);
- range[1] = range[1].length === 0 ? Infinity : parseFloat(range[1]);
- range[2] = map[key];
- rangelist.push(range);
- }
- }
- this.map = map;
- this.rangelist = rangelist || false;
- },
-
- get: function (value) {
- var rangelist = this.rangelist,
- i, range, result;
- if ((result = this.map[value]) !== undefined) {
- return result;
- }
- if (rangelist) {
- for (i = rangelist.length; i--;) {
- range = rangelist[i];
- if (range[0] <= value && range[1] >= value) {
- return range[2];
- }
- }
- }
- return undefined;
- }
- });
-
- // Convenience function
- $.range_map = function(map) {
- return new RangeMap(map);
- };
-
- MouseHandler = createClass({
- init: function (el, options) {
- var $el = $(el);
- this.$el = $el;
- this.options = options;
- this.currentPageX = 0;
- this.currentPageY = 0;
- this.el = el;
- this.splist = [];
- this.tooltip = null;
- this.over = false;
- this.displayTooltips = !options.get('disableTooltips');
- this.highlightEnabled = !options.get('disableHighlight');
- },
-
- registerSparkline: function (sp) {
- this.splist.push(sp);
- if (this.over) {
- this.updateDisplay();
- }
- },
-
- registerCanvas: function (canvas) {
- var $canvas = $(canvas.canvas);
- this.canvas = canvas;
- this.$canvas = $canvas;
- $canvas.mouseenter($.proxy(this.mouseenter, this));
- $canvas.mouseleave($.proxy(this.mouseleave, this));
- $canvas.click($.proxy(this.mouseclick, this));
- },
-
- reset: function (removeTooltip) {
- this.splist = [];
- if (this.tooltip && removeTooltip) {
- this.tooltip.remove();
- this.tooltip = undefined;
- }
- },
-
- mouseclick: function (e) {
- var clickEvent = $.Event('sparklineClick');
- clickEvent.originalEvent = e;
- clickEvent.sparklines = this.splist;
- this.$el.trigger(clickEvent);
- },
-
- mouseenter: function (e) {
- $(document.body).unbind('mousemove.jqs');
- $(document.body).bind('mousemove.jqs', $.proxy(this.mousemove, this));
- this.over = true;
- this.currentPageX = e.pageX;
- this.currentPageY = e.pageY;
- this.currentEl = e.target;
- if (!this.tooltip && this.displayTooltips) {
- this.tooltip = new Tooltip(this.options);
- this.tooltip.updatePosition(e.pageX, e.pageY);
- }
- this.updateDisplay();
- },
-
- mouseleave: function () {
- $(document.body).unbind('mousemove.jqs');
- var splist = this.splist,
- spcount = splist.length,
- needsRefresh = false,
- sp, i;
- this.over = false;
- this.currentEl = null;
-
- if (this.tooltip) {
- this.tooltip.remove();
- this.tooltip = null;
- }
-
- for (i = 0; i < spcount; i++) {
- sp = splist[i];
- if (sp.clearRegionHighlight()) {
- needsRefresh = true;
- }
- }
-
- if (needsRefresh) {
- this.canvas.render();
- }
- },
-
- mousemove: function (e) {
- this.currentPageX = e.pageX;
- this.currentPageY = e.pageY;
- this.currentEl = e.target;
- if (this.tooltip) {
- this.tooltip.updatePosition(e.pageX, e.pageY);
- }
- this.updateDisplay();
- },
-
- updateDisplay: function () {
- var splist = this.splist,
- spcount = splist.length,
- needsRefresh = false,
- offset = this.$canvas.offset(),
- localX = this.currentPageX - offset.left,
- localY = this.currentPageY - offset.top,
- tooltiphtml, sp, i, result, changeEvent;
- if (!this.over) {
- return;
- }
- for (i = 0; i < spcount; i++) {
- sp = splist[i];
- result = sp.setRegionHighlight(this.currentEl, localX, localY);
- if (result) {
- needsRefresh = true;
- }
- }
- if (needsRefresh) {
- changeEvent = $.Event('sparklineRegionChange');
- changeEvent.sparklines = this.splist;
- this.$el.trigger(changeEvent);
- if (this.tooltip) {
- tooltiphtml = '';
- for (i = 0; i < spcount; i++) {
- sp = splist[i];
- tooltiphtml += sp.getCurrentRegionTooltip();
- }
- this.tooltip.setContent(tooltiphtml);
- }
- if (!this.disableHighlight) {
- this.canvas.render();
- }
- }
- if (result === null) {
- this.mouseleave();
- }
- }
- });
-
-
- Tooltip = createClass({
- sizeStyle: 'position: static !important;' +
- 'display: block !important;' +
- 'visibility: hidden !important;' +
- 'float: left !important;',
-
- init: function (options) {
- var tooltipClassname = options.get('tooltipClassname', 'jqstooltip'),
- sizetipStyle = this.sizeStyle,
- offset;
- this.container = options.get('tooltipContainer') || document.body;
- this.tooltipOffsetX = options.get('tooltipOffsetX', 10);
- this.tooltipOffsetY = options.get('tooltipOffsetY', 12);
- // remove any previous lingering tooltip
- $('#jqssizetip').remove();
- $('#jqstooltip').remove();
- this.sizetip = $('', {
- id: 'jqssizetip',
- style: sizetipStyle,
- 'class': tooltipClassname
- });
- this.tooltip = $('', {
- id: 'jqstooltip',
- 'class': tooltipClassname
- }).appendTo(this.container);
- // account for the container's location
- offset = this.tooltip.offset();
- this.offsetLeft = offset.left;
- this.offsetTop = offset.top;
- this.hidden = true;
- $(window).unbind('resize.jqs scroll.jqs');
- $(window).bind('resize.jqs scroll.jqs', $.proxy(this.updateWindowDims, this));
- this.updateWindowDims();
- },
-
- updateWindowDims: function () {
- this.scrollTop = $(window).scrollTop();
- this.scrollLeft = $(window).scrollLeft();
- this.scrollRight = this.scrollLeft + $(window).width();
- this.updatePosition();
- },
-
- getSize: function (content) {
- this.sizetip.html(content).appendTo(this.container);
- this.width = this.sizetip.width() + 1;
- this.height = this.sizetip.height();
- this.sizetip.remove();
- },
-
- setContent: function (content) {
- if (!content) {
- this.tooltip.css('visibility', 'hidden');
- this.hidden = true;
- return;
- }
- this.getSize(content);
- this.tooltip.html(content)
- .css({
- 'width': this.width,
- 'height': this.height,
- 'visibility': 'visible'
- });
- if (this.hidden) {
- this.hidden = false;
- this.updatePosition();
- }
- },
-
- updatePosition: function (x, y) {
- if (x === undefined) {
- if (this.mousex === undefined) {
- return;
- }
- x = this.mousex - this.offsetLeft;
- y = this.mousey - this.offsetTop;
-
- } else {
- this.mousex = x = x - this.offsetLeft;
- this.mousey = y = y - this.offsetTop;
- }
- if (!this.height || !this.width || this.hidden) {
- return;
- }
-
- y -= this.height + this.tooltipOffsetY;
- x += this.tooltipOffsetX;
-
- if (y < this.scrollTop) {
- y = this.scrollTop;
- }
- if (x < this.scrollLeft) {
- x = this.scrollLeft;
- } else if (x + this.width > this.scrollRight) {
- x = this.scrollRight - this.width;
- }
-
- this.tooltip.css({
- 'left': x,
- 'top': y
- });
- },
-
- remove: function () {
- this.tooltip.remove();
- this.sizetip.remove();
- this.sizetip = this.tooltip = undefined;
- $(window).unbind('resize.jqs scroll.jqs');
- }
- });
-
- initStyles = function() {
- addCSS(defaultStyles);
- };
-
- $(initStyles);
-
- pending = [];
- $.fn.sparkline = function (userValues, userOptions) {
- return this.each(function () {
- var options = new $.fn.sparkline.options(this, userOptions),
- $this = $(this),
- render, i;
- render = function () {
- var values, width, height, tmp, mhandler, sp, vals;
- if (userValues === 'html' || userValues === undefined) {
- vals = this.getAttribute(options.get('tagValuesAttribute'));
- if (vals === undefined || vals === null) {
- vals = $this.html();
- }
- values = vals.replace(/(^\s*\s*$)|\s+/g, '').split(',');
- } else {
- values = userValues;
- }
-
- width = options.get('width') === 'auto' ? values.length * options.get('defaultPixelsPerValue') : options.get('width');
- if (options.get('height') === 'auto') {
- if (!options.get('composite') || !$.data(this, '_jqs_vcanvas')) {
- // must be a better way to get the line height
- tmp = document.createElement('span');
- tmp.innerHTML = 'a';
- $this.html(tmp);
- height = $(tmp).innerHeight() || $(tmp).height();
- $(tmp).remove();
- tmp = null;
- }
- } else {
- height = options.get('height');
- }
-
- if (!options.get('disableInteraction')) {
- mhandler = $.data(this, '_jqs_mhandler');
- if (!mhandler) {
- mhandler = new MouseHandler(this, options);
- $.data(this, '_jqs_mhandler', mhandler);
- } else if (!options.get('composite')) {
- mhandler.reset();
- }
- } else {
- mhandler = false;
- }
-
- if (options.get('composite') && !$.data(this, '_jqs_vcanvas')) {
- if (!$.data(this, '_jqs_errnotify')) {
- alert('Attempted to attach a composite sparkline to an element with no existing sparkline');
- $.data(this, '_jqs_errnotify', true);
- }
- return;
- }
-
- sp = new $.fn.sparkline[options.get('type')](this, values, options, width, height);
-
- sp.render();
-
- if (mhandler) {
- mhandler.registerSparkline(sp);
- }
- };
- // jQuery 1.3.0 completely changed the meaning of :hidden :-/
- if (($(this).html() && !options.get('disableHiddenCheck') && $(this).is(':hidden')) || ($.fn.jquery < '1.3.0' && $(this).parents().is(':hidden')) || !$(this).parents('body').length) {
- if (!options.get('composite') && $.data(this, '_jqs_pending')) {
- // remove any existing references to the element
- for (i = pending.length; i; i--) {
- if (pending[i - 1][0] == this) {
- pending.splice(i - 1, 1);
- }
- }
- }
- pending.push([this, render]);
- $.data(this, '_jqs_pending', true);
- } else {
- render.call(this);
- }
- });
- };
-
- $.fn.sparkline.defaults = getDefaults();
-
-
- $.sparkline_display_visible = function () {
- var el, i, pl;
- var done = [];
- for (i = 0, pl = pending.length; i < pl; i++) {
- el = pending[i][0];
- if ($(el).is(':visible') && !$(el).parents().is(':hidden')) {
- pending[i][1].call(el);
- $.data(pending[i][0], '_jqs_pending', false);
- done.push(i);
- } else if (!$(el).closest('html').length && !$.data(el, '_jqs_pending')) {
- // element has been inserted and removed from the DOM
- // If it was not yet inserted into the dom then the .data request
- // will return true.
- // removing from the dom causes the data to be removed.
- $.data(pending[i][0], '_jqs_pending', false);
- done.push(i);
- }
- }
- for (i = done.length; i; i--) {
- pending.splice(done[i - 1], 1);
- }
- };
-
-
- /**
- * User option handler
- */
- $.fn.sparkline.options = createClass({
- init: function (tag, userOptions) {
- var extendedOptions, defaults, base, tagOptionType;
- this.userOptions = userOptions = userOptions || {};
- this.tag = tag;
- this.tagValCache = {};
- defaults = $.fn.sparkline.defaults;
- base = defaults.common;
- this.tagOptionsPrefix = userOptions.enableTagOptions && (userOptions.tagOptionsPrefix || base.tagOptionsPrefix);
-
- tagOptionType = this.getTagSetting('type');
- if (tagOptionType === UNSET_OPTION) {
- extendedOptions = defaults[userOptions.type || base.type];
- } else {
- extendedOptions = defaults[tagOptionType];
- }
- this.mergedOptions = $.extend({}, base, extendedOptions, userOptions);
- },
-
-
- getTagSetting: function (key) {
- var prefix = this.tagOptionsPrefix,
- val, i, pairs, keyval;
- if (prefix === false || prefix === undefined) {
- return UNSET_OPTION;
- }
- if (this.tagValCache.hasOwnProperty(key)) {
- val = this.tagValCache.key;
- } else {
- val = this.tag.getAttribute(prefix + key);
- if (val === undefined || val === null) {
- val = UNSET_OPTION;
- } else if (val.substr(0, 1) === '[') {
- val = val.substr(1, val.length - 2).split(',');
- for (i = val.length; i--;) {
- val[i] = normalizeValue(val[i].replace(/(^\s*)|(\s*$)/g, ''));
- }
- } else if (val.substr(0, 1) === '{') {
- pairs = val.substr(1, val.length - 2).split(',');
- val = {};
- for (i = pairs.length; i--;) {
- keyval = pairs[i].split(':', 2);
- val[keyval[0].replace(/(^\s*)|(\s*$)/g, '')] = normalizeValue(keyval[1].replace(/(^\s*)|(\s*$)/g, ''));
- }
- } else {
- val = normalizeValue(val);
- }
- this.tagValCache.key = val;
- }
- return val;
- },
-
- get: function (key, defaultval) {
- var tagOption = this.getTagSetting(key),
- result;
- if (tagOption !== UNSET_OPTION) {
- return tagOption;
- }
- return (result = this.mergedOptions[key]) === undefined ? defaultval : result;
- }
- });
-
-
- $.fn.sparkline._base = createClass({
- disabled: false,
-
- init: function (el, values, options, width, height) {
- this.el = el;
- this.$el = $(el);
- this.values = values;
- this.options = options;
- this.width = width;
- this.height = height;
- this.currentRegion = undefined;
- },
-
- /**
- * Setup the canvas
- */
- initTarget: function () {
- var interactive = !this.options.get('disableInteraction');
- if (!(this.target = this.$el.simpledraw(this.width, this.height, this.options.get('composite'), interactive))) {
- this.disabled = true;
- } else {
- this.canvasWidth = this.target.pixelWidth;
- this.canvasHeight = this.target.pixelHeight;
- }
- },
-
- /**
- * Actually render the chart to the canvas
- */
- render: function () {
- if (this.disabled) {
- this.el.innerHTML = '';
- return false;
- }
- return true;
- },
-
- /**
- * Return a region id for a given x/y co-ordinate
- */
- getRegion: function (x, y) {
- },
-
- /**
- * Highlight an item based on the moused-over x,y co-ordinate
- */
- setRegionHighlight: function (el, x, y) {
- var currentRegion = this.currentRegion,
- highlightEnabled = !this.options.get('disableHighlight'),
- newRegion;
- if (x > this.canvasWidth || y > this.canvasHeight || x < 0 || y < 0) {
- return null;
- }
- newRegion = this.getRegion(el, x, y);
- if (currentRegion !== newRegion) {
- if (currentRegion !== undefined && highlightEnabled) {
- this.removeHighlight();
- }
- this.currentRegion = newRegion;
- if (newRegion !== undefined && highlightEnabled) {
- this.renderHighlight();
- }
- return true;
- }
- return false;
- },
-
- /**
- * Reset any currently highlighted item
- */
- clearRegionHighlight: function () {
- if (this.currentRegion !== undefined) {
- this.removeHighlight();
- this.currentRegion = undefined;
- return true;
- }
- return false;
- },
-
- renderHighlight: function () {
- this.changeHighlight(true);
- },
-
- removeHighlight: function () {
- this.changeHighlight(false);
- },
-
- changeHighlight: function (highlight) {},
-
- /**
- * Fetch the HTML to display as a tooltip
- */
- getCurrentRegionTooltip: function () {
- var options = this.options,
- header = '',
- entries = [],
- fields, formats, formatlen, fclass, text, i,
- showFields, showFieldsKey, newFields, fv,
- formatter, format, fieldlen, j;
- if (this.currentRegion === undefined) {
- return '';
- }
- fields = this.getCurrentRegionFields();
- formatter = options.get('tooltipFormatter');
- if (formatter) {
- return formatter(this, options, fields);
- }
- if (options.get('tooltipChartTitle')) {
- header += '
' + options.get('tooltipChartTitle') + '
\n';
- }
- formats = this.options.get('tooltipFormat');
- if (!formats) {
- return '';
- }
- if (!$.isArray(formats)) {
- formats = [formats];
- }
- if (!$.isArray(fields)) {
- fields = [fields];
- }
- showFields = this.options.get('tooltipFormatFieldlist');
- showFieldsKey = this.options.get('tooltipFormatFieldlistKey');
- if (showFields && showFieldsKey) {
- // user-selected ordering of fields
- newFields = [];
- for (i = fields.length; i--;) {
- fv = fields[i][showFieldsKey];
- if ((j = $.inArray(fv, showFields)) != -1) {
- newFields[j] = fields[i];
- }
- }
- fields = newFields;
- }
- formatlen = formats.length;
- fieldlen = fields.length;
- for (i = 0; i < formatlen; i++) {
- format = formats[i];
- if (typeof format === 'string') {
- format = new SPFormat(format);
- }
- fclass = format.fclass || 'jqsfield';
- for (j = 0; j < fieldlen; j++) {
- if (!fields[j].isNull || !options.get('tooltipSkipNull')) {
- $.extend(fields[j], {
- prefix: options.get('tooltipPrefix'),
- suffix: options.get('tooltipSuffix')
- });
- text = format.render(fields[j], options.get('tooltipValueLookups'), options);
- entries.push('
' + text + '
');
- }
- }
- }
- if (entries.length) {
- return header + entries.join('\n');
- }
- return '';
- },
-
- getCurrentRegionFields: function () {},
-
- calcHighlightColor: function (color, options) {
- var highlightColor = options.get('highlightColor'),
- lighten = options.get('highlightLighten'),
- parse, mult, rgbnew, i;
- if (highlightColor) {
- return highlightColor;
- }
- if (lighten) {
- // extract RGB values
- parse = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(color) || /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
- if (parse) {
- rgbnew = [];
- mult = color.length === 4 ? 16 : 1;
- for (i = 0; i < 3; i++) {
- rgbnew[i] = clipval(Math.round(parseInt(parse[i + 1], 16) * mult * lighten), 0, 255);
- }
- return 'rgb(' + rgbnew.join(',') + ')';
- }
-
- }
- return color;
- }
-
- });
-
- barHighlightMixin = {
- changeHighlight: function (highlight) {
- var currentRegion = this.currentRegion,
- target = this.target,
- shapeids = this.regionShapes[currentRegion],
- newShapes;
- // will be null if the region value was null
- if (shapeids) {
- newShapes = this.renderRegion(currentRegion, highlight);
- if ($.isArray(newShapes) || $.isArray(shapeids)) {
- target.replaceWithShapes(shapeids, newShapes);
- this.regionShapes[currentRegion] = $.map(newShapes, function (newShape) {
- return newShape.id;
- });
- } else {
- target.replaceWithShape(shapeids, newShapes);
- this.regionShapes[currentRegion] = newShapes.id;
- }
- }
- },
-
- render: function () {
- var values = this.values,
- target = this.target,
- regionShapes = this.regionShapes,
- shapes, ids, i, j;
-
- if (!this.cls._super.render.call(this)) {
- return;
- }
- for (i = values.length; i--;) {
- shapes = this.renderRegion(i);
- if (shapes) {
- if ($.isArray(shapes)) {
- ids = [];
- for (j = shapes.length; j--;) {
- shapes[j].append();
- ids.push(shapes[j].id);
- }
- regionShapes[i] = ids;
- } else {
- shapes.append();
- regionShapes[i] = shapes.id; // store just the shapeid
- }
- } else {
- // null value
- regionShapes[i] = null;
- }
- }
- target.render();
- }
- };
-
- /**
- * Line charts
- */
- $.fn.sparkline.line = line = createClass($.fn.sparkline._base, {
- type: 'line',
-
- init: function (el, values, options, width, height) {
- line._super.init.call(this, el, values, options, width, height);
- this.vertices = [];
- this.regionMap = [];
- this.xvalues = [];
- this.yvalues = [];
- this.yminmax = [];
- this.hightlightSpotId = null;
- this.lastShapeId = null;
- this.initTarget();
- },
-
- getRegion: function (el, x, y) {
- var i,
- regionMap = this.regionMap; // maps regions to value positions
- for (i = regionMap.length; i--;) {
- if (regionMap[i] !== null && x >= regionMap[i][0] && x <= regionMap[i][1]) {
- return regionMap[i][2];
- }
- }
- return undefined;
- },
-
- getCurrentRegionFields: function () {
- var currentRegion = this.currentRegion;
- return {
- isNull: this.yvalues[currentRegion] === null,
- x: this.xvalues[currentRegion],
- y: this.yvalues[currentRegion],
- color: this.options.get('lineColor'),
- fillColor: this.options.get('fillColor'),
- offset: currentRegion
- };
- },
-
- renderHighlight: function () {
- var currentRegion = this.currentRegion,
- target = this.target,
- vertex = this.vertices[currentRegion],
- options = this.options,
- spotRadius = options.get('spotRadius'),
- highlightSpotColor = options.get('highlightSpotColor'),
- highlightLineColor = options.get('highlightLineColor'),
- highlightSpot, highlightLine;
-
- if (!vertex) {
- return;
- }
- if (spotRadius && highlightSpotColor) {
- highlightSpot = target.drawCircle(vertex[0], vertex[1],
- spotRadius, undefined, highlightSpotColor);
- this.highlightSpotId = highlightSpot.id;
- target.insertAfterShape(this.lastShapeId, highlightSpot);
- }
- if (highlightLineColor) {
- highlightLine = target.drawLine(vertex[0], this.canvasTop, vertex[0],
- this.canvasTop + this.canvasHeight, highlightLineColor);
- this.highlightLineId = highlightLine.id;
- target.insertAfterShape(this.lastShapeId, highlightLine);
- }
- },
-
- removeHighlight: function () {
- var target = this.target;
- if (this.highlightSpotId) {
- target.removeShapeId(this.highlightSpotId);
- this.highlightSpotId = null;
- }
- if (this.highlightLineId) {
- target.removeShapeId(this.highlightLineId);
- this.highlightLineId = null;
- }
- },
-
- scanValues: function () {
- var values = this.values,
- valcount = values.length,
- xvalues = this.xvalues,
- yvalues = this.yvalues,
- yminmax = this.yminmax,
- i, val, isStr, isArray, sp;
- for (i = 0; i < valcount; i++) {
- val = values[i];
- isStr = typeof(values[i]) === 'string';
- isArray = typeof(values[i]) === 'object' && values[i] instanceof Array;
- sp = isStr && values[i].split(':');
- if (isStr && sp.length === 2) { // x:y
- xvalues.push(Number(sp[0]));
- yvalues.push(Number(sp[1]));
- yminmax.push(Number(sp[1]));
- } else if (isArray) {
- xvalues.push(val[0]);
- yvalues.push(val[1]);
- yminmax.push(val[1]);
- } else {
- xvalues.push(i);
- if (values[i] === null || values[i] === 'null') {
- yvalues.push(null);
- } else {
- yvalues.push(Number(val));
- yminmax.push(Number(val));
- }
- }
- }
- if (this.options.get('xvalues')) {
- xvalues = this.options.get('xvalues');
- }
-
- this.maxy = this.maxyorg = Math.max.apply(Math, yminmax);
- this.miny = this.minyorg = Math.min.apply(Math, yminmax);
-
- this.maxx = Math.max.apply(Math, xvalues);
- this.minx = Math.min.apply(Math, xvalues);
-
- this.xvalues = xvalues;
- this.yvalues = yvalues;
- this.yminmax = yminmax;
-
- },
-
- processRangeOptions: function () {
- var options = this.options,
- normalRangeMin = options.get('normalRangeMin'),
- normalRangeMax = options.get('normalRangeMax');
-
- if (normalRangeMin !== undefined) {
- if (normalRangeMin < this.miny) {
- this.miny = normalRangeMin;
- }
- if (normalRangeMax > this.maxy) {
- this.maxy = normalRangeMax;
- }
- }
- if (options.get('chartRangeMin') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMin') < this.miny)) {
- this.miny = options.get('chartRangeMin');
- }
- if (options.get('chartRangeMax') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMax') > this.maxy)) {
- this.maxy = options.get('chartRangeMax');
- }
- if (options.get('chartRangeMinX') !== undefined && (options.get('chartRangeClipX') || options.get('chartRangeMinX') < this.minx)) {
- this.minx = options.get('chartRangeMinX');
- }
- if (options.get('chartRangeMaxX') !== undefined && (options.get('chartRangeClipX') || options.get('chartRangeMaxX') > this.maxx)) {
- this.maxx = options.get('chartRangeMaxX');
- }
-
- },
-
- drawNormalRange: function (canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey) {
- var normalRangeMin = this.options.get('normalRangeMin'),
- normalRangeMax = this.options.get('normalRangeMax'),
- ytop = canvasTop + Math.round(canvasHeight - (canvasHeight * ((normalRangeMax - this.miny) / rangey))),
- height = Math.round((canvasHeight * (normalRangeMax - normalRangeMin)) / rangey);
- this.target.drawRect(canvasLeft, ytop, canvasWidth, height, undefined, this.options.get('normalRangeColor')).append();
- },
-
- render: function () {
- var options = this.options,
- target = this.target,
- canvasWidth = this.canvasWidth,
- canvasHeight = this.canvasHeight,
- vertices = this.vertices,
- spotRadius = options.get('spotRadius'),
- regionMap = this.regionMap,
- rangex, rangey, yvallast,
- canvasTop, canvasLeft,
- vertex, path, paths, x, y, xnext, xpos, xposnext,
- last, next, yvalcount, lineShapes, fillShapes, plen,
- valueSpots, hlSpotsEnabled, color, xvalues, yvalues, i;
-
- if (!line._super.render.call(this)) {
- return;
- }
-
- this.scanValues();
- this.processRangeOptions();
-
- xvalues = this.xvalues;
- yvalues = this.yvalues;
-
- if (!this.yminmax.length || this.yvalues.length < 2) {
- // empty or all null valuess
- return;
- }
-
- canvasTop = canvasLeft = 0;
-
- rangex = this.maxx - this.minx === 0 ? 1 : this.maxx - this.minx;
- rangey = this.maxy - this.miny === 0 ? 1 : this.maxy - this.miny;
- yvallast = this.yvalues.length - 1;
-
- if (spotRadius && (canvasWidth < (spotRadius * 4) || canvasHeight < (spotRadius * 4))) {
- spotRadius = 0;
- }
- if (spotRadius) {
- // adjust the canvas size as required so that spots will fit
- hlSpotsEnabled = options.get('highlightSpotColor') && !options.get('disableInteraction');
- if (hlSpotsEnabled || options.get('minSpotColor') || (options.get('spotColor') && yvalues[yvallast] === this.miny)) {
- canvasHeight -= Math.ceil(spotRadius);
- }
- if (hlSpotsEnabled || options.get('maxSpotColor') || (options.get('spotColor') && yvalues[yvallast] === this.maxy)) {
- canvasHeight -= Math.ceil(spotRadius);
- canvasTop += Math.ceil(spotRadius);
- }
- if (hlSpotsEnabled ||
- ((options.get('minSpotColor') || options.get('maxSpotColor')) && (yvalues[0] === this.miny || yvalues[0] === this.maxy))) {
- canvasLeft += Math.ceil(spotRadius);
- canvasWidth -= Math.ceil(spotRadius);
- }
- if (hlSpotsEnabled || options.get('spotColor') ||
- (options.get('minSpotColor') || options.get('maxSpotColor') &&
- (yvalues[yvallast] === this.miny || yvalues[yvallast] === this.maxy))) {
- canvasWidth -= Math.ceil(spotRadius);
- }
- }
-
-
- canvasHeight--;
-
- if (options.get('normalRangeMin') !== undefined && !options.get('drawNormalOnTop')) {
- this.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey);
- }
-
- path = [];
- paths = [path];
- last = next = null;
- yvalcount = yvalues.length;
- for (i = 0; i < yvalcount; i++) {
- x = xvalues[i];
- xnext = xvalues[i + 1];
- y = yvalues[i];
- xpos = canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex));
- xposnext = i < yvalcount - 1 ? canvasLeft + Math.round((xnext - this.minx) * (canvasWidth / rangex)) : canvasWidth;
- next = xpos + ((xposnext - xpos) / 2);
- regionMap[i] = [last || 0, next, i];
- last = next;
- if (y === null) {
- if (i) {
- if (yvalues[i - 1] !== null) {
- path = [];
- paths.push(path);
- }
- vertices.push(null);
- }
- } else {
- if (y < this.miny) {
- y = this.miny;
- }
- if (y > this.maxy) {
- y = this.maxy;
- }
- if (!path.length) {
- // previous value was null
- path.push([xpos, canvasTop + canvasHeight]);
- }
- vertex = [xpos, canvasTop + Math.round(canvasHeight - (canvasHeight * ((y - this.miny) / rangey)))];
- path.push(vertex);
- vertices.push(vertex);
- }
- }
-
- lineShapes = [];
- fillShapes = [];
- plen = paths.length;
- for (i = 0; i < plen; i++) {
- path = paths[i];
- if (path.length) {
- if (options.get('fillColor')) {
- path.push([path[path.length - 1][0], (canvasTop + canvasHeight)]);
- fillShapes.push(path.slice(0));
- path.pop();
- }
- // if there's only a single point in this path, then we want to display it
- // as a vertical line which means we keep path[0] as is
- if (path.length > 2) {
- // else we want the first value
- path[0] = [path[0][0], path[1][1]];
- }
- lineShapes.push(path);
- }
- }
-
- // draw the fill first, then optionally the normal range, then the line on top of that
- plen = fillShapes.length;
- for (i = 0; i < plen; i++) {
- target.drawShape(fillShapes[i],
- options.get('fillColor'), options.get('fillColor')).append();
- }
-
- if (options.get('normalRangeMin') !== undefined && options.get('drawNormalOnTop')) {
- this.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey);
- }
-
- plen = lineShapes.length;
- for (i = 0; i < plen; i++) {
- target.drawShape(lineShapes[i], options.get('lineColor'), undefined,
- options.get('lineWidth')).append();
- }
-
- if (spotRadius && options.get('valueSpots')) {
- valueSpots = options.get('valueSpots');
- if (valueSpots.get === undefined) {
- valueSpots = new RangeMap(valueSpots);
- }
- for (i = 0; i < yvalcount; i++) {
- color = valueSpots.get(yvalues[i]);
- if (color) {
- target.drawCircle(canvasLeft + Math.round((xvalues[i] - this.minx) * (canvasWidth / rangex)),
- canvasTop + Math.round(canvasHeight - (canvasHeight * ((yvalues[i] - this.miny) / rangey))),
- spotRadius, undefined,
- color).append();
- }
- }
-
- }
- if (spotRadius && options.get('spotColor') && yvalues[yvallast] !== null) {
- target.drawCircle(canvasLeft + Math.round((xvalues[xvalues.length - 1] - this.minx) * (canvasWidth / rangex)),
- canvasTop + Math.round(canvasHeight - (canvasHeight * ((yvalues[yvallast] - this.miny) / rangey))),
- spotRadius, undefined,
- options.get('spotColor')).append();
- }
- if (this.maxy !== this.minyorg) {
- if (spotRadius && options.get('minSpotColor')) {
- x = xvalues[$.inArray(this.minyorg, yvalues)];
- target.drawCircle(canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex)),
- canvasTop + Math.round(canvasHeight - (canvasHeight * ((this.minyorg - this.miny) / rangey))),
- spotRadius, undefined,
- options.get('minSpotColor')).append();
- }
- if (spotRadius && options.get('maxSpotColor')) {
- x = xvalues[$.inArray(this.maxyorg, yvalues)];
- target.drawCircle(canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex)),
- canvasTop + Math.round(canvasHeight - (canvasHeight * ((this.maxyorg - this.miny) / rangey))),
- spotRadius, undefined,
- options.get('maxSpotColor')).append();
- }
- }
-
- this.lastShapeId = target.getLastShapeId();
- this.canvasTop = canvasTop;
- target.render();
- }
- });
-
- /**
- * Bar charts
- */
- $.fn.sparkline.bar = bar = createClass($.fn.sparkline._base, barHighlightMixin, {
- type: 'bar',
-
- init: function (el, values, options, width, height) {
- var barWidth = parseInt(options.get('barWidth'), 10),
- barSpacing = parseInt(options.get('barSpacing'), 10),
- chartRangeMin = options.get('chartRangeMin'),
- chartRangeMax = options.get('chartRangeMax'),
- chartRangeClip = options.get('chartRangeClip'),
- stackMin = Infinity,
- stackMax = -Infinity,
- isStackString, groupMin, groupMax, stackRanges,
- numValues, i, vlen, range, zeroAxis, xaxisOffset, min, max, clipMin, clipMax,
- stacked, vlist, j, slen, svals, val, yoffset, yMaxCalc, canvasHeightEf;
- bar._super.init.call(this, el, values, options, width, height);
-
- // scan values to determine whether to stack bars
- for (i = 0, vlen = values.length; i < vlen; i++) {
- val = values[i];
- isStackString = typeof(val) === 'string' && val.indexOf(':') > -1;
- if (isStackString || $.isArray(val)) {
- stacked = true;
- if (isStackString) {
- val = values[i] = normalizeValues(val.split(':'));
- }
- val = remove(val, null); // min/max will treat null as zero
- groupMin = Math.min.apply(Math, val);
- groupMax = Math.max.apply(Math, val);
- if (groupMin < stackMin) {
- stackMin = groupMin;
- }
- if (groupMax > stackMax) {
- stackMax = groupMax;
- }
- }
- }
-
- this.stacked = stacked;
- this.regionShapes = {};
- this.barWidth = barWidth;
- this.barSpacing = barSpacing;
- this.totalBarWidth = barWidth + barSpacing;
- this.width = width = (values.length * barWidth) + ((values.length - 1) * barSpacing);
-
- this.initTarget();
-
- if (chartRangeClip) {
- clipMin = chartRangeMin === undefined ? -Infinity : chartRangeMin;
- clipMax = chartRangeMax === undefined ? Infinity : chartRangeMax;
- }
-
- numValues = [];
- stackRanges = stacked ? [] : numValues;
- var stackTotals = [];
- var stackRangesNeg = [];
- for (i = 0, vlen = values.length; i < vlen; i++) {
- if (stacked) {
- vlist = values[i];
- values[i] = svals = [];
- stackTotals[i] = 0;
- stackRanges[i] = stackRangesNeg[i] = 0;
- for (j = 0, slen = vlist.length; j < slen; j++) {
- val = svals[j] = chartRangeClip ? clipval(vlist[j], clipMin, clipMax) : vlist[j];
- if (val !== null) {
- if (val > 0) {
- stackTotals[i] += val;
- }
- if (stackMin < 0 && stackMax > 0) {
- if (val < 0) {
- stackRangesNeg[i] += Math.abs(val);
- } else {
- stackRanges[i] += val;
- }
- } else {
- stackRanges[i] += Math.abs(val - (val < 0 ? stackMax : stackMin));
- }
- numValues.push(val);
- }
- }
- } else {
- val = chartRangeClip ? clipval(values[i], clipMin, clipMax) : values[i];
- val = values[i] = normalizeValue(val);
- if (val !== null) {
- numValues.push(val);
- }
- }
- }
- this.max = max = Math.max.apply(Math, numValues);
- this.min = min = Math.min.apply(Math, numValues);
- this.stackMax = stackMax = stacked ? Math.max.apply(Math, stackTotals) : max;
- this.stackMin = stackMin = stacked ? Math.min.apply(Math, numValues) : min;
-
- if (options.get('chartRangeMin') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMin') < min)) {
- min = options.get('chartRangeMin');
- }
- if (options.get('chartRangeMax') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMax') > max)) {
- max = options.get('chartRangeMax');
- }
-
- this.zeroAxis = zeroAxis = options.get('zeroAxis', true);
- if (min <= 0 && max >= 0 && zeroAxis) {
- xaxisOffset = 0;
- } else if (zeroAxis == false) {
- xaxisOffset = min;
- } else if (min > 0) {
- xaxisOffset = min;
- } else {
- xaxisOffset = max;
- }
- this.xaxisOffset = xaxisOffset;
-
- range = stacked ? (Math.max.apply(Math, stackRanges) + Math.max.apply(Math, stackRangesNeg)) : max - min;
-
- // as we plot zero/min values a single pixel line, we add a pixel to all other
- // values - Reduce the effective canvas size to suit
- this.canvasHeightEf = (zeroAxis && min < 0) ? this.canvasHeight - 2 : this.canvasHeight - 1;
-
- if (min < xaxisOffset) {
- yMaxCalc = (stacked && max >= 0) ? stackMax : max;
- yoffset = (yMaxCalc - xaxisOffset) / range * this.canvasHeight;
- if (yoffset !== Math.ceil(yoffset)) {
- this.canvasHeightEf -= 2;
- yoffset = Math.ceil(yoffset);
- }
- } else {
- yoffset = this.canvasHeight;
- }
- this.yoffset = yoffset;
-
- if ($.isArray(options.get('colorMap'))) {
- this.colorMapByIndex = options.get('colorMap');
- this.colorMapByValue = null;
- } else {
- this.colorMapByIndex = null;
- this.colorMapByValue = options.get('colorMap');
- if (this.colorMapByValue && this.colorMapByValue.get === undefined) {
- this.colorMapByValue = new RangeMap(this.colorMapByValue);
- }
- }
-
- this.range = range;
- },
-
- getRegion: function (el, x, y) {
- var result = Math.floor(x / this.totalBarWidth);
- return (result < 0 || result >= this.values.length) ? undefined : result;
- },
-
- getCurrentRegionFields: function () {
- var currentRegion = this.currentRegion,
- values = ensureArray(this.values[currentRegion]),
- result = [],
- value, i;
- for (i = values.length; i--;) {
- value = values[i];
- result.push({
- isNull: value === null,
- value: value,
- color: this.calcColor(i, value, currentRegion),
- offset: currentRegion
- });
- }
- return result;
- },
-
- calcColor: function (stacknum, value, valuenum) {
- var colorMapByIndex = this.colorMapByIndex,
- colorMapByValue = this.colorMapByValue,
- options = this.options,
- color, newColor;
- if (this.stacked) {
- color = options.get('stackedBarColor');
- } else {
- color = (value < 0) ? options.get('negBarColor') : options.get('barColor');
- }
- if (value === 0 && options.get('zeroColor') !== undefined) {
- color = options.get('zeroColor');
- }
- if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
- color = newColor;
- } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
- color = colorMapByIndex[valuenum];
- }
- return $.isArray(color) ? color[stacknum % color.length] : color;
- },
-
- /**
- * Render bar(s) for a region
- */
- renderRegion: function (valuenum, highlight) {
- var vals = this.values[valuenum],
- options = this.options,
- xaxisOffset = this.xaxisOffset,
- result = [],
- range = this.range,
- stacked = this.stacked,
- target = this.target,
- x = valuenum * this.totalBarWidth,
- canvasHeightEf = this.canvasHeightEf,
- yoffset = this.yoffset,
- y, height, color, isNull, yoffsetNeg, i, valcount, val, minPlotted, allMin;
-
- vals = $.isArray(vals) ? vals : [vals];
- valcount = vals.length;
- val = vals[0];
- isNull = all(null, vals);
- allMin = all(xaxisOffset, vals, true);
-
- if (isNull) {
- if (options.get('nullColor')) {
- color = highlight ? options.get('nullColor') : this.calcHighlightColor(options.get('nullColor'), options);
- y = (yoffset > 0) ? yoffset - 1 : yoffset;
- return target.drawRect(x, y, this.barWidth - 1, 0, color, color);
- } else {
- return undefined;
- }
- }
- yoffsetNeg = yoffset;
- for (i = 0; i < valcount; i++) {
- val = vals[i];
-
- if (stacked && val === xaxisOffset) {
- if (!allMin || minPlotted) {
- continue;
- }
- minPlotted = true;
- }
-
- if (range > 0) {
- height = Math.floor(canvasHeightEf * ((Math.abs(val - xaxisOffset) / range))) + 1;
- } else {
- height = 1;
- }
- if (val < xaxisOffset || (val === xaxisOffset && yoffset === 0)) {
- y = yoffsetNeg;
- yoffsetNeg += height;
- } else {
- y = yoffset - height;
- yoffset -= height;
- }
- color = this.calcColor(i, val, valuenum);
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
- result.push(target.drawRect(x, y, this.barWidth - 1, height - 1, color, color));
- }
- if (result.length === 1) {
- return result[0];
- }
- return result;
- }
- });
-
- /**
- * Tristate charts
- */
- $.fn.sparkline.tristate = tristate = createClass($.fn.sparkline._base, barHighlightMixin, {
- type: 'tristate',
-
- init: function (el, values, options, width, height) {
- var barWidth = parseInt(options.get('barWidth'), 10),
- barSpacing = parseInt(options.get('barSpacing'), 10);
- tristate._super.init.call(this, el, values, options, width, height);
-
- this.regionShapes = {};
- this.barWidth = barWidth;
- this.barSpacing = barSpacing;
- this.totalBarWidth = barWidth + barSpacing;
- this.values = $.map(values, Number);
- this.width = width = (values.length * barWidth) + ((values.length - 1) * barSpacing);
-
- if ($.isArray(options.get('colorMap'))) {
- this.colorMapByIndex = options.get('colorMap');
- this.colorMapByValue = null;
- } else {
- this.colorMapByIndex = null;
- this.colorMapByValue = options.get('colorMap');
- if (this.colorMapByValue && this.colorMapByValue.get === undefined) {
- this.colorMapByValue = new RangeMap(this.colorMapByValue);
- }
- }
- this.initTarget();
- },
-
- getRegion: function (el, x, y) {
- return Math.floor(x / this.totalBarWidth);
- },
-
- getCurrentRegionFields: function () {
- var currentRegion = this.currentRegion;
- return {
- isNull: this.values[currentRegion] === undefined,
- value: this.values[currentRegion],
- color: this.calcColor(this.values[currentRegion], currentRegion),
- offset: currentRegion
- };
- },
-
- calcColor: function (value, valuenum) {
- var values = this.values,
- options = this.options,
- colorMapByIndex = this.colorMapByIndex,
- colorMapByValue = this.colorMapByValue,
- color, newColor;
-
- if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
- color = newColor;
- } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
- color = colorMapByIndex[valuenum];
- } else if (values[valuenum] < 0) {
- color = options.get('negBarColor');
- } else if (values[valuenum] > 0) {
- color = options.get('posBarColor');
- } else {
- color = options.get('zeroBarColor');
- }
- return color;
- },
-
- renderRegion: function (valuenum, highlight) {
- var values = this.values,
- options = this.options,
- target = this.target,
- canvasHeight, height, halfHeight,
- x, y, color;
-
- canvasHeight = target.pixelHeight;
- halfHeight = Math.round(canvasHeight / 2);
-
- x = valuenum * this.totalBarWidth;
- if (values[valuenum] < 0) {
- y = halfHeight;
- height = halfHeight - 1;
- } else if (values[valuenum] > 0) {
- y = 0;
- height = halfHeight - 1;
- } else {
- y = halfHeight - 1;
- height = 2;
- }
- color = this.calcColor(values[valuenum], valuenum);
- if (color === null) {
- return;
- }
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
- return target.drawRect(x, y, this.barWidth - 1, height - 1, color, color);
- }
- });
-
- /**
- * Discrete charts
- */
- $.fn.sparkline.discrete = discrete = createClass($.fn.sparkline._base, barHighlightMixin, {
- type: 'discrete',
-
- init: function (el, values, options, width, height) {
- discrete._super.init.call(this, el, values, options, width, height);
-
- this.regionShapes = {};
- this.values = values = $.map(values, Number);
- this.min = Math.min.apply(Math, values);
- this.max = Math.max.apply(Math, values);
- this.range = this.max - this.min;
- this.width = width = options.get('width') === 'auto' ? values.length * 2 : this.width;
- this.interval = Math.floor(width / values.length);
- this.itemWidth = width / values.length;
- if (options.get('chartRangeMin') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMin') < this.min)) {
- this.min = options.get('chartRangeMin');
- }
- if (options.get('chartRangeMax') !== undefined && (options.get('chartRangeClip') || options.get('chartRangeMax') > this.max)) {
- this.max = options.get('chartRangeMax');
- }
- this.initTarget();
- if (this.target) {
- this.lineHeight = options.get('lineHeight') === 'auto' ? Math.round(this.canvasHeight * 0.3) : options.get('lineHeight');
- }
- },
-
- getRegion: function (el, x, y) {
- return Math.floor(x / this.itemWidth);
- },
-
- getCurrentRegionFields: function () {
- var currentRegion = this.currentRegion;
- return {
- isNull: this.values[currentRegion] === undefined,
- value: this.values[currentRegion],
- offset: currentRegion
- };
- },
-
- renderRegion: function (valuenum, highlight) {
- var values = this.values,
- options = this.options,
- min = this.min,
- max = this.max,
- range = this.range,
- interval = this.interval,
- target = this.target,
- canvasHeight = this.canvasHeight,
- lineHeight = this.lineHeight,
- pheight = canvasHeight - lineHeight,
- ytop, val, color, x;
-
- val = clipval(values[valuenum], min, max);
- x = valuenum * interval;
- ytop = Math.round(pheight - pheight * ((val - min) / range));
- color = (options.get('thresholdColor') && val < options.get('thresholdValue')) ? options.get('thresholdColor') : options.get('lineColor');
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
- return target.drawLine(x, ytop, x, ytop + lineHeight, color);
- }
- });
-
- /**
- * Bullet charts
- */
- $.fn.sparkline.bullet = bullet = createClass($.fn.sparkline._base, {
- type: 'bullet',
-
- init: function (el, values, options, width, height) {
- var min, max, vals;
- bullet._super.init.call(this, el, values, options, width, height);
-
- // values: target, performance, range1, range2, range3
- this.values = values = normalizeValues(values);
- // target or performance could be null
- vals = values.slice();
- vals[0] = vals[0] === null ? vals[2] : vals[0];
- vals[1] = values[1] === null ? vals[2] : vals[1];
- min = Math.min.apply(Math, values);
- max = Math.max.apply(Math, values);
- if (options.get('base') === undefined) {
- min = min < 0 ? min : 0;
- } else {
- min = options.get('base');
- }
- this.min = min;
- this.max = max;
- this.range = max - min;
- this.shapes = {};
- this.valueShapes = {};
- this.regiondata = {};
- this.width = width = options.get('width') === 'auto' ? '4.0em' : width;
- this.target = this.$el.simpledraw(width, height, options.get('composite'));
- if (!values.length) {
- this.disabled = true;
- }
- this.initTarget();
- },
-
- getRegion: function (el, x, y) {
- var shapeid = this.target.getShapeAt(el, x, y);
- return (shapeid !== undefined && this.shapes[shapeid] !== undefined) ? this.shapes[shapeid] : undefined;
- },
-
- getCurrentRegionFields: function () {
- var currentRegion = this.currentRegion;
- return {
- fieldkey: currentRegion.substr(0, 1),
- value: this.values[currentRegion.substr(1)],
- region: currentRegion
- };
- },
-
- changeHighlight: function (highlight) {
- var currentRegion = this.currentRegion,
- shapeid = this.valueShapes[currentRegion],
- shape;
- delete this.shapes[shapeid];
- switch (currentRegion.substr(0, 1)) {
- case 'r':
- shape = this.renderRange(currentRegion.substr(1), highlight);
- break;
- case 'p':
- shape = this.renderPerformance(highlight);
- break;
- case 't':
- shape = this.renderTarget(highlight);
- break;
- }
- this.valueShapes[currentRegion] = shape.id;
- this.shapes[shape.id] = currentRegion;
- this.target.replaceWithShape(shapeid, shape);
- },
-
- renderRange: function (rn, highlight) {
- var rangeval = this.values[rn],
- rangewidth = Math.round(this.canvasWidth * ((rangeval - this.min) / this.range)),
- color = this.options.get('rangeColors')[rn - 2];
- if (highlight) {
- color = this.calcHighlightColor(color, this.options);
- }
- return this.target.drawRect(0, 0, rangewidth - 1, this.canvasHeight - 1, color, color);
- },
-
- renderPerformance: function (highlight) {
- var perfval = this.values[1],
- perfwidth = Math.round(this.canvasWidth * ((perfval - this.min) / this.range)),
- color = this.options.get('performanceColor');
- if (highlight) {
- color = this.calcHighlightColor(color, this.options);
- }
- return this.target.drawRect(0, Math.round(this.canvasHeight * 0.3), perfwidth - 1,
- Math.round(this.canvasHeight * 0.4) - 1, color, color);
- },
-
- renderTarget: function (highlight) {
- var targetval = this.values[0],
- x = Math.round(this.canvasWidth * ((targetval - this.min) / this.range) - (this.options.get('targetWidth') / 2)),
- targettop = Math.round(this.canvasHeight * 0.10),
- targetheight = this.canvasHeight - (targettop * 2),
- color = this.options.get('targetColor');
- if (highlight) {
- color = this.calcHighlightColor(color, this.options);
- }
- return this.target.drawRect(x, targettop, this.options.get('targetWidth') - 1, targetheight - 1, color, color);
- },
-
- render: function () {
- var vlen = this.values.length,
- target = this.target,
- i, shape;
- if (!bullet._super.render.call(this)) {
- return;
- }
- for (i = 2; i < vlen; i++) {
- shape = this.renderRange(i).append();
- this.shapes[shape.id] = 'r' + i;
- this.valueShapes['r' + i] = shape.id;
- }
- if (this.values[1] !== null) {
- shape = this.renderPerformance().append();
- this.shapes[shape.id] = 'p1';
- this.valueShapes.p1 = shape.id;
- }
- if (this.values[0] !== null) {
- shape = this.renderTarget().append();
- this.shapes[shape.id] = 't0';
- this.valueShapes.t0 = shape.id;
- }
- target.render();
- }
- });
-
- /**
- * Pie charts
- */
- $.fn.sparkline.pie = pie = createClass($.fn.sparkline._base, {
- type: 'pie',
-
- init: function (el, values, options, width, height) {
- var total = 0, i;
-
- pie._super.init.call(this, el, values, options, width, height);
-
- this.shapes = {}; // map shape ids to value offsets
- this.valueShapes = {}; // maps value offsets to shape ids
- this.values = values = $.map(values, Number);
-
- if (options.get('width') === 'auto') {
- this.width = this.height;
- }
-
- if (values.length > 0) {
- for (i = values.length; i--;) {
- total += values[i];
- }
- }
- this.total = total;
- this.initTarget();
- this.radius = Math.floor(Math.min(this.canvasWidth, this.canvasHeight) / 2);
- },
-
- getRegion: function (el, x, y) {
- var shapeid = this.target.getShapeAt(el, x, y);
- return (shapeid !== undefined && this.shapes[shapeid] !== undefined) ? this.shapes[shapeid] : undefined;
- },
-
- getCurrentRegionFields: function () {
- var currentRegion = this.currentRegion;
- return {
- isNull: this.values[currentRegion] === undefined,
- value: this.values[currentRegion],
- percent: this.values[currentRegion] / this.total * 100,
- color: this.options.get('sliceColors')[currentRegion % this.options.get('sliceColors').length],
- offset: currentRegion
- };
- },
-
- changeHighlight: function (highlight) {
- var currentRegion = this.currentRegion,
- newslice = this.renderSlice(currentRegion, highlight),
- shapeid = this.valueShapes[currentRegion];
- delete this.shapes[shapeid];
- this.target.replaceWithShape(shapeid, newslice);
- this.valueShapes[currentRegion] = newslice.id;
- this.shapes[newslice.id] = currentRegion;
- },
-
- renderSlice: function (valuenum, highlight) {
- var target = this.target,
- options = this.options,
- radius = this.radius,
- borderWidth = options.get('borderWidth'),
- offset = options.get('offset'),
- circle = 2 * Math.PI,
- values = this.values,
- total = this.total,
- next = offset ? (2*Math.PI)*(offset/360) : 0,
- start, end, i, vlen, color;
-
- vlen = values.length;
- for (i = 0; i < vlen; i++) {
- start = next;
- end = next;
- if (total > 0) { // avoid divide by zero
- end = next + (circle * (values[i] / total));
- }
- if (valuenum === i) {
- color = options.get('sliceColors')[i % options.get('sliceColors').length];
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
-
- return target.drawPieSlice(radius, radius, radius - borderWidth, start, end, undefined, color);
- }
- next = end;
- }
- },
-
- render: function () {
- var target = this.target,
- values = this.values,
- options = this.options,
- radius = this.radius,
- borderWidth = options.get('borderWidth'),
- shape, i;
-
- if (!pie._super.render.call(this)) {
- return;
- }
- if (borderWidth) {
- target.drawCircle(radius, radius, Math.floor(radius - (borderWidth / 2)),
- options.get('borderColor'), undefined, borderWidth).append();
- }
- for (i = values.length; i--;) {
- if (values[i]) { // don't render zero values
- shape = this.renderSlice(i).append();
- this.valueShapes[i] = shape.id; // store just the shapeid
- this.shapes[shape.id] = i;
- }
- }
- target.render();
- }
- });
-
- /**
- * Box plots
- */
- $.fn.sparkline.box = box = createClass($.fn.sparkline._base, {
- type: 'box',
-
- init: function (el, values, options, width, height) {
- box._super.init.call(this, el, values, options, width, height);
- this.values = $.map(values, Number);
- this.width = options.get('width') === 'auto' ? '4.0em' : width;
- this.initTarget();
- if (!this.values.length) {
- this.disabled = 1;
- }
- },
-
- /**
- * Simulate a single region
- */
- getRegion: function () {
- return 1;
- },
-
- getCurrentRegionFields: function () {
- var result = [
- { field: 'lq', value: this.quartiles[0] },
- { field: 'med', value: this.quartiles[1] },
- { field: 'uq', value: this.quartiles[2] }
- ];
- if (this.loutlier !== undefined) {
- result.push({ field: 'lo', value: this.loutlier});
- }
- if (this.routlier !== undefined) {
- result.push({ field: 'ro', value: this.routlier});
- }
- if (this.lwhisker !== undefined) {
- result.push({ field: 'lw', value: this.lwhisker});
- }
- if (this.rwhisker !== undefined) {
- result.push({ field: 'rw', value: this.rwhisker});
- }
- return result;
- },
-
- render: function () {
- var target = this.target,
- values = this.values,
- vlen = values.length,
- options = this.options,
- canvasWidth = this.canvasWidth,
- canvasHeight = this.canvasHeight,
- minValue = options.get('chartRangeMin') === undefined ? Math.min.apply(Math, values) : options.get('chartRangeMin'),
- maxValue = options.get('chartRangeMax') === undefined ? Math.max.apply(Math, values) : options.get('chartRangeMax'),
- canvasLeft = 0,
- lwhisker, loutlier, iqr, q1, q2, q3, rwhisker, routlier, i,
- size, unitSize;
-
- if (!box._super.render.call(this)) {
- return;
- }
-
- if (options.get('raw')) {
- if (options.get('showOutliers') && values.length > 5) {
- loutlier = values[0];
- lwhisker = values[1];
- q1 = values[2];
- q2 = values[3];
- q3 = values[4];
- rwhisker = values[5];
- routlier = values[6];
- } else {
- lwhisker = values[0];
- q1 = values[1];
- q2 = values[2];
- q3 = values[3];
- rwhisker = values[4];
- }
- } else {
- values.sort(function (a, b) { return a - b; });
- q1 = quartile(values, 1);
- q2 = quartile(values, 2);
- q3 = quartile(values, 3);
- iqr = q3 - q1;
- if (options.get('showOutliers')) {
- lwhisker = rwhisker = undefined;
- for (i = 0; i < vlen; i++) {
- if (lwhisker === undefined && values[i] > q1 - (iqr * options.get('outlierIQR'))) {
- lwhisker = values[i];
- }
- if (values[i] < q3 + (iqr * options.get('outlierIQR'))) {
- rwhisker = values[i];
- }
- }
- loutlier = values[0];
- routlier = values[vlen - 1];
- } else {
- lwhisker = values[0];
- rwhisker = values[vlen - 1];
- }
- }
- this.quartiles = [q1, q2, q3];
- this.lwhisker = lwhisker;
- this.rwhisker = rwhisker;
- this.loutlier = loutlier;
- this.routlier = routlier;
-
- unitSize = canvasWidth / (maxValue - minValue + 1);
- if (options.get('showOutliers')) {
- canvasLeft = Math.ceil(options.get('spotRadius'));
- canvasWidth -= 2 * Math.ceil(options.get('spotRadius'));
- unitSize = canvasWidth / (maxValue - minValue + 1);
- if (loutlier < lwhisker) {
- target.drawCircle((loutlier - minValue) * unitSize + canvasLeft,
- canvasHeight / 2,
- options.get('spotRadius'),
- options.get('outlierLineColor'),
- options.get('outlierFillColor')).append();
- }
- if (routlier > rwhisker) {
- target.drawCircle((routlier - minValue) * unitSize + canvasLeft,
- canvasHeight / 2,
- options.get('spotRadius'),
- options.get('outlierLineColor'),
- options.get('outlierFillColor')).append();
- }
- }
-
- // box
- target.drawRect(
- Math.round((q1 - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight * 0.1),
- Math.round((q3 - q1) * unitSize),
- Math.round(canvasHeight * 0.8),
- options.get('boxLineColor'),
- options.get('boxFillColor')).append();
- // left whisker
- target.drawLine(
- Math.round((lwhisker - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight / 2),
- Math.round((q1 - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight / 2),
- options.get('lineColor')).append();
- target.drawLine(
- Math.round((lwhisker - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight / 4),
- Math.round((lwhisker - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight - canvasHeight / 4),
- options.get('whiskerColor')).append();
- // right whisker
- target.drawLine(Math.round((rwhisker - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight / 2),
- Math.round((q3 - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight / 2),
- options.get('lineColor')).append();
- target.drawLine(
- Math.round((rwhisker - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight / 4),
- Math.round((rwhisker - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight - canvasHeight / 4),
- options.get('whiskerColor')).append();
- // median line
- target.drawLine(
- Math.round((q2 - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight * 0.1),
- Math.round((q2 - minValue) * unitSize + canvasLeft),
- Math.round(canvasHeight * 0.9),
- options.get('medianColor')).append();
- if (options.get('target')) {
- size = Math.ceil(options.get('spotRadius'));
- target.drawLine(
- Math.round((options.get('target') - minValue) * unitSize + canvasLeft),
- Math.round((canvasHeight / 2) - size),
- Math.round((options.get('target') - minValue) * unitSize + canvasLeft),
- Math.round((canvasHeight / 2) + size),
- options.get('targetColor')).append();
- target.drawLine(
- Math.round((options.get('target') - minValue) * unitSize + canvasLeft - size),
- Math.round(canvasHeight / 2),
- Math.round((options.get('target') - minValue) * unitSize + canvasLeft + size),
- Math.round(canvasHeight / 2),
- options.get('targetColor')).append();
- }
- target.render();
- }
- });
-
- // Setup a very simple "virtual canvas" to make drawing the few shapes we need easier
- // This is accessible as $(foo).simpledraw()
-
- // Detect browser renderer support
- (function() {
- if (document.namespaces && !document.namespaces.v) {
- $.fn.sparkline.hasVML = true;
- document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', '#default#VML');
- } else {
- $.fn.sparkline.hasVML = false;
- }
-
- var el = document.createElement('canvas');
- $.fn.sparkline.hasCanvas = !!(el.getContext && el.getContext('2d'));
-
- })()
-
- VShape = createClass({
- init: function (target, id, type, args) {
- this.target = target;
- this.id = id;
- this.type = type;
- this.args = args;
- },
- append: function () {
- this.target.appendShape(this);
- return this;
- }
- });
-
- VCanvas_base = createClass({
- _pxregex: /(\d+)(px)?\s*$/i,
-
- init: function (width, height, target) {
- if (!width) {
- return;
- }
- this.width = width;
- this.height = height;
- this.target = target;
- this.lastShapeId = null;
- if (target[0]) {
- target = target[0];
- }
- $.data(target, '_jqs_vcanvas', this);
- },
-
- drawLine: function (x1, y1, x2, y2, lineColor, lineWidth) {
- return this.drawShape([[x1, y1], [x2, y2]], lineColor, lineWidth);
- },
-
- drawShape: function (path, lineColor, fillColor, lineWidth) {
- return this._genShape('Shape', [path, lineColor, fillColor, lineWidth]);
- },
-
- drawCircle: function (x, y, radius, lineColor, fillColor, lineWidth) {
- return this._genShape('Circle', [x, y, radius, lineColor, fillColor, lineWidth]);
- },
-
- drawPieSlice: function (x, y, radius, startAngle, endAngle, lineColor, fillColor) {
- return this._genShape('PieSlice', [x, y, radius, startAngle, endAngle, lineColor, fillColor]);
- },
-
- drawRect: function (x, y, width, height, lineColor, fillColor) {
- return this._genShape('Rect', [x, y, width, height, lineColor, fillColor]);
- },
-
- getElement: function () {
- return this.canvas;
- },
-
- /**
- * Return the most recently inserted shape id
- */
- getLastShapeId: function () {
- return this.lastShapeId;
- },
-
- /**
- * Clear and reset the canvas
- */
- reset: function () {
- alert('reset not implemented');
- },
-
- _insert: function (el, target) {
- $(target).html(el);
- },
-
- /**
- * Calculate the pixel dimensions of the canvas
- */
- _calculatePixelDims: function (width, height, canvas) {
- // XXX This should probably be a configurable option
- var match;
- match = this._pxregex.exec(height);
- if (match) {
- this.pixelHeight = match[1];
- } else {
- this.pixelHeight = $(canvas).height();
- }
- match = this._pxregex.exec(width);
- if (match) {
- this.pixelWidth = match[1];
- } else {
- this.pixelWidth = $(canvas).width();
- }
- },
-
- /**
- * Generate a shape object and id for later rendering
- */
- _genShape: function (shapetype, shapeargs) {
- var id = shapeCount++;
- shapeargs.unshift(id);
- return new VShape(this, id, shapetype, shapeargs);
- },
-
- /**
- * Add a shape to the end of the render queue
- */
- appendShape: function (shape) {
- alert('appendShape not implemented');
- },
-
- /**
- * Replace one shape with another
- */
- replaceWithShape: function (shapeid, shape) {
- alert('replaceWithShape not implemented');
- },
-
- /**
- * Insert one shape after another in the render queue
- */
- insertAfterShape: function (shapeid, shape) {
- alert('insertAfterShape not implemented');
- },
-
- /**
- * Remove a shape from the queue
- */
- removeShapeId: function (shapeid) {
- alert('removeShapeId not implemented');
- },
-
- /**
- * Find a shape at the specified x/y co-ordinates
- */
- getShapeAt: function (el, x, y) {
- alert('getShapeAt not implemented');
- },
-
- /**
- * Render all queued shapes onto the canvas
- */
- render: function () {
- alert('render not implemented');
- }
- });
-
- VCanvas_canvas = createClass(VCanvas_base, {
- init: function (width, height, target, interact) {
- VCanvas_canvas._super.init.call(this, width, height, target);
- this.canvas = document.createElement('canvas');
- if (target[0]) {
- target = target[0];
- }
- $.data(target, '_jqs_vcanvas', this);
- $(this.canvas).css({ display: 'inline-block', width: width, height: height, verticalAlign: 'top' });
- this._insert(this.canvas, target);
- this._calculatePixelDims(width, height, this.canvas);
- this.canvas.width = this.pixelWidth;
- this.canvas.height = this.pixelHeight;
- this.interact = interact;
- this.shapes = {};
- this.shapeseq = [];
- this.currentTargetShapeId = undefined;
- $(this.canvas).css({width: this.pixelWidth, height: this.pixelHeight});
- },
-
- _getContext: function (lineColor, fillColor, lineWidth) {
- var context = this.canvas.getContext('2d');
- if (lineColor !== undefined) {
- context.strokeStyle = lineColor;
- }
- context.lineWidth = lineWidth === undefined ? 1 : lineWidth;
- if (fillColor !== undefined) {
- context.fillStyle = fillColor;
- }
- return context;
- },
-
- reset: function () {
- var context = this._getContext();
- context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
- this.shapes = {};
- this.shapeseq = [];
- this.currentTargetShapeId = undefined;
- },
-
- _drawShape: function (shapeid, path, lineColor, fillColor, lineWidth) {
- var context = this._getContext(lineColor, fillColor, lineWidth),
- i, plen;
- context.beginPath();
- context.moveTo(path[0][0] + 0.5, path[0][1] + 0.5);
- for (i = 1, plen = path.length; i < plen; i++) {
- context.lineTo(path[i][0] + 0.5, path[i][1] + 0.5); // the 0.5 offset gives us crisp pixel-width lines
- }
- if (lineColor !== undefined) {
- context.stroke();
- }
- if (fillColor !== undefined) {
- context.fill();
- }
- if (this.targetX !== undefined && this.targetY !== undefined &&
- context.isPointInPath(this.targetX, this.targetY)) {
- this.currentTargetShapeId = shapeid;
- }
- },
-
- _drawCircle: function (shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
- var context = this._getContext(lineColor, fillColor, lineWidth);
- context.beginPath();
- context.arc(x, y, radius, 0, 2 * Math.PI, false);
- if (this.targetX !== undefined && this.targetY !== undefined &&
- context.isPointInPath(this.targetX, this.targetY)) {
- this.currentTargetShapeId = shapeid;
- }
- if (lineColor !== undefined) {
- context.stroke();
- }
- if (fillColor !== undefined) {
- context.fill();
- }
- },
-
- _drawPieSlice: function (shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
- var context = this._getContext(lineColor, fillColor);
- context.beginPath();
- context.moveTo(x, y);
- context.arc(x, y, radius, startAngle, endAngle, false);
- context.lineTo(x, y);
- context.closePath();
- if (lineColor !== undefined) {
- context.stroke();
- }
- if (fillColor) {
- context.fill();
- }
- if (this.targetX !== undefined && this.targetY !== undefined &&
- context.isPointInPath(this.targetX, this.targetY)) {
- this.currentTargetShapeId = shapeid;
- }
- },
-
- _drawRect: function (shapeid, x, y, width, height, lineColor, fillColor) {
- return this._drawShape(shapeid, [[x, y], [x + width, y], [x + width, y + height], [x, y + height], [x, y]], lineColor, fillColor);
- },
-
- appendShape: function (shape) {
- this.shapes[shape.id] = shape;
- this.shapeseq.push(shape.id);
- this.lastShapeId = shape.id;
- return shape.id;
- },
-
- replaceWithShape: function (shapeid, shape) {
- var shapeseq = this.shapeseq,
- i;
- this.shapes[shape.id] = shape;
- for (i = shapeseq.length; i--;) {
- if (shapeseq[i] == shapeid) {
- shapeseq[i] = shape.id;
- }
- }
- delete this.shapes[shapeid];
- },
-
- replaceWithShapes: function (shapeids, shapes) {
- var shapeseq = this.shapeseq,
- shapemap = {},
- sid, i, first;
-
- for (i = shapeids.length; i--;) {
- shapemap[shapeids[i]] = true;
- }
- for (i = shapeseq.length; i--;) {
- sid = shapeseq[i];
- if (shapemap[sid]) {
- shapeseq.splice(i, 1);
- delete this.shapes[sid];
- first = i;
- }
- }
- for (i = shapes.length; i--;) {
- shapeseq.splice(first, 0, shapes[i].id);
- this.shapes[shapes[i].id] = shapes[i];
- }
-
- },
-
- insertAfterShape: function (shapeid, shape) {
- var shapeseq = this.shapeseq,
- i;
- for (i = shapeseq.length; i--;) {
- if (shapeseq[i] === shapeid) {
- shapeseq.splice(i + 1, 0, shape.id);
- this.shapes[shape.id] = shape;
- return;
- }
- }
- },
-
- removeShapeId: function (shapeid) {
- var shapeseq = this.shapeseq,
- i;
- for (i = shapeseq.length; i--;) {
- if (shapeseq[i] === shapeid) {
- shapeseq.splice(i, 1);
- break;
- }
- }
- delete this.shapes[shapeid];
- },
-
- getShapeAt: function (el, x, y) {
- this.targetX = x;
- this.targetY = y;
- this.render();
- return this.currentTargetShapeId;
- },
-
- render: function () {
- var shapeseq = this.shapeseq,
- shapes = this.shapes,
- shapeCount = shapeseq.length,
- context = this._getContext(),
- shapeid, shape, i;
- context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
- for (i = 0; i < shapeCount; i++) {
- shapeid = shapeseq[i];
- shape = shapes[shapeid];
- this['_draw' + shape.type].apply(this, shape.args);
- }
- if (!this.interact) {
- // not interactive so no need to keep the shapes array
- this.shapes = {};
- this.shapeseq = [];
- }
- }
-
- });
-
- VCanvas_vml = createClass(VCanvas_base, {
- init: function (width, height, target) {
- var groupel;
- VCanvas_vml._super.init.call(this, width, height, target);
- if (target[0]) {
- target = target[0];
- }
- $.data(target, '_jqs_vcanvas', this);
- this.canvas = document.createElement('span');
- $(this.canvas).css({ display: 'inline-block', position: 'relative', overflow: 'hidden', width: width, height: height, margin: '0px', padding: '0px', verticalAlign: 'top'});
- this._insert(this.canvas, target);
- this._calculatePixelDims(width, height, this.canvas);
- this.canvas.width = this.pixelWidth;
- this.canvas.height = this.pixelHeight;
- groupel = '';
- this.canvas.insertAdjacentHTML('beforeEnd', groupel);
- this.group = $(this.canvas).children()[0];
- this.rendered = false;
- this.prerender = '';
- },
-
- _drawShape: function (shapeid, path, lineColor, fillColor, lineWidth) {
- var vpath = [],
- initial, stroke, fill, closed, vel, plen, i;
- for (i = 0, plen = path.length; i < plen; i++) {
- vpath[i] = '' + (path[i][0]) + ',' + (path[i][1]);
- }
- initial = vpath.splice(0, 1);
- lineWidth = lineWidth === undefined ? 1 : lineWidth;
- stroke = lineColor === undefined ? ' stroked="false" ' : ' strokeWeight="' + lineWidth + 'px" strokeColor="' + lineColor + '" ';
- fill = fillColor === undefined ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
- closed = vpath[0] === vpath[vpath.length - 1] ? 'x ' : '';
- vel = '' +
- ' ';
- return vel;
- },
-
- _drawCircle: function (shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
- var stroke, fill, vel;
- x -= radius;
- y -= radius;
- stroke = lineColor === undefined ? ' stroked="false" ' : ' strokeWeight="' + lineWidth + 'px" strokeColor="' + lineColor + '" ';
- fill = fillColor === undefined ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
- vel = '';
- return vel;
-
- },
-
- _drawPieSlice: function (shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
- var vpath, startx, starty, endx, endy, stroke, fill, vel;
- if (startAngle === endAngle) {
- return ''; // VML seems to have problem when start angle equals end angle.
- }
- if ((endAngle - startAngle) === (2 * Math.PI)) {
- startAngle = 0.0; // VML seems to have a problem when drawing a full circle that doesn't start 0
- endAngle = (2 * Math.PI);
- }
-
- startx = x + Math.round(Math.cos(startAngle) * radius);
- starty = y + Math.round(Math.sin(startAngle) * radius);
- endx = x + Math.round(Math.cos(endAngle) * radius);
- endy = y + Math.round(Math.sin(endAngle) * radius);
-
- if (startx === endx && starty === endy) {
- if ((endAngle - startAngle) < Math.PI) {
- // Prevent very small slices from being mistaken as a whole pie
- return '';
- }
- // essentially going to be the entire circle, so ignore startAngle
- startx = endx = x + radius;
- starty = endy = y;
- }
-
- if (startx === endx && starty === endy && (endAngle - startAngle) < Math.PI) {
- return '';
- }
-
- vpath = [x - radius, y - radius, x + radius, y + radius, startx, starty, endx, endy];
- stroke = lineColor === undefined ? ' stroked="false" ' : ' strokeWeight="1px" strokeColor="' + lineColor + '" ';
- fill = fillColor === undefined ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
- vel = '' +
- ' ';
- return vel;
- },
-
- _drawRect: function (shapeid, x, y, width, height, lineColor, fillColor) {
- return this._drawShape(shapeid, [[x, y], [x, y + height], [x + width, y + height], [x + width, y], [x, y]], lineColor, fillColor);
- },
-
- reset: function () {
- this.group.innerHTML = '';
- },
-
- appendShape: function (shape) {
- var vel = this['_draw' + shape.type].apply(this, shape.args);
- if (this.rendered) {
- this.group.insertAdjacentHTML('beforeEnd', vel);
- } else {
- this.prerender += vel;
- }
- this.lastShapeId = shape.id;
- return shape.id;
- },
-
- replaceWithShape: function (shapeid, shape) {
- var existing = $('#jqsshape' + shapeid),
- vel = this['_draw' + shape.type].apply(this, shape.args);
- existing[0].outerHTML = vel;
- },
-
- replaceWithShapes: function (shapeids, shapes) {
- // replace the first shapeid with all the new shapes then toast the remaining old shapes
- var existing = $('#jqsshape' + shapeids[0]),
- replace = '',
- slen = shapes.length,
- i;
- for (i = 0; i < slen; i++) {
- replace += this['_draw' + shapes[i].type].apply(this, shapes[i].args);
- }
- existing[0].outerHTML = replace;
- for (i = 1; i < shapeids.length; i++) {
- $('#jqsshape' + shapeids[i]).remove();
- }
- },
-
- insertAfterShape: function (shapeid, shape) {
- var existing = $('#jqsshape' + shapeid),
- vel = this['_draw' + shape.type].apply(this, shape.args);
- existing[0].insertAdjacentHTML('afterEnd', vel);
- },
-
- removeShapeId: function (shapeid) {
- var existing = $('#jqsshape' + shapeid);
- this.group.removeChild(existing[0]);
- },
-
- getShapeAt: function (el, x, y) {
- var shapeid = el.id.substr(8);
- return shapeid;
- },
-
- render: function () {
- if (!this.rendered) {
- // batch the intial render into a single repaint
- this.group.innerHTML = this.prerender;
- this.rendered = true;
- }
- }
- });
-
-}));
diff --git a/addons/crm/static/src/js/crm_case_section.js b/addons/crm/static/src/js/crm_case_section.js
index 2b4ca741d75..e027313d6dc 100644
--- a/addons/crm/static/src/js/crm_case_section.js
+++ b/addons/crm/static/src/js/crm_case_section.js
@@ -8,27 +8,4 @@ openerp.crm = function(openerp) {
}
},
});
-
- openerp.crm.SparklineBarWidget = openerp.web_kanban.AbstractField.extend({
- className: "oe_sparkline_bar",
- start: function() {
- var self = this;
- var title = this.$node.html();
- setTimeout(function () {
- var value = _.pluck(self.field.value, 'value');
- var tooltips = _.pluck(self.field.value, 'tooltip');
- self.$el.sparkline(value, {
- type: 'bar',
- barWidth: 5,
- tooltipFormat: '{{offset:offset}} {{value}}',
- tooltipValueLookups: {
- 'offset': tooltips
- },
- });
- self.$el.tipsy({'delayIn': 0, 'html': true, 'title': function(){return title}, 'gravity': 'n'});
- }, 0);
- },
- });
- openerp.web_kanban.fields_registry.add("sparkline_bar", "openerp.crm.SparklineBarWidget");
-
};
diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py
index e5cb2b56eb3..73fb148c0ed 100644
--- a/addons/mail/mail_mail.py
+++ b/addons/mail/mail_mail.py
@@ -63,12 +63,16 @@ class mail_mail(osv.Model):
'notification': fields.boolean('Is Notification',
help='Mail has been created to notify people of an existing mail.message'),
# Bounce and tracking
- 'opened': fields.integer(
+ 'opened': fields.datetime(
'Opened',
- help='Number of times this email has been seen, using the OpenERP tracking.'),
- 'replied': fields.integer(
- 'Reply Received',
- help='If checked, a reply to this email has been received.'),
+ help='Date when this email has been opened for the first time.'),
+ 'replied': fields.datetime(
+ 'Replied',
+ help='Date when this email has been replied for the first time.'),
+ 'bounced': fields.datetime(
+ 'Bounced',
+ help='Date when this email has bounced.'
+ ),
}
_defaults = {
@@ -103,15 +107,24 @@ class mail_mail(osv.Model):
return self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
def set_opened(self, cr, uid, ids, context=None):
- """ Increment opened counter """
+ """ Set as opened """
for mail in self.browse(cr, uid, ids, context=context):
- self.write(cr, uid, [mail.id], {'opened': (mail.opened + 1)}, context=context)
+ if not mail.opened:
+ self.write(cr, uid, [mail.id], {'opened': fields.datetime.now()}, context=context)
return True
def set_replied(self, cr, uid, ids, context=None):
- """ Increment replied counter """
+ """ Set as replied """
for mail in self.browse(cr, uid, ids, context=context):
- self.write(cr, uid, [mail.id], {'replied': (mail.replied + 1)}, context=context)
+ if not mail.replied:
+ self.write(cr, uid, [mail.id], {'replied': fields.datetime.now()}, context=context)
+ return True
+
+ def set_bounced(self, cr, uid, ids, context=None):
+ """ Set as bounced """
+ for mail in self.browse(cr, uid, ids, context=context):
+ if not mail.bounced:
+ self.write(cr, uid, [mail.id], {'bounced': fields.datetime.now()}, context=context)
return True
def process_email_queue(self, cr, uid, ids=None, context=None):
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 9943114a07a..9a5d3e3580d 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -1426,8 +1426,7 @@ class mail_thread(osv.AbstractModel):
# update original mail_mail if exists
if type == 'email':
mail_mail_ids = self.pool['mail.mail'].search(cr, SUPERUSER_ID, [('mail_message_id', '=', parent_id)], context=context)
- for mail in self.pool['mail.mail'].browse(cr, SUPERUSER_ID, mail_mail_ids, context=context):
- self.pool['mail.mail'].write(cr, SUPERUSER_ID, [mail.id], {'replied': mail.replied + 1}, context=context)
+ self.pool['mail.mail'].set_replied(cr, SUPERUSER_ID, mail_mail_ids, context=context)
message_ids = mail_message.search(cr, SUPERUSER_ID, [('id', '=', parent_id), ('parent_id', '!=', False)], context=context)
# avoid loops when finding ancestors
diff --git a/addons/mail/tests/__init__.py b/addons/mail/tests/__init__.py
index 242beb60bf1..ff075d73d73 100644
--- a/addons/mail/tests/__init__.py
+++ b/addons/mail/tests/__init__.py
@@ -19,9 +19,10 @@
#
##############################################################################
-from . import test_mail_group, test_mail_message, test_mail_features, test_mail_gateway, test_message_read, test_invite
+from . import test_mail_mail, test_mail_group, test_mail_message, test_mail_features, test_mail_gateway, test_message_read, test_invite
checks = [
+ # test_mail_mail,
test_mail_group,
test_mail_message,
test_mail_features,
diff --git a/addons/mass_mailing/__openerp__.py b/addons/mass_mailing/__openerp__.py
index e6fbb42e886..9bb5b746f63 100644
--- a/addons/mass_mailing/__openerp__.py
+++ b/addons/mass_mailing/__openerp__.py
@@ -29,10 +29,16 @@
'description': """TODO""",
'data': [
'mass_mailing_view.xml',
+ 'mass_mailing_demo.xml',
'mail_mail_view.xml',
'wizard/mail_compose_message_view.xml',
'security/ir.model.access.csv',
],
+ 'js': [],
+ 'qweb': [],
+ 'css': [
+ 'static/src/css/mass_mailing.css'
+ ],
'demo': [],
'installable': True,
'auto_install': False,
diff --git a/addons/mass_mailing/mail_mail.py b/addons/mass_mailing/mail_mail.py
index d7f46446b56..529c6c73e7b 100644
--- a/addons/mass_mailing/mail_mail.py
+++ b/addons/mass_mailing/mail_mail.py
@@ -28,8 +28,14 @@ class MailMail(osv.Model):
_inherit = ['mail.mail']
_columns = {
- 'mass_mailing_campaign_id': fields.many2one(
- 'mail.mass_mailing.campaign', 'Mass Mailing Campaign',
+ 'mass_mailing_segment_id': fields.many2one(
+ 'mail.mass_mailing.segment', 'Mass Mailing Segment',
ondelete='set null',
),
+ 'mass_mailing_campaign_id': fields.related(
+ 'mass_mailing_segment_id', 'mass_mailing_campaign_id',
+ type='many2one', ondelete='set null',
+ relation='mail.mass_mailing.campaign',
+ store=True, readonly=True,
+ ),
}
diff --git a/addons/mass_mailing/mail_mail_view.xml b/addons/mass_mailing/mail_mail_view.xml
index dd66aede66f..957ee0f6f93 100644
--- a/addons/mass_mailing/mail_mail_view.xml
+++ b/addons/mass_mailing/mail_mail_view.xml
@@ -10,6 +10,7 @@
+
diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py
index 91392759b0e..f37f86e385a 100644
--- a/addons/mass_mailing/mass_mailing.py
+++ b/addons/mass_mailing/mass_mailing.py
@@ -19,6 +19,10 @@
#
##############################################################################
+from datetime import date, datetime
+from dateutil import relativedelta
+
+from openerp import tools
from openerp.osv import osv, fields
@@ -32,33 +36,42 @@ class MassMailingCampaign(osv.Model):
""" Compute statistics of the mass mailing campaign """
results = dict.fromkeys(ids, False)
for campaign in self.browse(cr, uid, ids, context=context):
- if not campaign.mail_ids:
- results[campaign.id] = {
- 'sent': 0,
- 'opened_ratio': 0.0,
- 'replied_ratio': 0.0,
- 'bounce_ratio': 0.0,
- }
- continue
results[campaign.id] = {
'sent': len(campaign.mail_ids),
- 'opened_ratio': len([mail for mail in campaign.mail_ids if mail.opened]) * 1.0 / len(campaign.mail_ids),
- 'replied_ratio': len([mail for mail in campaign.mail_ids if mail.replied]) * 1.0 / len(campaign.mail_ids),
- 'bounce_ratio': 0.0,
+ 'opened': len([mail for mail in campaign.mail_ids if mail.opened]),
+ 'replied': len([mail for mail in campaign.mail_ids if mail.replied]),
+ 'bounced': len([mail for mail in campaign.mail_ids if mail.bounced]),
}
return results
+ def _get_segment_kanban_ids(self, cr, uid, ids, name, arg, context=None):
+ results = dict.fromkeys(ids, '')
+ for campaign in self.browse(cr, uid, ids, context=context):
+ segment_results = []
+ for segment in campaign.segment_ids:
+ segment_object = {}
+ for attr in ['name', 'sent', 'opened', 'replied', 'bounced']:
+ segment_object[attr] = getattr(segment, attr)
+ segment_results.append(segment_object)
+ results[campaign.id] = segment_results
+ return results
+
_columns = {
'name': fields.char(
'Campaign Name', required=True,
),
- 'template_id': fields.many2one(
- 'email.template', 'Email Template',
- ondelete='set null',
+ 'segment_ids': fields.one2many(
+ 'mail.mass_mailing.segment', 'mass_mailing_campaign_id',
+ 'Segments',
+ ),
+ 'segment_kanban_ids': fields.function(
+ _get_segment_kanban_ids,
+ type='text', string='Segments (kanban data)',
+ help='This field has for purpose to gather data about segment to display them in kanban view as nested kanban views is not possible currently',
),
'mail_ids': fields.one2many(
'mail.mail', 'mass_mailing_campaign_id',
- 'Send Emails',
+ 'Sent Emails',
),
# stat fields
'sent': fields.function(
@@ -66,19 +79,132 @@ class MassMailingCampaign(osv.Model):
string='Sent Emails',
type='integer', multi='_get_statistics'
),
- 'opened_ratio': fields.function(
+ 'opened': fields.function(
_get_statistics,
- string='Opened Ratio',
- type='float', multi='_get_statistics',
+ string='Opened',
+ type='integer', multi='_get_statistics',
),
- 'replied_ratio': fields.function(
+ 'replied': fields.function(
_get_statistics,
- string='Replied Ratio',
- type='float', multi='_get_statistics'
+ string='Replied',
+ type='integer', multi='_get_statistics'
),
- 'bounce_ratio': fields.function(
+ 'bounced': fields.function(
_get_statistics,
- string='Bounce Ratio',
- type='float', multi='_get_statistics'
+ string='Bounced',
+ type='integer', multi='_get_statistics'
+ ),
+ }
+
+
+class MassMailingSegment(osv.Model):
+ """ TODO """
+ _name = 'mail.mass_mailing.segment'
+ _description = 'Segment of a mass mailing campaign'
+ # number of periods for tracking mail_mail statistics
+ _period_number = 6
+
+ def __get_bar_values(self, cr, uid, obj, domain, read_fields, value_field, groupby_field, context=None):
+ """ Generic method to generate data for bar chart values using SparklineBarWidget.
+ This method performs obj.read_group(cr, uid, domain, read_fields, groupby_field).
+
+ :param obj: the target model (i.e. crm_lead)
+ :param domain: the domain applied to the read_group
+ :param list read_fields: the list of fields to read in the read_group
+ :param str value_field: the field used to compute the value of the bar slice
+ :param str groupby_field: the fields used to group
+
+ :return list section_result: a list of dicts: [
+ { 'value': (int) bar_column_value,
+ 'tootip': (str) bar_column_tooltip,
+ }
+ ]
+ """
+ month_begin = date.today().replace(day=1)
+ section_result = [{'value': 0,
+ 'tooltip': (month_begin + relativedelta.relativedelta(months=-i)).strftime('%B'),
+ } for i in range(self._period_number - 1, -1, -1)]
+ group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
+ print group_obj
+ for group in group_obj:
+ group_begin_date = datetime.strptime(group['__domain'][0][2], tools.DEFAULT_SERVER_DATE_FORMAT)
+ month_delta = relativedelta.relativedelta(month_begin, group_begin_date)
+ section_result[self._period_number - (month_delta.months + 1)] = {'value': group.get(value_field, 0), 'tooltip': group_begin_date.strftime('%B')}
+ return section_result
+
+ def _get_monthly_statistics(self, cr, uid, ids, field_name, arg, context=None):
+ """ TODO
+ """
+ obj = self.pool.get('mail.mail')
+ res = dict.fromkeys(ids, False)
+ month_begin = date.today().replace(day=1)
+ groupby_begin = (month_begin + relativedelta.relativedelta(months=-4)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
+ for id in ids:
+ res[id] = dict()
+ domain = [('mass_mailing_segment_id', '=', id), ('opened', '>=', groupby_begin)]
+ res[id]['opened_monthly'] = self.__get_bar_values(cr, uid, obj, domain, ['opened'], 'opened_count', 'opened', context=context)
+ domain = [('mass_mailing_segment_id', '=', id), ('replied', '>=', groupby_begin)]
+ res[id]['replied_monthly'] = self.__get_bar_values(cr, uid, obj, domain, ['replied'], 'replied_count', 'replied', context=context)
+ return res
+
+ def _get_statistics(self, cr, uid, ids, name, arg, context=None):
+ """ Compute statistics of the mass mailing campaign """
+ results = dict.fromkeys(ids, False)
+ for segment in self.browse(cr, uid, ids, context=context):
+ results[segment.id] = {
+ 'sent': len(segment.mail_ids),
+ 'opened': len([mail for mail in segment.mail_ids if mail.opened]),
+ 'replied': len([mail for mail in segment.mail_ids if mail.replied]),
+ 'bounced': len([mail for mail in segment.mail_ids if mail.bounced]),
+ }
+ return results
+
+ _columns = {
+ 'name': fields.char('Name', required=True),
+ 'mass_mailing_campaign_id': fields.many2one(
+ 'mail.mass_mailing.campaign', 'Mass Mailing Campaign',
+ ondelete='cascade',
+ ),
+ 'template_id': fields.many2one(
+ 'email.template', 'Email Template',
+ ondelete='set null',
+ ),
+ 'domain': fields.char('Domain'),
+ 'date': fields.datetime('Date'),
+ # mail_mail data
+ 'mail_ids': fields.one2many(
+ 'mail.mail', 'mass_mailing_segment_id',
+ 'Send Emails',
+ ),
+ 'sent': fields.function(
+ _get_statistics,
+ string='Sent Emails',
+ type='integer', multi='_get_statistics'
+ ),
+ 'opened': fields.function(
+ _get_statistics,
+ string='Opened',
+ type='integer', multi='_get_statistics',
+ ),
+ 'replied': fields.function(
+ _get_statistics,
+ string='Replied',
+ type='integer', multi='_get_statistics'
+ ),
+ 'bounced': fields.function(
+ _get_statistics,
+ string='Bounce',
+ type='integer', multi='_get_statistics'
+ ),
+ # monthly ratio
+ 'opened_monthly': fields.function(
+ _get_monthly_statistics,
+ string='Sent Emails',
+ type='char', multi='_get_monthly_statistics',
+ ),
+ 'replied_monthly': fields.function(
+ _get_monthly_statistics,
+ string='Replied',
+ type='char', multi='_get_monthly_statistics',
),
}
diff --git a/addons/mass_mailing/mass_mailing_demo.xml b/addons/mass_mailing/mass_mailing_demo.xml
new file mode 100644
index 00000000000..3e04baf7cef
--- /dev/null
+++ b/addons/mass_mailing/mass_mailing_demo.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+ Partner Newsletter 1
+
+
+ ${object.id}
+ Hello]]>
+
+
+ Partner Newsletter 2
+
+
+ ${object.id}
+ Hello]]>
+
+
+
+ Partners Newsletter
+
+
+
+ First Newsletter
+
+
+
+
+
+ Second Newsletter
+
+
+
+
+
+
+
+
+
+ sent
+
+
+
+
+
+ sent
+
+
+
+
+ sent
+
+
+
+ sent
+
+
+
+
+ sent
+
+
+
+
+
+ sent
+
+
+
+
+ sent
+
+
+
+ sent
+
+
+
+
diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml
index bc28827343d..b847a89db53 100644
--- a/addons/mass_mailing/mass_mailing_view.xml
+++ b/addons/mass_mailing/mass_mailing_view.xml
@@ -3,7 +3,7 @@
-
+ mail.mass_mailing.campaign.treemail.mass_mailing.campaign10
@@ -14,7 +14,7 @@
-
+ mail.mass_mailing.campaign.formmail.mass_mailing.campaign
@@ -22,27 +22,188 @@
-
-
-
-
+
+
+
+
+
+
+ mail.mass_mailing.campaign.kanban
+ mail.mass_mailing.campaign
+
+
+
+
+
+
+
From 68f9b63c73823514602429df9c6a1d7b5851d725 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 3 Sep 2013 17:25:53 +0200
Subject: [PATCH 029/175] [IMP] mass_mailing: added fields on segment form view
+ rules for segment model
bzr revid: tde@openerp.com-20130903152553-y0s4jhqagu0ff92m
---
addons/mass_mailing/mass_mailing_view.xml | 13 +++++++++----
addons/mass_mailing/security/ir.model.access.csv | 4 +++-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml
index c85bb136bd3..ab421dda881 100644
--- a/addons/mass_mailing/mass_mailing_view.xml
+++ b/addons/mass_mailing/mass_mailing_view.xml
@@ -116,10 +116,15 @@
diff --git a/addons/mass_mailing/security/ir.model.access.csv b/addons/mass_mailing/security/ir.model.access.csv
index af6eaa7bb06..54f3413e9f1 100644
--- a/addons/mass_mailing/security/ir.model.access.csv
+++ b/addons/mass_mailing/security/ir.model.access.csv
@@ -1,3 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_mass_mailing_campaign,mail.mass_mailing.campaign.template,model_mail_mass_mailing_campaign,,1,1,1,0
+access_mass_mailing_campaign,mail.mass_mailing.campaign,model_mail_mass_mailing_campaign,,1,1,1,0
access_mass_mailing_campaign_system,mail.mass_mailing.campaign.system,model_mail_mass_mailing_campaign,base.group_system,1,1,1,1
+access_mass_mailing_segment,mail.mass_mailing.segment,model_mail_mass_mailing_segment,,1,1,1,0
+access_mass_mailing_segment_system,mail.mass_mailing.segment.system,model_mail_mass_mailing_segment,base.group_system,1,1,1,1
\ No newline at end of file
From 20ba3bd349647750452e35703dc78c0869957ed5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Fri, 6 Sep 2013 12:05:54 +0200
Subject: [PATCH 030/175] [IMP] crm, mass_mailing, sale_crm: added dependencies
to web_kanban_gauge/sparkline newly introduced modules
bzr revid: tde@openerp.com-20130906100554-vcg4rux2f5omyq3t
---
addons/crm/__openerp__.py | 3 ++-
addons/mass_mailing/__openerp__.py | 7 ++++++-
addons/mass_mailing/mass_mailing_view.xml | 4 ----
addons/sale_crm/__openerp__.py | 2 +-
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py
index ae9da7ade08..176186f016c 100644
--- a/addons/crm/__openerp__.py
+++ b/addons/crm/__openerp__.py
@@ -57,7 +57,8 @@ Dashboard for CRM will include:
'base_calendar',
'resource',
'board',
- 'fetchmail'
+ 'fetchmail',
+ 'web_kanban_sparkline',
],
'data': [
'crm_data.xml',
diff --git a/addons/mass_mailing/__openerp__.py b/addons/mass_mailing/__openerp__.py
index 9bb5b746f63..147b9bea89c 100644
--- a/addons/mass_mailing/__openerp__.py
+++ b/addons/mass_mailing/__openerp__.py
@@ -25,7 +25,12 @@
'author': 'OpenERP',
'website': 'http://www.openerp.com',
'category': 'Marketing',
- 'depends': ['mail', 'email_template'],
+ 'depends': [
+ 'mail',
+ 'email_template',
+ 'web_kanban_gauge',
+ 'web_kanban_sparkline',
+ ],
'description': """TODO""",
'data': [
'mass_mailing_view.xml',
diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml
index ab421dda881..4a3c2b5db07 100644
--- a/addons/mass_mailing/mass_mailing_view.xml
+++ b/addons/mass_mailing/mass_mailing_view.xml
@@ -193,10 +193,6 @@
kanban,tree,form
-
-
-
diff --git a/addons/sale_crm/__openerp__.py b/addons/sale_crm/__openerp__.py
index 0cc4ad3fad2..7a57484eab8 100644
--- a/addons/sale_crm/__openerp__.py
+++ b/addons/sale_crm/__openerp__.py
@@ -37,7 +37,7 @@ modules.
'author': 'OpenERP SA',
'website': 'http://www.openerp.com',
'images': ['images/crm_statistics_dashboard.jpeg', 'images/opportunity_to_quote.jpeg'],
- 'depends': ['sale', 'crm'],
+ 'depends': ['sale', 'crm', 'web_kanban_gauge'],
'data': [
'wizard/crm_make_sale_view.xml',
'sale_crm_view.xml',
From cd63d4d21a171c0c35e593cd04631ad25f8e1d1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Fri, 6 Sep 2013 12:33:25 +0200
Subject: [PATCH 031/175] [ADD] mass_mailing: added directories + skeletons for
doc and tests
bzr revid: tde@openerp.com-20130906103325-e15fmq49puldcwu3
---
addons/mass_mailing/doc/changelog.rst | 9 ++++++++
addons/mass_mailing/doc/index.rst | 13 ++++++++++++
addons/mass_mailing/tests/__init__.py | 26 +++++++++++++++++++++++
addons/mass_mailing/tests/test_mail.py | 29 ++++++++++++++++++++++++++
4 files changed, 77 insertions(+)
create mode 100644 addons/mass_mailing/doc/changelog.rst
create mode 100644 addons/mass_mailing/doc/index.rst
create mode 100644 addons/mass_mailing/tests/__init__.py
create mode 100644 addons/mass_mailing/tests/test_mail.py
diff --git a/addons/mass_mailing/doc/changelog.rst b/addons/mass_mailing/doc/changelog.rst
new file mode 100644
index 00000000000..a000c4ae396
--- /dev/null
+++ b/addons/mass_mailing/doc/changelog.rst
@@ -0,0 +1,9 @@
+.. _changelog:
+
+Changelog
+=========
+
+`trunk (saas-2)`
+----------------
+
+ - added module
\ No newline at end of file
diff --git a/addons/mass_mailing/doc/index.rst b/addons/mass_mailing/doc/index.rst
new file mode 100644
index 00000000000..3d991c7d9dd
--- /dev/null
+++ b/addons/mass_mailing/doc/index.rst
@@ -0,0 +1,13 @@
+Mass Mailing module documentation
+=================================
+
+Mass Mailing documentation topics
+'''''''''''''''''''''''''''''''''
+
+Changelog
+'''''''''
+
+.. toctree::
+ :maxdepth: 1
+
+ changelog.rst
diff --git a/addons/mass_mailing/tests/__init__.py b/addons/mass_mailing/tests/__init__.py
new file mode 100644
index 00000000000..f8610905393
--- /dev/null
+++ b/addons/mass_mailing/tests/__init__.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Business Applications
+# Copyright (C) 2013-Today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+from openerp.addons.mass_mailing.tests import test_mail
+
+checks = [
+ test_mail,
+]
diff --git a/addons/mass_mailing/tests/test_mail.py b/addons/mass_mailing/tests/test_mail.py
new file mode 100644
index 00000000000..0e3b4b8608e
--- /dev/null
+++ b/addons/mass_mailing/tests/test_mail.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Business Applications
+# Copyright (C) 2013-Today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp.addons.mail.tests.common import TestMail
+
+
+class test_message_compose(TestMail):
+
+ def test_OO_mail_mail_tracking(self):
+ """ Tests designed for mail_mail tracking (opened, replied, bounced) """
+ pass
From 12580e690aea8b9ea3a4862e547cf30e323c683a Mon Sep 17 00:00:00 2001
From: Antony Lesuisse
Date: Sun, 8 Sep 2013 19:35:35 +0200
Subject: [PATCH 032/175] [IMP] openerp threaded, gevent, prefork service
cleanup - unify signal handling - unify start and stop no new feature yet, it
paves the way for - developement mode auto reload - graceful restart on HUP -
multiprocessing and gevent on windows
bzr revid: al@openerp.com-20130908173535-xomt5w7xmqtwkmyy
---
openerp-long-polling | 11 --
openerp/__init__.py | 11 +-
openerp/cli/server.py | 120 +------------
openerp/service/__init__.py | 116 +------------
openerp/service/cron.py | 76 --------
openerp/service/workers.py | 309 +++++++++++++++++++++++++++++++--
openerp/service/wsgi_server.py | 66 -------
7 files changed, 317 insertions(+), 392 deletions(-)
delete mode 100755 openerp-long-polling
delete mode 100644 openerp/service/cron.py
diff --git a/openerp-long-polling b/openerp-long-polling
deleted file mode 100755
index 304cd01c1ee..00000000000
--- a/openerp-long-polling
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-
-import gevent.monkey
-gevent.monkey.patch_all()
-import gevent_psycopg2
-gevent_psycopg2.monkey_patch()
-
-import openerp
-
-if __name__ == "__main__":
- openerp.cli.main()
diff --git a/openerp/__init__.py b/openerp/__init__.py
index 22c8c98256a..161b06b0990 100644
--- a/openerp/__init__.py
+++ b/openerp/__init__.py
@@ -27,9 +27,16 @@ import sys
# Is the server running with gevent.
evented = False
-if sys.modules.get("gevent") is not None:
- evented = True
+for i in sys.argv:
+ if i.startswith('--gevent'):
+ evented = True
+ break
+if evented:
+ import gevent.monkey
+ gevent.monkey.patch_all()
+ import gevent_psycopg2
+ gevent_psycopg2.monkey_patch()
# Make sure the OpenERP server runs in UTC. This is especially necessary
# under Windows as under Linux it seems the real import of time is
diff --git a/openerp/cli/server.py b/openerp/cli/server.py
index fc1bf61b617..0c081b6156b 100644
--- a/openerp/cli/server.py
+++ b/openerp/cli/server.py
@@ -147,112 +147,15 @@ def import_translation():
cr.commit()
cr.close()
-# Variable keeping track of the number of calls to the signal handler defined
-# below. This variable is monitored by ``quit_on_signals()``.
-quit_signals_received = 0
-
-def signal_handler(sig, frame):
- """ Signal handler: exit ungracefully on the second handled signal.
-
- :param sig: the signal number
- :param frame: the interrupted stack frame or None
- """
- global quit_signals_received
- quit_signals_received += 1
- if quit_signals_received > 1:
- # logging.shutdown was already called at this point.
- sys.stderr.write("Forced shutdown.\n")
- os._exit(0)
-
-def dumpstacks(sig, frame):
- """ Signal handler: dump a stack trace for each existing thread."""
- # code from http://stackoverflow.com/questions/132058/getting-stack-trace-from-a-running-python-application#answer-2569696
- # modified for python 2.5 compatibility
- threads_info = dict([(th.ident, {'name': th.name,
- 'uid': getattr(th,'uid','n/a')})
- for th in threading.enumerate()])
- code = []
- for threadId, stack in sys._current_frames().items():
- thread_info = threads_info.get(threadId)
- code.append("\n# Thread: %s (id:%s) (uid:%s)" % \
- (thread_info and thread_info['name'] or 'n/a',
- threadId,
- thread_info and thread_info['uid'] or 'n/a'))
- for filename, lineno, name, line in traceback.extract_stack(stack):
- code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
- if line:
- code.append(" %s" % (line.strip()))
- _logger.info("\n".join(code))
-
-def setup_signal_handlers(signal_handler):
- """ Register the given signal handler. """
- SIGNALS = (signal.SIGINT, signal.SIGTERM)
- if os.name == 'posix':
- map(lambda sig: signal.signal(sig, signal_handler), SIGNALS)
- signal.signal(signal.SIGQUIT, dumpstacks)
- elif os.name == 'nt':
- import win32api
- win32api.SetConsoleCtrlHandler(lambda sig: signal_handler(sig, None), 1)
-
-def quit_on_signals():
- """ Wait for one or two signals then shutdown the server.
-
- The first SIGINT or SIGTERM signal will initiate a graceful shutdown while
- a second one if any will force an immediate exit.
-
- """
- # Wait for a first signal to be handled. (time.sleep will be interrupted
- # by the signal handler.) The try/except is for the win32 case.
- try:
- while quit_signals_received == 0:
- time.sleep(60)
- except KeyboardInterrupt:
- pass
-
- config = openerp.tools.config
- openerp.service.stop_services()
-
- if getattr(openerp, 'phoenix', False):
- # like the phoenix, reborn from ashes...
- openerp.service._reexec()
- return
-
- if config['pidfile']:
- os.unlink(config['pidfile'])
- sys.exit(0)
-
-def watch_parent(beat=4):
- import gevent
- ppid = os.getppid()
- while True:
- if ppid != os.getppid():
- pid = os.getpid()
- _logger.info("LongPolling (%s) Parent changed", pid)
- # suicide !!
- os.kill(pid, signal.SIGTERM)
- return
- gevent.sleep(beat)
-
def main(args):
check_root_user()
openerp.tools.config.parse_config(args)
-
- if openerp.tools.config.options["gevent"]:
- openerp.evented = True
- _logger.info('Using gevent mode')
- import gevent.monkey
- gevent.monkey.patch_all()
- import gevent_psycopg2
- gevent_psycopg2.monkey_patch()
-
check_postgres_user()
openerp.netsvc.init_logger()
report_configuration()
config = openerp.tools.config
- setup_signal_handlers(signal_handler)
-
if config["test_file"]:
run_test_file(config['db_name'], config['test_file'])
sys.exit(0)
@@ -265,28 +168,19 @@ def main(args):
import_translation()
sys.exit(0)
- if not config["stop_after_init"]:
- setup_pid_file()
- # Some module register themselves when they are loaded so we need the
- # services to be running before loading any registry.
- if not openerp.evented:
- if config['workers']:
- openerp.service.start_services_workers()
- else:
- openerp.service.start_services()
- else:
- config['xmlrpc_port'] = config['longpolling_port']
- import gevent
- gevent.spawn(watch_parent)
- openerp.service.start_services()
-
+ # preload registryies, needed for -u --stop_after_init
rc = 0
if config['db_name']:
for dbname in config['db_name'].split(','):
if not preload_registry(dbname):
rc += 1
- if config["stop_after_init"]:
+ if not config["stop_after_init"]:
+ setup_pid_file()
+ openerp.service.workers.start()
+ if config['pidfile']:
+ os.unlink(config['pidfile'])
+ else:
sys.exit(rc)
_logger.info('OpenERP server is running, waiting for connections...')
diff --git a/openerp/service/__init__.py b/openerp/service/__init__.py
index 2c6c80eb80c..02401d455e1 100644
--- a/openerp/service/__init__.py
+++ b/openerp/service/__init__.py
@@ -20,29 +20,12 @@
#
##############################################################################
-import logging
-import os
-import signal
-import subprocess
-import sys
-import threading
-import time
-
-import cron
-import wsgi_server
-
-import openerp
-import openerp.modules
-import openerp.netsvc
-import openerp.osv
-from openerp.release import nt_service_name
-import openerp.tools
-from openerp.tools.misc import stripped_sys_argv
-
import common
import db
import model
import report
+import wsgi_server
+import workers
#.apidoc title: RPC Services
@@ -55,100 +38,5 @@ import report
low-level behavior of the wire.
"""
-_logger = logging.getLogger(__name__)
-
-def load_server_wide_modules():
- for m in openerp.conf.server_wide_modules:
- try:
- openerp.modules.module.load_openerp_module(m)
- except Exception:
- msg = ''
- if m == 'web':
- msg = """
-The `web` module is provided by the addons found in the `openerp-web` project.
-Maybe you forgot to add those addons in your addons_path configuration."""
- _logger.exception('Failed to load server-wide module `%s`.%s', m, msg)
-
-start_internal_done = False
-main_thread_id = threading.currentThread().ident
-
-def start_internal():
- global start_internal_done
- if start_internal_done:
- return
- openerp.netsvc.init_logger()
-
- load_server_wide_modules()
- start_internal_done = True
-
-def start_services():
- """ Start all services including http, and cron """
- start_internal()
- # Start the WSGI server.
- wsgi_server.start_service()
- # Start the main cron thread.
- if not openerp.evented:
- cron.start_service()
-
-def stop_services():
- """ Stop all services. """
- # stop services
- if not openerp.evented:
- cron.stop_service()
- wsgi_server.stop_service()
-
- _logger.info("Initiating shutdown")
- _logger.info("Hit CTRL-C again or send a second signal to force the shutdown.")
-
- # Manually join() all threads before calling sys.exit() to allow a second signal
- # to trigger _force_quit() in case some non-daemon threads won't exit cleanly.
- # threading.Thread.join() should not mask signals (at least in python 2.5).
- me = threading.currentThread()
- _logger.debug('current thread: %r', me)
- for thread in threading.enumerate():
- _logger.debug('process %r (%r)', thread, thread.isDaemon())
- if thread != me and not thread.isDaemon() and thread.ident != main_thread_id:
- while thread.isAlive():
- _logger.debug('join and sleep')
- # Need a busyloop here as thread.join() masks signals
- # and would prevent the forced shutdown.
- thread.join(0.05)
- time.sleep(0.05)
-
- _logger.debug('--')
- openerp.modules.registry.RegistryManager.delete_all()
- logging.shutdown()
-
-def start_services_workers():
- import openerp.service.workers
- openerp.multi_process = True
- openerp.service.workers.Multicorn(openerp.service.wsgi_server.application).run()
-
-def _reexec():
- """reexecute openerp-server process with (nearly) the same arguments"""
- if openerp.tools.osutil.is_running_as_nt_service():
- subprocess.call('net stop {0} && net start {0}'.format(nt_service_name), shell=True)
- exe = os.path.basename(sys.executable)
- args = stripped_sys_argv()
- if not args or args[0] != exe:
- args.insert(0, exe)
- os.execv(sys.executable, args)
-
-def restart_server():
- if openerp.multi_process:
- raise NotImplementedError("Multicorn is not supported (but gunicorn was)")
- pid = openerp.wsgi.core.arbiter_pid
- os.kill(pid, signal.SIGHUP)
- else:
- if os.name == 'nt':
- def reborn():
- stop_services()
- _reexec()
-
- # run in a thread to let the current thread return response to the caller.
- threading.Thread(target=reborn).start()
- else:
- openerp.phoenix = True
- os.kill(os.getpid(), signal.SIGINT)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/service/cron.py b/openerp/service/cron.py
deleted file mode 100644
index f21b27f7fea..00000000000
--- a/openerp/service/cron.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2011 OpenERP SA ()
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-""" Cron jobs scheduling
-
-Cron jobs are defined in the ir_cron table/model. This module deals with all
-cron jobs, for all databases of a single OpenERP server instance.
-
-"""
-
-import logging
-import threading
-import time
-from datetime import datetime
-
-import openerp
-
-_logger = logging.getLogger(__name__)
-
-SLEEP_INTERVAL = 60 # 1 min
-
-def cron_runner(number):
- while True:
- time.sleep(SLEEP_INTERVAL + number) # Steve Reich timing style
- registries = openerp.modules.registry.RegistryManager.registries
- _logger.debug('cron%d polling for jobs', number)
- for db_name, registry in registries.items():
- while True and registry.ready:
- acquired = openerp.addons.base.ir.ir_cron.ir_cron._acquire_job(db_name)
- if not acquired:
- break
-
-def start_service():
- """ Start the above runner function in a daemon thread.
-
- The thread is a typical daemon thread: it will never quit and must be
- terminated when the main process exits - with no consequence (the processing
- threads it spawns are not marked daemon).
-
- """
-
- # Force call to strptime just before starting the cron thread
- # to prevent time.strptime AttributeError within the thread.
- # See: http://bugs.python.org/issue7980
- datetime.strptime('2012-01-01', '%Y-%m-%d')
-
- for i in range(openerp.tools.config['max_cron_threads']):
- def target():
- cron_runner(i)
- t = threading.Thread(target=target, name="openerp.service.cron.cron%d" % i)
- t.setDaemon(True)
- t.start()
- _logger.debug("cron%d started!" % i)
-
-def stop_service():
- pass
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/service/workers.py b/openerp/service/workers.py
index c8b8b84bca2..382d581720f 100644
--- a/openerp/service/workers.py
+++ b/openerp/service/workers.py
@@ -1,7 +1,7 @@
#-----------------------------------------------------------
-# Multicorn, multiprocessing inspired by gunicorn
-# TODO rename class: Multicorn -> Arbiter ?
+# Threaded, Gevent and Prefork Servers
#-----------------------------------------------------------
+import datetime
import errno
import fcntl
import logging
@@ -13,10 +13,14 @@ import select
import signal
import socket
import sys
+import threading
import time
+import traceback
import subprocess
import os.path
+import wsgi_server
+
import werkzeug.serving
try:
from setproctitle import setproctitle
@@ -25,11 +29,238 @@ except ImportError:
import openerp
import openerp.tools.config as config
+from openerp.release import nt_service_name
from openerp.tools.misc import stripped_sys_argv
_logger = logging.getLogger(__name__)
-class Multicorn(object):
+SLEEP_INTERVAL = 60 # 1 min
+
+#----------------------------------------------------------
+# Common
+#----------------------------------------------------------
+
+class CommonServer(object):
+ def __init__(self, app):
+ # TODO Change the xmlrpc_* options to http_*
+ self.app = app
+ # config
+ self.interface = config['xmlrpc_interface'] or '0.0.0.0'
+ self.port = config['xmlrpc_port']
+ # runtime
+ self.pid = os.getpid()
+
+ def dumpstacks(self):
+ """ Signal handler: dump a stack trace for each existing thread."""
+ # code from http://stackoverflow.com/questions/132058/getting-stack-trace-from-a-running-python-application#answer-2569696
+ # modified for python 2.5 compatibility
+ threads_info = dict([(th.ident, {'name': th.name,
+ 'uid': getattr(th,'uid','n/a')})
+ for th in threading.enumerate()])
+ code = []
+ for threadId, stack in sys._current_frames().items():
+ thread_info = threads_info.get(threadId)
+ code.append("\n# Thread: %s (id:%s) (uid:%s)" % \
+ (thread_info and thread_info['name'] or 'n/a',
+ threadId,
+ thread_info and thread_info['uid'] or 'n/a'))
+ for filename, lineno, name, line in traceback.extract_stack(stack):
+ code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
+ if line:
+ code.append(" %s" % (line.strip()))
+ _logger.info("\n".join(code))
+
+ def close_socket(self, sock):
+ """ Closes a socket instance cleanly
+ :param sock: the network socket to close
+ :type sock: socket.socket
+ """
+ try:
+ sock.shutdown(socket.SHUT_RDWR)
+ except socket.error, e:
+ # On OSX, socket shutdowns both sides if any side closes it
+ # causing an error 57 'Socket is not connected' on shutdown
+ # of the other side (or something), see
+ # http://bugs.python.org/issue4397
+ # note: stdlib fixed test, not behavior
+ if e.errno != errno.ENOTCONN or platform.system() not in ['Darwin', 'Windows']:
+ raise
+ sock.close()
+
+#----------------------------------------------------------
+# Threaded
+#----------------------------------------------------------
+
+class ThreadedServer(CommonServer):
+ def __init__(self, app):
+ super(ThreadedServer, self).__init__(app)
+ self.main_thread_id = threading.currentThread().ident
+ # Variable keeping track of the number of calls to the signal handler defined
+ # below. This variable is monitored by ``quit_on_signals()``.
+ self.quit_signals_received = 0
+
+ #self.socket = None
+ #self.queue = []
+ self.httpd = None
+
+ def signal_handler(self, sig, frame):
+ if sig in [signal.SIGINT,signal.SIGTERM]:
+ # shutdown on kill -INT or -TERM
+ self.quit_signals_received += 1
+ if self.quit_signals_received > 1:
+ # logging.shutdown was already called at this point.
+ sys.stderr.write("Forced shutdown.\n")
+ os._exit(0)
+ elif sig == signal.SIGHUP:
+ # restart on kill -HUP
+ openerp.phoenix = True
+ self.quit_signals_received += 1
+ elif sig == signal.SIGQUIT:
+ # dump stacks on kill -3
+ self.dumpstacks()
+
+ def cron_thread(self, number):
+ while True:
+ time.sleep(SLEEP_INTERVAL + number) # Steve Reich timing style
+ registries = openerp.modules.registry.RegistryManager.registries
+ _logger.debug('cron%d polling for jobs', number)
+ for db_name, registry in registries.items():
+ while True and registry.ready:
+ acquired = openerp.addons.base.ir.ir_cron.ir_cron._acquire_job(db_name)
+ if not acquired:
+ break
+
+ def cron_spawn(self):
+ """ Start the above runner function in a daemon thread.
+
+ The thread is a typical daemon thread: it will never quit and must be
+ terminated when the main process exits - with no consequence (the processing
+ threads it spawns are not marked daemon).
+
+ """
+ # Force call to strptime just before starting the cron thread
+ # to prevent time.strptime AttributeError within the thread.
+ # See: http://bugs.python.org/issue7980
+ datetime.datetime.strptime('2012-01-01', '%Y-%m-%d')
+ for i in range(openerp.tools.config['max_cron_threads']):
+ def target():
+ self.cron_thread(i)
+ t = threading.Thread(target=target, name="openerp.service.cron.cron%d" % i)
+ t.setDaemon(True)
+ t.start()
+ _logger.debug("cron%d started!" % i)
+
+ def http_thread(self):
+ self.httpd = werkzeug.serving.make_server(self.interface, self.port, self.app, threaded=True)
+ self.httpd.serve_forever()
+
+ def http_spawn(self):
+ threading.Thread(target=self.http_thread).start()
+ _logger.info('HTTP service (werkzeug) running on %s:%s', self.interface, self.port)
+
+ def start(self):
+ _logger.debug("Setting signal handlers")
+ if os.name == 'posix':
+ signal.signal(signal.SIGINT, self.signal_handler)
+ signal.signal(signal.SIGTERM, self.signal_handler)
+ signal.signal(signal.SIGCHLD, self.signal_handler)
+ signal.signal(signal.SIGHUP, self.signal_handler)
+ signal.signal(signal.SIGQUIT, self.signal_handler)
+ elif os.name == 'nt':
+ import win32api
+ win32api.SetConsoleCtrlHandler(lambda sig: signal_handler(sig, None), 1)
+ self.cron_spawn()
+ self.http_spawn()
+
+ def stop(self):
+ """ Shutdown the WSGI server. Wait for non deamon threads.
+ """
+ _logger.info("Initiating shutdown")
+ _logger.info("Hit CTRL-C again or send a second signal to force the shutdown.")
+
+ self.httpd.shutdown()
+ self.close_socket(self.httpd.socket)
+
+ # Manually join() all threads before calling sys.exit() to allow a second signal
+ # to trigger _force_quit() in case some non-daemon threads won't exit cleanly.
+ # threading.Thread.join() should not mask signals (at least in python 2.5).
+ me = threading.currentThread()
+ _logger.debug('current thread: %r', me)
+ for thread in threading.enumerate():
+ _logger.debug('process %r (%r)', thread, thread.isDaemon())
+ if thread != me and not thread.isDaemon() and thread.ident != main_thread_id:
+ while thread.isAlive():
+ _logger.debug('join and sleep')
+ # Need a busyloop here as thread.join() masks signals
+ # and would prevent the forced shutdown.
+ thread.join(0.05)
+ time.sleep(0.05)
+
+ _logger.debug('--')
+ openerp.modules.registry.RegistryManager.delete_all()
+ logging.shutdown()
+
+ def run(self):
+ """ Start the http server and the cron thread then wait for a signal.
+
+ The first SIGINT or SIGTERM signal will initiate a graceful shutdown while
+ a second one if any will force an immediate exit.
+ """
+ self.start()
+
+ # Wait for a first signal to be handled. (time.sleep will be interrupted
+ # by the signal handler.) The try/except is for the win32 case.
+ try:
+ while self.quit_signals_received == 0:
+ time.sleep(60)
+ except KeyboardInterrupt:
+ pass
+
+ self.stop()
+
+#----------------------------------------------------------
+# Gevent
+#----------------------------------------------------------
+
+class GeventServer(CommonServer):
+ def __init__(self, app):
+ super(GeventServer, self).__init__(app)
+ self.port = config['longpolling_port']
+ self.httpd = None
+
+ def watch_parent(self, beat=4):
+ import gevent
+ ppid = os.getppid()
+ while True:
+ if ppid != os.getppid():
+ pid = os.getpid()
+ _logger.info("LongPolling (%s) Parent changed", pid)
+ # suicide !!
+ os.kill(pid, signal.SIGTERM)
+ return
+ gevent.sleep(beat)
+
+ def start(self):
+ import gevent
+ from gevent.wsgi import WSGIServer
+ gevent.spawn(self.watch_parent)
+ self.httpd = WSGIServer((self.interface, self.port), self.app)
+ self.httpd.serve_forever()
+
+ def stop(self):
+ import gevent
+ self.httpd.stop()
+ gevent.shutdown()
+
+ def run(self):
+ self.start()
+ self.stop()
+
+#----------------------------------------------------------
+# Prefork
+#----------------------------------------------------------
+
+class Multicorn(CommonServer):
""" Multiprocessing inspired by (g)unicorn.
Multicorn currently uses accept(2) as dispatching method between workers
but we plan to replace it by a more intelligent dispatcher to will parse
@@ -92,10 +323,8 @@ class Multicorn(object):
sys.exit(0)
def long_polling_spawn(self):
- nargs = stripped_sys_argv('--pidfile')
- cmd = nargs[0]
- cmd = os.path.join(os.path.dirname(cmd), "openerp-long-polling")
- nargs[0] = cmd
+ nargs = stripped_sys_argv('--pidfile','--workers')
+ nargs += ['--gevent']
popen = subprocess.Popen(nargs)
self.long_polling_pid = popen.pid
@@ -122,6 +351,13 @@ class Multicorn(object):
sig = self.queue.pop(0)
if sig in [signal.SIGINT,signal.SIGTERM]:
raise KeyboardInterrupt
+ elif sig == signal.SIGHUP:
+ # restart on kill -HUP
+ openerp.phoenix = True
+ raise KeyboardInterrupt
+ elif sig == signal.SIGQUIT:
+ # dump stacks on kill -3
+ self.dumpstacks()
def process_zombie(self):
# reap dead workers
@@ -211,7 +447,6 @@ class Multicorn(object):
for pid in self.workers.keys():
self.worker_kill(pid, signal.SIGTERM)
self.socket.close()
- openerp.cli.server.quit_signals_received = 1
def run(self):
self.start()
@@ -389,7 +624,7 @@ class WorkerCron(Worker):
def sleep(self):
# Really sleep once all the databases have been processed.
if self.db_index == 0:
- interval = 60 + self.pid % 10 # chorus effect
+ interval = SLEEP_INTERVAL + self.pid % 10 # chorus effect
time.sleep(interval)
def _db_list(self):
@@ -437,12 +672,66 @@ class WorkerCron(Worker):
os.nice(10) # mommy always told me to be nice with others...
Worker.start(self)
self.multi.socket.close()
- openerp.service.start_internal()
# chorus effect: make cron workers do not all start at first database
mct = config['max_cron_threads']
p = float(self.pid % mct) / mct
self.db_index = int(len(self._db_list()) * p)
+#----------------------------------------------------------
+# start/stop public api
+#----------------------------------------------------------
+
+server = None
+
+def load_server_wide_modules():
+ for m in openerp.conf.server_wide_modules:
+ try:
+ openerp.modules.module.load_openerp_module(m)
+ except Exception:
+ msg = ''
+ if m == 'web':
+ msg = """
+The `web` module is provided by the addons found in the `openerp-web` project.
+Maybe you forgot to add those addons in your addons_path configuration."""
+ _logger.exception('Failed to load server-wide module `%s`.%s', m, msg)
+
+def _reexec():
+ """reexecute openerp-server process with (nearly) the same arguments"""
+ if openerp.tools.osutil.is_running_as_nt_service():
+ subprocess.call('net stop {0} && net start {0}'.format(nt_service_name), shell=True)
+ exe = os.path.basename(sys.executable)
+ args = stripped_sys_argv()
+ if not args or args[0] != exe:
+ args.insert(0, exe)
+ os.execv(sys.executable, args)
+
+def start():
+ """ Start the openerp http server and cron processor.
+ """
+ load_server_wide_modules()
+ if config['workers']:
+ openerp.multi_process = True
+ server = Multicorn(openerp.service.wsgi_server.application)
+ elif openerp.evented:
+ server = GeventServer(openerp.service.wsgi_server.application)
+ else:
+ server = ThreadedServer(openerp.service.wsgi_server.application)
+ server.run()
+
+ # like the legend of the phoenix, all ends with beginnings
+ if getattr(openerp, 'phoenix', False):
+ _reexec()
+ sys.exit(0)
+
+def restart_server():
+ """ Restart the server
+ """
+ if os.name == 'nt':
+ # run in a thread to let the current thread return response to the caller.
+ threading.Thread(target=_reexec).start()
+ else:
+ os.kill(server.pid, signal.SIGHUP)
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/service/wsgi_server.py b/openerp/service/wsgi_server.py
index acbfc67dd0b..002f8c248b9 100644
--- a/openerp/service/wsgi_server.py
+++ b/openerp/service/wsgi_server.py
@@ -400,8 +400,6 @@ def application_unproxied(environ, start_response):
if hasattr(threading.current_thread(), 'dbname'):
del threading.current_thread().dbname
- openerp.service.start_internal()
-
# Try all handlers until one returns some result (i.e. not None).
wsgi_handlers = [wsgi_xmlrpc_1, wsgi_xmlrpc, wsgi_xmlrpc_legacy, wsgi_webdav]
wsgi_handlers += module_handlers
@@ -422,69 +420,5 @@ def application(environ, start_response):
else:
return application_unproxied(environ, start_response)
-# The WSGI server, started by start_server(), stopped by stop_server().
-httpd = None
-
-def serve(interface, port, threaded):
- """ Serve HTTP requests via werkzeug development server.
-
- Calling this function is blocking, you might want to call it in its own
- thread.
- """
-
- global httpd
- if not openerp.evented:
- httpd = werkzeug.serving.make_server(interface, port, application, threaded=threaded)
- else:
- from gevent.wsgi import WSGIServer
- httpd = WSGIServer((interface, port), application)
- httpd.serve_forever()
-
-def start_service():
- """ Call serve() in its own thread.
-
- The WSGI server can be shutdown with stop_server() below.
- """
- # TODO Change the xmlrpc_* options to http_*
- interface = config['xmlrpc_interface'] or '0.0.0.0'
- port = config['xmlrpc_port']
- _logger.info('HTTP service (werkzeug) running on %s:%s', interface, port)
- if not openerp.evented:
- threading.Thread(target=serve, args=(interface, port, True)).start()
- else:
- serve(interface, port, True)
-
-def stop_service():
- """ Initiate the shutdown of the WSGI server.
-
- The server is supposed to have been started by start_server() above.
- """
- if httpd:
- if not openerp.evented:
- httpd.shutdown()
- close_socket(httpd.socket)
- else:
- import gevent
- httpd.stop()
- gevent.shutdown()
-
-def close_socket(sock):
- """ Closes a socket instance cleanly
-
- :param sock: the network socket to close
- :type sock: socket.socket
- """
- try:
- sock.shutdown(socket.SHUT_RDWR)
- except socket.error, e:
- # On OSX, socket shutdowns both sides if any side closes it
- # causing an error 57 'Socket is not connected' on shutdown
- # of the other side (or something), see
- # http://bugs.python.org/issue4397
- # note: stdlib fixed test, not behavior
- if e.errno != errno.ENOTCONN or platform.system() not in ['Darwin', 'Windows']:
- raise
- sock.close()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
From 093dec2ab01cd5cd8e3f1962cd707f4afdaea17f Mon Sep 17 00:00:00 2001
From: Stephane Wirtel
Date: Mon, 9 Sep 2013 15:10:24 +0200
Subject: [PATCH 033/175] [FIX] Add the platform lib [IMP] Log when the Long
Polling Service is running
bzr revid: stw@openerp.com-20130909131024-23an5cvt1qaa90su
---
openerp/service/workers.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/openerp/service/workers.py b/openerp/service/workers.py
index 382d581720f..73df8cc5aaf 100644
--- a/openerp/service/workers.py
+++ b/openerp/service/workers.py
@@ -18,6 +18,7 @@ import time
import traceback
import subprocess
import os.path
+import platform
import wsgi_server
@@ -245,6 +246,7 @@ class GeventServer(CommonServer):
from gevent.wsgi import WSGIServer
gevent.spawn(self.watch_parent)
self.httpd = WSGIServer((self.interface, self.port), self.app)
+ _logger.info('Evented Service (longpolling) running on %s:%s', self.interface, self.port)
self.httpd.serve_forever()
def stop(self):
From f8c0310d8ea8364b13a1a6b7c51862f1760a4ca9 Mon Sep 17 00:00:00 2001
From: Stephane Wirtel
Date: Mon, 9 Sep 2013 15:11:23 +0200
Subject: [PATCH 034/175] [FIX] Use psycogreen instead of gevent-psycopg2
green-psycopg2 has been deprecated by the developer, he asks to use an
alternative, in this case, the alternative is psycogreen
https://bitbucket.org/dvarrazzo/psycogreen
bzr revid: stw@openerp.com-20130909131123-u0gqhvxqwv13yqke
---
openerp/__init__.py | 4 ++--
openerpcommand/web.py | 4 ++--
setup.py | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/openerp/__init__.py b/openerp/__init__.py
index 161b06b0990..2cb3bce21d6 100644
--- a/openerp/__init__.py
+++ b/openerp/__init__.py
@@ -35,8 +35,8 @@ for i in sys.argv:
if evented:
import gevent.monkey
gevent.monkey.patch_all()
- import gevent_psycopg2
- gevent_psycopg2.monkey_patch()
+ import psycogreen.gevent
+ psycogreen.gevent.patch_psycopg()
# Make sure the OpenERP server runs in UTC. This is especially necessary
# under Windows as under Linux it seems the real import of time is
diff --git a/openerpcommand/web.py b/openerpcommand/web.py
index 5875978ad32..5d9d429244b 100644
--- a/openerpcommand/web.py
+++ b/openerpcommand/web.py
@@ -30,9 +30,9 @@ def run(args):
import gevent
import gevent.monkey
import gevent.wsgi
- import gevent_psycopg2
+ import psycogreen.gevent
gevent.monkey.patch_all()
- gevent_psycopg2.monkey_patch()
+ psycogreen.gevent.patch_psycopg()
import threading
import openerp
import openerp.cli.server
diff --git a/setup.py b/setup.py
index ff801a97933..4f4ffe6e505 100644
--- a/setup.py
+++ b/setup.py
@@ -120,7 +120,7 @@ setuptools.setup(
'feedparser',
'gdata',
'gevent',
- 'gevent-psycopg2',
+ 'psycogreen',
'Jinja2',
'lxml', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
'mako',
From 2a6d0299d97251d93e1a10976096b2354f8f625b Mon Sep 17 00:00:00 2001
From: Antony Lesuisse
Date: Mon, 9 Sep 2013 22:08:25 +0200
Subject: [PATCH 035/175] revert to use a separate executable for gevent, add
--dev option
bzr revid: al@openerp.com-20130909200825-sm5c3invmg7tt70j
---
openerp-gevent | 13 +++++++++++++
openerp/__init__.py | 10 ----------
openerp/service/workers.py | 4 +++-
openerp/tools/config.py | 4 ++--
4 files changed, 18 insertions(+), 13 deletions(-)
create mode 100755 openerp-gevent
diff --git a/openerp-gevent b/openerp-gevent
new file mode 100755
index 00000000000..e1c9fa797e1
--- /dev/null
+++ b/openerp-gevent
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+import gevent.monkey
+gevent.monkey.patch_all()
+import psycogreen.gevent
+psycogreen.gevent.patch_psycopg()
+
+import openerp
+
+openerp.evented = True
+
+if __name__ == "__main__":
+ openerp.cli.main()
diff --git a/openerp/__init__.py b/openerp/__init__.py
index 2cb3bce21d6..fe439838497 100644
--- a/openerp/__init__.py
+++ b/openerp/__init__.py
@@ -27,16 +27,6 @@ import sys
# Is the server running with gevent.
evented = False
-for i in sys.argv:
- if i.startswith('--gevent'):
- evented = True
- break
-
-if evented:
- import gevent.monkey
- gevent.monkey.patch_all()
- import psycogreen.gevent
- psycogreen.gevent.patch_psycopg()
# Make sure the OpenERP server runs in UTC. This is especially necessary
# under Windows as under Linux it seems the real import of time is
diff --git a/openerp/service/workers.py b/openerp/service/workers.py
index 73df8cc5aaf..50aa8f245d0 100644
--- a/openerp/service/workers.py
+++ b/openerp/service/workers.py
@@ -326,7 +326,9 @@ class Multicorn(CommonServer):
def long_polling_spawn(self):
nargs = stripped_sys_argv('--pidfile','--workers')
- nargs += ['--gevent']
+ cmd = nargs[0]
+ cmd = os.path.join(os.path.dirname(cmd), "openerp-gevent")
+ nargs[0] = cmd
popen = subprocess.Popen(nargs)
self.long_polling_pid = popen.pid
diff --git a/openerp/tools/config.py b/openerp/tools/config.py
index cc3c187c775..a399f6d133c 100644
--- a/openerp/tools/config.py
+++ b/openerp/tools/config.py
@@ -106,7 +106,7 @@ class configmanager(object):
help="specify additional addons paths (separated by commas).",
action="callback", callback=self._check_addons_path, nargs=1, type="string")
group.add_option("--load", dest="server_wide_modules", help="Comma-separated list of server-wide modules default=web")
- group.add_option("--gevent", dest="gevent", action="store_true", my_default=False, help="Activate the GEvent mode, this also desactivate the cron.")
+ group.add_option("--dev", dest="dev", action="store_true", my_default=False, help="Activate the developer mode. (code and views auto-reload).")
parser.add_option_group(group)
# XML-RPC / HTTP
@@ -399,7 +399,7 @@ class configmanager(object):
'list_db', 'xmlrpcs', 'proxy_mode',
'test_file', 'test_enable', 'test_commit', 'test_report_directory',
'osv_memory_count_limit', 'osv_memory_age_limit', 'max_cron_threads', 'unaccent',
- 'workers', 'limit_memory_hard', 'limit_memory_soft', 'limit_time_cpu', 'limit_time_real', 'limit_request', 'gevent'
+ 'workers', 'limit_memory_hard', 'limit_memory_soft', 'limit_time_cpu', 'limit_time_real', 'limit_request', 'dev'
]
for arg in keys:
From 3bc9a499d4e872176db809c80222edd5d6cd6f11 Mon Sep 17 00:00:00 2001
From: Antony Lesuisse
Date: Mon, 9 Sep 2013 22:17:06 +0200
Subject: [PATCH 036/175] add signals to increase/decrease number of workers
bzr revid: al@openerp.com-20130909201706-sllijtol7p6mi5nr
---
openerp/service/workers.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/openerp/service/workers.py b/openerp/service/workers.py
index 50aa8f245d0..0e7e15fcc39 100644
--- a/openerp/service/workers.py
+++ b/openerp/service/workers.py
@@ -362,6 +362,12 @@ class Multicorn(CommonServer):
elif sig == signal.SIGQUIT:
# dump stacks on kill -3
self.dumpstacks()
+ elif sig == signal.SIGTTIN:
+ # increase number of workers
+ self.population += 1
+ elif sig == signal.SIGTTOUT:
+ # decrease number of workers
+ self.population -= 1
def process_zombie(self):
# reap dead workers
@@ -423,10 +429,14 @@ class Multicorn(CommonServer):
# by a signal simulating a pseudo SA_RESTART. We write to a pipe in the
# signal handler to overcome this behaviour
self.pipe = self.pipe_new()
- # set signal
+ # set signal handlers
signal.signal(signal.SIGINT, self.signal_handler)
signal.signal(signal.SIGTERM, self.signal_handler)
+ signal.signal(signal.SIGHUP, self.signal_handler)
signal.signal(signal.SIGCHLD, self.signal_handler)
+ signal.signal(signal.SIGQUIT, self.signal_handler)
+ signal.signal(signal.SIGTTIN, self.signal_handler)
+ signal.signal(signal.SIGTTOUT, self.signal_handler)
# listen to socket
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
From 65c0538a8359c5836a3e42ac6c2c0e739d4d6bff Mon Sep 17 00:00:00 2001
From: Antony Lesuisse
Date: Tue, 10 Sep 2013 01:05:53 +0200
Subject: [PATCH 037/175] autoreload, first working version for both python and
data, still wip
bzr revid: al@openerp.com-20130909230553-jn26ue5qenv0sd3p
---
openerp/service/workers.py | 117 +++++++++++++++++++++++++++++++++----
1 file changed, 107 insertions(+), 10 deletions(-)
diff --git a/openerp/service/workers.py b/openerp/service/workers.py
index 0e7e15fcc39..f2f4c60d5db 100644
--- a/openerp/service/workers.py
+++ b/openerp/service/workers.py
@@ -41,6 +41,97 @@ SLEEP_INTERVAL = 60 # 1 min
# Common
#----------------------------------------------------------
+class AutoReload(object):
+ def __init__(self):
+ self.files = {}
+ import pyinotify
+ class EventHandler(pyinotify.ProcessEvent):
+ def __init__(self, autoreload):
+ self.autoreload = autoreload
+
+ def process_IN_CREATE(self, event):
+ _logger.debug('File created: %s', event.pathname)
+ self.autoreload.files[event.pathname] = 1
+
+ def process_IN_MODIFY(self, event):
+ _logger.debug('File modified: %s', event.pathname)
+ self.autoreload.files[event.pathname] = 1
+
+ self.wm = pyinotify.WatchManager()
+ self.handler = EventHandler(self)
+ self.notifier = pyinotify.Notifier(self.wm, self.handler, timeout=0)
+ mask = pyinotify.IN_MODIFY | pyinotify.IN_CREATE # IN_MOVED_FROM, IN_MOVED_TO ?
+ for path in openerp.tools.config.options["addons_path"].split(','):
+ _logger.info('Watching addons folder %s', path)
+ self.wm.add_watch(path, mask, rec=True)
+
+ def process_data(self, touched_files):
+ # pyinotify notifier + fs modiciation tracker
+ from openerp.modules.module import load_information_from_description_file as load_manifest
+ addons_path = openerp.tools.config.options["addons_path"].split(',')
+ registries = openerp.modules.registry.RegistryManager.registries
+ keys = ['data', 'demo', 'test', 'init_xml', 'update_xml', 'demo_xml']
+ # This will only work for loaded registies, so we have to use -d
+ # al: proposed to move this code in the registry manager so it can be lazy
+ for db_name, registry in registries.items():
+ cr = registry.db.cursor()
+ try:
+ for tfile in touched_files:
+ for path in addons_path:
+ if tfile.startswith(path):
+ # find out wich addons path the file belongs to
+ # and extract it's module name
+ right = tfile[len(path) + 1:].split('/')
+ if len(right) < 2:
+ continue
+ module = right[0]
+ relname = "/".join(right[1:])
+ domain = [('name', '=', module), ('state', 'in', ['installed', 'to upgrade'])]
+ if registry.get('ir.module.module').search(cr, openerp.SUPERUSER_ID, domain):
+ manifest = load_manifest(module)
+ kind = [key for key in keys if relname in manifest[key]]
+ if kind:
+ _logger.info('Updating changed xml file: %s', tfile)
+ idref = {}
+ openerp.tools.convert_file(cr, module, relname, idref, mode='update', kind=kind[0])
+ cr.commit()
+ except Exception,e:
+ _logger.exception(e)
+ finally:
+ cr.close()
+
+ def process_python(self, files):
+ # process python changes
+ py_files = [i for i in files if i.endswith('.py')]
+ py_errors = []
+ # TODO keep python errors until they are ok
+ if py_files:
+ for i in py_files:
+ try:
+ source = open(i, 'rb').read() + '\n'
+ compile(source, i, 'exec')
+ except SyntaxError:
+ py_errors.append(i)
+ if py_errors:
+ _logger.info('autoreload: python code change detected, errors found')
+ for i in py_errors:
+ _logger.info('autoreload: SyntaxError %s',i)
+ else:
+ _logger.info('autoreload: python code updated, autoreload activated')
+ restart_server()
+
+ def check(self):
+ # Check if some files have been touched in the addons path.
+ # If true, check if the touched file belongs to an installed module
+ # in any of the database used in the registry manager.
+ while self.notifier.check_events(0):
+ self.notifier.read_events()
+ self.notifier.process_events()
+ l = self.files.keys()
+ self.files.clear()
+ self.process_data(l)
+ self.process_python(l)
+
class CommonServer(object):
def __init__(self, app):
# TODO Change the xmlrpc_* options to http_*
@@ -101,8 +192,8 @@ class ThreadedServer(CommonServer):
self.quit_signals_received = 0
#self.socket = None
- #self.queue = []
self.httpd = None
+ self.autoreload = None
def signal_handler(self, sig, frame):
if sig in [signal.SIGINT,signal.SIGTERM]:
@@ -152,7 +243,11 @@ class ThreadedServer(CommonServer):
_logger.debug("cron%d started!" % i)
def http_thread(self):
- self.httpd = werkzeug.serving.make_server(self.interface, self.port, self.app, threaded=True)
+ def app(e,s):
+ if self.autoreload:
+ self.autoreload.check()
+ return self.app(e,s)
+ self.httpd = werkzeug.serving.make_server(self.interface, self.port, app, threaded=True)
self.httpd.serve_forever()
def http_spawn(self):
@@ -172,6 +267,7 @@ class ThreadedServer(CommonServer):
win32api.SetConsoleCtrlHandler(lambda sig: signal_handler(sig, None), 1)
self.cron_spawn()
self.http_spawn()
+ self.autoreload = AutoReload()
def stop(self):
""" Shutdown the WSGI server. Wait for non deamon threads.
@@ -189,7 +285,7 @@ class ThreadedServer(CommonServer):
_logger.debug('current thread: %r', me)
for thread in threading.enumerate():
_logger.debug('process %r (%r)', thread, thread.isDaemon())
- if thread != me and not thread.isDaemon() and thread.ident != main_thread_id:
+ if thread != me and not thread.isDaemon() and thread.ident != self.main_thread_id:
while thread.isAlive():
_logger.debug('join and sleep')
# Need a busyloop here as thread.join() masks signals
@@ -262,11 +358,11 @@ class GeventServer(CommonServer):
# Prefork
#----------------------------------------------------------
-class Multicorn(CommonServer):
+class PreforkServer(CommonServer):
""" Multiprocessing inspired by (g)unicorn.
- Multicorn currently uses accept(2) as dispatching method between workers
- but we plan to replace it by a more intelligent dispatcher to will parse
- the first HTTP request line.
+ PreforkServer (aka Multicorn) currently uses accept(2) as dispatching
+ method between workers but we plan to replace it by a more intelligent
+ dispatcher to will parse the first HTTP request line.
"""
def __init__(self, app):
# config
@@ -617,12 +713,12 @@ class WorkerBaseWSGIServer(werkzeug.serving.BaseWSGIServer):
def __init__(self, app):
werkzeug.serving.BaseWSGIServer.__init__(self, "1", "1", app)
def server_bind(self):
- # we dont bind beause we use the listen socket of Multicorn#socket
+ # we dont bind beause we use the listen socket of PreforkServer#socket
# instead we close the socket
if self.socket:
self.socket.close()
def server_activate(self):
- # dont listen as we use Multicorn#socket
+ # dont listen as we use PreforkServer#socket
pass
class WorkerCron(Worker):
@@ -723,10 +819,11 @@ def _reexec():
def start():
""" Start the openerp http server and cron processor.
"""
+ global server
load_server_wide_modules()
if config['workers']:
openerp.multi_process = True
- server = Multicorn(openerp.service.wsgi_server.application)
+ server = PreforkServer(openerp.service.wsgi_server.application)
elif openerp.evented:
server = GeventServer(openerp.service.wsgi_server.application)
else:
From 082b1dc9fc91200d4eeb9a78c05930dbfac510c6 Mon Sep 17 00:00:00 2001
From: Antony Lesuisse
Date: Tue, 10 Sep 2013 01:19:46 +0200
Subject: [PATCH 038/175] restore the original gevent detection
bzr revid: al@openerp.com-20130909231946-aglho23enxhfwm0i
---
openerp-gevent | 2 --
openerp/__init__.py | 2 ++
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/openerp-gevent b/openerp-gevent
index e1c9fa797e1..55044976492 100755
--- a/openerp-gevent
+++ b/openerp-gevent
@@ -7,7 +7,5 @@ psycogreen.gevent.patch_psycopg()
import openerp
-openerp.evented = True
-
if __name__ == "__main__":
openerp.cli.main()
diff --git a/openerp/__init__.py b/openerp/__init__.py
index fe439838497..a06c85d0c21 100644
--- a/openerp/__init__.py
+++ b/openerp/__init__.py
@@ -27,6 +27,8 @@ import sys
# Is the server running with gevent.
evented = False
+if sys.modules.get("gevent") is not None:
+ evented = True
# Make sure the OpenERP server runs in UTC. This is especially necessary
# under Windows as under Linux it seems the real import of time is
From aca5e7606209cd3382c07f1a4aeedce3960650a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 10 Sep 2013 12:45:00 +0200
Subject: [PATCH 039/175] [IMP] orm: first draft of improvign group_by on date
field, allowing to tune the grain, format and interval when grouping on a
date field. Default behavior is the old one, grouping on month.
bzr revid: tde@openerp.com-20130910104500-sfjosqkmpfxa2jxk
---
openerp/osv/orm.py | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py
index 51b0c2b56b9..f081e11b9e2 100644
--- a/openerp/osv/orm.py
+++ b/openerp/osv/orm.py
@@ -2641,11 +2641,26 @@ class BaseModel(object):
fget = self.fields_get(cr, uid, fields)
flist = ''
group_count = group_by = groupby
+ group_by_params = {}
if groupby:
if fget.get(groupby):
groupby_type = fget[groupby]['type']
if groupby_type in ('date', 'datetime'):
- qualified_groupby_field = "to_char(%s,'yyyy-mm')" % qualified_groupby_field
+ if context.get('datetime_format') and isinstance(context['datetime_format'], dict) \
+ and context['datetime_format'].get(groupby) and isinstance(context['datetime_format'][groupby], dict):
+ groupby_format = context['datetime_format'][groupby].get('groupby_format', 'yyyy-mm')
+ display_format = context['datetime_format'][groupby].get('display_format', 'MMMM yyyy')
+ interval = context['datetime_format'][groupby].get('interval', 'month')
+ else:
+ groupby_format = 'yyyy-mm'
+ display_format = 'MMMM yyyy'
+ interval = 'month'
+ group_by_params = {
+ 'groupby_format': groupby_format,
+ 'display_format': display_format,
+ 'interval': interval,
+ }
+ qualified_groupby_field = "to_char(%s,%%s)" % qualified_groupby_field
flist = "%s as %s " % (qualified_groupby_field, groupby)
elif groupby_type == 'boolean':
qualified_groupby_field = "coalesce(%s,false)" % qualified_groupby_field
@@ -2672,6 +2687,8 @@ class BaseModel(object):
gb = groupby and (' GROUP BY ' + qualified_groupby_field) or ''
from_clause, where_clause, where_clause_params = query.get_sql()
+ if group_by_params and group_by_params.get('groupby_format'):
+ where_clause_params = [group_by_params['groupby_format']] + where_clause_params + [group_by_params['groupby_format']]
where_clause = where_clause and ' WHERE ' + where_clause
limit_str = limit and ' limit %d' % limit or ''
offset_str = offset and ' offset %d' % offset or ''
@@ -2708,14 +2725,17 @@ class BaseModel(object):
d['__context'] = {'group_by': groupby_list[1:]}
if groupby and groupby in fget:
if d[groupby] and fget[groupby]['type'] in ('date', 'datetime'):
- dt = datetime.datetime.strptime(alldata[d['id']][groupby][:7], '%Y-%m')
- days = calendar.monthrange(dt.year, dt.month)[1]
-
- date_value = datetime.datetime.strptime(d[groupby][:10], '%Y-%m-%d')
+ groupby_datetime = datetime.datetime.strptime(alldata[d['id']][groupby], '%Y-%m-%d')
d[groupby] = babel.dates.format_date(
- date_value, format='MMMM yyyy', locale=context.get('lang', 'en_US'))
- d['__domain'] = [(groupby, '>=', alldata[d['id']][groupby] and datetime.datetime.strptime(alldata[d['id']][groupby][:7] + '-01', '%Y-%m-%d').strftime('%Y-%m-%d') or False),\
- (groupby, '<=', alldata[d['id']][groupby] and datetime.datetime.strptime(alldata[d['id']][groupby][:7] + '-' + str(days), '%Y-%m-%d').strftime('%Y-%m-%d') or False)] + domain
+ groupby_datetime, format=group_by_params.get('display_format', 'MMMM yyyy'), locale=context.get('lang', 'en_US'))
+ if group_by_params.get('interval') == 'day':
+ domain_dt_begin = groupby_datetime.replace(hour=0, minute=0)
+ domain_dt_end = groupby_datetime.replace(hour=23, minute=59, second=59)
+ else:
+ days = calendar.monthrange(groupby_datetime.year, groupby_datetime.month)[1]
+ domain_dt_begin = groupby_datetime.replace(day=1)
+ domain_dt_end = groupby_datetime.replace(day=days)
+ d['__domain'] = [(group_by, '>=', domain_dt_begin.strftime('%Y-%m-%d')), (group_by, '<=', domain_dt_end.strftime('%Y-%m-%d'))] + domain
del alldata[d['id']][groupby]
d.update(alldata[d['id']])
del d['id']
From 316ce91243aaf6974f87ed3b0664f4522a391a5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 10 Sep 2013 12:46:23 +0200
Subject: [PATCH 040/175] [IMP] mass_mailing Added delivered field, number of
delivered emails Improved kanban view of mass mailing campaign Improved
statistics of segments, now daily instead of monthly
bzr revid: tde@openerp.com-20130910104623-7ljg0q9pebbcqk7m
---
addons/mass_mailing/mass_mailing.py | 40 +++++++++++++++----
addons/mass_mailing/mass_mailing_demo.xml | 20 +++++-----
addons/mass_mailing/mass_mailing_view.xml | 17 ++++++--
.../static/src/css/mass_mailing.css | 2 +-
4 files changed, 57 insertions(+), 22 deletions(-)
diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py
index f37f86e385a..ba56bc57d4f 100644
--- a/addons/mass_mailing/mass_mailing.py
+++ b/addons/mass_mailing/mass_mailing.py
@@ -41,6 +41,8 @@ class MassMailingCampaign(osv.Model):
'opened': len([mail for mail in campaign.mail_ids if mail.opened]),
'replied': len([mail for mail in campaign.mail_ids if mail.replied]),
'bounced': len([mail for mail in campaign.mail_ids if mail.bounced]),
+ # delivered: shouldn't be: all mails - (failed + bounced) ?
+ 'delivered': len([mail for mail in campaign.mail_ids if mail.state == 'sent' and not mail.bounced]),
}
return results
@@ -73,12 +75,18 @@ class MassMailingCampaign(osv.Model):
'mail.mail', 'mass_mailing_campaign_id',
'Sent Emails',
),
+ 'color': fields.integer('Color Index'),
# stat fields
'sent': fields.function(
_get_statistics,
string='Sent Emails',
type='integer', multi='_get_statistics'
),
+ 'delivered': fields.function(
+ _get_statistics,
+ string='Delivered',
+ type='integer', multi='_get_statistics',
+ ),
'opened': fields.function(
_get_statistics,
string='Opened',
@@ -120,16 +128,16 @@ class MassMailingSegment(osv.Model):
}
]
"""
- month_begin = date.today().replace(day=1)
+ # month_begin = date.today().replace(day=1)
+ date_begin = date.today()
section_result = [{'value': 0,
- 'tooltip': (month_begin + relativedelta.relativedelta(months=-i)).strftime('%B'),
+ 'tooltip': (date_begin + relativedelta.relativedelta(days=-i)).strftime('%d %B %Y'),
} for i in range(self._period_number - 1, -1, -1)]
group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
- print group_obj
for group in group_obj:
group_begin_date = datetime.strptime(group['__domain'][0][2], tools.DEFAULT_SERVER_DATE_FORMAT)
- month_delta = relativedelta.relativedelta(month_begin, group_begin_date)
- section_result[self._period_number - (month_delta.months + 1)] = {'value': group.get(value_field, 0), 'tooltip': group_begin_date.strftime('%B')}
+ month_delta = relativedelta.relativedelta(date_begin, group_begin_date)
+ section_result[self._period_number - (month_delta.days + 1)] = {'value': group.get(value_field, 0), 'tooltip': group.get(groupby_field)}
return section_result
def _get_monthly_statistics(self, cr, uid, ids, field_name, arg, context=None):
@@ -137,8 +145,20 @@ class MassMailingSegment(osv.Model):
"""
obj = self.pool.get('mail.mail')
res = dict.fromkeys(ids, False)
- month_begin = date.today().replace(day=1)
- groupby_begin = (month_begin + relativedelta.relativedelta(months=-4)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
+ date_begin = date.today()
+ context['datetime_format'] = {
+ 'opened': {
+ 'interval': 'day',
+ 'groupby_format': 'yyyy-mm-dd',
+ 'display_format': 'dd MMMM YYYY'
+ },
+ 'replied': {
+ 'interval': 'day',
+ 'groupby_format': 'yyyy-mm-dd',
+ 'display_format': 'dd MMMM YYYY'
+ },
+ }
+ groupby_begin = (date_begin + relativedelta.relativedelta(days=-4)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
for id in ids:
res[id] = dict()
domain = [('mass_mailing_segment_id', '=', id), ('opened', '>=', groupby_begin)]
@@ -153,6 +173,7 @@ class MassMailingSegment(osv.Model):
for segment in self.browse(cr, uid, ids, context=context):
results[segment.id] = {
'sent': len(segment.mail_ids),
+ 'delivered': len([mail for mail in segment.mail_ids if mail.state == 'sent' and not mail.bounced]),
'opened': len([mail for mail in segment.mail_ids if mail.opened]),
'replied': len([mail for mail in segment.mail_ids if mail.replied]),
'bounced': len([mail for mail in segment.mail_ids if mail.bounced]),
@@ -181,6 +202,11 @@ class MassMailingSegment(osv.Model):
string='Sent Emails',
type='integer', multi='_get_statistics'
),
+ 'delivered': fields.function(
+ _get_statistics,
+ string='Delivered',
+ type='integer', multi='_get_statistics',
+ ),
'opened': fields.function(
_get_statistics,
string='Opened',
diff --git a/addons/mass_mailing/mass_mailing_demo.xml b/addons/mass_mailing/mass_mailing_demo.xml
index 3e04baf7cef..9f525d61c3a 100644
--- a/addons/mass_mailing/mass_mailing_demo.xml
+++ b/addons/mass_mailing/mass_mailing_demo.xml
@@ -25,31 +25,31 @@
First Newsletter
-
+ Second Newsletter
-
+
-
-
+
+ sent
-
-
+
+ sent
-
+ sent
@@ -58,18 +58,18 @@
-
+ sent
-
+ sent
-
+ sent
diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml
index 4a3c2b5db07..8d2d003d08b 100644
--- a/addons/mass_mailing/mass_mailing_view.xml
+++ b/addons/mass_mailing/mass_mailing_view.xml
@@ -23,6 +23,7 @@
+
@@ -41,6 +42,7 @@
+
@@ -66,16 +68,23 @@
-
-
+
+
+ i
+
+
+
+
-
-
+
diff --git a/addons/mass_mailing/static/src/css/mass_mailing.css b/addons/mass_mailing/static/src/css/mass_mailing.css
index 8b217d8d588..94f8e4ed070 100644
--- a/addons/mass_mailing/static/src/css/mass_mailing.css
+++ b/addons/mass_mailing/static/src/css/mass_mailing.css
@@ -1,5 +1,5 @@
.openerp .oe_kanban_view .oe_kanban_mass_mailing.oe_kanban_mass_mailing_campaign {
- width: 270px;
+ width: 540px;
}
.openerp .oe_kanban_view .oe_kanban_mass_mailing.oe_kanban_mass_mailing_segment {
From a89547aab615b7bde8e8804b8d66a1b48daa847e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 10 Sep 2013 13:01:04 +0200
Subject: [PATCH 041/175] [FIX] mass_mailing: forgotten brackets
bzr revid: tde@openerp.com-20130910110104-a0pr7q06k3i1lv6h
---
addons/mass_mailing/mass_mailing_demo.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/addons/mass_mailing/mass_mailing_demo.xml b/addons/mass_mailing/mass_mailing_demo.xml
index 9f525d61c3a..f09fb2d05da 100644
--- a/addons/mass_mailing/mass_mailing_demo.xml
+++ b/addons/mass_mailing/mass_mailing_demo.xml
@@ -25,13 +25,13 @@
First Newsletter
-
+ Second Newsletter
-
+
From 43bfef6918f7947c2733cb4f0e93cff480360040 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 10 Sep 2013 14:11:23 +0200
Subject: [PATCH 042/175] [FIX] mass_mailing: fixed sparkline computation for
opened and replied emails, using dates and group_by; fixed demo data
bzr revid: tde@openerp.com-20130910121123-uu4hplm91xb5aexi
---
addons/mass_mailing/mass_mailing.py | 38 +++++++++++------------
addons/mass_mailing/mass_mailing_demo.xml | 4 +--
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py
index ba56bc57d4f..f116cb67c87 100644
--- a/addons/mass_mailing/mass_mailing.py
+++ b/addons/mass_mailing/mass_mailing.py
@@ -106,13 +106,15 @@ class MassMailingCampaign(osv.Model):
class MassMailingSegment(osv.Model):
- """ TODO """
+ """ MassMailingSegment models a segment for a mass mailign campaign. A segment
+ is an occurence of sending emails. """
+
_name = 'mail.mass_mailing.segment'
_description = 'Segment of a mass mailing campaign'
# number of periods for tracking mail_mail statistics
_period_number = 6
- def __get_bar_values(self, cr, uid, obj, domain, read_fields, value_field, groupby_field, context=None):
+ def __get_bar_values(self, cr, uid, id, obj, domain, read_fields, value_field, groupby_field, context=None):
""" Generic method to generate data for bar chart values using SparklineBarWidget.
This method performs obj.read_group(cr, uid, domain, read_fields, groupby_field).
@@ -128,24 +130,22 @@ class MassMailingSegment(osv.Model):
}
]
"""
- # month_begin = date.today().replace(day=1)
- date_begin = date.today()
+ date_begin = datetime.strptime(self.browse(cr, uid, id, context=context).date, tools.DEFAULT_SERVER_DATETIME_FORMAT).date()
section_result = [{'value': 0,
- 'tooltip': (date_begin + relativedelta.relativedelta(days=-i)).strftime('%d %B %Y'),
- } for i in range(self._period_number - 1, -1, -1)]
+ 'tooltip': (date_begin + relativedelta.relativedelta(days=i)).strftime('%d %B %Y'),
+ } for i in range(0, self._period_number)]
group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
for group in group_obj:
- group_begin_date = datetime.strptime(group['__domain'][0][2], tools.DEFAULT_SERVER_DATE_FORMAT)
- month_delta = relativedelta.relativedelta(date_begin, group_begin_date)
- section_result[self._period_number - (month_delta.days + 1)] = {'value': group.get(value_field, 0), 'tooltip': group.get(groupby_field)}
+ group_begin_date = datetime.strptime(group['__domain'][0][2], tools.DEFAULT_SERVER_DATE_FORMAT).date()
+ timedelta = relativedelta.relativedelta(group_begin_date, date_begin)
+ section_result[timedelta.days] = {'value': group.get(value_field, 0), 'tooltip': group.get(groupby_field)}
return section_result
def _get_monthly_statistics(self, cr, uid, ids, field_name, arg, context=None):
""" TODO
"""
- obj = self.pool.get('mail.mail')
- res = dict.fromkeys(ids, False)
- date_begin = date.today()
+ obj = self.pool['mail.mail']
+ res = {}
context['datetime_format'] = {
'opened': {
'interval': 'day',
@@ -158,13 +158,13 @@ class MassMailingSegment(osv.Model):
'display_format': 'dd MMMM YYYY'
},
}
- groupby_begin = (date_begin + relativedelta.relativedelta(days=-4)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
for id in ids:
- res[id] = dict()
- domain = [('mass_mailing_segment_id', '=', id), ('opened', '>=', groupby_begin)]
- res[id]['opened_monthly'] = self.__get_bar_values(cr, uid, obj, domain, ['opened'], 'opened_count', 'opened', context=context)
- domain = [('mass_mailing_segment_id', '=', id), ('replied', '>=', groupby_begin)]
- res[id]['replied_monthly'] = self.__get_bar_values(cr, uid, obj, domain, ['replied'], 'replied_count', 'replied', context=context)
+ res[id] = {}
+ date_begin = self.browse(cr, uid, id, context=context).date
+ domain = [('mass_mailing_segment_id', '=', id), ('opened', '>=', date_begin)]
+ res[id]['opened_monthly'] = self.__get_bar_values(cr, uid, id, obj, domain, ['opened'], 'opened_count', 'opened', context=context)
+ domain = [('mass_mailing_segment_id', '=', id), ('replied', '>=', date_begin)]
+ res[id]['replied_monthly'] = self.__get_bar_values(cr, uid, id, obj, domain, ['replied'], 'replied_count', 'replied', context=context)
return res
def _get_statistics(self, cr, uid, ids, name, arg, context=None):
@@ -225,7 +225,7 @@ class MassMailingSegment(osv.Model):
# monthly ratio
'opened_monthly': fields.function(
_get_monthly_statistics,
- string='Sent Emails',
+ string='Opened',
type='char', multi='_get_monthly_statistics',
),
'replied_monthly': fields.function(
diff --git a/addons/mass_mailing/mass_mailing_demo.xml b/addons/mass_mailing/mass_mailing_demo.xml
index f09fb2d05da..b2278064d36 100644
--- a/addons/mass_mailing/mass_mailing_demo.xml
+++ b/addons/mass_mailing/mass_mailing_demo.xml
@@ -25,13 +25,13 @@
First Newsletter
-
+ Second Newsletter
-
+
From c063f54691a5726a8ab90d273a70fe46bdaff844 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 10 Sep 2013 14:47:54 +0200
Subject: [PATCH 043/175] [IMP] mail: in mass mail mode, default value is now
to send emails, not to perform a mass post on documents.
bzr revid: tde@openerp.com-20130910124754-jssus6l43nil4qad
---
addons/email_template/tests/test_mail.py | 6 ++---
addons/mail/tests/test_mail_features.py | 2 ++
addons/mail/wizard/mail_compose_message.py | 5 ++--
.../mail/wizard/mail_compose_message_view.xml | 24 +++++++++++--------
4 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/addons/email_template/tests/test_mail.py b/addons/email_template/tests/test_mail.py
index adb550aa617..ccc8a49b875 100644
--- a/addons/email_template/tests/test_mail.py
+++ b/addons/email_template/tests/test_mail.py
@@ -73,7 +73,7 @@ class test_message_compose(TestMail):
# 1. Comment on pigs
compose_id = mail_compose.create(cr, uid,
- {'subject': 'Forget me subject', 'body': '
diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py
index 73fb148c0ed..127d1502028 100644
--- a/addons/mail/mail_mail.py
+++ b/addons/mail/mail_mail.py
@@ -108,21 +108,24 @@ class mail_mail(osv.Model):
def set_opened(self, cr, uid, ids, context=None):
""" Set as opened """
- for mail in self.browse(cr, uid, ids, context=context):
+ existing_ids = self.exists(cr, uid, ids, context=context)
+ for mail in self.browse(cr, uid, existing_ids, context=context):
if not mail.opened:
self.write(cr, uid, [mail.id], {'opened': fields.datetime.now()}, context=context)
return True
def set_replied(self, cr, uid, ids, context=None):
""" Set as replied """
- for mail in self.browse(cr, uid, ids, context=context):
+ existing_ids = self.exists(cr, uid, ids, context=context)
+ for mail in self.browse(cr, uid, existing_ids, context=context):
if not mail.replied:
self.write(cr, uid, [mail.id], {'replied': fields.datetime.now()}, context=context)
return True
def set_bounced(self, cr, uid, ids, context=None):
""" Set as bounced """
- for mail in self.browse(cr, uid, ids, context=context):
+ existing_ids = self.exists(cr, uid, ids, context=context)
+ for mail in self.browse(cr, uid, existing_ids, context=context):
if not mail.bounced:
self.write(cr, uid, [mail.id], {'bounced': fields.datetime.now()}, context=context)
return True
diff --git a/addons/mail/mail_mail_view.xml b/addons/mail/mail_mail_view.xml
index 3901a192225..9a2a178d61c 100644
--- a/addons/mail/mail_mail_view.xml
+++ b/addons/mail/mail_mail_view.xml
@@ -44,6 +44,7 @@
+
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 9a5d3e3580d..8c51e99a94c 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -792,6 +792,7 @@ class mail_thread(osv.AbstractModel):
bounce_match = tools.bounce_re.search(email_to)
if bounce_match:
bounced_mail_id = bounce_match.group(1)
+ self.pool['mail.mail'].set_bounced(cr, uid, [bounced_mail_id], context=context)
if self.pool['mail.mail'].exists(cr, uid, bounced_mail_id):
mail = self.pool['mail.mail'].browse(cr, uid, bounced_mail_id, context=context)
bounced_model = mail.model
@@ -1426,7 +1427,8 @@ class mail_thread(osv.AbstractModel):
# update original mail_mail if exists
if type == 'email':
mail_mail_ids = self.pool['mail.mail'].search(cr, SUPERUSER_ID, [('mail_message_id', '=', parent_id)], context=context)
- self.pool['mail.mail'].set_replied(cr, SUPERUSER_ID, mail_mail_ids, context=context)
+ if mail_mail_ids:
+ self.pool['mail.mail'].set_replied(cr, SUPERUSER_ID, mail_mail_ids, context=context)
message_ids = mail_message.search(cr, SUPERUSER_ID, [('id', '=', parent_id), ('parent_id', '!=', False)], context=context)
# avoid loops when finding ancestors
diff --git a/addons/mail/wizard/mail_compose_message_view.xml b/addons/mail/wizard/mail_compose_message_view.xml
index ff1dd96229e..0c86bae7e5f 100644
--- a/addons/mail/wizard/mail_compose_message_view.xml
+++ b/addons/mail/wizard/mail_compose_message_view.xml
@@ -14,6 +14,7 @@
+
@@ -32,9 +33,6 @@
context="{'force_email':True, 'show_email':True}"/>
diff --git a/addons/mass_mailing/static/src/css/mass_mailing.css b/addons/mass_mailing/static/src/css/mass_mailing.css
index 94f8e4ed070..ca5455d6323 100644
--- a/addons/mass_mailing/static/src/css/mass_mailing.css
+++ b/addons/mass_mailing/static/src/css/mass_mailing.css
@@ -14,6 +14,7 @@
border: 1px solid rgba(0, 0, 0, 0.16);
-webkit-border-radius: 2px;
border-radius: 2px;
+ background-color: #FFFFFF;
}
.openerp .oe_kanban_view .oe_kanban_mass_mailing .oe_mail_result {
diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py
index 2f74ef2c732..2b36389cb7b 100644
--- a/addons/mass_mailing/wizard/mail_compose_message.py
+++ b/addons/mass_mailing/wizard/mail_compose_message.py
@@ -28,24 +28,30 @@ class MailComposeMessage(osv.TransientModel):
_inherit = 'mail.compose.message'
_columns = {
- 'mass_mail_campaign_id': fields.many2one(
- 'mail.mass_mailing.campaign', 'Mass mailing campaign'
+ 'use_mass_mailing_campaign': fields.boolean(
+ 'Use mass mailing campaigns',
+ ),
+ 'mass_mailing_campaign_id': fields.many2one(
+ 'mail.mass_mailing.campaign', 'Mass mailing campaign',
+ ),
+ 'mass_mailing_segment_id': fields.many2one(
+ 'mail.mass_mailing.segment', 'Mass mailing segment',
+ domain="[('mass_mailing_campaign_id', '=', mass_mailing_campaign_id)]",
),
}
- def onchange_mass_mail_campaign_id(self, cr, uid, ids, mass_mail_campaign_id, context=None):
- values = {}
- if mass_mail_campaign_id:
- campaign = self.pool['mail.mass_mailing.campaign'].browse(cr, uid, mass_mail_campaign_id, context=context)
- if campaign and campaign.template_id:
- values['template_id'] = campaign.template_id.id
- return {'value': values}
+ _defaults = {
+ 'use_mass_mailing_campaign': True,
+ }
- def render_message(self, cr, uid, wizard, res_id, context=None):
+ def onchange_mass_mail_campaign_id(self, cr, uid, ids, mass_mail_campaign_id, context=None):
+ return {'value': {'mass_mailing_segment_id': False}}
+
+ def render_message_batch(self, cr, uid, wizard, res_ids, context=None):
""" Override method that generated the mail content by adding the mass
mailing campaign, when doing pure email mass mailing. """
- res = super(MailComposeMessage, self).render_message(cr, uid, wizard, res_id, context=context)
- print res, wizard.mass_mail_campaign_id
- if wizard.composition_mode == 'mass_mail' and wizard.mass_mail_campaign_id: # TODO: which kind of mass mailing ?
- res['mass_mailing_campaign_id'] = wizard.mass_mail_campaign_id.id
+ res = super(MailComposeMessage, self).render_message_batch(cr, uid, wizard, res_ids, context=context)
+ if wizard.composition_mode == 'mass_mail' and wizard.mass_mailing_segment_id: # TODO: which kind of mass mailing ?
+ for res_id in res_ids:
+ res[res_id]['mass_mailing_segment_id'] = wizard.mass_mailing_segment_id.id
return res
diff --git a/addons/mass_mailing/wizard/mail_compose_message_view.xml b/addons/mass_mailing/wizard/mail_compose_message_view.xml
index bc5f1a9eb6a..fda29f33399 100644
--- a/addons/mass_mailing/wizard/mail_compose_message_view.xml
+++ b/addons/mass_mailing/wizard/mail_compose_message_view.xml
@@ -8,10 +8,25 @@
mail.compose.message
-
-
+
+
+
+
+
+
+
+
+
From 128d7f39c89ad860615a4a923bf01c516483a62e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Tue, 10 Sep 2013 17:29:33 +0200
Subject: [PATCH 046/175] [IMP] mass_mailing: using delivered instead of
bounced in kanban views
bzr revid: tde@openerp.com-20130910152933-3xb34l0xyhj9yh21
---
addons/mass_mailing/mass_mailing.py | 4 ++--
addons/mass_mailing/mass_mailing_view.xml | 16 ++++++++--------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py
index be31b04957c..31122bf514c 100644
--- a/addons/mass_mailing/mass_mailing.py
+++ b/addons/mass_mailing/mass_mailing.py
@@ -19,7 +19,7 @@
#
##############################################################################
-from datetime import date, datetime
+from datetime import datetime
from dateutil import relativedelta
from openerp import tools
@@ -52,7 +52,7 @@ class MassMailingCampaign(osv.Model):
segment_results = []
for segment in campaign.segment_ids:
segment_object = {}
- for attr in ['name', 'sent', 'opened', 'replied', 'bounced']:
+ for attr in ['name', 'sent', 'delivered', 'opened', 'replied', 'bounced']:
segment_object[attr] = getattr(segment, attr)
segment_results.append(segment_object)
results[campaign.id] = segment_results
diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml
index 91c68d8d734..9dddd82ad5e 100644
--- a/addons/mass_mailing/mass_mailing_view.xml
+++ b/addons/mass_mailing/mass_mailing_view.xml
@@ -53,6 +53,10 @@
Sent
+
+
+ Delivered
+
Opened
@@ -61,10 +65,6 @@
Replied
-
-
- Bounced
-
@@ -187,6 +187,10 @@
Sent
+
+
+ Delivered
+
Opened
@@ -195,10 +199,6 @@
Replied
-
-
- Bounced
-
From 6efdf7615c686491568eff7ec43e9759f0977938 Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Wed, 11 Sep 2013 12:02:10 +0530
Subject: [PATCH 047/175] [IMP] called method from server to get a list of
system fonts
bzr revid: dizzy.zala@gmail.com-20130911063210-b271n7eaq3gnup77
---
addons/base_setup/res_config.py | 60 ++++++---------------------------
1 file changed, 10 insertions(+), 50 deletions(-)
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index b9d3280e49e..5501c74ed22 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -22,57 +22,16 @@
from openerp.osv import fields, osv
import re
import os
-import platform
-from reportlab import rl_config
-from openerp.tools import config
-
-_lst_font=[]
-TTFSearchPath_Linux = [
- '/usr/share/fonts/truetype', # SuSE
- '/usr/share/fonts/dejavu', '/usr/share/fonts/liberation', # Fedora, RHEL
- '/usr/share/fonts/truetype/*', # Ubuntu,
- '/usr/share/fonts/TTF/*', # at Mandriva/Mageia
- '/usr/share/fonts/TTF', # Arch Linux
- ]
-
-TTFSearchPath_Windows = [
- 'c:/winnt/fonts',
- 'c:/windows/fonts'
- ]
-
-TTFSearchPath_Darwin = [
- '~/Library/Fonts',
- '/Library/Fonts',
- '/Network/Library/Fonts',
- '/System/Library/Fonts',
- ]
-
-TTFSearchPathMap = {
- 'Darwin': TTFSearchPath_Darwin,
- 'Windows': TTFSearchPath_Windows,
- 'Linux': TTFSearchPath_Linux,
-}
-searchpath = []
-
-if config.get('fonts_search_path'):
- searchpath += map(str.strip, config.get('fonts_search_path').split(','))
-
-local_platform = platform.system()
-if local_platform in TTFSearchPathMap:
- searchpath += TTFSearchPathMap[local_platform]
-
-searchpath += rl_config.TTFSearchPath
-for dirglob in searchpath:
- if os.path.isdir(dirglob):
- for file in os.listdir('/'+dirglob):
- if os.path.isfile('/'+dirglob+'/'+file):
- font=file.strip('.ttf')
- font=font.replace('-',' ')
- _lst_font.append((font,font))
+from openerp.addons.base.res import res_company
class base_config_settings(osv.osv_memory):
_name = 'base.config.settings'
_inherit = 'res.config.settings'
+
+ def _get_font(self, cr, uid, context=None):
+ font_list = res_company.get_font_list()
+ return font_list
+
_columns = {
'module_multi_company': fields.boolean('Manage multiple companies',
help="""Work in multi-company environments, with appropriate security access between companies.
@@ -87,8 +46,9 @@ class base_config_settings(osv.osv_memory):
'module_base_import': fields.boolean("Allow users to import data from CSV files"),
'module_google_drive': fields.boolean('Attach Google documents to any record',
help="""This installs the module google_docs."""),
- 'font': fields.selection(_lst_font, "Select Font",help="Set your favorite font into company header"),
+ 'font': fields.selection(_get_font, "Select Font",help="Set your favorite font into company header"),
}
+
def open_company(self, cr, uid, ids, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context)
return {
@@ -106,7 +66,7 @@ class base_config_settings(osv.osv_memory):
default_para = re.sub('fontName.?=.?".*"', 'fontName="%s"'% font,header)
return re.sub('("%s"\g<3>'% font,default_para)
-
+
def set_base_defaults(self, cr, uid, ids, context=None):
ir_model_data = self.pool.get('ir.model.data')
wizard = self.browse(cr, uid, ids)[0]
@@ -139,5 +99,5 @@ class sale_config_settings(osv.osv_memory):
email into an OpenERP mail message with attachments.
This installs the module plugin_outlook."""),
}
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
From 4bd0540505604acfd9384a2b8cf8d6014cc3f3d5 Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Wed, 11 Sep 2013 12:11:04 +0530
Subject: [PATCH 048/175] [IMP] added a global method for getting system font
list
bzr revid: dizzy.zala@gmail.com-20130911064104-6umza2px5v4oltk2
---
openerp/addons/base/res/res_company.py | 61 ++++++++++++++------
openerp/addons/base/res/res_company_view.xml | 4 +-
2 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 3524bb2e519..2fe3ab04219 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -27,24 +27,43 @@ from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools import image_resize_image
+from reportlab import rl_config
+from openerp.tools import config
+import platform
+import glob
+from openerp.report.render.rml2pdf import customfonts
-_select_font=[ ('DejaVu Sans',"DejaVu Sans"),
- ('DejaVu Sans Bold',"DejaVu Sans Bold"),
- ('DejaVu Sans Oblique',"DejaVu Sans Oblique"),
- ('DejaVu Sans BoldOblique',"DejaVu Sans BoldOblique"),
- ('Liberation Serif',"Liberation Serif"),
- ('Liberation Serif Bold',"Liberation Serif Bold"),
- ('Liberation Serif Italic',"Liberation Serif Italic"),
- ('Liberation Serif BoldItalic',"Liberation Serif BoldItalic"),
- ('Liberation Serif',"Liberation Serif"),
- ('Liberation Serif Bold',"Liberation Serif Bold"),
- ('Liberation Serif Italic',"Liberation Serif Italic"),
- ('Liberation Serif BoldItalic',"Liberation Serif BoldItalic"),
- ('FreeMono',"FreeMono"),
- ('FreeMono Bold',"FreeMono Bold"),
- ('FreeMono Oblique',"FreeMono Oblique"),
- ('FreeMono BoldOblique',"FreeMono BoldOblique"),
-]
+def get_font_list():
+ _lst_font=[]
+ TTFSearchPath_Linux = customfonts.TTFSearchPath_Linux
+ TTFSearchPath_Darwin = customfonts.TTFSearchPath_Darwin
+ TTFSearchPath_Windows = customfonts.TTFSearchPath_Windows
+ TTFSearchPathMap = customfonts.TTFSearchPathMap
+ searchpath = []
+ select_font = []
+ if config.get('fonts_search_path'):
+ searchpath += map(str.strip, config.get('fonts_search_path').split(','))
+
+ local_platform = platform.system()
+ if local_platform in TTFSearchPathMap:
+ searchpath += TTFSearchPathMap[local_platform]
+
+ searchpath += rl_config.TTFSearchPath
+
+ for dirglob in searchpath:
+ dirglob = os.path.expanduser(dirglob)
+ for dirname in glob.iglob(dirglob):
+ abp = os.path.abspath(dirname)
+ if os.path.isdir(abp):
+ for f in os.listdir(abp):
+ abs_filename = os.path.join(abp, f)
+ from PIL import ImageFont
+ if f.find('.ttf') != -1:
+ f_test = ImageFont.truetype(abs_filename, 1)
+ font_family = f_test.font.family
+ font_familystyle = f_test.font.family +" "+ f_test.font.style.replace(" ","")
+ _lst_font.append((font_familystyle,font_familystyle))
+ return _lst_font
class multi_company_default(osv.osv):
"""
@@ -92,7 +111,7 @@ class res_company(osv.osv):
_name = "res.company"
_description = 'Companies'
_order = 'name'
-
+
def _get_address_data(self, cr, uid, ids, field_names, arg, context=None):
""" Read the 'address' functional fields. """
result = {}
@@ -129,6 +148,10 @@ class res_company(osv.osv):
def _get_companies_from_partner(self, cr, uid, ids, context=None):
return self.pool['res.company'].search(cr, uid, [('partner_id', 'in', ids)], context=context)
+
+ def _get_font(self, cr, uid, context=None):
+ font_list = get_font_list()
+ return font_list
_columns = {
'name': fields.related('partner_id', 'name', string='Company Name', size=128, required=True, store=True, type='char'),
@@ -165,7 +188,7 @@ class res_company(osv.osv):
'vat': fields.related('partner_id', 'vat', string="Tax ID", type="char", size=32),
'company_registry': fields.char('Company Registry', size=64),
'paper_format': fields.selection([('a4', 'A4'), ('us_letter', 'US Letter')], "Paper Format", required=True),
- 'font': fields.selection(_select_font, "Select Font",help="Set your favorite font into company header"),
+ 'font': fields.selection(_get_font, "Font",help="Set your favorite font into company header"),
}
_sql_constraints = [
('name_uniq', 'unique (name)', 'The company name must be unique !')
diff --git a/openerp/addons/base/res/res_company_view.xml b/openerp/addons/base/res/res_company_view.xml
index c386dd27698..e9acf7940b3 100644
--- a/openerp/addons/base/res/res_company_view.xml
+++ b/openerp/addons/base/res/res_company_view.xml
@@ -80,12 +80,10 @@
+
-
-
-
From 9676487680645949d3b333654a981caf268cd21d Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Wed, 11 Sep 2013 15:59:59 +0530
Subject: [PATCH 049/175] [IMP] improved get font method
bzr revid: dizzy.zala@gmail.com-20130911102959-i7fnvt4pom219r9i
---
addons/base_setup/res_config.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index 5501c74ed22..ee824516b50 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -24,13 +24,17 @@ import re
import os
from openerp.addons.base.res import res_company
+supported_fonts = []
+
class base_config_settings(osv.osv_memory):
_name = 'base.config.settings'
_inherit = 'res.config.settings'
def _get_font(self, cr, uid, context=None):
- font_list = res_company.get_font_list()
- return font_list
+ global supported_fonts
+ if not supported_fonts:
+ supported_fonts.extend(res_company.get_font_list())
+ return supported_fonts
_columns = {
'module_multi_company': fields.boolean('Manage multiple companies',
From 5ae665f803c04836eadad78ba830516eade986ac Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Wed, 11 Sep 2013 16:29:12 +0530
Subject: [PATCH 050/175] [IMP] improved get_font_list method so user can have
choice of available fonts to print rml reports
bzr revid: dizzy.zala@gmail.com-20130911105912-6pov1orhqo39qeb2
---
openerp/addons/base/res/res_company.py | 27 +++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 2fe3ab04219..8cdafa87b38 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -32,15 +32,17 @@ from openerp.tools import config
import platform
import glob
from openerp.report.render.rml2pdf import customfonts
+from reportlab.pdfbase import pdfmetrics
+from reportlab.pdfbase.ttfonts import TTFont
+import logging
+
+_logger = logging.getLogger('openerp')
+supported_fonts = []
def get_font_list():
_lst_font=[]
- TTFSearchPath_Linux = customfonts.TTFSearchPath_Linux
- TTFSearchPath_Darwin = customfonts.TTFSearchPath_Darwin
- TTFSearchPath_Windows = customfonts.TTFSearchPath_Windows
TTFSearchPathMap = customfonts.TTFSearchPathMap
searchpath = []
- select_font = []
if config.get('fonts_search_path'):
searchpath += map(str.strip, config.get('fonts_search_path').split(','))
@@ -49,7 +51,6 @@ def get_font_list():
searchpath += TTFSearchPathMap[local_platform]
searchpath += rl_config.TTFSearchPath
-
for dirglob in searchpath:
dirglob = os.path.expanduser(dirglob)
for dirname in glob.iglob(dirglob):
@@ -60,9 +61,15 @@ def get_font_list():
from PIL import ImageFont
if f.find('.ttf') != -1:
f_test = ImageFont.truetype(abs_filename, 1)
- font_family = f_test.font.family
font_familystyle = f_test.font.family +" "+ f_test.font.style.replace(" ","")
- _lst_font.append((font_familystyle,font_familystyle))
+ if (font_familystyle,font_familystyle) not in _lst_font:
+ try:
+ pdfmetrics.registerFont(TTFont(font_familystyle, f))
+ _lst_font.append((font_familystyle,font_familystyle))
+ except:
+ _logger.warning("Could not register Font %s",font_familystyle)
+ global supported_fonts
+ supported_fonts.extend(_lst_font)
return _lst_font
class multi_company_default(osv.osv):
@@ -150,8 +157,10 @@ class res_company(osv.osv):
return self.pool['res.company'].search(cr, uid, [('partner_id', 'in', ids)], context=context)
def _get_font(self, cr, uid, context=None):
- font_list = get_font_list()
- return font_list
+ global supported_fonts
+ if not supported_fonts:
+ get_font_list()
+ return supported_fonts
_columns = {
'name': fields.related('partner_id', 'name', string='Company Name', size=128, required=True, store=True, type='char'),
From 420c4a9489a38b3613da7ce238e7fd0fd89c777f Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Wed, 11 Sep 2013 16:54:01 +0530
Subject: [PATCH 051/175] [IMP] improved header templates
bzr revid: dizzy.zala@gmail.com-20130911112401-9oe7kvus5nirx9ic
---
openerp/addons/base/res/res_company.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 8cdafa87b38..d912d49d017 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -346,12 +346,12 @@ class res_company(osv.osv):
-
+
-
+ [[ formatLang(time.strftime("%%Y-%%m-%%d"), date=True) ]] [[ time.strftime("%%H:%%M") ]][[ company.partner_id.name ]]
@@ -359,7 +359,7 @@ class res_company(osv.osv):
%s
-
+
"""
@@ -384,13 +384,13 @@ class res_company(osv.osv):
-
+
-
+ [[ company.logo or removeParentNode('image') ]]
@@ -441,7 +441,7 @@ class res_company(osv.osv):
'rml_header2': _header2,
'rml_header3': _header3,
'logo':_get_logo,
- 'font':'DejaVu Sans'
+ 'font':'DejaVu Sans Book'
}
_constraints = [
From f5639479dbd6102013d64bf6e9059cb9ef68ea99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Thu, 12 Sep 2013 12:08:29 +0200
Subject: [PATCH 052/175] [DOC] mail: updated changelog
bzr revid: tde@openerp.com-20130912100829-nnp723by9nvwjozb
---
addons/mail/doc/changelog.rst | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/addons/mail/doc/changelog.rst b/addons/mail/doc/changelog.rst
index a7a2cfcf2b5..852c548aa0f 100644
--- a/addons/mail/doc/changelog.rst
+++ b/addons/mail/doc/changelog.rst
@@ -6,6 +6,20 @@ Changelog
`trunk (saas-2)`
----------------
+ - ``mass_mailing_campaign`` update
+
+ - ``mail_mail``: added ``opened``, ``replied`` and ``bounced`` datetime fields
+ holding the first time the mail has been respectively opened, replied or has
+ bounced.
+ - controllers: added a web controller to track opened mail
+ - ``mail_mail`: moved ``reply_to`` computation from ``mail_mail`` to ``mail_message``
+ where it belongs, as the field is located onto the ``mail_message`` model.
+ - ``mail_compose_message``: template rendering is now done in batch. Each template
+ is rendered for all res_ids, instead of all templates one id at a time.
+ - ``mail_thread``: added support for bounce alias. Using an alias on Return-Path
+ the mail gateway now flags emails and models having a ``message_bounce`` field
+ as bounced.
+
- added support of ``active_domain`` form context, coming from the list view.
When checking the header hook, the mass mailing will be done on all records
matching the ``active_domain``.
From f8922d6b168b1563cfbaa437f1039e4c7e4fedd0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Thu, 12 Sep 2013 12:09:09 +0200
Subject: [PATCH 053/175] [IMP] [ADD] mass_mailing: added a wizard to create
new segments. It can be called directly from within the campaign form view,
using a button. It allows to easily create new segments and launch the
composer.
bzr revid: tde@openerp.com-20130912100909-ofalececxn64a389
---
addons/mail/wizard/mail_compose_message.py | 2 +-
addons/mass_mailing/__openerp__.py | 3 +-
addons/mass_mailing/mass_mailing.py | 18 +++
addons/mass_mailing/mass_mailing_view.xml | 10 ++
addons/mass_mailing/wizard/__init__.py | 1 +
.../wizard/mail_compose_message.py | 10 +-
.../wizard/mail_compose_message_view.xml | 2 +-
.../mail_mass_mailing_create_segment.py | 122 ++++++++++++++++++
.../mail_mass_mailing_create_segment.xml | 71 ++++++++++
9 files changed, 233 insertions(+), 6 deletions(-)
create mode 100644 addons/mass_mailing/wizard/mail_mass_mailing_create_segment.py
create mode 100644 addons/mass_mailing/wizard/mail_mass_mailing_create_segment.xml
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 1b3f6010893..f129e5bf0f9 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -75,7 +75,7 @@ class mail_compose_message(osv.TransientModel):
if 'active_domain' in context: # not context.get() because we want to keep global [] domains
result['use_active_domain'] = True
result['active_domain'] = '%s' % context.get('active_domain')
- else:
+ elif not result.get('active_domain'):
result['active_domain'] = ''
# get default values according to the composition mode
if composition_mode == 'reply':
diff --git a/addons/mass_mailing/__openerp__.py b/addons/mass_mailing/__openerp__.py
index 147b9bea89c..7f2c26e4a28 100644
--- a/addons/mass_mailing/__openerp__.py
+++ b/addons/mass_mailing/__openerp__.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2013-today OpenERP SA ()
+# Copyright (C) 2013-Today OpenERP SA ()
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -37,6 +37,7 @@
'mass_mailing_demo.xml',
'mail_mail_view.xml',
'wizard/mail_compose_message_view.xml',
+ 'wizard/mail_mass_mailing_create_segment.xml',
'security/ir.model.access.csv',
],
'js': [],
diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py
index 31122bf514c..b255f3163c9 100644
--- a/addons/mass_mailing/mass_mailing.py
+++ b/addons/mass_mailing/mass_mailing.py
@@ -23,6 +23,7 @@ from datetime import datetime
from dateutil import relativedelta
from openerp import tools
+from openerp.tools.translate import _
from openerp.osv import osv, fields
@@ -104,6 +105,23 @@ class MassMailingCampaign(osv.Model):
),
}
+ def launch_segment_create_wizard(self, cr, uid, ids, context=None):
+ ctx = dict(context)
+ ctx.update({
+ 'default_mass_mailing_campaign_id': ids[0],
+ })
+ return {
+ 'name': _('Create a Segment for the Campaign'),
+ 'type': 'ir.actions.act_window',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'mail.mass_mailing.segment.create',
+ 'views': [(False, 'form')],
+ 'view_id': False,
+ 'target': 'new',
+ 'context': ctx,
+ }
+
class MassMailingSegment(osv.Model):
""" MassMailingSegment models a segment for a mass mailign campaign. A segment
diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml
index 9dddd82ad5e..cc2ffc9cb25 100644
--- a/addons/mass_mailing/mass_mailing_view.xml
+++ b/addons/mass_mailing/mass_mailing_view.xml
@@ -19,6 +19,10 @@
mail.mass_mailing.campaign
@@ -114,6 +120,10 @@
+
+
+
+
diff --git a/addons/mass_mailing/wizard/__init__.py b/addons/mass_mailing/wizard/__init__.py
index 155849362cd..669d12289c2 100644
--- a/addons/mass_mailing/wizard/__init__.py
+++ b/addons/mass_mailing/wizard/__init__.py
@@ -20,3 +20,4 @@
##############################################################################
import mail_compose_message
+import mail_mass_mailing_create_segment
diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py
index 2b36389cb7b..4fe858734fe 100644
--- a/addons/mass_mailing/wizard/mail_compose_message.py
+++ b/addons/mass_mailing/wizard/mail_compose_message.py
@@ -41,17 +41,21 @@ class MailComposeMessage(osv.TransientModel):
}
_defaults = {
- 'use_mass_mailing_campaign': True,
+ 'use_mass_mailing_campaign': False,
}
- def onchange_mass_mail_campaign_id(self, cr, uid, ids, mass_mail_campaign_id, context=None):
+ def onchange_mass_mail_campaign_id(self, cr, uid, ids, mass_mailing_campaign_id, mass_mail_segment_id, context=None):
+ if mass_mail_segment_id:
+ segment = self.pool['mail.mass_mailing.segment'].browse(cr, uid, mass_mail_segment_id, context=context)
+ if segment.mass_mailing_campaign_id.id == mass_mailing_campaign_id:
+ return {}
return {'value': {'mass_mailing_segment_id': False}}
def render_message_batch(self, cr, uid, wizard, res_ids, context=None):
""" Override method that generated the mail content by adding the mass
mailing campaign, when doing pure email mass mailing. """
res = super(MailComposeMessage, self).render_message_batch(cr, uid, wizard, res_ids, context=context)
- if wizard.composition_mode == 'mass_mail' and wizard.mass_mailing_segment_id: # TODO: which kind of mass mailing ?
+ if wizard.composition_mode == 'mass_mail' and wizard.use_mass_mailing_campaign and wizard.mass_mailing_segment_id: # TODO: which kind of mass mailing ?
for res_id in res_ids:
res[res_id]['mass_mailing_segment_id'] = wizard.mass_mailing_segment_id.id
return res
diff --git a/addons/mass_mailing/wizard/mail_compose_message_view.xml b/addons/mass_mailing/wizard/mail_compose_message_view.xml
index fda29f33399..9dcf57682f6 100644
--- a/addons/mass_mailing/wizard/mail_compose_message_view.xml
+++ b/addons/mass_mailing/wizard/mail_compose_message_view.xml
@@ -15,7 +15,7 @@
)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+
+from openerp.tools.translate import _
+
+
+class MailMassMailingSegmentCreate(osv.TransientModel):
+ """Wizard to help creating mass mailing segments for a campaign. """
+
+ _name = 'mail.mass_mailing.segment.create'
+ _description = 'Mass mailing segment creation'
+
+ _columns = {
+ 'mass_mailing_campaign_id': fields.many2one(
+ 'mail.mass_mailing.campaign', 'Mass mailing campaign',
+ required=True,
+ ),
+ 'model_id': fields.many2one(
+ 'ir.model', 'Model',
+ required=True,
+ ),
+ 'model_model': fields.related(
+ 'model_id', 'name',
+ type='char', string='Model Name'
+ ),
+ 'filter_id': fields.many2one(
+ 'ir.filters', 'Filter',
+ domain="[('model_id', '=', model_model)]",
+ ),
+ 'domain': fields.related(
+ 'filter_id', 'domain',
+ type='char', string='Domain',
+ ),
+ 'template_id': fields.many2one(
+ 'email.template', 'Template', required=True,
+ domain="[('model_id', '=', model_id)]",
+ ),
+ 'segment_name': fields.char(
+ 'Segment name', required=True,
+ ),
+ 'mass_mailing_segment_id': fields.many2one(
+ 'mail.mass_mailing.segment', 'Mass Mailing Segment',
+ ),
+ }
+
+ _defaults = {
+ }
+
+ def on_change_model_id(self, cr, uid, ids, model_id, context=None):
+ if model_id:
+ model_model = self.pool['ir.model'].browse(cr, uid, model_id, context=context).model
+ else:
+ model_model = False
+ return {'value': {'model_model': model_model}}
+
+ def on_change_filter_id(self, cr, uid, ids, filter_id, context=None):
+ if filter_id:
+ domain = self.pool['ir.filters'].browse(cr, uid, filter_id, context=context).domain
+ else:
+ domain = False
+ return {'value': {'domain': domain}}
+
+ def create_segment(self, cr, uid, ids, context=None):
+ """ Create a segment based on wizard data, and update the wizard """
+ for wizard in self.browse(cr, uid, ids, context=context):
+ segment_values = {
+ 'name': wizard.segment_name,
+ 'mass_mailing_campaign_id': wizard.mass_mailing_campaign_id.id,
+ 'domain': wizard.domain,
+ 'template_id': wizard.template_id.id,
+ }
+ segment_id = self.pool['mail.mass_mailing.segment'].create(cr, uid, segment_values, context=context)
+ self.write(cr, uid, [wizard.id], {'mass_mailing_segment_id': segment_id}, context=context)
+ return True
+
+ def launch_composer(self, cr, uid, ids, context=None):
+ """ Main wizard action: create a new segment and launch the mail.compose.message
+ email composer with wizard data. """
+ self.create_segment(cr, uid, ids, context=context)
+
+ wizard = self.browse(cr, uid, ids[0], context=context)
+ ctx = dict(context)
+ ctx.update({
+ 'default_composition_mode': 'mass_mail',
+ 'default_template_id': wizard.template_id.id,
+ 'default_use_mass_mailing_campaign': True,
+ 'default_use_active_domain': True,
+ 'default_active_domain': wizard.domain,
+ 'default_mass_mailing_campaign_id': wizard.mass_mailing_campaign_id.id,
+ 'default_mass_mailing_segment_id': wizard.mass_mailing_segment_id.id,
+ })
+ return {
+ 'name': _('Compose Email for Mass Mailing'),
+ 'type': 'ir.actions.act_window',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'mail.compose.message',
+ 'views': [(False, 'form')],
+ 'view_id': False,
+ 'target': 'new',
+ 'context': ctx,
+ }
diff --git a/addons/mass_mailing/wizard/mail_mass_mailing_create_segment.xml b/addons/mass_mailing/wizard/mail_mass_mailing_create_segment.xml
new file mode 100644
index 00000000000..5d211bb9eb4
--- /dev/null
+++ b/addons/mass_mailing/wizard/mail_mass_mailing_create_segment.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+ mail.mass_mailing.segment.create.form
+ mail.mass_mailing.segment.create
+
+
+
+
+
+
+ Create Mass Mailing Segment
+ mail.mass_mailing.segment.create
+ mail.mass_mailing.campaign
+ ir.actions.act_window
+ form
+ form
+ new
+
+
+
+
From b0145992181117f8632e766f450c64d635b9352e Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Thu, 12 Sep 2013 17:27:34 +0530
Subject: [PATCH 054/175] [IMP] improved code
bzr revid: dizzy.zala@gmail.com-20130912115734-24orbo1tqq1f80nc
---
addons/base_setup/res_config.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index ee824516b50..11751c7e8f2 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -21,21 +21,17 @@
from openerp.osv import fields, osv
import re
-import os
-from openerp.addons.base.res import res_company
-
-supported_fonts = []
+from openerp.report.render.rml2pdf import customfonts
class base_config_settings(osv.osv_memory):
_name = 'base.config.settings'
_inherit = 'res.config.settings'
def _get_font(self, cr, uid, context=None):
- global supported_fonts
- if not supported_fonts:
- supported_fonts.extend(res_company.get_font_list())
- return supported_fonts
-
+ if not customfonts.supported_fonts:
+ customfonts.RegisterCustomFonts()
+ return customfonts.supported_fonts
+
_columns = {
'module_multi_company': fields.boolean('Manage multiple companies',
help="""Work in multi-company environments, with appropriate security access between companies.
@@ -53,6 +49,10 @@ class base_config_settings(osv.osv_memory):
'font': fields.selection(_get_font, "Select Font",help="Set your favorite font into company header"),
}
+ _defaults= {
+ 'font': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.font or 'DejaVuSans',
+ }
+
def open_company(self, cr, uid, ids, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context)
return {
@@ -76,7 +76,7 @@ class base_config_settings(osv.osv_memory):
wizard = self.browse(cr, uid, ids)[0]
if wizard.font:
user = self.pool.get('res.users').browse(cr, uid, uid, context)
- user.company_id.write({'rml_header': self._change_header(user.company_id.rml_header,wizard.font), 'rml_header2': self._change_header(user.company_id.rml_header2,wizard.font), 'rml_header3': self._change_header(user.company_id.rml_header3,wizard.font)})
+ user.company_id.write({'font':wizard.font,'rml_header': self._change_header(user.company_id.rml_header,wizard.font), 'rml_header2': self._change_header(user.company_id.rml_header2,wizard.font), 'rml_header3': self._change_header(user.company_id.rml_header3,wizard.font)})
return {}
# Preferences wizard for Sales & CRM.
# It is defined here because it is inherited independently in modules sale, crm,
From a20a7f20a8354dfe18a6c55a39ed81c7451f709e Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Thu, 12 Sep 2013 17:30:59 +0530
Subject: [PATCH 055/175] [IMP] code improvement
bzr revid: dizzy.zala@gmail.com-20130912120059-rnn784u646xph74l
---
openerp/addons/base/res/res_company.py | 66 +++----------
openerp/report/render/rml2pdf/customfonts.py | 99 ++++----------------
2 files changed, 29 insertions(+), 136 deletions(-)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index d912d49d017..b5e1b39a03f 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -27,51 +27,8 @@ from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools import image_resize_image
-from reportlab import rl_config
-from openerp.tools import config
-import platform
-import glob
from openerp.report.render.rml2pdf import customfonts
-from reportlab.pdfbase import pdfmetrics
-from reportlab.pdfbase.ttfonts import TTFont
-import logging
-
-_logger = logging.getLogger('openerp')
-supported_fonts = []
-
-def get_font_list():
- _lst_font=[]
- TTFSearchPathMap = customfonts.TTFSearchPathMap
- searchpath = []
- if config.get('fonts_search_path'):
- searchpath += map(str.strip, config.get('fonts_search_path').split(','))
-
- local_platform = platform.system()
- if local_platform in TTFSearchPathMap:
- searchpath += TTFSearchPathMap[local_platform]
-
- searchpath += rl_config.TTFSearchPath
- for dirglob in searchpath:
- dirglob = os.path.expanduser(dirglob)
- for dirname in glob.iglob(dirglob):
- abp = os.path.abspath(dirname)
- if os.path.isdir(abp):
- for f in os.listdir(abp):
- abs_filename = os.path.join(abp, f)
- from PIL import ImageFont
- if f.find('.ttf') != -1:
- f_test = ImageFont.truetype(abs_filename, 1)
- font_familystyle = f_test.font.family +" "+ f_test.font.style.replace(" ","")
- if (font_familystyle,font_familystyle) not in _lst_font:
- try:
- pdfmetrics.registerFont(TTFont(font_familystyle, f))
- _lst_font.append((font_familystyle,font_familystyle))
- except:
- _logger.warning("Could not register Font %s",font_familystyle)
- global supported_fonts
- supported_fonts.extend(_lst_font)
- return _lst_font
-
+
class multi_company_default(osv.osv):
"""
Manage multi company default value
@@ -157,10 +114,9 @@ class res_company(osv.osv):
return self.pool['res.company'].search(cr, uid, [('partner_id', 'in', ids)], context=context)
def _get_font(self, cr, uid, context=None):
- global supported_fonts
- if not supported_fonts:
- get_font_list()
- return supported_fonts
+ if not customfonts.supported_fonts:
+ customfonts.RegisterCustomFonts()
+ return customfonts.supported_fonts
_columns = {
'name': fields.related('partner_id', 'name', string='Company Name', size=128, required=True, store=True, type='char'),
@@ -346,20 +302,20 @@ class res_company(osv.osv):
-
+
-
+ [[ formatLang(time.strftime("%%Y-%%m-%%d"), date=True) ]] [[ time.strftime("%%H:%%M") ]]
-
+ [[ company.partner_id.name ]]%s
-
+
"""
@@ -384,13 +340,13 @@ class res_company(osv.osv):
-
+
-
+ [[ company.logo or removeParentNode('image') ]]
@@ -441,7 +397,7 @@ class res_company(osv.osv):
'rml_header2': _header2,
'rml_header3': _header3,
'logo':_get_logo,
- 'font':'DejaVu Sans Book'
+ 'font':'DejaVuSans'
}
_constraints = [
diff --git a/openerp/report/render/rml2pdf/customfonts.py b/openerp/report/render/rml2pdf/customfonts.py
index cb5b3d69e0b..a65031dc4fa 100644
--- a/openerp/report/render/rml2pdf/customfonts.py
+++ b/openerp/report/render/rml2pdf/customfonts.py
@@ -20,13 +20,13 @@
#
##############################################################################
-import glob
import logging
import os
+from reportlab.pdfbase import pdfmetrics
+from reportlab.pdfbase import ttfonts
import platform
from reportlab import rl_config
-
-from openerp.tools import config
+supported_fonts = []
#.apidoc title: TTF Font Table
@@ -42,28 +42,6 @@ and Ubuntu distros, we have to override the search path, too.
_logger = logging.getLogger(__name__)
-CustomTTFonts = [ ('Helvetica',"DejaVu Sans", "DejaVuSans.ttf", 'normal'),
- ('Helvetica',"DejaVu Sans Bold", "DejaVuSans-Bold.ttf", 'bold'),
- ('Helvetica',"DejaVu Sans Oblique", "DejaVuSans-Oblique.ttf", 'italic'),
- ('Helvetica',"DejaVu Sans BoldOblique", "DejaVuSans-BoldOblique.ttf", 'bolditalic'),
- ('Times',"Liberation Serif", "LiberationSerif-Regular.ttf", 'normal'),
- ('Times',"Liberation Serif Bold", "LiberationSerif-Bold.ttf", 'bold'),
- ('Times',"Liberation Serif Italic", "LiberationSerif-Italic.ttf", 'italic'),
- ('Times',"Liberation Serif BoldItalic", "LiberationSerif-BoldItalic.ttf", 'bolditalic'),
- ('Times-Roman',"Liberation Serif", "LiberationSerif-Regular.ttf", 'normal'),
- ('Times-Roman',"Liberation Serif Bold", "LiberationSerif-Bold.ttf", 'bold'),
- ('Times-Roman',"Liberation Serif Italic", "LiberationSerif-Italic.ttf", 'italic'),
- ('Times-Roman',"Liberation Serif BoldItalic", "LiberationSerif-BoldItalic.ttf", 'bolditalic'),
- ('Courier',"FreeMono", "FreeMono.ttf", 'normal'),
- ('Courier',"FreeMono Bold", "FreeMonoBold.ttf", 'bold'),
- ('Courier',"FreeMono Oblique", "FreeMonoOblique.ttf", 'italic'),
- ('Courier',"FreeMono BoldOblique", "FreeMonoBoldOblique.ttf", 'bolditalic'),
-
- # Sun-ExtA can be downloaded from http://okuc.net/SunWb/
- ('Sun-ExtA',"Sun-ExtA", "Sun-ExtA.ttf", 'normal'),
-]
-
-
TTFSearchPath_Linux = [
'/usr/share/fonts/truetype', # SuSE
'/usr/share/fonts/dejavu', '/usr/share/fonts/liberation', # Fedora, RHEL
@@ -92,67 +70,26 @@ TTFSearchPathMap = {
'Linux': TTFSearchPath_Linux,
}
-# ----- The code below is less distro-specific, please avoid editing! -------
-__foundFonts = None
-
-def FindCustomFonts():
- """Fill the __foundFonts list with those filenames, whose fonts
- can be found in the reportlab ttf font path.
-
- This process needs only be done once per loading of this module,
- it is cached. But, if the system admin adds some font in the
- meanwhile, the server must be restarted eventually.
- """
- dirpath = []
- global __foundFonts
- __foundFonts = {}
+def RegisterCustomFonts():
searchpath = []
-
- if config.get('fonts_search_path'):
- searchpath += map(str.strip, config.get('fonts_search_path').split(','))
-
+ global supported_fonts
local_platform = platform.system()
if local_platform in TTFSearchPathMap:
searchpath += TTFSearchPathMap[local_platform]
-
# Append the original search path of reportlab (at the end)
- searchpath += rl_config.TTFSearchPath
-
- # Perform the search for font files ourselves, as reportlab's
- # TTFOpenFile is not very good at it.
- for dirglob in searchpath:
- dirglob = os.path.expanduser(dirglob)
- for dirname in glob.iglob(dirglob):
- abp = os.path.abspath(dirname)
- if os.path.isdir(abp):
- dirpath.append(abp)
-
- for k, (name, font, filename, mode) in enumerate(CustomTTFonts):
- if filename in __foundFonts:
- continue
- for d in dirpath:
- abs_filename = os.path.join(d, filename)
- if os.path.exists(abs_filename):
- _logger.debug("Found font %s at %s", filename, abs_filename)
- __foundFonts[filename] = abs_filename
- break
-
-def SetCustomFonts(rmldoc):
- """ Map some font names to the corresponding TTF fonts
-
- The ttf font may not even have the same name, as in
- Times -> Liberation Serif.
- This function is called once per report, so it should
- avoid system-wide processing (cache it, instead).
- """
- global __foundFonts
- if __foundFonts is None:
- FindCustomFonts()
- for name, font, filename, mode in CustomTTFonts:
- if os.path.isabs(filename) and os.path.exists(filename):
- rmldoc.setTTFontMapping(name, font, filename, mode)
- elif filename in __foundFonts:
- rmldoc.setTTFontMapping(name, font, __foundFonts[filename], mode)
+ searchpath += rl_config.TTFSearchPath
+ for dirname in searchpath:
+ if os.path.exists(dirname):
+ for filename in os.listdir(dirname):
+ if filename.lower().endswith('.ttf'):
+ filename = os.path.join(dirname, filename)
+ try:
+ face = ttfonts.TTFontFace(filename)
+ pdfmetrics.registerFont(ttfonts.TTFont(face.name, filename, asciiReadable=0))
+ supported_fonts.append((face.name,face.name))
+ _logger.debug("Found font %s at %s", face.name, filename)
+ except:
+ _logger.warning("Could not register Font %s",face.name)
return True
#eof
From 651f76e274093fb4b8a0a34fb7065896e20daa1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?=
Date: Thu, 12 Sep 2013 15:50:44 +0200
Subject: [PATCH 056/175] [IMP] point_of_sale: log pushed orders to the backend
+ disable proxy rpcs when the proxy is disconnected
bzr revid: fva@openerp.com-20130912135044-93c6va8e8yttkir1
---
addons/point_of_sale/controllers/main.py | 21 +++++++------------
addons/point_of_sale/static/src/js/devices.js | 19 ++++++++++++++++-
addons/point_of_sale/static/src/js/models.js | 1 +
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/addons/point_of_sale/controllers/main.py b/addons/point_of_sale/controllers/main.py
index e0bd19545a6..de757238d6f 100644
--- a/addons/point_of_sale/controllers/main.py
+++ b/addons/point_of_sale/controllers/main.py
@@ -10,6 +10,8 @@ from openerp.addons.web import http
from openerp.addons.web.http import request
from openerp.addons.web.controllers.main import manifest_list, module_boot, html_template
+_logger = logging.getLogger(__name__)
+
class PointOfSaleController(http.Controller):
def __init__(self):
self.scale = 'closed'
@@ -71,7 +73,7 @@ class PointOfSaleController(http.Controller):
@http.route('/pos/test_connection', type='json', auth='admin')
def test_connection(self):
- return
+ _logger.info('Received Connection Test from the Point of Sale');
@http.route('/pos/scan_item_success', type='json', auth='admin')
def scan_item_success(self, ean):
@@ -79,7 +81,6 @@ class PointOfSaleController(http.Controller):
A product has been scanned with success
"""
print 'scan_item_success: ' + str(ean)
- return
@http.route('/pos/scan_item_error_unrecognized')
def scan_item_error_unrecognized(self, ean):
@@ -87,7 +88,6 @@ class PointOfSaleController(http.Controller):
A product has been scanned without success
"""
print 'scan_item_error_unrecognized: ' + str(ean)
- return
@http.route('/pos/help_needed', type='json', auth='admin')
def help_needed(self):
@@ -95,7 +95,6 @@ class PointOfSaleController(http.Controller):
The user wants an help (ex: light is on)
"""
print "help_needed"
- return
@http.route('/pos/help_canceled', type='json', auth='admin')
def help_canceled(self):
@@ -103,7 +102,6 @@ class PointOfSaleController(http.Controller):
The user stops the help request
"""
print "help_canceled"
- return
@http.route('/pos/weighting_start', type='json', auth='admin')
def weighting_start(self):
@@ -115,7 +113,6 @@ class PointOfSaleController(http.Controller):
print "... Scale Open."
else:
print "WARNING: Scale already Connected !!!"
- return
@http.route('/pos/weighting_read_kg', type='json', auth='admin')
def weighting_read_kg(self):
@@ -156,41 +153,37 @@ class PointOfSaleController(http.Controller):
@http.route('/pos/payment_cancel', type='json', auth='admin')
def payment_cancel(self):
print "payment_cancel"
- return
@http.route('/pos/transaction_start', type='json', auth='admin')
def transaction_start(self):
print 'transaction_start'
- return
@http.route('/pos/transaction_end', type='json', auth='admin')
def transaction_end(self):
print 'transaction_end'
- return
@http.route('/pos/cashier_mode_activated', type='json', auth='admin')
def cashier_mode_activated(self):
print 'cashier_mode_activated'
- return
@http.route('/pos/cashier_mode_deactivated', type='json', auth='admin')
def cashier_mode_deactivated(self):
print 'cashier_mode_deactivated'
- return
@http.route('/pos/open_cashbox', type='json', auth='admin')
def open_cashbox(self):
print 'open_cashbox'
- return
@http.route('/pos/print_receipt', type='json', auth='admin')
def print_receipt(self, receipt):
print 'print_receipt' + str(receipt)
- return
+
+ @http.route('/pos/log', type='json', auth='admin')
+ def log(self, arguments):
+ _logger.info(' '.join(str(v) for v in arguments))
@http.route('/pos/print_pdf_invoice', type='json', auth='admin')
def print_pdf_invoice(self, pdfinvoice):
print 'print_pdf_invoice' + str(pdfinvoice)
- return
diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js
index 0c737ec1e1a..89f705d09bc 100644
--- a/addons/point_of_sale/static/src/js/devices.js
+++ b/addons/point_of_sale/static/src/js/devices.js
@@ -82,6 +82,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
module.ProxyDevice = instance.web.Class.extend({
init: function(options){
+ var self = this;
options = options || {};
url = options.url || 'http://localhost:8069';
@@ -101,8 +102,13 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
this.connection = new instance.web.Session(undefined,url);
this.connection.session_id = _.uniqueId('posproxy');
+ this.connected = true;
this.bypass_proxy = false;
this.notifications = {};
+ this.message('test_connection').fail(function(){
+ self.connected = false;
+ console.error('Could not connect to the OpenERP Device Proxy Server');
+ });
},
close: function(){
@@ -113,7 +119,11 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
for(var i = 0; i < callbacks.length; i++){
callbacks[i](params);
}
- return this.connection.rpc('/pos/' + name, params || {});
+ if(this.connected){
+ return this.connection.rpc('/pos/' + name, params || {});
+ }else{
+ return (new $.Deferred()).reject();
+ }
},
// this allows the client to be notified when a proxy call is made. The notification
@@ -124,6 +134,8 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
}
this.notifications[name].push(callback);
},
+
+
//a product has been scanned and recognized with success
// ean is a parsed ean object
@@ -316,6 +328,11 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
return this.message('print_receipt',{receipt: receipt});
},
+ // asks the proxy to log some information, as with the debug.log you can provide several arguments.
+ log: function(){
+ return this.message('log',{'arguments': _.toArray(arguments)});
+ },
+
// asks the proxy to print an invoice in pdf form ( used to print invoices generated by the server )
print_pdf_invoice: function(pdfinvoice){
return this.message('print_pdf_invoice',{pdfinvoice: pdfinvoice});
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index fbbb15af9c7..55984d0032d 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -270,6 +270,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
// it returns a deferred that succeeds after having tried to send the order and all the other pending orders.
push_order: function(order) {
var self = this;
+ this.proxy.log('push_order',order.export_as_JSON());
var order_id = this.db.add_order(order.export_as_JSON());
var pushed = new $.Deferred();
From ed62d1dac714398c58b5cc149f144ebc70b56438 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Fri, 13 Sep 2013 13:54:08 +0200
Subject: [PATCH 057/175] [REF] mass_mailing: first refactor
Mail statistics are now stored onto a separated object (mail.mail.statistics), allowing to
handle emails separately from statistics (among other removing mail.mail entries while keeping
statistics).
Everything linnked to opened/replied/bounce is not managed by mass_mailing, removed added code
in mail module.
bzr revid: tde@openerp.com-20130913115408-322cyjipdg680as6
---
addons/mail/controllers/main.py | 8 -
addons/mail/data/mail_data.xml | 6 -
addons/mail/mail_mail.py | 47 -----
addons/mail/mail_mail_view.xml | 5 -
addons/mail/mail_thread.py | 101 ++++------
addons/mail/res_config.py | 26 ---
addons/mail/res_config_view.xml | 8 -
addons/mail/tests/__init__.py | 3 +-
addons/mass_mailing/__init__.py | 1 +
addons/mass_mailing/__openerp__.py | 4 +-
addons/mass_mailing/controllers/__init__.py | 3 +
addons/mass_mailing/controllers/main.py | 12 ++
addons/mass_mailing/mail_data.xml | 12 ++
addons/mass_mailing/mail_mail.py | 54 ++---
addons/mass_mailing/mail_mail_view.xml | 20 --
addons/mass_mailing/mail_thread.py | 82 ++++++++
addons/mass_mailing/mass_mailing.py | 184 ++++++++++++++----
addons/mass_mailing/mass_mailing_demo.xml | 45 +++--
addons/mass_mailing/mass_mailing_view.xml | 68 +++----
.../mass_mailing/security/ir.model.access.csv | 5 +-
.../wizard/mail_compose_message.py | 18 +-
.../wizard/mail_compose_message_view.xml | 6 +-
.../mail_mass_mailing_create_segment.py | 34 ++--
.../mail_mass_mailing_create_segment.xml | 26 +--
24 files changed, 431 insertions(+), 347 deletions(-)
create mode 100644 addons/mass_mailing/controllers/__init__.py
create mode 100644 addons/mass_mailing/controllers/main.py
create mode 100644 addons/mass_mailing/mail_data.xml
delete mode 100644 addons/mass_mailing/mail_mail_view.xml
create mode 100644 addons/mass_mailing/mail_thread.py
diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py
index 27373c34add..959877ad098 100644
--- a/addons/mail/controllers/main.py
+++ b/addons/mail/controllers/main.py
@@ -5,7 +5,6 @@ import openerp
from openerp import SUPERUSER_ID
import openerp.addons.web.http as http
from openerp.addons.web.controllers.main import content_disposition
-from openerp.addons.web.http import request
class MailController(http.Controller):
@@ -38,10 +37,3 @@ class MailController(http.Controller):
except psycopg2.Error:
pass
return True
-
- @http.route('/mail/track//blank.gif', type='http', auth='admin')
- def track_read_email(self, mail_id):
- """ Email tracking. """
- mail_mail = request.registry.get('mail.mail')
- mail_mail.set_opened(request.cr, request.uid, [mail_id])
- return False
diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml
index 79754f5f5a4..e1ca797670b 100644
--- a/addons/mail/data/mail_data.xml
+++ b/addons/mail/data/mail_data.xml
@@ -51,12 +51,6 @@
catchall
-
-
- mail.bounce.alias
- bounce
-
-
Discussions
diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py
index 127d1502028..91799b0ac63 100644
--- a/addons/mail/mail_mail.py
+++ b/addons/mail/mail_mail.py
@@ -62,17 +62,6 @@ class mail_mail(osv.Model):
# and during unlink() we will not cascade delete the parent and its attachments
'notification': fields.boolean('Is Notification',
help='Mail has been created to notify people of an existing mail.message'),
- # Bounce and tracking
- 'opened': fields.datetime(
- 'Opened',
- help='Date when this email has been opened for the first time.'),
- 'replied': fields.datetime(
- 'Replied',
- help='Date when this email has been replied for the first time.'),
- 'bounced': fields.datetime(
- 'Bounced',
- help='Date when this email has bounced.'
- ),
}
_defaults = {
@@ -106,30 +95,6 @@ class mail_mail(osv.Model):
def cancel(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
- def set_opened(self, cr, uid, ids, context=None):
- """ Set as opened """
- existing_ids = self.exists(cr, uid, ids, context=context)
- for mail in self.browse(cr, uid, existing_ids, context=context):
- if not mail.opened:
- self.write(cr, uid, [mail.id], {'opened': fields.datetime.now()}, context=context)
- return True
-
- def set_replied(self, cr, uid, ids, context=None):
- """ Set as replied """
- existing_ids = self.exists(cr, uid, ids, context=context)
- for mail in self.browse(cr, uid, existing_ids, context=context):
- if not mail.replied:
- self.write(cr, uid, [mail.id], {'replied': fields.datetime.now()}, context=context)
- return True
-
- def set_bounced(self, cr, uid, ids, context=None):
- """ Set as bounced """
- existing_ids = self.exists(cr, uid, ids, context=context)
- for mail in self.browse(cr, uid, existing_ids, context=context):
- if not mail.bounced:
- self.write(cr, uid, [mail.id], {'bounced': fields.datetime.now()}, context=context)
- return True
-
def process_email_queue(self, cr, uid, ids=None, context=None):
"""Send immediately queued messages, committing after each
message is sent - this is not transactional and should
@@ -200,15 +165,6 @@ class mail_mail(osv.Model):
else:
return None
- def _get_tracking_url(self, cr, uid, mail, partner=None, context=None):
- if not mail.auto_delete:
- base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
- track_url = urljoin(base_url, 'mail/track/%d/blank.gif' % mail.id)
- print base_url, track_url
- return '' % track_url
- else:
- return ''
-
def send_get_mail_subject(self, cr, uid, mail, force=False, partner=None, context=None):
""" If subject is void and record_name defined: ' posted on '
@@ -233,11 +189,8 @@ class mail_mail(osv.Model):
# generate footer
link = self._get_partner_access_link(cr, uid, mail, partner, context=context)
- tracking_url = self._get_tracking_url(cr, uid, mail, partner, context=context)
if link:
body = tools.append_content_to_html(body, link, plaintext=False, container_tag='div')
- if tracking_url:
- body = tools.append_content_to_html(body, tracking_url, plaintext=False, container_tag='div')
return body
def send_get_email_dict(self, cr, uid, mail, partner=None, context=None):
diff --git a/addons/mail/mail_mail_view.xml b/addons/mail/mail_mail_view.xml
index 9a2a178d61c..dd6a78fd8a4 100644
--- a/addons/mail/mail_mail_view.xml
+++ b/addons/mail/mail_mail_view.xml
@@ -41,11 +41,6 @@
-
-
-
-
-
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 8c51e99a94c..2bfd17fdb59 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -778,7 +778,6 @@ class mail_thread(osv.AbstractModel):
"""
assert isinstance(message, Message), 'message must be an email.message.Message at this point'
fallback_model = model
- bounce_alias = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.bounce.alias", context=context)
# Get email.message.Message variables for future processing
message_id = message.get('Message-Id')
@@ -787,25 +786,6 @@ class mail_thread(osv.AbstractModel):
references = decode_header(message, 'References')
in_reply_to = decode_header(message, 'In-Reply-To')
- # 0. Verify whether this is a bounced email (wrong destination,...) -> use it to collect data, such as dead leads
- if bounce_alias in email_to:
- bounce_match = tools.bounce_re.search(email_to)
- if bounce_match:
- bounced_mail_id = bounce_match.group(1)
- self.pool['mail.mail'].set_bounced(cr, uid, [bounced_mail_id], context=context)
- if self.pool['mail.mail'].exists(cr, uid, bounced_mail_id):
- mail = self.pool['mail.mail'].browse(cr, uid, bounced_mail_id, context=context)
- bounced_model = mail.model
- bounced_thread_id = mail.res_id
- else:
- bounced_model = bounce_match.group(2)
- bounced_thread_id = int(bounce_match.group(3)) if bounce_match.group(3) else 0
- _logger.info('Routing mail from %s to %s with Message-Id %s: bounced mail from mail %s, model: %s, thread_id: %s',
- email_from, email_to, message_id, bounced_mail_id, bounced_model, bounced_thread_id)
- if bounced_model and bounced_model in self.pool and hasattr(self.pool[bounced_model], 'message_receive_bounce'):
- self.pool[bounced_model].message_receive_bounce(cr, uid, [bounced_thread_id], mail_id=bounced_mail_id, context=context)
- return []
-
# 1. Verify if this is a reply to an existing thread
thread_references = references or in_reply_to
ref_match = thread_references and tools.reference_re.search(thread_references)
@@ -894,6 +874,40 @@ class mail_thread(osv.AbstractModel):
"No possible route found for incoming message from %s to %s (Message-Id %s:)." \
"Create an appropriate mail.alias or force the destination model." % (email_from, email_to, message_id)
+ def message_route_process(self, cr, uid, msg, routes, context=None):
+ # postpone setting msg.partner_ids after message_post, to avoid double notifications
+ partner_ids = msg.pop('partner_ids', [])
+ thread_id = False
+ for model, thread_id, custom_values, user_id, alias in routes:
+ if self._name == 'mail.thread':
+ context.update({'thread_model': model})
+ if model:
+ model_pool = self.pool[model]
+ assert thread_id and hasattr(model_pool, 'message_update') or hasattr(model_pool, 'message_new'), \
+ "Undeliverable mail with Message-Id %s, model %s does not accept incoming emails" % \
+ (msg['message_id'], model)
+
+ # disabled subscriptions during message_new/update to avoid having the system user running the
+ # email gateway become a follower of all inbound messages
+ nosub_ctx = dict(context, mail_create_nosubscribe=True, mail_create_nolog=True)
+ if thread_id and hasattr(model_pool, 'message_update'):
+ model_pool.message_update(cr, user_id, [thread_id], msg, context=nosub_ctx)
+ else:
+ thread_id = model_pool.message_new(cr, user_id, msg, custom_values, context=nosub_ctx)
+ else:
+ assert thread_id == 0, "Posting a message without model should be with a null res_id, to create a private message."
+ model_pool = self.pool.get('mail.thread')
+ if not hasattr(model_pool, 'message_post'):
+ context['thread_model'] = model
+ model_pool = self.pool['mail.thread']
+ new_msg_id = model_pool.message_post(cr, uid, [thread_id], context=context, subtype='mail.mt_comment', **msg)
+
+ if partner_ids:
+ # postponed after message_post, because this is an external message and we don't want to create
+ # duplicate emails due to notifications
+ self.pool.get('mail.message').write(cr, uid, [new_msg_id], {'partner_ids': partner_ids}, context=context)
+ return thread_id
+
def message_process(self, cr, uid, model, message, custom_values=None,
save_original=False, strip_attachments=False,
thread_id=None, context=None):
@@ -946,8 +960,7 @@ class mail_thread(osv.AbstractModel):
msg = self.message_parse(cr, uid, msg_txt, save_original=save_original, context=context)
if strip_attachments:
msg.pop('attachments', None)
- # postpone setting msg.partner_ids after message_post, to avoid double notifications
- partner_ids = msg.pop('partner_ids', [])
+
if msg.get('message_id'): # should always be True as message_parse generate one if missing
existing_msg_ids = self.pool.get('mail.message').search(cr, SUPERUSER_ID, [
('message_id', '=', msg.get('message_id')),
@@ -959,36 +972,7 @@ class mail_thread(osv.AbstractModel):
# find possible routes for the message
routes = self.message_route(cr, uid, msg_txt, msg, model, thread_id, custom_values, context=context)
- thread_id = False
- for model, thread_id, custom_values, user_id, alias in routes:
- if self._name == 'mail.thread':
- context.update({'thread_model': model})
- if model:
- model_pool = self.pool[model]
- assert thread_id and hasattr(model_pool, 'message_update') or hasattr(model_pool, 'message_new'), \
- "Undeliverable mail with Message-Id %s, model %s does not accept incoming emails" % \
- (msg['message_id'], model)
-
- # disabled subscriptions during message_new/update to avoid having the system user running the
- # email gateway become a follower of all inbound messages
- nosub_ctx = dict(context, mail_create_nosubscribe=True, mail_create_nolog=True)
- if thread_id and hasattr(model_pool, 'message_update'):
- model_pool.message_update(cr, user_id, [thread_id], msg, context=nosub_ctx)
- else:
- thread_id = model_pool.message_new(cr, user_id, msg, custom_values, context=nosub_ctx)
- else:
- assert thread_id == 0, "Posting a message without model should be with a null res_id, to create a private message."
- model_pool = self.pool.get('mail.thread')
- if not hasattr(model_pool, 'message_post'):
- context['thread_model'] = model
- model_pool = self.pool['mail.thread']
- new_msg_id = model_pool.message_post(cr, uid, [thread_id], context=context, subtype='mail.mt_comment', **msg)
-
- if partner_ids:
- # postponed after message_post, because this is an external message and we don't want to create
- # duplicate emails due to notifications
- self.pool.get('mail.message').write(cr, uid, [new_msg_id], {'partner_ids': partner_ids}, context=context)
-
+ thread_id = self.message_route_process(cr, uid, msg, routes, context=context)
return thread_id
def message_new(self, cr, uid, msg_dict, custom_values=None, context=None):
@@ -1044,15 +1028,6 @@ class mail_thread(osv.AbstractModel):
self.write(cr, uid, ids, update_vals, context=context)
return True
- def message_receive_bounce(self, cr, uid, ids, mail_id=None, context=None):
- """Called by ``message_process`` when a bounce email (such as Undelivered
- Mail Returned to Sender) is received for an existing thread. The default
- behavior is to check is an integer ``message_bounce`` column exists.
- If it is the case, its content is incremented. """
- if self._all_columns.get('message_bounce'):
- for obj in self.browse(cr, uid, ids, context=context):
- self.write(cr, uid, [obj.id], {'message_bounce': obj.message_bounce + 1}, context=context)
-
def _message_extract_payload(self, message, save_original=False):
"""Extract body as HTML and attachments from the mail message"""
attachments = []
@@ -1303,8 +1278,8 @@ class mail_thread(osv.AbstractModel):
return result
def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification',
- subtype=None, parent_id=False, attachments=None, context=None,
- content_subtype='html', **kwargs):
+ subtype=None, parent_id=False, attachments=None, context=None,
+ content_subtype='html', **kwargs):
""" Post a new message in an existing thread, returning the new
mail.message ID.
diff --git a/addons/mail/res_config.py b/addons/mail/res_config.py
index 750c82d54ba..a0cc7ef5c53 100644
--- a/addons/mail/res_config.py
+++ b/addons/mail/res_config.py
@@ -32,14 +32,6 @@ class project_configuration(osv.TransientModel):
'Alias Domain',
help="If you have setup a catch-all email domain redirected to the OpenERP server, enter the domain name here."
),
- 'alias_bounce': fields.char(
- 'Return-Path for Emails',
- help="Return-Path of send Emails. Used to compute bounced emails.",
- ),
- 'alias_catchall': fields.char(
- 'Default Alias',
- help='Default email alias',
- ),
}
def get_default_alias_domain(self, cr, uid, ids, context=None):
@@ -56,21 +48,3 @@ class project_configuration(osv.TransientModel):
config_parameters = self.pool.get("ir.config_parameter")
for record in self.browse(cr, uid, ids, context=context):
config_parameters.set_param(cr, uid, "mail.catchall.domain", record.alias_domain or '', context=context)
-
- def get_default_alias_bounce(self, cr, uid, ids, context=None):
- alias_bounce = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.bounce.alias", context=context)
- return {'alias_bounce': alias_bounce}
-
- def set_alias_bounce(self, cr, uid, ids, context=None):
- config_parameters = self.pool.get("ir.config_parameter")
- for record in self.browse(cr, uid, ids, context=context):
- config_parameters.set_param(cr, uid, "mail.bounce.alias", record.alias_bounce or '', context=context)
-
- def get_default_alias_catchall(self, cr, uid, ids, context=None):
- alias_catchall = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.alias", context=context)
- return {'alias_catchall': alias_catchall}
-
- def set_alias_catchall(self, cr, uid, ids, context=None):
- config_parameters = self.pool.get("ir.config_parameter")
- for record in self.browse(cr, uid, ids, context=context):
- config_parameters.set_param(cr, uid, "mail.catchall.alias", record.alias_catchall or '', context=context)
diff --git a/addons/mail/res_config_view.xml b/addons/mail/res_config_view.xml
index 440cf358e47..d3797ba2dcc 100644
--- a/addons/mail/res_config_view.xml
+++ b/addons/mail/res_config_view.xml
@@ -11,14 +11,6 @@
-
-
-
-
-
-
-
-
diff --git a/addons/mail/tests/__init__.py b/addons/mail/tests/__init__.py
index ff075d73d73..242beb60bf1 100644
--- a/addons/mail/tests/__init__.py
+++ b/addons/mail/tests/__init__.py
@@ -19,10 +19,9 @@
#
##############################################################################
-from . import test_mail_mail, test_mail_group, test_mail_message, test_mail_features, test_mail_gateway, test_message_read, test_invite
+from . import test_mail_group, test_mail_message, test_mail_features, test_mail_gateway, test_message_read, test_invite
checks = [
- # test_mail_mail,
test_mail_group,
test_mail_message,
test_mail_features,
diff --git a/addons/mass_mailing/__init__.py b/addons/mass_mailing/__init__.py
index 37f3850306a..f7b250bd2ed 100644
--- a/addons/mass_mailing/__init__.py
+++ b/addons/mass_mailing/__init__.py
@@ -22,3 +22,4 @@
import mass_mailing
import mail_mail
import wizard
+import controllers
diff --git a/addons/mass_mailing/__openerp__.py b/addons/mass_mailing/__openerp__.py
index 7f2c26e4a28..0301484afec 100644
--- a/addons/mass_mailing/__openerp__.py
+++ b/addons/mass_mailing/__openerp__.py
@@ -21,6 +21,7 @@
{
'name': 'Mass Mailing Campaigns',
+ 'description': """TODO""",
'version': '1.0',
'author': 'OpenERP',
'website': 'http://www.openerp.com',
@@ -31,11 +32,10 @@
'web_kanban_gauge',
'web_kanban_sparkline',
],
- 'description': """TODO""",
'data': [
+ 'mail_data.xml',
'mass_mailing_view.xml',
'mass_mailing_demo.xml',
- 'mail_mail_view.xml',
'wizard/mail_compose_message_view.xml',
'wizard/mail_mass_mailing_create_segment.xml',
'security/ir.model.access.csv',
diff --git a/addons/mass_mailing/controllers/__init__.py b/addons/mass_mailing/controllers/__init__.py
new file mode 100644
index 00000000000..e11f9ba81bb
--- /dev/null
+++ b/addons/mass_mailing/controllers/__init__.py
@@ -0,0 +1,3 @@
+import main
+
+# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py
new file mode 100644
index 00000000000..9997d854cf3
--- /dev/null
+++ b/addons/mass_mailing/controllers/main.py
@@ -0,0 +1,12 @@
+
+import openerp.addons.web.http as http
+from openerp.addons.web.http import request
+
+
+class MassMailController(http.Controller):
+ @http.route('/mail/track//blank.gif', type='http', auth='admin')
+ def track_mail_open(self, mail_id):
+ """ Email tracking. """
+ mail_mail_stats = request.registry.get('mail.mail.statistics')
+ mail_mail_stats.set_opened(request.cr, request.uid, mail_ids=[mail_id])
+ return False
diff --git a/addons/mass_mailing/mail_data.xml b/addons/mass_mailing/mail_data.xml
new file mode 100644
index 00000000000..a1a0e404fe3
--- /dev/null
+++ b/addons/mass_mailing/mail_data.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+ mail.bounce.alias
+ bounce
+
+
+
+
diff --git a/addons/mass_mailing/mail_mail.py b/addons/mass_mailing/mail_mail.py
index 2ecf38fd31e..5d576c158a9 100644
--- a/addons/mass_mailing/mail_mail.py
+++ b/addons/mass_mailing/mail_mail.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2013-today OpenERP SA ()
+# Copyright (C) 2013-Today OpenERP SA ()
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -19,7 +19,11 @@
#
##############################################################################
-from openerp.osv import osv, fields
+from urlparse import urljoin
+
+from openerp import tools
+from openerp import SUPERUSER_ID
+from openerp.osv import osv
class MailMail(osv.Model):
@@ -27,23 +31,29 @@ class MailMail(osv.Model):
_name = 'mail.mail'
_inherit = ['mail.mail']
- _columns = {
- 'mass_mailing_segment_id': fields.many2one(
- 'mail.mass_mailing.segment', 'Mass Mailing Segment',
- ondelete='set null',
- ),
- 'mass_mailing_campaign_id': fields.related(
- 'mass_mailing_segment_id', 'mass_mailing_campaign_id',
- type='many2one', ondelete='set null',
- relation='mail.mass_mailing.campaign',
- string='Mass Mailing Campaign',
- store=True, readonly=True,
- ),
- 'template_id': fields.related(
- 'mass_mailing_segment_id', 'template_id',
- type='many2one', ondelete='set null',
- relation='email.template',
- string='Email Template',
- store=True, readonly=True,
- ),
- }
+ def create(self, cr, uid, values, context=None):
+ """ Override mail_mail creation to create an entry in mail.mail.statistics """
+ # TDE note: should be after 'all values computed', to have values (FIXME after merging other branch holding create refactoring)
+ mail_id = super(MailMail, self).create(cr, uid, values, context=context)
+ message_id = self.browse(cr, SUPERUSER_ID, mail_id).message_id
+ self.pool['mail.mail.statistics'].create(
+ cr, uid, {
+ 'mail_mail_id': mail_id,
+ 'message_id': message_id,
+ }, context=context)
+ return mail_id
+
+ def _get_tracking_url(self, cr, uid, mail, partner=None, context=None):
+ base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
+ track_url = urljoin(base_url, 'mail/track/%d/blank.gif' % mail.id)
+ return '' % track_url
+
+ def send_get_mail_body(self, cr, uid, mail, partner=None, context=None):
+ """ Override to add the tracking URL to the body. """
+ body = super(MailMail, self).send_get_mail_body(cr, uid, mail, partner=partner, context=context)
+
+ # generate tracking URL
+ tracking_url = self._get_tracking_url(cr, uid, mail, partner, context=context)
+ if tracking_url:
+ body = tools.append_content_to_html(body, tracking_url, plaintext=False, container_tag='div')
+ return body
diff --git a/addons/mass_mailing/mail_mail_view.xml b/addons/mass_mailing/mail_mail_view.xml
deleted file mode 100644
index 11fa08776f7..00000000000
--- a/addons/mass_mailing/mail_mail_view.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
- mail.mail.form.mass_mailing
- mail.mail
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/mass_mailing/mail_thread.py b/addons/mass_mailing/mail_thread.py
new file mode 100644
index 00000000000..292e13eab3a
--- /dev/null
+++ b/addons/mass_mailing/mail_thread.py
@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013-Today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+import logging
+
+from openerp import tools
+from openerp.addons.mail.mail_thread import decode_header
+from openerp.osv import osv
+
+_logger = logging.getLogger(__name__)
+
+
+class MailThread(osv.Model):
+ """ Update MailThread to add the feature of bounced emails and replied emails
+ in message_process. """
+ _name = 'mail.thread'
+ _inherit = ['mail.thread']
+
+ def message_route_check_bounce(self, cr, uid, message, context=None):
+ bounce_alias = self.pool['ir.config_parameter'].get_param(cr, uid, "mail.bounce.alias", context=context)
+ message_id = message.get('Message-Id')
+ email_from = decode_header(message, 'From')
+ email_to = decode_header(message, 'To')
+
+ # 0. Verify whether this is a bounced email (wrong destination,...) -> use it to collect data, such as dead leads
+ if bounce_alias in email_to:
+ bounce_match = tools.bounce_re.search(email_to)
+ if bounce_match:
+ bounced_mail_id = bounce_match.group(1)
+ self.pool['mail.mail'].set_bounced(cr, uid, [bounced_mail_id], context=context)
+ if self.pool['mail.mail'].exists(cr, uid, bounced_mail_id):
+ mail = self.pool['mail.mail'].browse(cr, uid, bounced_mail_id, context=context)
+ bounced_model = mail.model
+ bounced_thread_id = mail.res_id
+ else:
+ bounced_model = bounce_match.group(2)
+ bounced_thread_id = int(bounce_match.group(3)) if bounce_match.group(3) else 0
+ _logger.info('Routing mail from %s to %s with Message-Id %s: bounced mail from mail %s, model: %s, thread_id: %s',
+ email_from, email_to, message_id, bounced_mail_id, bounced_model, bounced_thread_id)
+ if bounced_model and bounced_model in self.pool and hasattr(self.pool[bounced_model], 'message_receive_bounce'):
+ self.pool[bounced_model].message_receive_bounce(cr, uid, [bounced_thread_id], mail_id=bounced_mail_id, context=context)
+ return False
+
+ return True
+
+ def message_route(self, cr, uid, message, message_dict, model=None, thread_id=None,
+ custom_values=None, context=None):
+ if not self.message_route_check_bounce(cr, uid, message, context=context):
+ return []
+ return super(MailThread, self).message_route(cr, uid, message, message_dict, model, thread_id, custom_values, context)
+
+ def message_receive_bounce(self, cr, uid, ids, mail_id=None, context=None):
+ """Called by ``message_process`` when a bounce email (such as Undelivered
+ Mail Returned to Sender) is received for an existing thread. The default
+ behavior is to check is an integer ``message_bounce`` column exists.
+ If it is the case, its content is incremented. """
+ if self._all_columns.get('message_bounce'):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.write(cr, uid, [obj.id], {'message_bounce': obj.message_bounce + 1}, context=context)
+
+ def message_route_process(self, cr, uid, msg, routes, context=None):
+ if msg.get('message_id'):
+ self.pool['mail.mail.statistics'].set_replied(cr, uid, mail_message_ids=[msg.get('message_id')], context=context)
+ return super(MailThread, self).message_route_process(cr, uid, msg, routes, context=context)
diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py
index b255f3163c9..61fea847486 100644
--- a/addons/mass_mailing/mass_mailing.py
+++ b/addons/mass_mailing/mass_mailing.py
@@ -38,42 +38,46 @@ class MassMailingCampaign(osv.Model):
results = dict.fromkeys(ids, False)
for campaign in self.browse(cr, uid, ids, context=context):
results[campaign.id] = {
- 'sent': len(campaign.mail_ids),
- 'opened': len([mail for mail in campaign.mail_ids if mail.opened]),
- 'replied': len([mail for mail in campaign.mail_ids if mail.replied]),
- 'bounced': len([mail for mail in campaign.mail_ids if mail.bounced]),
+ 'sent': len(campaign.statistics_ids),
# delivered: shouldn't be: all mails - (failed + bounced) ?
- 'delivered': len([mail for mail in campaign.mail_ids if mail.state == 'sent' and not mail.bounced]),
+ 'delivered': len([stat for stat in campaign.statistics_ids if not stat.bounced]), # stat.state == 'sent' and
+ 'opened': len([stat for stat in campaign.statistics_ids if stat.opened]),
+ 'replied': len([stat for stat in campaign.statistics_ids if stat.replied]),
+ 'bounced': len([stat for stat in campaign.statistics_ids if stat.bounced]),
}
return results
- def _get_segment_kanban_ids(self, cr, uid, ids, name, arg, context=None):
+ def _get_mass_mailing_kanban_ids(self, cr, uid, ids, name, arg, context=None):
results = dict.fromkeys(ids, '')
for campaign in self.browse(cr, uid, ids, context=context):
- segment_results = []
- for segment in campaign.segment_ids:
- segment_object = {}
+ mass_mailing_results = []
+ for mass_mailing in campaign.mass_mailing_ids:
+ mass_mailing_object = {}
for attr in ['name', 'sent', 'delivered', 'opened', 'replied', 'bounced']:
- segment_object[attr] = getattr(segment, attr)
- segment_results.append(segment_object)
- results[campaign.id] = segment_results
+ mass_mailing_object[attr] = getattr(mass_mailing, attr)
+ mass_mailing_results.append(mass_mailing_object)
+ results[campaign.id] = mass_mailing_results
return results
_columns = {
'name': fields.char(
'Campaign Name', required=True,
),
- 'segment_ids': fields.one2many(
- 'mail.mass_mailing.segment', 'mass_mailing_campaign_id',
- 'Segments',
+ 'user_id': fields.many2one(
+ 'res.users', 'Responsible',
+ required=True,
),
- 'segment_kanban_ids': fields.function(
- _get_segment_kanban_ids,
- type='text', string='Segments (kanban data)',
- help='This field has for purpose to gather data about segment to display them in kanban view as nested kanban views is not possible currently',
+ 'mass_mailing_ids': fields.one2many(
+ 'mail.mass_mailing', 'mass_mailing_campaign_id',
+ 'Mass Mailings',
),
- 'mail_ids': fields.one2many(
- 'mail.mail', 'mass_mailing_campaign_id',
+ 'mass_mailing_kanban_ids': fields.function(
+ _get_mass_mailing_kanban_ids,
+ type='text', string='Mass Mailings (kanban data)',
+ help='This field has for purpose to gather data about mass mailings to display them in kanban view as nested kanban views is not possible currently',
+ ),
+ 'statistics_ids': fields.one2many(
+ 'mail.mail.statistics', 'mass_mailing_campaign_id',
'Sent Emails',
),
'color': fields.integer('Color Index'),
@@ -105,17 +109,21 @@ class MassMailingCampaign(osv.Model):
),
}
- def launch_segment_create_wizard(self, cr, uid, ids, context=None):
+ # _defaults = {
+ # 'user_id': lambda self, cr, uid, ctx=None: uid,
+ # },
+
+ def launch_mass_mailing_create_wizard(self, cr, uid, ids, context=None):
ctx = dict(context)
ctx.update({
'default_mass_mailing_campaign_id': ids[0],
})
return {
- 'name': _('Create a Segment for the Campaign'),
+ 'name': _('Create a Mass Mailing for the Campaign'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
- 'res_model': 'mail.mass_mailing.segment.create',
+ 'res_model': 'mail.mass_mailing.create',
'views': [(False, 'form')],
'view_id': False,
'target': 'new',
@@ -123,12 +131,12 @@ class MassMailingCampaign(osv.Model):
}
-class MassMailingSegment(osv.Model):
- """ MassMailingSegment models a segment for a mass mailign campaign. A segment
- is an occurence of sending emails. """
+class MassMailing(osv.Model):
+ """ MassMailing models a wave of emails for a mass mailign campaign.
+ A mass mailing is an occurence of sending emails. """
- _name = 'mail.mass_mailing.segment'
- _description = 'Segment of a mass mailing campaign'
+ _name = 'mail.mass_mailing'
+ _description = 'Wave of sending emails'
# number of periods for tracking mail_mail statistics
_period_number = 6
@@ -162,7 +170,7 @@ class MassMailingSegment(osv.Model):
def _get_monthly_statistics(self, cr, uid, ids, field_name, arg, context=None):
""" TODO
"""
- obj = self.pool['mail.mail']
+ obj = self.pool['mail.mail.statistics']
res = {}
context['datetime_format'] = {
'opened': {
@@ -179,22 +187,22 @@ class MassMailingSegment(osv.Model):
for id in ids:
res[id] = {}
date_begin = self.browse(cr, uid, id, context=context).date
- domain = [('mass_mailing_segment_id', '=', id), ('opened', '>=', date_begin)]
+ domain = [('mass_mailing_id', '=', id), ('opened', '>=', date_begin)]
res[id]['opened_monthly'] = self.__get_bar_values(cr, uid, id, obj, domain, ['opened'], 'opened_count', 'opened', context=context)
- domain = [('mass_mailing_segment_id', '=', id), ('replied', '>=', date_begin)]
+ domain = [('mass_mailing_id', '=', id), ('replied', '>=', date_begin)]
res[id]['replied_monthly'] = self.__get_bar_values(cr, uid, id, obj, domain, ['replied'], 'replied_count', 'replied', context=context)
return res
def _get_statistics(self, cr, uid, ids, name, arg, context=None):
""" Compute statistics of the mass mailing campaign """
results = dict.fromkeys(ids, False)
- for segment in self.browse(cr, uid, ids, context=context):
- results[segment.id] = {
- 'sent': len(segment.mail_ids),
- 'delivered': len([mail for mail in segment.mail_ids if mail.state == 'sent' and not mail.bounced]),
- 'opened': len([mail for mail in segment.mail_ids if mail.opened]),
- 'replied': len([mail for mail in segment.mail_ids if mail.replied]),
- 'bounced': len([mail for mail in segment.mail_ids if mail.bounced]),
+ for mass_mailing in self.browse(cr, uid, ids, context=context):
+ results[mass_mailing.id] = {
+ 'sent': len(mass_mailing.statistics_ids),
+ 'delivered': len([stat for stat in mass_mailing.statistics_ids if not stat.bounced]), # mail.state == 'sent' and
+ 'opened': len([stat for stat in mass_mailing.statistics_ids if stat.opened]),
+ 'replied': len([stat for stat in mass_mailing.statistics_ids if stat.replied]),
+ 'bounced': len([stat for stat in mass_mailing.statistics_ids if stat.bounced]),
}
return results
@@ -214,9 +222,9 @@ class MassMailingSegment(osv.Model):
'mass_mailing_campaign_id', 'color',
type='integer', string='Color Index',
),
- # mail_mail data
- 'mail_ids': fields.one2many(
- 'mail.mail', 'mass_mailing_segment_id',
+ # statistics data
+ 'statistics_ids': fields.one2many(
+ 'mail.mail.statistics', 'mass_mailing_id',
'Send Emails',
),
'sent': fields.function(
@@ -260,3 +268,95 @@ class MassMailingSegment(osv.Model):
_defaults = {
'date': fields.datetime.now(),
}
+
+
+class MailMailStats(osv.Model):
+ """ MailMailStats models the statistics collected about emails. Those statistics
+ are stored in a separated model and table to avoid bloating the mail_mail table
+ with statistics values. This also allows to delete emails send with mass mailing
+ without loosing the statistics about them. """
+
+ _name = 'mail.mail.statistics'
+ _description = 'Email Statistics'
+ _rec_name = 'message_id'
+ _order = 'message_id'
+
+ _columns = {
+ 'mail_mail_id': fields.integer(
+ 'Mail ID',
+ help='ID of the related mail_mail. This field is an integer field because'
+ 'the related mail_mail can be deleted separately from its statistics.'
+ ),
+ 'message_id': fields.char(
+ 'Message-ID', required=True,
+ ),
+ # campaign / wave data
+ 'mass_mailing_id': fields.many2one(
+ 'mail.mass_mailing', 'Mass Mailing',
+ ondelete='set null',
+ ),
+ 'mass_mailing_campaign_id': fields.related(
+ 'mass_mailing_id', 'mass_mailing_campaign_id',
+ type='many2one', ondelete='set null',
+ relation='mail.mass_mailing.campaign',
+ string='Mass Mailing Campaign',
+ store=True, readonly=True,
+ ),
+ 'template_id': fields.related(
+ 'mass_mailing_id', 'template_id',
+ type='many2one', ondelete='set null',
+ relation='email.template',
+ string='Email Template',
+ store=True, readonly=True,
+ ),
+ # Bounce and tracking
+ 'opened': fields.datetime(
+ 'Opened',
+ help='Date when this email has been opened for the first time.'),
+ 'replied': fields.datetime(
+ 'Replied',
+ help='Date when this email has been replied for the first time.'),
+ 'bounced': fields.datetime(
+ 'Bounced',
+ help='Date when this email has bounced.'
+ ),
+ }
+
+ def set_opened(self, cr, uid, ids=None, mail_mail_ids=None, mail_message_ids=None, context=None):
+ """ Set as opened """
+ if not ids and mail_mail_ids:
+ ids = self.search(cr, uid, [('mail_mail_id', 'in', mail_mail_ids)], context=context)
+ elif not ids and mail_message_ids:
+ ids = self.search(cr, uid, [('message_id', 'in', mail_message_ids)], context=context)
+ else:
+ ids = []
+ for stat in self.browse(cr, uid, ids, context=context):
+ if not stat.opened:
+ self.write(cr, uid, [stat.id], {'opened': fields.datetime.now()}, context=context)
+ return True
+
+ def set_replied(self, cr, uid, ids=None, mail_mail_ids=None, mail_message_ids=None, context=None):
+ """ Set as replied """
+ if not ids and mail_mail_ids:
+ ids = self.search(cr, uid, [('mail_mail_id', 'in', mail_mail_ids)], context=context)
+ elif not ids and mail_message_ids:
+ ids = self.search(cr, uid, [('message_id', 'in', mail_message_ids)], context=context)
+ else:
+ ids = []
+ for stat in self.browse(cr, uid, ids, context=context):
+ if not stat.replied:
+ self.write(cr, uid, [stat.id], {'replied': fields.datetime.now()}, context=context)
+ return True
+
+ def set_bounced(self, cr, uid, ids=None, mail_mail_ids=None, mail_message_ids=None, context=None):
+ """ Set as bounced """
+ if not ids and mail_mail_ids:
+ ids = self.search(cr, uid, [('mail_mail_id', 'in', mail_mail_ids)], context=context)
+ elif not ids and mail_message_ids:
+ ids = self.search(cr, uid, [('message_id', 'in', mail_message_ids)], context=context)
+ else:
+ ids = []
+ for stat in self.browse(cr, uid, ids, context=context):
+ if not stat.bounced:
+ self.write(cr, uid, [stat.id], {'bounced': fields.datetime.now()}, context=context)
+ return True
diff --git a/addons/mass_mailing/mass_mailing_demo.xml b/addons/mass_mailing/mass_mailing_demo.xml
index b2278064d36..d75351e1166 100644
--- a/addons/mass_mailing/mass_mailing_demo.xml
+++ b/addons/mass_mailing/mass_mailing_demo.xml
@@ -20,60 +20,69 @@
Partners Newsletter
+
-
+ First Newsletter
-
+ Second Newsletter
-
-
+
+
+ 1111000@OpenERP.comsent
-
-
+
+
+ 1111001@OpenERP.comsent
-
-
+
+
+ 1111002@OpenERP.comsent
-
-
+
+
+ 1111003@OpenERP.comsent
-
-
+
+
+ 1111004@OpenERP.comsent
-
-
+
+
+ 1111005@OpenERP.comsent
-
-
+
+
+ 1111006@OpenERP.comsent
-
-
+
+
+ 1111007@OpenERP.comsent
diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml
index cc2ffc9cb25..2dc95220f6f 100644
--- a/addons/mass_mailing/mass_mailing_view.xml
+++ b/addons/mass_mailing/mass_mailing_view.xml
@@ -20,8 +20,8 @@
@@ -46,29 +46,29 @@
mail.mass_mailing.campaign
-
+
-
+
-
+
-
+
Sent
-
+
Delivered
-
+
Opened
-
+
Replied
@@ -93,8 +93,8 @@
-
-
+
+
@@ -112,13 +112,13 @@
kanban,tree,form
-
-
- mail.mass_mailing.segment.tree
- mail.mass_mailing.segment
+
+
+ mail.mass_mailing.tree
+ mail.mass_mailing10
-
+
@@ -128,11 +128,11 @@
-
- mail.mass_mailing.segment.form
- mail.mass_mailing.segment
+
+ mail.mass_mailing.form
+ mail.mass_mailing
-
-
- mail.mass_mailing.segment.form
- mail.mass_mailing.segment
+
+ mail.mass_mailing.form
+ mail.mass_mailing18
-
-
- mail.mass_mailing.segment.kanban
- mail.mass_mailing.segment
+
+ mail.mass_mailing.kanban
+ mail.mass_mailing
@@ -229,9 +229,9 @@
-
- Mass Mailing Segments
- mail.mass_mailing.segment
+
+ Mass Mailings
+ mail.mass_mailingformkanban,tree,form
@@ -245,9 +245,9 @@
-
+ action="action_view_mass_mailings"/>
diff --git a/addons/mass_mailing/security/ir.model.access.csv b/addons/mass_mailing/security/ir.model.access.csv
index 54f3413e9f1..6931ab0265b 100644
--- a/addons/mass_mailing/security/ir.model.access.csv
+++ b/addons/mass_mailing/security/ir.model.access.csv
@@ -1,5 +1,6 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_mass_mailing_campaign,mail.mass_mailing.campaign,model_mail_mass_mailing_campaign,,1,1,1,0
access_mass_mailing_campaign_system,mail.mass_mailing.campaign.system,model_mail_mass_mailing_campaign,base.group_system,1,1,1,1
-access_mass_mailing_segment,mail.mass_mailing.segment,model_mail_mass_mailing_segment,,1,1,1,0
-access_mass_mailing_segment_system,mail.mass_mailing.segment.system,model_mail_mass_mailing_segment,base.group_system,1,1,1,1
\ No newline at end of file
+access_mass_mailing,mail.mass_mailing,model_mail_mass_mailing,,1,1,1,0
+access_mass_mailing_system,mail.mass_mailing.system,model_mail_mass_mailing,base.group_system,1,1,1,1
+access_mail_mail_statistics,mail.mail.statistics,model_mail_mail_statistics,,1,1,1,1
\ No newline at end of file
diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py
index 4fe858734fe..7b22bc8f4aa 100644
--- a/addons/mass_mailing/wizard/mail_compose_message.py
+++ b/addons/mass_mailing/wizard/mail_compose_message.py
@@ -34,8 +34,8 @@ class MailComposeMessage(osv.TransientModel):
'mass_mailing_campaign_id': fields.many2one(
'mail.mass_mailing.campaign', 'Mass mailing campaign',
),
- 'mass_mailing_segment_id': fields.many2one(
- 'mail.mass_mailing.segment', 'Mass mailing segment',
+ 'mass_mailing_id': fields.many2one(
+ 'mail.mass_mailing', 'Mass mailing',
domain="[('mass_mailing_campaign_id', '=', mass_mailing_campaign_id)]",
),
}
@@ -44,18 +44,18 @@ class MailComposeMessage(osv.TransientModel):
'use_mass_mailing_campaign': False,
}
- def onchange_mass_mail_campaign_id(self, cr, uid, ids, mass_mailing_campaign_id, mass_mail_segment_id, context=None):
- if mass_mail_segment_id:
- segment = self.pool['mail.mass_mailing.segment'].browse(cr, uid, mass_mail_segment_id, context=context)
- if segment.mass_mailing_campaign_id.id == mass_mailing_campaign_id:
+ def onchange_mass_mail_campaign_id(self, cr, uid, ids, mass_mailing_campaign_id, mass_mailing_id, context=None):
+ if mass_mailing_id:
+ mass_mailing = self.pool['mail.mass_mailing'].browse(cr, uid, mass_mailing_id, context=context)
+ if mass_mailing.mass_mailing_campaign_id.id == mass_mailing_campaign_id:
return {}
- return {'value': {'mass_mailing_segment_id': False}}
+ return {'value': {'mass_mailing_id': False}}
def render_message_batch(self, cr, uid, wizard, res_ids, context=None):
""" Override method that generated the mail content by adding the mass
mailing campaign, when doing pure email mass mailing. """
res = super(MailComposeMessage, self).render_message_batch(cr, uid, wizard, res_ids, context=context)
- if wizard.composition_mode == 'mass_mail' and wizard.use_mass_mailing_campaign and wizard.mass_mailing_segment_id: # TODO: which kind of mass mailing ?
+ if wizard.composition_mode == 'mass_mail' and wizard.use_mass_mailing_campaign and wizard.mass_mailing_id: # TODO: which kind of mass mailing ?
for res_id in res_ids:
- res[res_id]['mass_mailing_segment_id'] = wizard.mass_mailing_segment_id.id
+ res[res_id]['mass_mailing_id'] = wizard.mass_mailing_id.id
return res
diff --git a/addons/mass_mailing/wizard/mail_compose_message_view.xml b/addons/mass_mailing/wizard/mail_compose_message_view.xml
index 9dcf57682f6..bdd4431a71d 100644
--- a/addons/mass_mailing/wizard/mail_compose_message_view.xml
+++ b/addons/mass_mailing/wizard/mail_compose_message_view.xml
@@ -15,16 +15,16 @@
From ad6bbe490a204da0d57a453a9c519ccad04284b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?=
Date: Tue, 17 Sep 2013 14:34:46 +0200
Subject: [PATCH 081/175] [FIX] point_of_sale: scaled product weren't ordered
with the correct weight
bzr revid: fva@openerp.com-20130917123446-671ijt70i93p0w67
---
addons/point_of_sale/static/src/js/screens.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js
index 9f1b22f2a75..0c3e488d212 100644
--- a/addons/point_of_sale/static/src/js/screens.js
+++ b/addons/point_of_sale/static/src/js/screens.js
@@ -542,8 +542,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
}
},
order_product: function(){
- var weight = this.pos.proxy.weighting_read_kg();
- this.pos.get('selectedOrder').addProduct(this.get_product(),{ quantity:weight });
+ this.pos.get('selectedOrder').addProduct(this.get_product(),{ quantity: this.weight });
},
get_product_name: function(){
var product = this.get_product();
From 0d826f64ca6bf16eedffcb33325452252c244467 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?=
Date: Tue, 17 Sep 2013 14:46:15 +0200
Subject: [PATCH 082/175] [FIX] point_of_sale: missing renamings from the
JobQueue refactor
bzr revid: fva@openerp.com-20130917124615-kqtix2atp1xguszw
---
addons/point_of_sale/static/src/js/screens.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js
index 0c3e488d212..a5017d517b7 100644
--- a/addons/point_of_sale/static/src/js/screens.js
+++ b/addons/point_of_sale/static/src/js/screens.js
@@ -455,7 +455,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
queue.schedule(function(){
return self.pos.proxy.weighting_start();
- },{ unclearable: true });
+ },{ important: true });
queue.schedule(function(){
return self.pos.proxy.weighting_read_kg().then(function(weight){
@@ -479,7 +479,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos.proxy_queue.clear();
this.pos.proxy_queue.schedule(function(){
return self.pos.proxy.weighting_end();
- },{ unclearable: true });
+ },{ important: true });
},
});
@@ -516,7 +516,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
queue.schedule(function(){
return self.pos.proxy.weighting_start()
- },{ unclearable: true });
+ },{ important: true });
queue.schedule(function(){
return self.pos.proxy.weighting_read_kg().then(function(weight){
@@ -566,7 +566,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos.proxy_queue.clear();
this.pos.proxy_queue.schedule(function(){
self.pos.proxy.weighting_end();
- },{ unclearable: true });
+ },{ important: true });
},
});
From d1a23edd2efd6fd3c89ef4eb513fad07dadca464 Mon Sep 17 00:00:00 2001
From: "Darshan Kalola (OpenERP)"
Date: Tue, 17 Sep 2013 18:38:14 +0530
Subject: [PATCH 083/175] [IMP]align multi-line string
bzr revid: dka@tinyerp.com-20130917130814-wikgcy25594gk8dx
---
addons/base_setup/res_config.py | 18 ++++-----
addons/crm/res_config.py | 2 +-
addons/hr_recruitment/res_config.py | 6 +--
addons/hr_timesheet_sheet/res_config.py | 2 +-
addons/knowledge/res_config.py | 8 ++--
addons/marketing/res_config.py | 8 ++--
addons/mrp/res_config.py | 50 ++++++++++++-------------
addons/project/res_config.py | 24 ++++++------
addons/purchase/res_config.py | 20 +++++-----
addons/sale/res_config.py | 36 +++++++++---------
addons/sale_stock/res_config.py | 12 +++---
addons/stock/res_config.py | 16 ++++----
12 files changed, 101 insertions(+), 101 deletions(-)
diff --git a/addons/base_setup/res_config.py b/addons/base_setup/res_config.py
index 5bf9c9bbf83..9a5309d5c54 100644
--- a/addons/base_setup/res_config.py
+++ b/addons/base_setup/res_config.py
@@ -27,7 +27,7 @@ class base_config_settings(osv.osv_memory):
_columns = {
'module_multi_company': fields.boolean('Manage multiple companies',
help='Work in multi-company environments, with appropriate security access between companies.\n'
- '-This installs the module multi_company.'),
+ '-This installs the module multi_company.'),
'module_share': fields.boolean('Allow documents sharing',
help="""Share or embbed any screen of openerp."""),
'module_portal': fields.boolean('Activate the customer portal',
@@ -65,16 +65,16 @@ class sale_config_settings(osv.osv_memory):
'module_sale' : fields.boolean('SALE'),
'module_plugin_thunderbird': fields.boolean('Enable Thunderbird plug-in',
help='The plugin allows you archive email and its attachments to the selected '
- 'OpenERP objects. You can select a partner, or a lead and '
- 'attach the selected mail as a .eml file in '
- 'the attachment of a selected record. You can create documents for CRM Lead, '
- 'Partner from the selected emails.\n'
- '-This installs the module plugin_thunderbird.'),
+ 'OpenERP objects. You can select a partner, or a lead and '
+ 'attach the selected mail as a .eml file in '
+ 'the attachment of a selected record. You can create documents for CRM Lead, '
+ 'Partner from the selected emails.\n'
+ '-This installs the module plugin_thunderbird.'),
'module_plugin_outlook': fields.boolean('Enable Outlook plug-in',
help='The Outlook plugin allows you to select an object that you would like to add '
- 'to your email and its attachments from MS Outlook. You can select a partner, '
- 'or a lead object and archive a selected email into an OpenERP mail message with attachments.\n'
- '-This installs the module plugin_outlook.'),
+ 'to your email and its attachments from MS Outlook. You can select a partner, '
+ 'or a lead object and archive a selected email into an OpenERP mail message with attachments.\n'
+ '-This installs the module plugin_outlook.'),
'module_mass_mailing': fields.boolean(
'Manage mass mailing campaigns',
help='Get access to statistics with your mass mailing, manage campaigns.'),
diff --git a/addons/crm/res_config.py b/addons/crm/res_config.py
index c7ad5fb3d7e..5f3ffe272e7 100644
--- a/addons/crm/res_config.py
+++ b/addons/crm/res_config.py
@@ -59,7 +59,7 @@ class crm_configuration(osv.TransientModel):
help="""Allows you to trace and manage your activities for fund raising."""),
'module_crm_claim': fields.boolean("Manage Customer Claims",
help='Allows you to track your customers/suppliers claims and grievances.\n'
- '-This installs the module crm_claim.'),
+ '-This installs the module crm_claim.'),
'module_crm_helpdesk': fields.boolean("Manage Helpdesk and Support",
help='Allows you to communicate with Customer, process Customer query, and provide better help and support.\n'
'-This installs the module crm_helpdesk.'),
diff --git a/addons/hr_recruitment/res_config.py b/addons/hr_recruitment/res_config.py
index 53fd01546ec..d18ca7de477 100644
--- a/addons/hr_recruitment/res_config.py
+++ b/addons/hr_recruitment/res_config.py
@@ -28,10 +28,10 @@ class hr_applicant_settings(osv.osv_memory):
_columns = {
'module_document_ftp': fields.boolean('Allow the automatic indexation of resumes',
help='Manage your CV\'s and motivation letter related to all applicants.\n'
- '-This installs the module document_ftp. This will install the knowledge management module in order to allow you to search using specific keywords through the content of all documents (PDF, .DOCx...)'),
+ '-This installs the module document_ftp. This will install the knowledge management module in order to allow you to search using specific keywords through the content of all documents (PDF, .DOCx...)'),
'fetchmail_applicants': fields.boolean('Create applicants from an incoming email account',
fetchmail_model='hr.applicant', fetchmail_name='Incoming HR Applications',
- help ='Allow applicants to send their job application to an email address (jobs@mycompany.com), '
- 'and create automatically application documents in the system.'),
+ help='Allow applicants to send their job application to an email address (jobs@mycompany.com), '
+ 'and create automatically application documents in the system.'),
}
diff --git a/addons/hr_timesheet_sheet/res_config.py b/addons/hr_timesheet_sheet/res_config.py
index f3ef5b8496a..6e63b2badc9 100644
--- a/addons/hr_timesheet_sheet/res_config.py
+++ b/addons/hr_timesheet_sheet/res_config.py
@@ -29,7 +29,7 @@ class hr_timesheet_settings(osv.osv_memory):
'Validate timesheets every', help="Periodicity on which you validate your timesheets."),
'timesheet_max_difference': fields.float('Allow a difference of time between timesheets and attendances of (in hours)',
help='Allowed difference in hours between the sign in/out and the timesheet '
- 'computation for one sheet. Set this to 0 if you do not want any control.'),
+ 'computation for one sheet. Set this to 0 if you do not want any control.'),
}
def get_default_timesheet(self, cr, uid, fields, context=None):
diff --git a/addons/knowledge/res_config.py b/addons/knowledge/res_config.py
index 0800cd84856..c1e0bc1e1d3 100644
--- a/addons/knowledge/res_config.py
+++ b/addons/knowledge/res_config.py
@@ -29,14 +29,14 @@ class knowledge_config_settings(osv.osv_memory):
help="""This installs the module document_page."""),
'module_document': fields.boolean('Manage documents',
help='This is a complete document management system, with: user authentication, '
- 'full document search (but pptx and docx are not supported), and a document dashboard.\n'
- '-This installs the module document.'),
+ 'full document search (but pptx and docx are not supported), and a document dashboard.\n'
+ '-This installs the module document.'),
'module_document_ftp': fields.boolean('Share repositories (FTP)',
help='Access your documents in OpenERP through an FTP interface.\n'
- '-This installs the module document_ftp.'),
+ '-This installs the module document_ftp.'),
'module_document_webdav': fields.boolean('Share repositories (WebDAV)',
help='Access your documents in OpenERP through WebDAV.\n'
- '-This installs the module document_webdav.'),
+ '-This installs the module document_webdav.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/marketing/res_config.py b/addons/marketing/res_config.py
index b0a0679d68e..a58a5c56fc7 100644
--- a/addons/marketing/res_config.py
+++ b/addons/marketing/res_config.py
@@ -27,14 +27,14 @@ class marketing_config_settings(osv.osv_memory):
_columns = {
'module_marketing_campaign': fields.boolean('Marketing campaigns',
help='Provides leads automation through marketing campaigns. '
- 'Campaigns can in fact be defined on any resource, not just CRM leads.\n'
- '-This installs the module marketing_campaign.'),
+ 'Campaigns can in fact be defined on any resource, not just CRM leads.\n'
+ '-This installs the module marketing_campaign.'),
'module_marketing_campaign_crm_demo': fields.boolean('Demo data for marketing campaigns',
help='Installs demo data like leads, campaigns and segments for Marketing Campaigns.\n'
- '-This installs the module marketing_campaign_crm_demo.'),
+ '-This installs the module marketing_campaign_crm_demo.'),
'module_crm_profiling': fields.boolean('Track customer profile to focus your campaigns',
help='Allows users to perform segmentation within partners.\n'
- '-This installs the module crm_profiling.'),
+ '-This installs the module crm_profiling.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/res_config.py b/addons/mrp/res_config.py
index 45a3ce41cf6..929af752c42 100644
--- a/addons/mrp/res_config.py
+++ b/addons/mrp/res_config.py
@@ -29,47 +29,47 @@ class mrp_config_settings(osv.osv_memory):
_columns = {
'module_mrp_repair': fields.boolean("Manage repairs of products ",
help='Allows to manage all product repairs.\n'
- '* Add/remove products in the reparation\n'
- '* Impact for stocks\n'
- '* Invoicing (products and/or services)\n'
- '* Warranty concept\n'
- '* Repair quotation report\n'
- '* Notes for the technician and for the final customer.\n'
- '-This installs the module mrp_repair.'),
+ '* Add/remove products in the reparation\n'
+ '* Impact for stocks\n'
+ '* Invoicing (products and/or services)\n'
+ '* Warranty concept\n'
+ '* Repair quotation report\n'
+ '* Notes for the technician and for the final customer.\n'
+ '-This installs the module mrp_repair.'),
'module_mrp_operations': fields.boolean("Allow detailed planning of work order",
help='This allows to add state, date_start,date_stop in production order operation lines (in the "Work Centers" tab).\n'
- '-This installs the module mrp_operations.'),
+ '-This installs the module mrp_operations.'),
'module_mrp_byproduct': fields.boolean("Produce several products from one manufacturing order",
help='You can configure by-products in the bill of material.\n'
- 'Without this module: A + B + C -> D.\n'
- 'With this module: A + B + C -> D + E.\n'
- '-This installs the module mrp_byproduct.'),
+ 'Without this module: A + B + C -> D.\n'
+ 'With this module: A + B + C -> D + E.\n'
+ '-This installs the module mrp_byproduct.'),
'module_mrp_jit': fields.boolean("Generate procurement in real time",
help='This allows Just In Time computation of procurement orders.\n'
- 'All procurement orders will be processed immediately, which could in some '
- 'cases entail a small performance impact.\n'
- '-This installs the module mrp_jit.'),
+ 'All procurement orders will be processed immediately, which could in some '
+ 'cases entail a small performance impact.\n'
+ '-This installs the module mrp_jit.'),
'module_stock_no_autopicking': fields.boolean("Manage manual picking to fulfill manufacturing orders ",
help='This module allows an intermediate picking process to provide raw materials to production orders.\n'
- 'For example to manage production made by your suppliers (sub-contracting).\n'
- 'To achieve this, set the assembled product which is sub-contracted to "No Auto-Picking" '
- 'and put the location of the supplier in the routing of the assembly operation.\n'
- '-This installs the module stock_no_autopicking.'),
+ 'For example to manage production made by your suppliers (sub-contracting).\n'
+ 'To achieve this, set the assembled product which is sub-contracted to "No Auto-Picking" '
+ 'and put the location of the supplier in the routing of the assembly operation.\n'
+ '-This installs the module stock_no_autopicking.'),
'group_mrp_routings': fields.boolean("Manage routings and work orders ",
implied_group='mrp.group_mrp_routings',
help='Routings allow you to create and manage the manufacturing operations that should be followed '
- 'within your work centers in order to produce a product. They are attached to bills of materials '
- 'that will define the required raw materials.'),
+ 'within your work centers in order to produce a product. They are attached to bills of materials '
+ 'that will define the required raw materials.'),
'group_mrp_properties': fields.boolean("Allow several bill of materials per products using properties",
implied_group='product.group_mrp_properties',
help="""The selection of the right Bill of Material to use will depend on the properties specified on the sales order and the Bill of Material."""),
'module_product_manufacturer': fields.boolean("Define manufacturers on products ",
help='This allows you to define the following for a product:\n'
- '* Manufacturer\n'
- '* Manufacturer Product Name\n'
- '* Manufacturer Product Code\n'
- '* Product Attributes.\n'
- '-This installs the module product_manufacturer.'),
+ '* Manufacturer\n'
+ '* Manufacturer Product Name\n'
+ '* Manufacturer Product Code\n'
+ '* Product Attributes.\n'
+ '-This installs the module product_manufacturer.'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project/res_config.py b/addons/project/res_config.py
index 78b05144208..101a868d574 100644
--- a/addons/project/res_config.py
+++ b/addons/project/res_config.py
@@ -28,30 +28,30 @@ class project_configuration(osv.osv_memory):
_columns = {
'module_project_mrp': fields.boolean('Generate tasks from sale orders',
- help ='This feature automatically creates project tasks from service products in sale orders. '
- 'More precisely, tasks are created for procurement lines with product of type \'Service\', '
- 'procurement method \'Make to Order\', and supply method \'Manufacture\'.\n'
- '-This installs the module project_mrp.'),
+ help='This feature automatically creates project tasks from service products in sale orders. '
+ 'More precisely, tasks are created for procurement lines with product of type \'Service\', '
+ 'procurement method \'Make to Order\', and supply method \'Manufacture\'.\n'
+ '-This installs the module project_mrp.'),
'module_pad': fields.boolean("Use integrated collaborative note pads on task",
help='Lets the company customize which Pad installation should be used to link to new pads '
- '(for example: http://ietherpad.com/).\n'
- '-This installs the module pad.'),
+ '(for example: http://ietherpad.com/).\n'
+ '-This installs the module pad.'),
'module_project_timesheet': fields.boolean("Record timesheet lines per tasks",
help='This allows you to transfer the entries under tasks defined for Project Management to '
- 'the timesheet line entries for particular date and user, with the effect of creating, '
- 'editing and deleting either ways.\n'
- '-This installs the module project_timesheet.'),
+ 'the timesheet line entries for particular date and user, with the effect of creating, '
+ 'editing and deleting either ways.\n'
+ '-This installs the module project_timesheet.'),
'module_project_long_term': fields.boolean("Manage resources planning on gantt view",
help='A long term project management module that tracks planning, scheduling, and resource allocation.\n'
- '-This installs the module project_long_term.'),
+ '-This installs the module project_long_term.'),
'module_project_issue': fields.boolean("Track issues and bugs",
help='Provides management of issues/bugs in projects.\n'
- '-This installs the module project_issue.'),
+ '-This installs the module project_issue.'),
'time_unit': fields.many2one('product.uom', 'Working time unit', required=True,
help="""This will set the unit of measure used in projects and tasks."""),
'module_project_issue_sheet': fields.boolean("Invoice working time on issues",
help='Provides timesheet support for the issues/bugs management in project.\n'
- '-This installs the module project_issue_sheet.'),
+ '-This installs the module project_issue_sheet.'),
'group_tasks_work_on_tasks': fields.boolean("Log work activities on tasks",
implied_group='project.group_tasks_work_on_tasks',
help="Allows you to compute work on tasks."),
diff --git a/addons/purchase/res_config.py b/addons/purchase/res_config.py
index 82b07a839d2..87db14c5a90 100644
--- a/addons/purchase/res_config.py
+++ b/addons/purchase/res_config.py
@@ -35,7 +35,7 @@ class purchase_config_settings(osv.osv_memory):
'group_purchase_pricelist':fields.boolean("Manage pricelist per supplier",
implied_group='product.group_purchase_pricelist',
help='Allows to manage different prices based on rules per category of Supplier.\n'
- 'Example: 10% for retailers, promotion of 5 EUR on this product, etc.'),
+ 'Example: 10% for retailers, promotion of 5 EUR on this product, etc.'),
'group_uom':fields.boolean("Manage different units of measure for products",
implied_group='product.group_uom',
help="""Allows you to select and maintain different units of measure for products."""),
@@ -44,18 +44,18 @@ class purchase_config_settings(osv.osv_memory):
help="""Allows you to compute product cost price based on average cost."""),
'module_warning': fields.boolean("Alerts by products or supplier",
help='Allow to configure notification on products and trigger them when a user wants to purchase a given product or a given supplier.\n'
- 'Example: Product: this product is deprecated, do not purchase more than 5.\n'
- 'Supplier: don\'t forget to ask for an express delivery.'),
+ 'Example: Product: this product is deprecated, do not purchase more than 5.\n'
+ 'Supplier: don\'t forget to ask for an express delivery.'),
'module_purchase_double_validation': fields.boolean("Force two levels of approvals",
help='Provide a double validation mechanism for purchases exceeding minimum amount.\n'
- '-This installs the module purchase_double_validation.'),
+ '-This installs the module purchase_double_validation.'),
'module_purchase_requisition': fields.boolean("Manage purchase requisitions",
help='Purchase Requisitions are used when you want to request quotations from several suppliers for a given set of products.\n'
- 'You can configure per product if you directly do a Request for Quotation '
- 'to one supplier or if you want a purchase requisition to negotiate with several suppliers.'),
+ 'You can configure per product if you directly do a Request for Quotation '
+ 'to one supplier or if you want a purchase requisition to negotiate with several suppliers.'),
'module_purchase_analytic_plans': fields.boolean('Use multiple analytic accounts on purchase orders',
- help ='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
- '-This installs the module purchase_analytic_plans.'),
+ help='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
+ '-This installs the module purchase_analytic_plans.'),
'group_analytic_account_for_purchases': fields.boolean('Analytic accounting for purchases',
implied_group='purchase.group_analytic_accounting',
help="Allows you to specify an analytic account on purchase orders."),
@@ -77,8 +77,8 @@ class account_config_settings(osv.osv_memory):
_inherit = 'account.config.settings'
_columns = {
'module_purchase_analytic_plans': fields.boolean('Use multiple analytic accounts on orders',
- help ='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
- '-This installs the module purchase_analytic_plans.'),
+ help='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
+ '-This installs the module purchase_analytic_plans.'),
'group_analytic_account_for_purchases': fields.boolean('Analytic accounting for purchases',
implied_group='purchase.group_analytic_accounting',
help="Allows you to specify an analytic account on purchase orders."),
diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py
index 7c080d8168f..04958521ab5 100644
--- a/addons/sale/res_config.py
+++ b/addons/sale/res_config.py
@@ -34,15 +34,15 @@ class sale_configuration(osv.osv_memory):
implied_group='sale.group_invoice_so_lines',
help="To allow your salesman to make invoices for sales order lines using the menu 'Lines to Invoice'."),
'timesheet': fields.boolean('Prepare invoices based on timesheets',
- help = 'For modifying account analytic view to show important data to project manager of services companies.'
- 'You can also view the report of account analytic summary user-wise as well as month wise.\n'
- '-This installs the module account_analytic_analysis.'),
+ help='For modifying account analytic view to show important data to project manager of services companies.'
+ 'You can also view the report of account analytic summary user-wise as well as month wise.\n'
+ '-This installs the module account_analytic_analysis.'),
'module_account_analytic_analysis': fields.boolean('Use contracts management',
- help = 'Allows to define your customer contracts conditions: invoicing '
- 'method (fixed price, on timesheet, advance invoice), the exact pricing '
- '(650€/day for a developer), the duration (one year support contract).\n'
- 'You will be able to follow the progress of the contract and invoice automatically.\n'
- '-It installs the account_analytic_analysis module.'),
+ help='Allows to define your customer contracts conditions: invoicing '
+ 'method (fixed price, on timesheet, advance invoice), the exact pricing '
+ '(650€/day for a developer), the duration (one year support contract).\n'
+ 'You will be able to follow the progress of the contract and invoice automatically.\n'
+ '-It installs the account_analytic_analysis module.'),
'time_unit': fields.many2one('product.uom', 'The default working time unit for services is'),
'group_sale_pricelist':fields.boolean("Use pricelists to adapt your price per customers",
implied_group='product.group_sale_pricelist',
@@ -59,25 +59,25 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
help="""Allow to manage several variants per product. As an example, if you sell T-Shirts, for the same "Linux T-Shirt", you may have variants on sizes or colors; S, M, L, XL, XXL."""),
'module_warning': fields.boolean("Allow configuring alerts by customer or products",
help='Allow to configure notification on products and trigger them when a user wants to sell a given product or a given customer.\n'
- 'Example: Product: this product is deprecated, do not purchase more than 5.\n'
- 'Supplier: don\'t forget to ask for an express delivery.'),
+ 'Example: Product: this product is deprecated, do not purchase more than 5.\n'
+ 'Supplier: don\'t forget to ask for an express delivery.'),
'module_sale_margin': fields.boolean("Display margins on sales orders",
help='This adds the \'Margin\' on sales order.\n'
- 'This gives the profitability by calculating the difference between the Unit Price and Cost Price.\n'
- '-This installs the module sale_margin.'),
+ 'This gives the profitability by calculating the difference between the Unit Price and Cost Price.\n'
+ '-This installs the module sale_margin.'),
'module_sale_journal': fields.boolean("Allow batch invoicing of delivery orders through journals",
help='Allows you to categorize your sales and deliveries (picking lists) between different journals, '
- 'and perform batch operations on journals.\n'
- '-This installs the module sale_journal.'),
+ 'and perform batch operations on journals.\n'
+ '-This installs the module sale_journal.'),
'module_analytic_user_function': fields.boolean("One employee can have different roles per contract",
help='Allows you to define what is the default function of a specific user on a given account.\n'
- 'This is mostly used when a user encodes his timesheet. The values are retrieved and the fields are auto-filled. '
- 'But the possibility to change these values is still available.\n'
- '-This installs the module analytic_user_function.'),
+ 'This is mostly used when a user encodes his timesheet. The values are retrieved and the fields are auto-filled. '
+ 'But the possibility to change these values is still available.\n'
+ '-This installs the module analytic_user_function.'),
'module_project': fields.boolean("Project"),
'module_sale_stock': fields.boolean("Trigger delivery orders automatically from sales orders",
help='Allows you to Make Quotation, Sale Order using different Order policy and Manage Related Stock.\n'
- '-This installs the module sale_stock.'),
+ '-This installs the module sale_stock.'),
}
def default_get(self, cr, uid, fields, context=None):
diff --git a/addons/sale_stock/res_config.py b/addons/sale_stock/res_config.py
index 01871bf6f1d..f52dcf89659 100644
--- a/addons/sale_stock/res_config.py
+++ b/addons/sale_stock/res_config.py
@@ -34,17 +34,17 @@ class sale_configuration(osv.osv_memory):
help="To allow your salesman to make invoices for Delivery Orders using the menu 'Deliveries to Invoice'."),
'task_work': fields.boolean("Prepare invoices based on task's activities",
help='Lets you transfer the entries under tasks defined for Project Management to '
- 'the Timesheet line entries for particular date and particular user with the effect of creating, editing and deleting either ways '
- 'and to automatically creates project tasks from procurement lines.\n'
- '-This installs the modules project_timesheet and project_mrp.'),
+ 'the Timesheet line entries for particular date and particular user with the effect of creating, editing and deleting either ways '
+ 'and to automatically creates project tasks from procurement lines.\n'
+ '-This installs the modules project_timesheet and project_mrp.'),
'default_order_policy': fields.selection(
[('manual', 'Invoice based on sales orders'), ('picking', 'Invoice based on deliveries')],
'The default invoicing method is', default_model='sale.order',
help="You can generate invoices based on sales orders or based on shippings."),
'module_delivery': fields.boolean('Allow adding shipping costs',
- help ='Allows you to add delivery methods in sales orders and delivery orders.\n'
- 'You can define your own carrier and delivery grids for prices.\n'
- '-This installs the module delivery.'),
+ help='Allows you to add delivery methods in sales orders and delivery orders.\n'
+ 'You can define your own carrier and delivery grids for prices.\n'
+ '-This installs the module delivery.'),
'default_picking_policy' : fields.boolean("Deliver all at once when all products are available.",
help = "Sales order by default will be configured to deliver all products at once instead of delivering each product when it is available. This may have an impact on the shipping price."),
'group_mrp_properties': fields.boolean('Product properties on order lines',
diff --git a/addons/stock/res_config.py b/addons/stock/res_config.py
index 1ce5d9d25fa..453f86bc607 100644
--- a/addons/stock/res_config.py
+++ b/addons/stock/res_config.py
@@ -28,11 +28,11 @@ class stock_config_settings(osv.osv_memory):
_columns = {
'module_claim_from_delivery': fields.boolean("Allow claim on deliveries",
help='Adds a Claim link to the delivery order.\n'
- '-This installs the module claim_from_delivery.'),
+ '-This installs the module claim_from_delivery.'),
'module_stock_invoice_directly': fields.boolean("Create and open the invoice when the user finish a delivery order",
help='This allows to automatically launch the invoicing wizard if the delivery is '
- 'to be invoiced when you send or deliver goods.\n'
- '-This installs the module stock_invoice_directly.'),
+ 'to be invoiced when you send or deliver goods.\n'
+ '-This installs the module stock_invoice_directly.'),
'module_product_expiry': fields.boolean("Expiry date on serial numbers",
help="""Track different dates on products and serial numbers.
The following dates can be tracked:
@@ -43,16 +43,16 @@ The following dates can be tracked:
This installs the module product_expiry."""),
'module_stock_location': fields.boolean("Create push/pull logistic rules",
help='Provide push and pull inventory flows. Typical uses of this feature are: '
- 'manage product manufacturing chains, manage default locations per product, '
- 'define routes within your warehouse according to business needs, etc.\n'
- '-This installs the module stock_location.'),
+ 'manage product manufacturing chains, manage default locations per product, '
+ 'define routes within your warehouse according to business needs, etc.\n'
+ '-This installs the module stock_location.'),
'group_uom': fields.boolean("Manage different units of measure for products",
implied_group='product.group_uom',
help="""Allows you to select and maintain different units of measure for products."""),
'group_uos': fields.boolean("Invoice products in a different unit of measure than the sales order",
implied_group='product.group_uos',
help='Allows you to sell units of a product, but invoice based on a different unit of measure.\n'
- 'For instance, you can sell pieces of meat that you invoice based on their weight.'),
+ 'For instance, you can sell pieces of meat that you invoice based on their weight.'),
'group_stock_packaging': fields.boolean("Allow to define several packaging methods on products",
implied_group='product.group_stock_packaging',
help="""Allows you to create and manage your packaging dimensions and types you want to be maintained in your system."""),
@@ -68,7 +68,7 @@ This installs the module product_expiry."""),
'group_stock_multiple_locations': fields.boolean("Manage multiple locations and warehouses",
implied_group='stock.group_locations',
help='This allows to configure and use multiple stock locations and warehouses, '
- 'instead of having a single default one.'),
+ 'instead of having a single default one.'),
'decimal_precision': fields.integer('Decimal precision on weight', help="As an example, a decimal precision of 2 will allow weights like: 9.99 kg, whereas a decimal precision of 4 will allow weights like: 0.0231 kg."),
}
From fb7d1001dd30f53be79532aa3e6a81b8b01dff7d Mon Sep 17 00:00:00 2001
From: Launchpad Translations on behalf of openerp <>
Date: Wed, 18 Sep 2013 04:49:24 +0000
Subject: [PATCH 084/175] Launchpad automatic translations update.
bzr revid: launchpad_translations_on_behalf_of_openerp-20130918044924-csoci28hkz0lyqm3
---
addons/marketing_campaign/i18n/th.po | 1056 ++++++++++++++++++++++++++
1 file changed, 1056 insertions(+)
create mode 100644 addons/marketing_campaign/i18n/th.po
diff --git a/addons/marketing_campaign/i18n/th.po b/addons/marketing_campaign/i18n/th.po
new file mode 100644
index 00000000000..5988dbb8b22
--- /dev/null
+++ b/addons/marketing_campaign/i18n/th.po
@@ -0,0 +1,1056 @@
+# Thai translation for openobject-addons
+# Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013
+# This file is distributed under the same license as the openobject-addons package.
+# FIRST AUTHOR , 2013.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: openobject-addons\n"
+"Report-Msgid-Bugs-To: FULL NAME \n"
+"POT-Creation-Date: 2012-12-21 17:05+0000\n"
+"PO-Revision-Date: 2013-09-18 00:30+0000\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: Thai
\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Launchpad-Export-Date: 2013-09-18 04:49+0000\n"
+"X-Generator: Launchpad (build 16765)\n"
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+msgid "Manual Mode"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.transition,activity_from_id:0
+msgid "Previous Activity"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:819
+#, python-format
+msgid "The current step for this item has no email or report to preview."
+msgstr ""
+
+#. module: marketing_campaign
+#: constraint:marketing.campaign.transition:0
+msgid "The To/From Activity of transition must be of the same Campaign "
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.transition,trigger:0
+msgid "Time"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.activity,type:0
+msgid "Custom Action"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: view:marketing.campaign:0
+#: view:marketing.campaign.segment:0
+#: view:marketing.campaign.workitem:0
+msgid "Group By..."
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,revenue:0
+msgid ""
+"Set an expected revenue if you consider that every campaign item that has "
+"reached this point has generated a certain revenue. You can get revenue "
+"statistics in the Reporting section"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.transition,trigger:0
+msgid "Trigger"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+msgid "Follow-Up"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:campaign.analysis,count:0
+msgid "# of Actions"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+msgid "Campaign Editor"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+#: selection:marketing.campaign,state:0
+#: view:marketing.campaign.segment:0
+#: selection:marketing.campaign.segment,state:0
+msgid "Running"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:email.template,body_html:marketing_campaign.email_template_3
+msgid ""
+"Hi, we are delighted to let you know that you have entered the select circle "
+"of our Gold Partners"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "March"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,object_id:0
+msgid "Object"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "Sync mode: only records created after last sync"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,condition:0
+msgid ""
+"Python expression to decide whether the activity can be executed, otherwise "
+"it will be deleted or cancelled.The expression may use the following "
+"[browsable] variables:\n"
+" - activity: the campaign activity\n"
+" - workitem: the campaign workitem\n"
+" - resource: the resource object this campaign item represents\n"
+" - transitions: list of campaign transitions outgoing from this activity\n"
+"...- re: Python regular expression module"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+#: view:marketing.campaign.segment:0
+msgid "Set to Draft"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.activity:0
+#: field:marketing.campaign.activity,to_ids:0
+msgid "Next Activities"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:148
+#, python-format
+msgid ""
+"The campaign cannot be started. It does not have any starting activity. "
+"Modify campaign's activities to mark one as the starting point."
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,email_template_id:0
+msgid "The email to send when this activity is activated"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+#: field:marketing.campaign.segment,date_run:0
+msgid "Launch Date"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,day:0
+msgid "Day"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.activity:0
+msgid "Outgoing Transitions"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+msgid "Reset"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign,object_id:0
+msgid "Choose the resource on which you want this campaign to be run"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.actions.client,name:marketing_campaign.action_client_marketing_menu
+msgid "Open Marketing Menu"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.segment,sync_last_date:0
+msgid "Last Synchronization"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.transition,interval_type:0
+msgid "Year(s)"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.segment,sync_last_date:0
+msgid ""
+"Date on which this segment was synchronized last time (automatically or "
+"manually)"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,state:0
+#: selection:marketing.campaign,state:0
+#: selection:marketing.campaign.segment,state:0
+#: selection:marketing.campaign.workitem,state:0
+msgid "Cancelled"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.transition,trigger:0
+msgid "Automatic"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign,mode:0
+msgid ""
+"Test - It creates and process all the activities directly (without waiting "
+"for the delay on transitions) but does not send emails or produce reports.\n"
+"Test in Realtime - It creates and processes all the activities directly but "
+"does not send emails or produce reports.\n"
+"With Manual Confirmation - the campaigns runs normally, but the user has to "
+"validate all workitem manually.\n"
+"Normal - the campaign runs normally and automatically sends all emails and "
+"reports (be very careful with this mode, you're live!)"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.segment,date_run:0
+msgid "Initial start date of this segment."
+msgstr ""
+
+#. module: marketing_campaign
+#: view:res.partner:0
+msgid "False"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,campaign_id:0
+#: view:marketing.campaign:0
+#: field:marketing.campaign.activity,campaign_id:0
+#: view:marketing.campaign.segment:0
+#: field:marketing.campaign.segment,campaign_id:0
+#: view:marketing.campaign.workitem:0
+#: field:marketing.campaign.workitem,campaign_id:0
+msgid "Campaign"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:email.template,body_html:marketing_campaign.email_template_1
+msgid "Hello, you will receive your welcome pack via email shortly."
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,segment_id:0
+#: view:marketing.campaign.segment:0
+#: view:marketing.campaign.workitem:0
+#: field:marketing.campaign.workitem,segment_id:0
+msgid "Segment"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:214
+#, python-format
+msgid "You cannot duplicate a campaign, Not supported yet."
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,type:0
+msgid ""
+"The type of action to execute when an item enters this activity, such as:\n"
+" - Email: send an email using a predefined email template\n"
+" - Report: print an existing Report defined on the resource item and save "
+"it into a specific directory\n"
+" - Custom Action: execute a predefined action, e.g. to modify the fields "
+"of the resource record\n"
+" "
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.segment,date_next_sync:0
+msgid "Next time the synchronization job is scheduled to run automatically"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.transition,interval_type:0
+msgid "Month(s)"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,partner_id:0
+#: model:ir.model,name:marketing_campaign.model_res_partner
+#: field:marketing.campaign.workitem,partner_id:0
+msgid "Partner"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.filters,name:marketing_campaign.filter0
+msgid "Partners"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+msgid "Marketing Reports"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign,state:0
+#: selection:marketing.campaign.segment,state:0
+msgid "New"
+msgstr ""
+
+#. module: marketing_campaign
+#: sql_constraint:marketing.campaign.transition:0
+msgid "The interval must be positive or zero"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.activity,type:0
+msgid "Email"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign,name:0
+#: field:marketing.campaign.activity,name:0
+#: field:marketing.campaign.segment,name:0
+#: field:marketing.campaign.transition,name:0
+msgid "Name"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.workitem,res_name:0
+msgid "Resource Name"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.segment,sync_mode:0
+msgid "Synchronization mode"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+#: view:marketing.campaign.segment:0
+msgid "Run"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.activity:0
+#: field:marketing.campaign.activity,from_ids:0
+msgid "Previous Activities"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:email.template,subject:marketing_campaign.email_template_2
+msgid "Congratulations! You are now a Silver Partner!"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.segment,date_done:0
+msgid "Date this segment was last closed or cancelled."
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+msgid "Marketing Campaign Activities"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+#: field:marketing.campaign.workitem,error_msg:0
+msgid "Error Message"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.actions.act_window,name:marketing_campaign.action_marketing_campaign_form
+#: model:ir.ui.menu,name:marketing_campaign.menu_marketing_campaign
+#: model:ir.ui.menu,name:marketing_campaign.menu_marketing_campaign_form
+#: view:marketing.campaign:0
+#: view:res.partner:0
+msgid "Campaigns"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.transition,interval_type:0
+msgid "Interval Unit"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:campaign.analysis,country_id:0
+msgid "Country"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,report_id:0
+#: selection:marketing.campaign.activity,type:0
+msgid "Report"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "July"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.ui.menu,name:marketing_campaign.menu_marketing_configuration
+msgid "Configuration"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,variable_cost:0
+msgid ""
+"Set a variable cost if you consider that every campaign item that has "
+"reached this point has entailed a certain cost. You can get cost statistics "
+"in the Reporting section"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.transition,interval_type:0
+msgid "Hour(s)"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.model,name:marketing_campaign.model_marketing_campaign_segment
+msgid "Campaign Segment"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,keep_if_condition_not_met:0
+msgid ""
+"By activating this option, workitems that aren't executed because the "
+"condition is not met are marked as cancelled instead of being deleted."
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+msgid "Exceptions"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.actions.act_window,name:marketing_campaign.act_marketing_campaing_followup
+#: field:res.partner,workitem_ids:0
+msgid "Workitems"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign,fixed_cost:0
+msgid "Fixed Cost"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "Newly Modified"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.actions.act_window,help:marketing_campaign.action_marketing_campaign_form
+msgid ""
+"
\n"
+" Click to create a marketing campaign.\n"
+"
\n"
+" OpenERP's marketing campaign allows you to automate "
+"communication\n"
+" to your prospects. You can define a segment (set of conditions) "
+"on\n"
+" your leads and partners to fullfil the campaign.\n"
+"
\n"
+" A campaign can have many activities like sending an email, "
+"printing\n"
+" a letter, assigning to a team, etc. These activities are "
+"triggered\n"
+" from specific situations; contact form, 10 days after first\n"
+" contact, if a lead is not closed yet, etc.\n"
+"
\n"
+" "
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.transition,interval_nbr:0
+msgid "Interval Value"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:campaign.analysis,revenue:0
+#: field:marketing.campaign.activity,revenue:0
+msgid "Revenue"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "September"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "December"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign,partner_field_id:0
+msgid ""
+"The generated workitems will be linked to the partner related to the record. "
+"If the record is the partner itself leave this field empty. This is useful "
+"for reporting purposes, via the Campaign Analysis or Campaign Follow-up "
+"views."
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,month:0
+msgid "Month"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.transition,activity_to_id:0
+msgid "Next Activity"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.actions.act_window,name:marketing_campaign.act_marketing_campaing_stat
+#: model:ir.actions.act_window,name:marketing_campaign.action_marketing_campaign_workitem
+#: model:ir.ui.menu,name:marketing_campaign.menu_action_marketing_campaign_workitem
+msgid "Campaign Follow-up"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+msgid "Test Mode"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.segment,sync_mode:0
+msgid "Only records modified after last sync (no duplicates)"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.model,name:marketing_campaign.model_ir_actions_report_xml
+msgid "ir.actions.report.xml"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+msgid "Campaign Statistics"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,server_action_id:0
+msgid "The action to perform when this activity is activated"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign,partner_field_id:0
+msgid "Partner Field"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: model:ir.actions.act_window,name:marketing_campaign.action_campaign_analysis_all
+#: model:ir.model,name:marketing_campaign.model_campaign_analysis
+#: model:ir.ui.menu,name:marketing_campaign.menu_action_campaign_analysis_all
+msgid "Campaign Analysis"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.segment,sync_mode:0
+msgid ""
+"Determines an additional criterion to add to the filter when selecting new "
+"records to inject in the campaign. \"No duplicates\" prevents selecting "
+"records which have already entered the campaign previously.If the campaign "
+"has a \"unique field\" set, \"no duplicates\" will also prevent selecting "
+"records which have the same value for the unique field as other records that "
+"already entered the campaign."
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign,mode:0
+msgid "Test in Realtime"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign,mode:0
+msgid "Test Directly"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,report_directory_id:0
+msgid "Directory"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+#: view:marketing.campaign.segment:0
+msgid "Draft"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+msgid "Marketing Campaign Activity"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+msgid "Preview"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,state:0
+#: view:marketing.campaign:0
+#: field:marketing.campaign,state:0
+#: view:marketing.campaign.segment:0
+#: field:marketing.campaign.segment,state:0
+#: view:marketing.campaign.workitem:0
+#: field:marketing.campaign.workitem,state:0
+msgid "Status"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "August"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign,mode:0
+msgid "Normal"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,start:0
+msgid "This activity is launched when the campaign starts."
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,signal:0
+msgid ""
+"An activity with a signal can be called programmatically. Be careful, the "
+"workitem is always created when a signal is sent"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: selection:campaign.analysis,state:0
+#: view:marketing.campaign.workitem:0
+#: selection:marketing.campaign.workitem,state:0
+msgid "To Do"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "June"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.model,name:marketing_campaign.model_email_template
+msgid "Email Templates"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "Sync mode: all records"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.segment,sync_mode:0
+msgid "All records (no duplicates)"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "Newly Created"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:campaign.analysis,date:0
+msgid "Date"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "November"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,condition:0
+msgid "Condition"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,report_id:0
+msgid "The report to generate when this activity is activated"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign,unique_field_id:0
+msgid "Unique Field"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,state:0
+#: view:marketing.campaign.workitem:0
+#: selection:marketing.campaign.workitem,state:0
+msgid "Exception"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "October"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,email_template_id:0
+msgid "Email Template"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "January"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+#: field:marketing.campaign.workitem,date:0
+msgid "Execution Date"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.model,name:marketing_campaign.model_marketing_campaign_workitem
+msgid "Campaign Workitem"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.model,name:marketing_campaign.model_marketing_campaign_activity
+msgid "Campaign Activity"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.activity,report_directory_id:0
+msgid "This folder is used to store the generated reports"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:136
+#: code:addons/marketing_campaign/marketing_campaign.py:148
+#: code:addons/marketing_campaign/marketing_campaign.py:158
+#, python-format
+msgid "Error"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,server_action_id:0
+msgid "Action"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:528
+#, python-format
+msgid "Automatic transition"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,start:0
+msgid "Start"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:819
+#, python-format
+msgid "No preview"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+msgid "Process"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:530
+#: selection:marketing.campaign.transition,trigger:0
+#, python-format
+msgid "Cosmetic"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.transition,trigger:0
+msgid "How is the destination workitem triggered"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: selection:campaign.analysis,state:0
+#: view:marketing.campaign:0
+#: selection:marketing.campaign,state:0
+#: selection:marketing.campaign.segment,state:0
+#: selection:marketing.campaign.workitem,state:0
+msgid "Done"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:214
+#, python-format
+msgid "Operation not supported"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+msgid "Cancel"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "Close"
+msgstr ""
+
+#. module: marketing_campaign
+#: constraint:marketing.campaign.segment:0
+msgid "Model of filter must be same as resource model of Campaign "
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "Synchronize Manually"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.workitem:0
+#: field:marketing.campaign.workitem,res_id:0
+msgid "Resource ID"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.model,name:marketing_campaign.model_marketing_campaign_transition
+msgid "Campaign Transition"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "Marketing Campaign Segment"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.actions.act_window,name:marketing_campaign.act_marketing_campaing_segment_opened
+#: model:ir.actions.act_window,name:marketing_campaign.action_marketing_campaign_segment_form
+#: model:ir.ui.menu,name:marketing_campaign.menu_marketing_campaign_segment_form
+#: view:marketing.campaign:0
+#: view:marketing.campaign.segment:0
+msgid "Segments"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,keep_if_condition_not_met:0
+msgid "Don't Delete Workitems"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.activity:0
+msgid "Incoming Transitions"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.transition,interval_type:0
+msgid "Day(s)"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+#: field:marketing.campaign,activity_ids:0
+#: view:marketing.campaign.activity:0
+msgid "Activities"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign,mode:0
+msgid "With Manual Confirmation"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "May"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,type:0
+msgid "Type"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:email.template,subject:marketing_campaign.email_template_3
+msgid "Congratulations! You are now one of our Gold Partners!"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign,unique_field_id:0
+msgid ""
+"If set, this field will help segments that work in \"no duplicates\" mode to "
+"avoid selecting similar records twice. Similar records are records that have "
+"the same value for this unique field. For example by choosing the "
+"\"email_from\" field for CRM Leads you would prevent sending the same "
+"campaign to the same email address again. If not set, the \"no duplicates\" "
+"segments will only avoid selecting the same record again if it entered the "
+"campaign previously. Only easily comparable fields like textfields, "
+"integers, selections or single relationships may be used."
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:529
+#, python-format
+msgid "After %(interval_nbr)d %(interval_type)s"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:ir.model,name:marketing_campaign.model_marketing_campaign
+#: view:marketing.campaign:0
+msgid "Marketing Campaign"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.segment,date_done:0
+msgid "End Date"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "February"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,res_id:0
+#: view:marketing.campaign:0
+#: field:marketing.campaign,object_id:0
+#: field:marketing.campaign.segment,object_id:0
+#: view:marketing.campaign.workitem:0
+#: field:marketing.campaign.workitem,object_id:0
+msgid "Resource"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign,fixed_cost:0
+msgid ""
+"Fixed cost for running this campaign. You may also specify variable cost and "
+"revenue on each campaign activity. Cost and Revenue statistics are included "
+"in Campaign Reporting."
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "Sync mode: only records updated after last sync"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:793
+#, python-format
+msgid "Email Preview"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,signal:0
+msgid "Signal"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.workitem,date:0
+msgid "If date is not set, this workitem has to be run manually"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:campaign.analysis,month:0
+msgid "April"
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:158
+#, python-format
+msgid "The campaign cannot be marked as done before all segments are closed."
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign:0
+#: field:marketing.campaign,mode:0
+msgid "Mode"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,activity_id:0
+#: view:marketing.campaign.workitem:0
+#: field:marketing.campaign.workitem,activity_id:0
+msgid "Activity"
+msgstr ""
+
+#. module: marketing_campaign
+#: help:marketing.campaign.segment,ir_filter_id:0
+msgid ""
+"Filter to select the matching resource records that belong to this segment. "
+"New filters can be created and saved using the advanced search on the list "
+"view of the Resource. If no filter is set, all records are selected without "
+"filtering. The synchronization mode may also add a criterion to the filter."
+msgstr ""
+
+#. module: marketing_campaign
+#: code:addons/marketing_campaign/marketing_campaign.py:136
+#, python-format
+msgid "The campaign cannot be started. There are no activities in it."
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.segment,date_next_sync:0
+msgid "Next Synchronization"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:email.template,body_html:marketing_campaign.email_template_2
+msgid ""
+"Hi, we are delighted to welcome you among our Silver Partners as of today!"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.segment,ir_filter_id:0
+msgid "Filter"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:marketing.campaign.segment:0
+msgid "All"
+msgstr ""
+
+#. module: marketing_campaign
+#: selection:marketing.campaign.segment,sync_mode:0
+msgid "Only records created after last sync"
+msgstr ""
+
+#. module: marketing_campaign
+#: field:marketing.campaign.activity,variable_cost:0
+msgid "Variable Cost"
+msgstr ""
+
+#. module: marketing_campaign
+#: model:email.template,subject:marketing_campaign.email_template_1
+msgid "Welcome to the OpenERP Partner Channel!"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,total_cost:0
+msgid "Cost"
+msgstr ""
+
+#. module: marketing_campaign
+#: view:campaign.analysis:0
+#: field:campaign.analysis,year:0
+msgid "Year"
+msgstr ""
From 0afff9aae3497d2621bd9b3d5abd56531f60fb95 Mon Sep 17 00:00:00 2001
From: ima-openerp
Date: Wed, 18 Sep 2013 12:28:54 +0530
Subject: [PATCH 085/175] [IMP]removed unused method which is defined only for
web shortcuts module.
bzr revid: ishwarmalvi13@gmail.com-20130918065854-u0aiyu5e1z7tf09g
---
addons/web/controllers/main.py | 7 -------
1 file changed, 7 deletions(-)
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 651e5c42a97..81d37b5aae0 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -1010,13 +1010,6 @@ class Menu(http.Controller):
"""
return request.session.model('ir.ui.menu').get_needaction_data(menu_ids, request.context)
- @http.route('/web/menu/action', type='json', auth="user")
- def action(self, menu_id):
- # still used by web_shortcut
- actions = load_actions_from_ir_values('action', 'tree_but_open',
- [('ir.ui.menu', menu_id)], False)
- return {"action": actions}
-
class DataSet(http.Controller):
@http.route('/web/dataset/search_read', type='json', auth="user")
From bb729505467b889175af354034803f0b678cc1e6 Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Wed, 18 Sep 2013 19:06:11 +0530
Subject: [PATCH 086/175] [IMP] improved code for compatibility of tags in rml
file
bzr revid: dizzy.zala@gmail.com-20130918133611-v75spcf3tgnoadnr
---
openerp/report/render/rml2pdf/customfonts.py | 76 ++++++++++++++++----
1 file changed, 61 insertions(+), 15 deletions(-)
diff --git a/openerp/report/render/rml2pdf/customfonts.py b/openerp/report/render/rml2pdf/customfonts.py
index c09f9a11a9b..9c55d0a25d3 100644
--- a/openerp/report/render/rml2pdf/customfonts.py
+++ b/openerp/report/render/rml2pdf/customfonts.py
@@ -36,7 +36,7 @@ should have the same filenames, only need the code below).
Due to an awful configuration that ships with reportlab at many Linux
and Ubuntu distros, we have to override the search path, too.
"""
-_fonts_info = {'supported_fonts':[], 'font_len': 0}
+_fonts_cache = {'regestered_fonts':[], 'total_system_fonts': 0}
_logger = logging.getLogger(__name__)
CustomTTFonts = [ ('Helvetica', "DejaVu Sans", "DejaVuSans.ttf", 'normal'),
@@ -89,7 +89,12 @@ TTFSearchPathMap = {
'Linux': TTFSearchPath_Linux,
}
+__foundFonts = None
+
def linux_home_fonts():
+ """
+ This function appends local font directory in TTFSearchPath_Linux.
+ """
home = os.environ.get('HOME')
if home is not None:
# user fonts on OSX
@@ -98,8 +103,13 @@ def linux_home_fonts():
TTFSearchPath_Linux.append(path)
def all_sysfonts_list():
+ """
+ This function returns list of font directories of system.
+ """
searchpath = []
filepath = []
+ global __foundFonts
+ __foundFonts = {}
local_platform = platform.system()
if local_platform in TTFSearchPathMap:
if local_platform == 'Linux':
@@ -112,25 +122,59 @@ def all_sysfonts_list():
if os.path.exists(dirname):
for filename in [x for x in os.listdir(dirname) if x.lower().endswith('.ttf')]:
filepath.append(os.path.join(dirname, filename))
+ __foundFonts[filename]=os.path.join(dirname, filename)
return filepath
def RegisterCustomFonts():
- global _fonts_info
- all_system_fonts = all_sysfonts_list()
- if len(all_system_fonts) > _fonts_info['font_len']:
+ """
+ This function registers all fonts in reportlab if font is not regestered
+ and returns the updated list of registered fonts.
+ """
+ global _fonts_cache
+ all_system_fonts = sorted(all_sysfonts_list())
+ if len(all_system_fonts) > _fonts_cache['total_system_fonts']:
+ all_mode = {}
+ last_family = ""
for dirname in all_system_fonts:
try:
- face = ttfonts.TTFontFace(dirname)
- if (face.name, face.name) not in _fonts_info['supported_fonts']:
- font_info = ttfonts.TTFontFile(dirname)
- pdfmetrics.registerFont(ttfonts.TTFont(face.name, dirname, asciiReadable=0))
- _fonts_info['supported_fonts'].append((face.name, face.name))
- CustomTTFonts.append((font_info.familyName, font_info.name, dirname.split('/')[-1], font_info.styleName.lower().replace(" ", "")))
- _logger.debug("Found font %s at %s", face.name, dirname)
+ font_info = ttfonts.TTFontFile(dirname)
+ if (font_info.name, font_info.name) not in _fonts_cache['regestered_fonts']:
+ if font_info.name not in pdfmetrics._fonts:
+ pdfmetrics.registerFont(ttfonts.TTFont(font_info.name, dirname, asciiReadable=0))
+ if not last_family:
+ last_family = font_info.familyName
+ if not all_mode:
+ all_mode = {
+ 'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
+ 'italic':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'italic'),
+ 'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
+ 'bolditalic':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bolditalic'),
+ }
+ if last_family != font_info.familyName:
+ CustomTTFonts.extend(all_mode.values())
+ all_mode = {
+ 'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
+ 'italic':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'italic'),
+ 'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
+ 'bolditalic':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bolditalic'),
+ }
+ mode = font_info.styleName.lower().replace(" ", "")
+ if (mode== 'normal') or (mode == 'regular') or (mode == 'medium') or (mode == 'book'):
+ all_mode['regular'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular')
+ elif (mode == 'italic') or (mode == 'oblique'):
+ all_mode['italic'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'italic')
+ elif mode == 'bold':
+ all_mode['bold'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold')
+ elif (mode == 'bolditalic') or (mode == 'boldoblique'):
+ all_mode['bolditalic'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'bolditalic')
+ last_family = font_info.familyName
+ _fonts_cache['regestered_fonts'].append((font_info.name, font_info.name))
+ _logger.debug("Found font %s at %s", font_info.name, dirname)
except:
+ remain_mode = ['regular','italic','bold','bolditalic']
_logger.warning("Could not register Font %s", dirname)
- _fonts_info['font_len'] = len(all_system_fonts)
- return _fonts_info['supported_fonts']
+ _fonts_cache['total_system_fonts'] = len(all_system_fonts)
+ return _fonts_cache['regestered_fonts']
def SetCustomFonts(rmldoc):
""" Map some font names to the corresponding TTF fonts
@@ -140,12 +184,14 @@ def SetCustomFonts(rmldoc):
This function is called once per report, so it should
avoid system-wide processing (cache it, instead).
"""
- global _fonts_info
- if not _fonts_info['supported_fonts']:
+ global _fonts_cache
+ if not _fonts_cache['regestered_fonts']:
RegisterCustomFonts()
for name, font, filename, mode in CustomTTFonts:
if os.path.isabs(filename) and os.path.exists(filename):
rmldoc.setTTFontMapping(name, font, filename, mode)
+ elif filename in __foundFonts:
+ rmldoc.setTTFontMapping(name, font, __foundFonts[filename], mode)
return True
# eof
From e9980e87254e2cc9539abdde7200416106b44b9e Mon Sep 17 00:00:00 2001
From: Christophe Simonis
Date: Wed, 18 Sep 2013 23:22:16 +0200
Subject: [PATCH 087/175] [FIX] test_views: update matching error message
bzr revid: chs@openerp.com-20130918212216-libtu7zpsn2768j0
---
openerp/addons/base/tests/test_views.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openerp/addons/base/tests/test_views.py b/openerp/addons/base/tests/test_views.py
index 992ef0886da..6203e4f001e 100644
--- a/openerp/addons/base/tests/test_views.py
+++ b/openerp/addons/base/tests/test_views.py
@@ -13,7 +13,7 @@ class test_views(common.TransactionCase):
self.assertTrue(Views.pool._init)
- error_msg = "Invalid XML for View Architecture"
+ error_msg = "The model name does not exist or the view architecture cannot be rendered"
# test arch check is call for views without xmlid during registry initialization
with self.assertRaisesRegexp(except_orm, error_msg):
Views.create(self.cr, self.uid, {
From 0d09c2c27fdbc551b4ba210030c31435f510e983 Mon Sep 17 00:00:00 2001
From: Launchpad Translations on behalf of openerp <>
Date: Thu, 19 Sep 2013 04:42:13 +0000
Subject: [PATCH 088/175] Launchpad automatic translations update.
bzr revid: launchpad_translations_on_behalf_of_openerp-20130919044213-8gsduei1mhxo2pg9
---
addons/marketing_campaign/i18n/th.po | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/marketing_campaign/i18n/th.po b/addons/marketing_campaign/i18n/th.po
index 5988dbb8b22..1db67eba8ac 100644
--- a/addons/marketing_campaign/i18n/th.po
+++ b/addons/marketing_campaign/i18n/th.po
@@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2013-09-18 04:49+0000\n"
+"X-Launchpad-Export-Date: 2013-09-19 04:42+0000\n"
"X-Generator: Launchpad (build 16765)\n"
#. module: marketing_campaign
From ffdcf3367353028ba0ee72fedc0dd91aae943be2 Mon Sep 17 00:00:00 2001
From: Christophe Simonis
Date: Thu, 19 Sep 2013 13:45:08 +0200
Subject: [PATCH 089/175] [IMP] ir.ui.view: log traceback when validation of
view arch fail
bzr revid: chs@openerp.com-20130919114508-72pv3u1stxw4l3ry
---
openerp/addons/base/ir/ir_ui_view.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py
index f46ac13af42..794f3fcd826 100644
--- a/openerp/addons/base/ir/ir_ui_view.py
+++ b/openerp/addons/base/ir/ir_ui_view.py
@@ -129,6 +129,7 @@ class view(osv.osv):
fvg = self.pool[view.model].fields_view_get(cr, uid, view_id=view.id, view_type=view.type, context=context)
return fvg['arch']
except Exception:
+ _logger.exception('cannot render view %s', view.xml_id)
return False
def _check_xml(self, cr, uid, ids, context=None):
From 28b09221d6b0673edd6eda7708d66bc7f76869cb Mon Sep 17 00:00:00 2001
From: Christophe Simonis
Date: Thu, 19 Sep 2013 13:47:11 +0200
Subject: [PATCH 090/175] [FIX] orm.BaseModel.exists(): early return if no ids
given
bzr revid: chs@openerp.com-20130919114711-ofx2aubtr5z7dgh4
---
openerp/osv/orm.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py
index 83346cae8b3..608b8043706 100644
--- a/openerp/osv/orm.py
+++ b/openerp/osv/orm.py
@@ -5117,6 +5117,8 @@ class BaseModel(object):
"""
if type(ids) in (int, long):
ids = [ids]
+ if not ids:
+ return []
query = 'SELECT id FROM "%s"' % self._table
cr.execute(query + "WHERE ID IN %s", (tuple(ids),))
return [x[0] for x in cr.fetchall()]
From ef96f0424a0e26dbab23a049be9e8103ee93c586 Mon Sep 17 00:00:00 2001
From: Christophe Simonis
Date: Thu, 19 Sep 2013 13:50:14 +0200
Subject: [PATCH 091/175] [IMP] ir.module.module: _get_views(): explictly skip
non-existing records instead of catching exceptions. This avoid useless error
logs
bzr revid: chs@openerp.com-20130919115014-bwjaar877w04k41s
---
openerp/addons/base/module/module.py | 40 +++++++++++-----------------
1 file changed, 15 insertions(+), 25 deletions(-)
diff --git a/openerp/addons/base/module/module.py b/openerp/addons/base/module/module.py
index 39d59a4ab2c..e160c49481e 100644
--- a/openerp/addons/base/module/module.py
+++ b/openerp/addons/base/module/module.py
@@ -24,6 +24,7 @@ from docutils.transforms import Transform, writer_aux
from docutils.writers.html4css1 import Writer
import imp
import logging
+from operator import attrgetter
import os
import re
import shutil
@@ -178,9 +179,6 @@ class module(osv.osv):
def _get_views(self, cr, uid, ids, field_name=None, arg=None, context=None):
res = {}
model_data_obj = self.pool.get('ir.model.data')
- view_obj = self.pool.get('ir.ui.view')
- report_obj = self.pool.get('ir.actions.report.xml')
- menu_obj = self.pool.get('ir.ui.menu')
dmodels = []
if field_name is None or 'views_by_module' in field_name:
@@ -192,7 +190,7 @@ class module(osv.osv):
assert dmodels, "no models for %s" % field_name
for module_rec in self.browse(cr, uid, ids, context=context):
- res[module_rec.id] = {
+ res_mod_dic = res[module_rec.id] = {
'menus_by_module': [],
'reports_by_module': [],
'views_by_module': []
@@ -212,28 +210,20 @@ class module(osv.osv):
for imd_res in model_data_obj.read(cr, uid, imd_ids, ['model', 'res_id'], context=context):
imd_models[imd_res['model']].append(imd_res['res_id'])
- # For each one of the models, get the names of these ids.
- # We use try except, because views or menus may not exist.
- try:
- res_mod_dic = res[module_rec.id]
- view_ids = imd_models.get('ir.ui.view', [])
- for v in view_obj.browse(cr, uid, view_ids, context=context):
- aa = v.inherit_id and '* INHERIT ' or ''
- res_mod_dic['views_by_module'].append('%s%s (%s)' % (aa, v.name, v.type))
+ def browse(model):
+ M = self.pool[model]
+ # as this method is called before the module update, some xmlid may be invalid at this stage
+ # explictly filter records before reading them
+ ids = M.exists(cr, uid, imd_models.get(model, []), context)
+ return M.browse(cr, uid, ids, context)
- report_ids = imd_models.get('ir.actions.report.xml', [])
- for rx in report_obj.browse(cr, uid, report_ids, context=context):
- res_mod_dic['reports_by_module'].append(rx.name)
+ def format_view(v):
+ aa = v.inherit_id and '* INHERIT ' or ''
+ return '%s%s (%s)' % (aa, v.name, v.type)
- menu_ids = imd_models.get('ir.ui.menu', [])
- for um in menu_obj.browse(cr, uid, menu_ids, context=context):
- res_mod_dic['menus_by_module'].append(um.complete_name)
- except KeyError, e:
- _logger.warning('Data not found for items of %s', module_rec.name)
- except AttributeError, e:
- _logger.warning('Data not found for items of %s %s', module_rec.name, str(e))
- except Exception, e:
- _logger.warning('Unknown error while fetching data of %s', module_rec.name, exc_info=True)
+ res_mod_dic['views_by_module'] = map(format_view, browse('ir.ui.view'))
+ res_mod_dic['reports_by_module'] = map(attrgetter('name'), browse('ir.actions.report.xml'))
+ res_mod_dic['menus_by_module'] = map(attrgetter('complete_name'), browse('ir.ui.menu'))
for key in res.iterkeys():
for k, v in res[key].iteritems():
@@ -624,7 +614,7 @@ class module(osv.osv):
# wsgi handlers, so they can react accordingly
if tuple(res) != (0, 0):
for handler in openerp.service.wsgi_server.module_handlers:
- if hasattr(handler,'load_addons'):
+ if hasattr(handler, 'load_addons'):
handler.load_addons()
return res
From 316d079b59d35390cd9aabe2e77aa073e17d8a64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?=
Date: Thu, 19 Sep 2013 15:10:12 +0200
Subject: [PATCH 092/175] [IMP] point_of_sale: remove empty payment lines when
going back to product screen
bzr revid: fva@openerp.com-20130919131012-ylnqrab48a9746l6
---
addons/point_of_sale/static/src/js/screens.js | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js
index a5017d517b7..4d453099690 100644
--- a/addons/point_of_sale/static/src/js/screens.js
+++ b/addons/point_of_sale/static/src/js/screens.js
@@ -883,6 +883,11 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
label: _t('Back'),
icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png',
click: function(){
+ _.each(self.paymentlinewidgets, function(widget){
+ if( widget.payment_line.get_amount() === 0 ){
+ widget.payment_line.destroy();
+ }
+ });
self.pos_widget.screen_selector.set_current_screen(self.back_screen);
},
});
From 91763dbd570f253d2cbd200f17d4dbefa1dff296 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?=
Date: Thu, 19 Sep 2013 15:12:28 +0200
Subject: [PATCH 093/175] [IMP] point_of_sale: confirmation message on session
close when there are unposted orders
bzr revid: fva@openerp.com-20130919131228-hhrp3guno8ddt5m2
---
addons/point_of_sale/static/src/js/widgets.js | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js
index cfec71be68d..0768791651b 100644
--- a/addons/point_of_sale/static/src/js/widgets.js
+++ b/addons/point_of_sale/static/src/js/widgets.js
@@ -668,7 +668,18 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
var self = this;
this._super();
if(this.action){
- this.$el.click(function(){ self.action(); });
+ this.$el.click(function(){
+ var draft_order = _.find( self.pos.get('orders').models, function(order){
+ return order.get('orderLines').length !== 0 && order.get('paymentLines').length === 0;
+ });
+ if(draft_order){
+ if (confirm(_t("Pending orders will be lost.\nAre you sure you want to leave this session?"))) {
+ self.action();
+ }
+ }else{
+ self.action();
+ }
+ });
}
},
show: function(){ this.$el.removeClass('oe_hidden'); },
From 9ddaf705cf8492526c491215101c970d4eaa8c49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?=
Date: Thu, 19 Sep 2013 15:24:35 +0200
Subject: [PATCH 094/175] [FIX] point_of_sale: hr demo data products shouldn't
be available in the point of sale by default
bzr revid: fva@openerp.com-20130919132435-dpr8antwh2e5c6bh
---
addons/hr_expense/hr_expense_demo.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/addons/hr_expense/hr_expense_demo.xml b/addons/hr_expense/hr_expense_demo.xml
index b7b6cd37956..aa490eddbea 100644
--- a/addons/hr_expense/hr_expense_demo.xml
+++ b/addons/hr_expense/hr_expense_demo.xml
@@ -15,6 +15,7 @@
+ /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCACAAIADASIAAhEBAxEB/8QAHQABAAMBAQEBAQEAAAAAAAAAAAYHCAUEAgMBCf/EAD0QAAEDAwMCBAQDBgILAAAAAAECAwQABREGEiEHMRMiQVEUYXGBCDJCFVKRobHBJHIjJSYzU2JjkqLR8f/EABsBAQADAAMBAAAAAAAAAAAAAAABAgMEBQYH/8QAIREAAgICAgIDAQAAAAAAAAAAAAECEQMxBCESQQUTUWH/2gAMAwEAAhEDEQA/ANl0pSgFKUoBSlKAUpSgFKUoBSlKAUpSgFKUoBSlKAUpSgFKUoBSlKAUpSgFKUPHegFKqHUP4gtE2TXh07LcJgoy29dUry028P04A5SOxXnAPpgE1JI3UITZkQw7HcDbHnkNOTXE4QkrVtTgjKSMlOeQRkcHnFZSUdkWTqlKVYkUpSgFKUoBSlKAUpXE1xMulv0vMm2cxhLZSFgyM+GlORuUrHIATk/b1qG6Vg7ZIHc4qNaj11piwrLM25oXIGR8OwkuuZAzgpTnB5HfFQeTZdYX8PN3i7lCOApiNuc86TlaVHyNp4IAOF9s5znPI6j6ah6S6eXS5QGC1P8ACKWpD7xeU3htawNoASMLQPygE5I9TnD7rdIo5P0d299Urk7GcVYLO2yEpUS9O3KSkjuFBHlGMHPn4xzWf+tnVPUEh1Nni6tdnvutlD7cTLDCSrgM5GN54OSQQPRRAOIrctd3U6MtGjUY8KFtakORStXibfKlWVAFKNoSoggH37VCY6ZbL0gKt6UPqVtbfU4MqSfTk5Hb78e1bKPthJvtn2i2NiIVXNxK+fEVtPc+xz+ntx645x2q4/w89U2YUiboXVCXYtuuEdMeBdnFK2Q9qdjbSgo4DQz5VJxtOArjGyrm2y3aplxcX4zkRtDyuMgZdQjA/wC/Ga5Oqp4MVQTyokhORkE+386SUZ2i9H+lOnppuNliTFpCHHGgXUfuL/Un6g5H2r31lD8LPW+NAeh9ONWuhkKV4dsmqVkBZyrwnD8zkpUfmPQVq+pSpUBSlKkClKUArk3m+x4ClMto+IkpHKEqwEf5len05PyqLXnqA0qZc7ZEbVEXBeLDrzxCVgj9SUH0PO1R4I55qttQa8tMRCm/j20jJJ2qK1E+pOM8/WrKP6VcixpespgdKX32WEezIz/M819sXq1XJCmH5aJSHElDranMkpIwoY+hNZyvvVG3N7gw0+8r5kJH9/6VCrlr+5z3P8FFaZVnyqJKiPvxVvG+inmkaR6vWm6XnpmyI0xKH23izcAuYhlLrjYU3u3OnbgLSVbPXII5AqsurXUlFi6YR+nfhplagdUpElBUsphpLhUhlCjys7SEjBKQngFQwa7GutcX3S+grVKbiPLub7CPEuyHCExJPhJbdQoAYKlBsLAUcEqKiCUis7Wtplx5+7uOmXIySSs7ikkZOCe6vf6/XPEx4v30WUVdnmZdnW1pEaTIQ4XleYk8NH90+/19Tx7Z6d1c0/OsMdpMyQzNZWsy5ToIZCR2Awnyqzj1OMnPoK/F1SGoy33mytx9OFIUnkJI/JgjP1FerR9jTPv8Ry5SEORY2Hww5kkkKATvJJCtqlA49QOScVbO1GHm21XfRtjVvxS2Xj0W6VQbppC4S7/MhBmehCWhHdWVuNIdbd3KKkpKFZ8pwD3BPOQbP0/orRRjqdTpi2pZQNjS0FTgW2M4P1PJ9TznknnixrlEYuirN8SFtIS0ypWQUJI8MEj67Nx5PJ+RzNL3c0xVfDoTtbCMg+mc9v8A73z64OPG8jm5c7t9HY/QoKl7IDrXpR03vYU27p2PbFKjrdhzYp/0jqinJBbIyoJBSR6Z7j3sjor+1bfppWnL9fReJ1uecbjvqaKVripVtRuUSfFUkgpK+DwMjPKonp+beJ18iMSYMl21yWkre3tEtI3NhxCgVDGQrbyPXNdaM87a5chKch21J+JbISUpUjcpS0pGBnxEL291eYcklFb8H5HJgyJTdxK5cCa62WlXy4422MuLSn2ye9RzWGqWLNNh2popVPmJW4AeQ20j8yz9SQAPqedpFeG33tmUwVpWC8OHNx8wPzr2KVnWN0Sd2elP+7bUr5qO0f8Av+Vc6ZcXlJKfHDYP/DHP8T/bFcaVcfdVciZdAkHzVdRKuRR/XnpZrGfcF3vSVyRcvOVuQpjpS73Jw252wCcgHbgjOTk1nfVN41hZ2HWNQ2qZapiAUp+IjKShw+4VjaftxW35N1JJwquRcbhEU2USi0pK+CleDu+WPWrqBRyRgiFqyciSFzW0SW8+Ydj9vSrl6UR2dQartwaT/g20/GOkjshIyM/faPvVwXLRGjr86r/Yy0urPd1UVLSj9wN1fpaek1hscG4v22Iq3qkMbXfAeWAUpO4ABROBkDOO9Sk1tkOn2kVjrzTolWU3+VqJS1SyqZ8A40Qhkr525Ku4TgE49KgMaBPhRkKctc2JBffKg8Y60NLTgEjcocn2we38tb6f0XZLWlEhMZoyCkbn3AFOH5bjzj5V+2qLDpq+W/4G7wxJZGdqQ4pGCRjPBHPPHtUSSeiYWtmSEyDKkPyjhLcfhBUO6+c/w/vUs6KFiVqb4aU+USSUuJU3jKACf3sDuUd8f3rgdQNLS9DXUxVuqftYG6HJcwTIUT+VWOygAB7flxxXO0fqlNm1XCmr8kcqKLglxHKUHGSfXAUEHjuBxXXc/FLJx5wjujl8eajkjJ6NGavkSUaptbCg1CakR222kqUA22dxSSAkEpSVZ75JIUe2APXe71Mt8VyLMl+NsT5VDkAdsA4B9D3yf6V+V1tMC6WaN4KmfEfUBCkB3ISrnc1+YknKUY743n6VH9WW25sSVIvihHS3ILCnEhSmXlAE5BAynjBAI5BOOxFeGjO1o9B4J0Szpzd79b9YIgy5a3bdIaCg0V7ko3I3pUnP5T2BHYg+vBFlXV1hy5xfihva8Vt0jKU7Qg7iSc5UBtBx37/pJxWumbe/EQu6PEttMN+L4jx2hW4KwST8kng4+5xUvsEVV5vq2GtoRPyXE5CiljCUrcKh2Ckp2pHuoHnHDDDJlko122YZ1GLcl6R99f8ARNy1Xb5z2m7oLVqYRVxYshTqkBTZIJRweCRuAVg7d5I5ArHcbXPWHpC+mzamtklyMydjQuCFHA/6T6TyPllQHtW2uvGlnr7CgzoEow7hBcK47wUUgKIwQSOQDx5h2IFQS0ajuakpsmqWGlOq8gRLQkeL9P0ufVOa+jJnn/4Qbpp1jd1daYzsiO5BnSZSozEZRDod2hGVhWEYTlYHPr6nBxZ93tV9iqQiVJitleM4bPH/AJVz9R6Z0u6mOxL0/ZpIaR4jTbkVKvCCieyTwnJB7d8VFbhFsiY6X4dptewZCHERkEcexxitV5PTMnS2SCTAd+JQybiJfiAEFlwBI+RIA9vevjUlw0toiz/tW+T4kRCuEuPDcXFeyEDKln7Go7YrwtqRIkTJJ8Fsc+gSkDKjx8qg8bTEjqXqJOodRoubsOXIDEKPEJRllLqEOYcKVBKUJWpWwAFzw3DkYzUzk49CCUuz1x+vWm7jfGosCdJjulwJZcfihttRzwMjtn54q2pOoPjrGp9HAdjk49iU8isfdcOn8bSa7fcrYzPisyh4ciJLWFuRpCUpK0pWEp8RvJUlK9oyW19wATpK1ufCabjR5jqWlljCysgYURk/1qMb8tia8X0S9dzdU0nzY8orrQrLHmJbW7qizN+IAQ2mQFOD5FJxzVUy7zECdrkyRKOPyNDw0fx7/wAzXPN6fBKYENmPnuoJ3KP39amUor2EpP0XLqTpPbtQRBHmXNclkAkbYYVtVwUrSd/BBGQaqbSH4ZpMXWFwumqbquXDYdxbURI53PoyTveSrhJHHlBVznngZ8bMG93VwA/EO5OQOcD7VLrB071LL2nxJDST/wA5FYuTbNVGkTmLo1+2x3E2mTcQpWCpp9tXhukdtxCs/fn6HAxH9W6a1TcoyIqdLvObVBxXguJ8EqxjKUZTtPzxzx6ZBlen+lD6QlU2fIVj08U1OrToe0wkjLfiEeqjmuo5PxHH5E3k7Te69nMw8zJiVLtf0q3T2mtbzGmWZNvh2dKUhLj8p/x3iUgBJQE8oAx23f0AEz0fo692ic7KfujcpTy9ziwVFaz7qJFT+NAiRkgNMoTj2FeoADsK34vx+HjO4Lv9ZTLyJ5dnjulvZuEcsvDIIqA6g6cuvMuIgzlpbUMFlwBxsj22qzx9MVZVK5ybWjjtJ7M63LSeqrE24iHbLctkncRGa8Hce2cDIzUEuX7WhtLjrtT8ZtSysthRUgKPchPYfathuNoWMLSCPmK5Vx05apwIeitkn5VosrRm8SZhjXd7etdmSlTbjSpbyGB5VDgqG4k/5c1ZfS7Ulu05p6JeEwlyQLeqK4I7Sd6XGy45sVglSiUhaxwkDcANxXxd2pOkumb3BchzYTbrDndJ4wfcEcg/MVAJf4aLWp3/AFdqO7QG1DatKFgkj23DB/jmqzm5Oy0IKKozp1h+M1tq9y1W5LLU1UpyZMcS0geCQNjYUtCQpZxkjf5khSQexqeWPSmoLiwz4zTrz+xIccOTuVjk8/OtCaE6KaQ0lEDEGIXFE5cddIUtw+5P9gAKsCFaLfESEsx0JA+VULmdtP8ASC5yilUkbEn3qxLB0itcQJVJAWoVaaUpSMJAFf2gOHa9LWi3pAZit5Hriuw0y02MIQlI+Qr9KUApSlAKUpQClKUApSlAKUpQClKUApSlAKUpQClKUApSlAf/2Q==
@@ -26,6 +27,7 @@
AT
+ /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCACAAIADASIAAhEBAxEB/8QAHAAAAwEAAwEBAAAAAAAAAAAAAAUGBwMECAIB/8QAPBAAAQMDAwEECQEGBQUAAAAAAQIDBAAFEQYSITETQVFhBxQiMkJxgZGhFSMzkrHB0QhDYoKiFiRS4fD/xAAbAQABBQEBAAAAAAAAAAAAAAAAAQIDBAUHBv/EADYRAAECBAMFBgQGAwEAAAAAAAEAAgMEESEFMUEGElGR8BNhcYGh0SIyM7EUQlLB4fEjJGKy/9oADAMBAAIRAxEAPwD2XRRRQhFFFde4yW4sNbq5DEckhDa3jhPaKISgdRklRSAM5JIA5NBNEoBJoF2KKjXJ7kTXMKQ6slmc2qMc5O1WRjA7ucfc1ZUC4B4pNSEUUUUIRRRRQhFFccl9mO32jzgQnOMnvPgPGvmFKalsB1rIB7j1FJvCtEtFzUUi1NqFFqdjQ2GkyJ0pYbabKwkAngE/Ujjj5imFi/Vf0OB+u+pfq3qzfr3qW71ft9o7Ts9/tbN2du7nGM80Agoou7RRRSpEUUUUIRXw/wAMOH/Sf5V91wT3UNRVlZI3DakAZJJ6f/dw56UhyShQ2vWFKszkhv8AeQ3+0BHcArH9R9qtbPObuVqiz2ina+0leEq3BJI5TnyOR9Ki5ipl5ny4EYobtYBD0nqp5RT7iO7APJV9B3kc/oenuO2SVanyrtbe+U4KQAEqJOPP2gv7ikgCsMjUH7pIho8d6uKKKKchFFFFCEl1S2AmJKxy26UZ8AoY/mBSiNcDb5DpUtSWFpKzhWMYHtc93j/F4091WkqsUjCgNu1Qz4gjH5xWYauvDbcVEUubQ8Atzx29Upx4nqfpVSKCH1UzPlTzQKXL9rCZf30EMxk9nHGeEk+R8ifqmtHrFdBa4asi3Yz0FHqry924eysHPJ3H3up4J+1axZL5b7xH7aI6RggFDg2kE5x5Hp3E1LCLQKJjwa1TKiiipkxFFFFCF17hMYhR1OvutNgJKv2iwkYHUknoB3ms/iP3rWMswESpjFhdDjn6iGOzclt7hlpsgYbR7QAUfbWkZ5wVG3vtitF8TGTdoLUsRne2Z359lWCO7qOeh4NMEJShIShISkDAAGAKEKb2oakhttO1HYI2jwxkf2qQsbwsnpedjq2oYubZwTnqoZ4896cfWqrUk2Ja3mZElwNtqK2UJAypaiobUJA5KjjgCor0pR5rCbbqSAlSZEFwbxtBUnJBSccg4Vx39aikzSLuH81ksz9PeGl1rFwmRoEN2ZMeSyw0MrWru/uSeAByScCsuv2q7pcbiJESRJgsNfuWm14I5B3LA4UTgcHKQOOcknhud6u2qXYqHmQzhIKYyDlKFY9pZPeevyHHXJNDabXGgw1MlKXVuDDqlD3vL5VdnsSlMAhtdHG/Fdk3gNSermwtUrDixYk64thGjBrxKfaP1IzfI5adCGZ7ScutDoodN6M/D4jqk8HuJfLWlCSpZASOpNZLcoD9mnNT4S1BDbgW2sHls+B8j08wSDVSnUIftKbiHkOSkoSHm+UtpUM52pJOCcnB57qI7peNAbNyhrDd6HgevdXJCYe9xgxfmHqnt2mNBpxD6UFogfs1DlXmrwHTjrUSLFatTy5TjFtZcLCwHHgCApZ+HcCM4GMjPGR41Pz75dNX38af02HVArT67MSkFMZskZVyQCrBztz+cCtZ03Y7bp61ot1sYDTQO5ajyt1Zxla1fEo4HPkB0AFUBD37uK097dyUpC0nGinb/wBPxlY7woqz/EP613YkSPFO+LAdh7wM9igBKvA4TkHr4VYUUhlxxS9p3JXZzKWsqcW4GwkYCknnrjy+3lTSiipmN3RRRuNTVFFFFOSIqcumsrBGtLc9m5NyWZDaVxVxf2vrQUAU9hjh3IIwUkgZya72rosqdpm4QokKBPckMloxZwyw+hXC21jByFJKhzxzzxS3TulgzNRe746J94/y14w3FSRjs2k9APE9SeT0FCEoTGkS4rF/u0UMzmdy47JcCxHbPPXvWpHClZPXA78pb1dHrtIEGACWCevTtPM+Cad+lSPepNskfobjZdZUlxyOtOe2TtAwDnqOuO+sy0Zq15SlwpDbTMwqOFFGO0x8PkR4U+O84dhsXFWM7VzPyi+7/wBOFjQd3uRjYhOERmSZ+EOGfHuHX86PaILUBnanCnFe+vx8vlXfC6lUXyX3ho/7a50X5742W1fIkVxGZ2jhTkZ0aO8lzsyR7K2wMY0NbYBUDu1aFIWApKhgg9DUjqSzKTHebZeeaYeSU9o2rC26aN31g/vGnE/LBrjkXuHJkptcFxuROeGEsHqM+Ir1ux+MRjOCDJ/5A75m6U1JrlTioJsQyzeJoRkdaqh9EqLJAsKbPbY6YslkFbySrKnuf3mfiHTPeDweoJtKyafAudgmtlS1x3cBTbrSuPPyPmDwe/Iq/wBKX1N5iKDqEtS2sB1CfdV4LT5HwPIPHPBPUp6RbDHbQbsPp1/aWRnnPPZRrOHqnVFFFZa1EUUUUIRRRRQhFFFde4TY8BhL0kuBK3UNJDbSnFFS1BI9lIJxk5JxhIBUSACQoFTQIWeekaQ8Ly5EEllzctDiUspKVNjYAErO47lZ3KyAn2VJGOCpUDqj0eiVNcuDiJ0OYshS5MN3hSh8Sk8gnzIB86sULVdtZvSVqK0h9bmSAMJScIHHkEj+9VKledMxraV+BRYUvBYHfDV1e/QEZZag1svPmAJ5z3vNq28ljkdOp4DQS45DvSE8bservEefVJP2rlGo4bSg3cWpNscPH/dNkIJ8ljKT961CZChyeXo6FK/8gMH7ilEuwNLSQy77J+B0bga59M4Vsziri8b0s88PiZyFxyAU4ZMwhSzhyKhLxfENs9nb3G331pzvQd6Wx4nHU+AqQsuqZtiusbUdvfC4u7Dj5SStpzOFB0H4T0PTb+arLxoOwTFl+O09a5CXdwk250tZWPEe4r5EVO3LROo7fMXcLLNh3PtBtkxJKexMhPTqMp347yBnoa61srs7J7PSfZQBvOd87yLu7qfpH6fOtVgTTokxF3ycshlTz48DobEUXonTt6tGvNOqSQEPhI7ZrIKmVY4Uk948D3/es/vTs/Sl7bj3ILYKVb4k9gewvzwehwcFPI5wcg1lFkvt49Hl3ZmOwp9tgA+yp1HaIjZ6oUpOQpo/8fsa9HWW66b9JulVtFTLpwC62hwKWyvuWk+Hgfoe8VpDdkXlwFYRzGrfDiOHHI3V7edPsDSaRRkdHU+x48MxZONI6hjX6FuQpPrDaU9rtHsLyPeRyeM54JyO/uJeV55usDUHo+1ElUd9SBkqjvhOW3k4wcg8ZweR3fY1r2gNZwtVxnEhtMW4sgrfipUtYQguLSghwoSFEpSCQnO0qAPUE0sSwkwW/iYB3oR1Gnj56+RvSt7DMW7Zxl5gbsRvHXw7+hVVFFFFYa3EUUVwSZCWiEAb3CMhPl4nwpCQBUpQKonyDHjqU2lDj5SeybUopC1Y4BIBwPPBxSDU109SgSJClAyNhS0nPCCeB9e+vm+XlmA2t114FzGCrw8hWbTL6u9THglWWmVAbQfiPj54/nTpKGZqZYzSt/AZqGciCXgOfrp4p9o9ns2HpJ6rIQk+Q6/k/inpXS+IG4UFllxaUbU87jjnqfzXG7doLf8AnhR/0gmuZ7QYpDm8QizDnAAm19BYegVSWhiFCawpgpVdS4yOwhuuD3gnCfmeB+aXvX6OPcadV88CpjV+rvV+yYQwynguqU87hIxwnPzJ/FM2cZBxXE4UpDNamp8Bc3yyCZNzLYEFzyVoejLxZItoFvlHClLJcUtG5Cj07s9wHWm7+m9P3NsuxNjefjjLGPtyK85OanujSu1l6eDWefWbYtTgPmU5Cvwa5LbrfURkb7Jd7VMWnqw6hcd9PlkHP3TXdYkhF3y5ji1x6yNDyqshmIwuzDHtDmjrMVHOi2y46ImoSr1V5qU2eChY2kjw8DUY/pFi0XBE5q2u2mWg+y9Gyzny9n2SKW2z00ahtiwm/QFtNjgqfZKm/o62SB/uFaJp70q6avDAMjLCVcFaSHmvun+ooP4xlQ5oiDuz5Z+iUOkohDmuMM6Vy55eqnbjPuFwti7dcXUXCMrlIfT7aD3KSscg/PNZ2q43nSV29babkxVthQamtNB1vBBGSCCAcHoR/Q16D/SdM31kvwVsKzzviuDj5gcfiorXVhm6cty7k1MiyIwWlGxxCkOEk9BgkH8dKmw2bhNcYDKjetunK/XcosSk4r2iO+jt2+8MxS/WaT6X9Lus5UJyW7o9m/xG1BCn7S9haD4rbO5WSOcYHfjyrtJ+lzTF6kRbbNTNs94fU216jKjOZLqsDalQTyNxxkhPjgUv9GNogLtxv6re3EmSFqSHGCUFTY49oDhXOTyDVg3Ahzp8REuLGlCO56y32wypC0+6sdxIJGMjg4I5Aryk9OyjJ58qwXBIzOYz45eS35CK+JAY+I7OmlfbNUDiwhOTyScAZHNQur9VRrP6wXCk7klfaJITvIHunPTAAwSefpUB/idm67gX+0TdGWO9XaQxHwhMSA4602FrIdytA4UQhvGT7OMjqab2b0RzLzKbna5uD8pOd5hmQVpCgVbRgDYAN3dnIAz0GI3sDqXWg1xFbKJsdy1F6Tr0mBa9sSKtJcVO52hsEBQbCgNykkgFWMAkYBzitHuPoiSzaW4unr8/BWhCi4lxsESHCBhRWMKSSRyTu+XGDpFotlvtEMRLZDZiMBRVsbTgEnvPieByfCu3VqUmYko8Pg2Pkedehoq0zKw5pm5Fv6fbrivOVx0R6QNPOktNypjO8JC4yjJQokZ9wjeB1BJSBnv5GV8XUktI2zIaXPFbKsH+E/3r07Sy96fst6SRdLbHkqKQntFJw4ADkALGFAZz0PefGkxCWwXGKnEpNpcfzs+F3iSKV8zTuWKcGjwLykYgcHXH8clg8e9QJBCUvhpZ+B0bD+ev0pJLDdxmS3HUIdZUrskpWkFJSnjofPJrXb56JrZI3rtc1yPnersX09ogk+6kHgpA6ZO4/bmRuOgb/aAEJt5ksghKVxAXByM+6BuA8yMfinbJbKYJgs++blIxO83dDX0qKkE3sDlTLLVZWKNxF8IMiQ8jWrbj3Cgk6bjNHfbJEq2L64jufs/qhWU/gV159rujiQLhbLbfW09FpHYPj5ZyM/Iiq1DJBxjpXMhryroMSDCIoLeGXLL0WHDmYlnE1+/PP1UE081DWGmLzcLO4eBGuzRcaPkFnu+S6+5NvVv9amWAKUefXrK9hR89owT/AMqvHIqHWy262lxCuqVAEH6Gk7ulLehZdty5NrdPO6I4UJPzQcpP2qo6C4WFx1oajlRWmTDa1Nj1qKHnVILVcp7EkGy6kakPo6MTQWJA8twwfuDVadQan1DAatl5DyS28OzQtaXNyiMAhQ5I576Q3O03hTeyZFtl/YHQOoDLw+R5Tn7VY+jW0NJuURCGFtMxk9sW1rKyg9ycknOCfxVaam2yMvEm4o+m0m/HQCtc8rO8lIAYpEKGfmNLfvSnq3zWqWyO3b7ZGgt42sNJQPPA5NfkB5c2+IjQ2g4IrgXKkE4SwduQ2D8TigeU9yVZVjKQv5efS22pxRwEgk1SWuOYtvZYWEhwJy4EqKhvPKsE84yT4fIVxXZ//emXzEWpp/6PH252sfdNh1oxtgOuuiOzRRRXtFbRRRRQhFFFFCEUUUUIXVuVtgXJvs50NmQACElaASnPXaeoPmPCpm5aAtjyiuDIdiEkeyodogDHQZIV155J76sKKsQZuNA+m4j7clVmJKXmPqMB+/PNZTcdG3mEkrEcSUAAlUc7upxjbwr7A0jejLbcU2tBStJKVJIwQR1BFblXXmwoc1ITLisvgAgdogHbnrjwrVg448WiNr4LDmNm4ZvBdTuPXusMda8qptExgxDdkkYU8rA+Q/8Aeae33RLj10iJtTcZmA4F+tuPSFlxjCfY7NG0hzceDuWjb1G7pXC9brhaGgw5bpDrDSGgH4ye2Sta1lG0IT+09k4KlFO0JUDnAVt8xt3ik1OYT+Hk4TiXOuBQndB4AnN1KD5qAmlLqHD8JjSsxvxRYCxHH+kytSFSbmw2AralXaLIIGAnkdfPaPrVZSPSsRbfbyX2lIcJDaQtspUB1JBPcSR/DTysXZSUdL4c0vFHOqT+3ovTwRaq/9k=
@@ -36,6 +38,7 @@
HA0
+ /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCACAAIADASIAAhEBAxEB/8QAHQAAAgIDAQEBAAAAAAAAAAAABgcEBQADCAECCf/EAEIQAAIBAwIEAwUECAMHBQAAAAECAwQFEQAhBhIxQRMiUQcUYXGBFTKRsSMkM1JicqHBCDTRFiU2QnTw8VSCkqOy/8QAGwEAAwEBAQEBAAAAAAAAAAAABAUGAwcBAgj/xAA5EQABAgUBBAkDAgUFAQAAAAABAhEAAwQFITESQVFhBhNxgZGhsdHwFCLBMuEzQlJy8QcVI0SCwv/aAAwDAQACEQMRAD8A7L1mot4rorZaKy5TlRFSQPO5ZuUcqKWOT22HXQXceNLpZrPT3S6x296aofmjkhBUCNVJbIZycnYKQCBvnquRamsl02Zj8dOEDzqmXJ/X/iCG68S0lJX0dFTKtbLUTPExjkHLEy4BViM4bJwF+DemtnCV8e+0tXM9GKU09UaflEvPzYVW5s4GPvYx8NKbh6+3alus9wNZO8twophHLJiV/EZ4yjHGFyqhhgIBkqOUKMAp9nfGKwRtauInalqFZuSWerknaXGAdymFGMHBbvtnfCCkv6J08ba2SXw2OTncd53ZELZFzTMmJ2lMC+G8A+47+G6GToB9pnErUw+zKCoq6eoilUzNH+j5/LkICRkr5lYlSNwFycsur3iniSjoLClXS1Pi++Ql6WeAh05SBiQNgqfvKQN+bI7ZIUE88003vknM9RMf0Cklj1+8SepznfucnTK51nVp6tByfSOhWC1dYvr5owNBxP7fNIuqLi3iSjSlo0ujyCmC+KZ0WQ8igDldiOZjgbtnmJPXO+rek9pNyR3nq6Cjkp8FY0j5o3ZsjfJLDAGc7dSN9BXIu9Or4RPNUSDff0Hr6D1OvC4wKllAUeWCPr07/T+p0lTWVCNFn1+fkxUTLXRzf1Sx4N6cfIQzaL2j0LYjrbZVQzk7JC6yALjqSSuD8MbeurOPjvhhqbx2r5IwACytTyEqT22Ugn5Z0nyjqfAG88u8pJ+6OuD+Z184RzygkU8W5bux/wBT2+GiU3aoTqx7R7N3wBM6N0Sy4cdh937ofNNeLRUzx09PdKGaaTPJHHUIzNjJOADk9D+Gp2ueOc/5mQD0iXG239h+ehPj7i+u4doJLZZ7jVUdwrlBmemnaJoo98HKkHmOTj0GT30Si9/1I84AmdFAf4czxH5f8R1nrNKD2Ie2Kh4ooYrPxNV01Ff4uWNJJGWOOvyQqlOgEpJAKDqTlRjKq39OZE9E9AWg4iWq6SbSTDLmhiPPsjNZrNZraBoo+OEp6nh6poZa40s0qeJCEqI4ZJGjYPyq0gIAJAUnBwG7bHSigNzlm55bxUXSRocztMRGqRIpVolIIORlRyBSW5mJyc5Jfa7XUlxvFut9KWaopVlb3mOXyhmPKYdiQT5CWBAIwuCMnQfG89HDHJF4UoEhf9sykDOT97Azt03PfUFfK9MysKAMJYONePiD8eJe41IXUEbk7w/p3njEaHx5EPjyPIzF8JupYZwOb90Y/dwfjqWt7gsta1dO1vqZEQkw1SCRc7YCbjzYHr0231EmQz1L8zVDc0h93IXm58AN8N8bHPw1Eu8M9bb1hFFTTxcpYKpJYDH3vhjIzk9Btqcp1hCwdk92rb9ccNfxC2nVsrGuvf8AO3HrHtRx+/E14knuULpRq+zh/KNzyqfQdh9TuSdWjO6yITj3yp2iQbci47D5dPQb6V9dRpRzpT0NcLhIJOV6eBGXJA5j5jscai1Vbd7jd1KT1nj1TExGaTdEOxGQANwN+wGq+cuVM/5EHUP7a57McTHcbDchPSmSnLszsMHc2CzZ0Y8Ya0klKgMLVEaU8Pmmk5gOZvhn8B9TrUbjRDFXJVUwJ2p4/EGABtn5D+p+ulfQz+8zSU078lFTEySMo3kbpt6k9B6DJ9dTPGKj7TmRQ7eWkix5VA25sfur29T8jpVNqlSyxA+e27iYvqe3S56NpKjw0b4+p4CGSu/6tC6yVEn7Uhs8o68v9zr3CSHw1Yini3d/3j6/M9B/50tVWemxSQF/f6jHikHBQHflz6nqfw9dWNNf6ynb3dapZaKnUvPLLuDjq2euOwH+uvlNaCWUn5w949mWlSRtIU/l3/gQTcSXmns1rlutUqkL+jpoM/tH7L8h1J/10oKKjr+JrlVVlTUEO5LyTEZ8x6AD/vbUjie9VfF19iWKIxQIOSnhzkRr3Y/E9SdFVoo4qGkSmhHlXqe7HuTrOvq+qTsp1+fBEzcK36VGyn9Z8hC2q4Kmgrmoa6PwpwMr+7Iv7ynuNdF+xX25we60vDvG88vjh1hp7q5BUrg494JOQQcDxN85y2MMxDa/hWn4ktLx1S8pU5gkXZ0b1U9vyOlXeLdcLBcfs+6pgsSIKgDCTD+zeo192m9ArPVn7xqOPzxEDg091lCTUhlbj7e0foVrNcq+xj211/DnuPD3Ep96sUeY0qeVmnpFOOXv541wfLjmAOxIUIepqWeCqpoqqlmjngmQSRSxsGR1IyGBGxBG4I1fUlbLqkujXeOERNytc+3zNmZodDuP78oT/tF91peKrhFQW1xNIUMslNKyczyKOYEMeUNjclB0bJJOcDEz1MMc08dEXkWXaJmy0mWCghid8HfYDYnrppcf2GskuUV3tls+0pCjCenlZWhOAACUJBYFcgqM55RtnqraKq8OnEbvFULT4YtIGJRRlQGGT1Oeh1z29UypVaraDAksd2W/xjLxz2vkmVPVtYclsY48M6584yCRpU8CcF6pJAyO2Y8EdfKD07Z/01DKyAU/uMzColmBkbJKiNCeZdhjlxjfHr89TveY2mmmWXxIZHBMaN9xBttt0buOu2olRBBU+DK8lxjNO4KmA7O2cYyvTft+OlsgnrAxdu7dyblGEogLTl23t8fxgcuiQXGvNEsVU70JaaOWni5S0hGW+OASN/hjVHfbfWUtro5JHrDUTs0MZYgosYJLLzA5BOckEdNGkPjyVsNJ73HT17NJEGjjPOisv3iCBy59c99B17qa+422ltcIqJJoZnjbK4XA9D0bYZLDt66c0q/sSWYb/POdHiz6O1gRUSsgIGrnTBznjv7ecVdpNPJVNG5ZKOIczsOrn0HxPQeg+urXxiM3SoRQfuUkOPKMd8fur/U/XVLR+HJUonO4pIWzK46vnYnfueg/86uI5xLzXSohCxIfDpYCPKSOg/lXqfU/M6yrUMvaHxvwN3Ex+gbRNCpOyePrlu07+Ajxlkp4/CAZ6+rHm7sit2/mbv8AD5nQ7xRXqo+yKRw0aNmokU7SSDsP4V6fE5PpqyvVwe20hkMha5VikqxO8UZ6uf4m3A+GT6aquGLd4sorJl8iHyA9z6/TWcpIlJ61Xd84mB71c008sh9NeZ4CLnhe2+5U/iyr+nlG/wDCPTRDQpLVCqWmHiSQhdl3wS2N9RYFLMFUEknAA76M+HeDbu9qugSjbnq/DKOxCq3K+difTRVjl09VVL+pY4fPaB6Rxm/V9UwmSwSpROn9pI7NGixs1JURcO01RVkeI+VCjGwDMO3y1B4isdvv1vko6+BZUcd+oPYg9iPXRHLQ1Ns4coKCskR6iIEPyvzblmPX5EagDUBe1dRdJpkYAVhsdjQ8oFKVTIUrVh2vCB4o4auPDFV4dSWqKFjiGqxuPRX9D8eh0aexb2l37hC+UtvArbtaKh1ha2oS7KWY4MC9n5mJ5RgPnB3wysOvoqa4UktJVRrJFIhVgRnbGr72eewO2cJ8ZxX6W/S3WmpJHkoqSajUGNuiF3yQ5UHIIVfMFYYxjVt0WrKm5kqRhSCHPIvlu4uIbz7rTilVKrBtOC3Mj0POCb2syU9RU263mem8fDOkdRM0casxCpI3bAw4zuRk4G+lrcxRGuglikc11BzLCqqFjwy8p5lbYsQxOMnHUd8tv2o8M2a+WuC6XW309U9kZ62MtSJNKVVeYxxliOUlkjbqBzRpnoCFBRgRoI56SSJo1UVPg5YSYXKkEjORzDfboNGdJRNlVe1/Voe5txfHc7793FroqZJn7SS21vy7M274wjc6SSUOZpo8qSmYJOR2zk5OdlPbHTVdUVK+P7uPHjp/DBWpiBwMsG3BG+M9T13xqd4BmkETPG7zLnEjEMvLv5sDGfn6nWt6rwEqpXmnRS4DhZhhBjZQTtv6Df8AppDJWdoFY+D576wDTEBX3Bx4/N3GK+51VNNdQlCkADxvErM3KcMAQ23YYI39dUtRbjURUsMTsBSO3IIZD5mbbm237kbdtWxvVotzyNTIkSKhjmaRDzOzA8pxnG6jqfTpqrs1TVTX6loqYxMFgV4JUQrIAwBBYjbvjOnMu3TzIVVpH2JBUToCzu3nFBb0JRPMpaMqYB8ZL8A+XPrwil4i9nFdRgS2ZqiCNhvA1QGbxFzzeU42/HVEW4lpJ4WraSOuhgARYm/REgb4/Hr6504JJ6Wmr0pb1UpFVFQxeoc8pjzgEMNs5ONzopWnpJqRYvDhmgxgAgMpGpSo6STpCQZsvbSrQkNjkdD5R1C3VFVSpCZc1iBkO+fXxJjmZKa4Xe7SzVqSpI5MkzOuMD0H5DRTTIsaLGihVUYAHbTWuvCNmqIJXihamflJBibA6eh20EUvDlWt0WmmGYB5jKvQr6fPW6L9IrEkuzbj8zGFznT6hSdvTl6xYcIW3P6/Muw2iB/PRea+tMCwCplESDAUNgAfTUSJFjRURQqqMADsNU7WwXaW6pNXVQEXLyxqcKo5gNA2qgn3uqWEzNgAc9HAbzhZWVcuhlpKg7+xP4i5WWN3KrIruBkgNk62DXxaLRR2nhunWljIaRiZHY5LEO4GvsdNJ7lSpo6pchJfZLPo8H083rZSV8Y+l6/Q/lp96QidfodPvXQf9Nv+z/4/+oV3n+Tv/EBvtQrrhTUUUEdLBJbJ0dauSSLmKtsY8EnlXLbbjOWHKQRpV1clDKzz87x4UGTC555Dvyg5ySCeXy7HA75J6G0rOPeFaSkutqpLFBT00lSqwUtOuI44FiKKoXssagr5FGwXA7DVHf7ZNW9QFbQcBiBgctN/774h7pRqU80F9Ma8sZ47ucAghPuss6UppaPlIwDsnUM7AjOe2q6stU1eZJFgkigji5y7/cbA8oAOOuOurPipooOHa6pNt5kMMbyQtCZIosnlRmPbmbcZ/wCYEjoACShhik4btEUkaNG1qo+ZSNj+rx6gLquZRUyagBjtbPiCXHg3bDHopaUTpvXKP6X7Dp4a6NC/4c4Ri4omqaWrubUityPG5i5lUqCAp3HXmPTRtHwhV2O9UtUIo3o46KOnE8TZUsqAHIO4yQe2he4S3mz3O4z2NYJKZKmFHpJBt5kc5X0+766J7LxG9bMtqqqapo6loUnMT7oQVDZB+uqGZdrwjo/M2ZAVTTEKAIOUuGO0PbEOJ1rt024IKllM1BSW3Fi4HD8xScYQUM1XczXxK8MdvibJGSv6xGMj44J1AsPgUdbw79mS1sUFWkniRs/lbEjjcfTR4trs1VUVL3SnmnSogEDqsnKAoYMCMb5yoPXtryfhG3RC3VdpuHNFblYeDOPOQzltiPTm9O3XW3Ra82lXRmbQz1jrAlZY/wBhZn3u0D36kuf+5y6imH2faDx/Wl+7ZfnGyo/y8n8h/LQ4NEtSP1aX+Q/lpX+0yrnpbDG1NM8MnjqQyNgjXJLZINRMEsFnMWk3KgILBrVSK1P9o1CjOQhYeo5xnSnTjy/0lF4ZkhnYnAkkTLD8Ouqmt4nv1fzCouU4VuqRnkU/Qa6N0applqnTJkxlAgAMeYPDlCK92WdcUy0S1hOySX11SRp2l9Ye91vFpo7LTCouNNEcueVpBzY537ddLbjfieOsmo/sO7TwNAzF3jQ4bIG2+AfroBUlm5mJYnqScnW+PXky3SVViqs5JJLbsw7paYSZSZZLsGhs+z6+Vl4gqEq2DtThQJOUKWyD1A27a6j1yD7KJ2hq6qBkPLOBhsdwDrr7T3obKEqrqwkMPsbwV+YTXxnQ3P8AEZryR0jjaSR1RFBLMxwAB1JOqDjniin4XtsVQ8K1NRUS+HBAZhHzHGSSdyABtkA7lR3yOZ7j7aa+5cYVFJWUEVLLHN4ZmmJIUZwqchHlUkjBznfJJznVsqoBWZcvKhryhXKpgZfWzCyXbiX7OwjXjh4cH+I8G78EUNNaSK6dbmjmOnPiMAIpRkgdskD6jUS1xTm0UULU06NSU0VKxaMgOYo1jLrnflYrlcgHBGQDkBdU3EKVNcYaziuSByokFIqszqpAIzy/PXtNxRw9LXikN9mEgYqyyGRSCOx2zqUvVjnX6UETPsDg6jcCOfGHiJlFQKZM0qZ9E8W4twgkvXD3EVdSXiS1UsxZquCRSjAM6LHIG5RnJwWG3XWu2U1VDxjSCpMyvHaoEdJMghvCXOQe+plHd7TBIBar5DT1hXmXmqC6yZ7EMc9e/XUv/bijrayO0XmGGO6IvOkoTOE6HzAbKfnjWdVVVFm6PzbVNlbSShYStOckfzDUenOJ6otUuvuaK+TNIIUl0ngk7s7+3uih4upq6S+VNTbK+SjqoKGNlZej5mRcEf8AuPrqbY75d0mt1HeKSOR6xWK1EDDAIZl3H01PuHDlVfpbh7pWUsIqaFIYmeQjLCVH7DphSM/HVSOGrjZq/hiKvpWjanWVS48yZMjnAYbdCD66A6P2e1XTostVQEmbLCyP6gySRkZZxocco8vd1raC6IEpJ6tWyCdzlaUnyLwW1P8Alpf5D+Wlp7QbVVXOzEUoDPEQ5TuQOuNM2pH6tL/Ify0LDXI7ZPVImdYnUGLOaciEJXUdUERBA7MW25RnUTw1hYrPKkbDYr1I+g01+ILHNHcPEoYGkimOeVB91u4+WlTd6eZbzWRGNudZ2Vh6HOuoW2ql1gcHc8YfUTCWaL6xWmmraEVjSylDIU5cBen46vqW3UcGPDp0z6nc/wBdW3s24ejfhZZ6xw6moPKsbeqg7n4Zxj56MKago6f9jTRqfXGT+J0iul1TInrlByxaPlpkzJOIHuGKaYXKKbwXEYVvNy4HQ66ipJ4qqliqYGLRTIsiMQRlSMg4O429dIfJCkjsDjRv7HuL62908dlqLXyLb6NQ1YsjFWwQqKQRsxXJzzHJUnHo66D3VJq5suZjbCQNTkP7mEt5myZBlSlH7lO3Dc/4bvgH/wARHjUl8qLhWo1XTxUsUkUUTcjrECcjOOobnbv2GewR/F0UfEdthjpqFam5FhGlXHOsZKDcFifvfLrrpH2zWauq7lNNUDmpKmDwKeQLkJ5TlW268xZt+oO3Qgc+2jhDiekoJhcLfHE0MhCGKcOJVycEDqMbddMpNcmnr6hJVsrCywUW2grRs5DjHIiMujtbTJM6grCyFqcHDg8n4t4Rqp+GeJ1vVJVvQl0NHHFPKZUI51JG+/pynV3H7Mrtd74tzpq2mi8oM0Qy0mR3xsOmp/BdyuElT7hIqyIAFLSOFOScBTnqc9uurC/Vl1s9QZIXARH5ecDzRt6HG3176aKvU+VLyGHZ7xcI6MUlROISt1HRzjvZj5xDu3slgudRHUXE3FzEMKY25VA+gPffU6k4ZFiQR03vIGMASyO+R8ObOvig4hgvLCnr6n3KvO0dQDiGQ+jj/kP8Q29R31Miv1/sUslLLM4RGIeGbDKD9dtAVFcKtBExRKT3+IxDaTYkUp2Uy07Q3EbuRLv8dolWS4zU08bQ1GYecCRQcgDO+R20yUr6kUr0zSF4nGMNvjSXa/0PEXE9PSUa0iXCZWEkcPlDcoJ5iBtnAI+O2i+0XyC0t9lTVTXBoxzyNEv7AE4C47j6n+wi7zY6iRJVW0RIToWw4P4zkZ1hFd/oqMjaUx3jUJy2umsFlVtSyn+A/loWGiIVlLW26aWlnSVfDOcHcbdx20Nu6RrzSOqD1Y41E0iSHBGYCVMSoBQOI+xpMcSf8Q3D/qX/AD02ZrtRxnCO0zeka5/r00CXKwzVNxqKwxMEnlZxzdsnONVNjWJExRmYcQDMvNJTHKnPAZgs9mX/AAMn/WyfkNXlRUU9OvNPPHEP42A0F2WirKSMUiVs8NM7ZZFfAz0zq+hsNOjczqZG9W3OhbhKlmoUtSsHMJqrpSlH8OW55mNst+oMmODxZ2O2UQ4/E6+eERPS8QW2pgpBVTpUxmOEyFOdi2AOYEY3Pfb1BGQZCUEaDCxgfTVhY7T7/d6SjZJCk0yo/hjzBSfMR16DJ+GNfFHMCJ6BJGSR4vjc3kYk7jcKi5TEFYA2dG5t7Qz/AGmQVM1upWT/ACySEyjHRiMIfgN2HzI+GgA0m267HTs1VVnD9pqYVjWkjp+XZWgUIQNtsAYPTuNdG6UdDKm5VSqymmhyB9quQbB58xrvzhlUUnWK2gY5p9q/BsVzsjtArI0tRAspU428QLk/Lm6/9ih4PmjqoKhOJLnOrULNRVfJIFkmXlBjdidicHB7krroLiPhKpelnoTG80dRGyiSFCSvocdiNj/fXPkfAfHVXe7r4tPbRSXDlZq01QCEqDh1UAkgg57aFs9wT9FMob2oyloOCSxII3HeRyd3B5wzt12qKJW0VZZs8P28osUvfsztmC1FJcnA3EkzkH/4kjQ9e6WT2j3ySWzubfQUSDxI5akpGiE+XJPXGCPlo9rvYvWVdkjoKfhugtVV5PEr1nqqmQkfewrBVXm+uNSbD/h6jWPnrpq6s3wyNiFSR8MgkfXVJMvFslkCUhS1DLIll/JIHiYJm3momAhSip+JUee8lu6Fg9jsVneeS38QG4X1s+FFbYSwDnbd99tz0Oi/gG2VNvpYTPRMLjNKxqGaQuZEOOVSOgxue+5037R7KYLbRctDSUdOcfsi5TJ/iZVJ/qdWUXB9ZSsywUKAZxzK6+b8TnUt0hut2q6bqJFCsS1N/KSotkOBkfMwoqp86odKh89IBp7KOcyU7NE5GCVODjUePh1C3NMS59WOdM+k4Sq5OVp5IoVOeYZ5mH0G39dfUvB9SJCIp6dk7FsqT9MH89RqOj1/MoTBTqY9j+Dv5ctYDFPN2W3QvIbRTxDaMfhrc9BG8ZjaMcp7aMn4YuauVFMGAOAwkXB+O5GvP9mbp/6X/wCxP9dAKtN4fNNMf+xXtGf0q+EK2625qOUbExt91v7ayiuEkBCTKZY/6jTKr+G63wvCqKCSRH7KOf8A/OcapaX2c19ZVOEkNPCBkGdCpz6dN9MaWmq6hX006QsL4FJHPhjEbpkhQ2ViKyjamq15oHDY6r3H00Xezqi/394olkjaOJm5VG0inYgnPYlTjB6dsa94Z9m3uFzFTcKqOaNRssZIJPzwNtHdDbqGhA91pY4iARzAZYgnOCx3Oqno90NrEV0uqm/ahBdi+0W7N3adzMRHsuj2VhQ0Ef/Z
From 26ad0436a974daee9cda5bd82258c8cf9ee6d0f1 Mon Sep 17 00:00:00 2001
From: "Dharmraj Zala (OpenERP Trainee)"
Date: Thu, 19 Sep 2013 19:04:23 +0530
Subject: [PATCH 095/175] [IMP] improved code
bzr revid: dizzy.zala@gmail.com-20130919133423-l3n2ovrfw59v4yyx
---
openerp/report/render/rml2pdf/customfonts.py | 77 ++++++++++----------
1 file changed, 38 insertions(+), 39 deletions(-)
diff --git a/openerp/report/render/rml2pdf/customfonts.py b/openerp/report/render/rml2pdf/customfonts.py
index 9c55d0a25d3..000d6eac4d4 100644
--- a/openerp/report/render/rml2pdf/customfonts.py
+++ b/openerp/report/render/rml2pdf/customfonts.py
@@ -36,7 +36,7 @@ should have the same filenames, only need the code below).
Due to an awful configuration that ships with reportlab at many Linux
and Ubuntu distros, we have to override the search path, too.
"""
-_fonts_cache = {'regestered_fonts':[], 'total_system_fonts': 0}
+_fonts_cache = {'registered_fonts':[], 'total_system_fonts': 0}
_logger = logging.getLogger(__name__)
CustomTTFonts = [ ('Helvetica', "DejaVu Sans", "DejaVuSans.ttf", 'normal'),
@@ -127,54 +127,54 @@ def all_sysfonts_list():
def RegisterCustomFonts():
"""
- This function registers all fonts in reportlab if font is not regestered
- and returns the updated list of registered fonts.
+ This function prepares a list for all system fonts to be registered
+ in reportlab and returns the updated list with new fonts.
"""
- global _fonts_cache
all_system_fonts = sorted(all_sysfonts_list())
if len(all_system_fonts) > _fonts_cache['total_system_fonts']:
all_mode = {}
last_family = ""
- for dirname in all_system_fonts:
+ for i,dirname in enumerate(all_system_fonts):
try:
font_info = ttfonts.TTFontFile(dirname)
- if (font_info.name, font_info.name) not in _fonts_cache['regestered_fonts']:
- if font_info.name not in pdfmetrics._fonts:
- pdfmetrics.registerFont(ttfonts.TTFont(font_info.name, dirname, asciiReadable=0))
- if not last_family:
- last_family = font_info.familyName
- if not all_mode:
- all_mode = {
- 'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
- 'italic':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'italic'),
- 'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
- 'bolditalic':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bolditalic'),
- }
- if last_family != font_info.familyName:
- CustomTTFonts.extend(all_mode.values())
- all_mode = {
- 'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
- 'italic':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'italic'),
- 'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
- 'bolditalic':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bolditalic'),
- }
- mode = font_info.styleName.lower().replace(" ", "")
- if (mode== 'normal') or (mode == 'regular') or (mode == 'medium') or (mode == 'book'):
- all_mode['regular'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular')
- elif (mode == 'italic') or (mode == 'oblique'):
- all_mode['italic'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'italic')
- elif mode == 'bold':
- all_mode['bold'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold')
- elif (mode == 'bolditalic') or (mode == 'boldoblique'):
- all_mode['bolditalic'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'bolditalic')
+ if not last_family:
last_family = font_info.familyName
- _fonts_cache['regestered_fonts'].append((font_info.name, font_info.name))
+ if not all_mode:
+ all_mode = {
+ 'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
+ 'italic':(),
+ 'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
+ 'bolditalic':(),
+ }
+ if (last_family != font_info.familyName) or ((i+1) == len(all_system_fonts)):
+ if not all_mode['italic']:
+ all_mode['italic'] = (all_mode['regular'][0],all_mode['regular'][1],all_mode['regular'][2],'italic')
+ if not all_mode['bolditalic']:
+ all_mode['bolditalic'] = (all_mode['bold'][0],all_mode['bold'][1],all_mode['bold'][2],'bolditalic')
+ CustomTTFonts.extend(all_mode.values())
+ all_mode = {
+ 'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
+ 'italic':(),
+ 'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
+ 'bolditalic':(),
+ }
+ mode = font_info.styleName.lower().replace(" ", "")
+ if (mode== 'normal') or (mode == 'regular') or (mode == 'medium') or (mode == 'book'):
+ all_mode['regular'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular')
+ elif (mode == 'italic') or (mode == 'oblique'):
+ all_mode['italic'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'italic')
+ elif mode == 'bold':
+ all_mode['bold'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold')
+ elif (mode == 'bolditalic') or (mode == 'boldoblique'):
+ all_mode['bolditalic'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'bolditalic')
+ last_family = font_info.familyName
+ _fonts_cache['registered_fonts'].append((font_info.name, font_info.name))
_logger.debug("Found font %s at %s", font_info.name, dirname)
except:
- remain_mode = ['regular','italic','bold','bolditalic']
_logger.warning("Could not register Font %s", dirname)
_fonts_cache['total_system_fonts'] = len(all_system_fonts)
- return _fonts_cache['regestered_fonts']
+ _fonts_cache['registered_fonts'] = list(set(_fonts_cache['registered_fonts']))
+ return _fonts_cache['registered_fonts']
def SetCustomFonts(rmldoc):
""" Map some font names to the corresponding TTF fonts
@@ -184,8 +184,7 @@ def SetCustomFonts(rmldoc):
This function is called once per report, so it should
avoid system-wide processing (cache it, instead).
"""
- global _fonts_cache
- if not _fonts_cache['regestered_fonts']:
+ if not _fonts_cache['registered_fonts']:
RegisterCustomFonts()
for name, font, filename, mode in CustomTTFonts:
if os.path.isabs(filename) and os.path.exists(filename):
From 6700ef32bdb3380a7c5431a4113dfdc831d09e6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?=
Date: Thu, 19 Sep 2013 15:54:13 +0200
Subject: [PATCH 096/175] [IMP] point_of_sale: rename Start Selling to Resume
Session when appropriate
bzr revid: fva@openerp.com-20130919135413-6hwj3b7vxstf8wq1
---
addons/point_of_sale/wizard/pos_session_opening.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/point_of_sale/wizard/pos_session_opening.xml b/addons/point_of_sale/wizard/pos_session_opening.xml
index a7dbe43c962..5aa3f8d4764 100644
--- a/addons/point_of_sale/wizard/pos_session_opening.xml
+++ b/addons/point_of_sale/wizard/pos_session_opening.xml
@@ -15,7 +15,7 @@
-
From c17ecb54ec8cb69eed42e8e6967a456fbf15b548 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Thu, 19 Sep 2013 16:23:38 +0200
Subject: [PATCH 097/175] [FIX] addons: fixed various calls to
fields.datetime.now in defaults
bzr revid: tde@openerp.com-20130919142338-v2ygkid2abw2j3wl
---
addons/crm/crm_lead.py | 2 +-
addons/crm_claim/crm_claim.py | 2 +-
addons/crm_helpdesk/crm_helpdesk.py | 2 +-
addons/hr_recruitment/hr_recruitment.py | 2 +-
addons/mail/mail_message.py | 2 +-
addons/mass_mailing/mass_mailing.py | 2 +-
addons/project/project.py | 2 +-
addons/project_issue/project_issue.py | 2 +-
8 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 9d17526c19f..fcfec50d344 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -298,7 +298,7 @@ class crm_lead(format_address, osv.osv):
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'color': 0,
- 'date_last_stage_update': fields.datetime.now(),
+ 'date_last_stage_update': fields.datetime.now,
}
_sql_constraints = [
diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py
index c655ce2c12b..a3b09c272f6 100644
--- a/addons/crm_claim/crm_claim.py
+++ b/addons/crm_claim/crm_claim.py
@@ -108,7 +108,7 @@ class crm_claim(osv.osv):
_defaults = {
'user_id': lambda s, cr, uid, c: uid,
'section_id': lambda s, cr, uid, c: s._get_default_section_id(cr, uid, c),
- 'date': fields.datetime.now(),
+ 'date': fields.datetime.now,
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'active': lambda *a: 1,
diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py
index 03e6a243851..80a86c87c7c 100644
--- a/addons/crm_helpdesk/crm_helpdesk.py
+++ b/addons/crm_helpdesk/crm_helpdesk.py
@@ -80,7 +80,7 @@ class crm_helpdesk(osv.osv):
'active': lambda *a: 1,
'user_id': lambda s, cr, uid, c: uid,
'state': lambda *a: 'draft',
- 'date': lambda *a: fields.datetime.now(),
+ 'date': fields.datetime.now,
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
}
diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py
index 8664a2c1166..0f0f2785fc1 100644
--- a/addons/hr_recruitment/hr_recruitment.py
+++ b/addons/hr_recruitment/hr_recruitment.py
@@ -225,7 +225,7 @@ class hr_applicant(osv.Model):
'department_id': lambda s, cr, uid, c: s._get_default_department_id(cr, uid, c),
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'hr.applicant', context=c),
'color': 0,
- 'date_last_stage_update': fields.datetime.now(),
+ 'date_last_stage_update': fields.datetime.now,
}
_group_by_full = {
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index 3719dbc1c63..72ccdc83bb6 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -212,7 +212,7 @@ class mail_message(osv.Model):
_defaults = {
'type': 'email',
- 'date': fields.datetime.now(),
+ 'date': fields.datetime.now,
'author_id': lambda self, cr, uid, ctx=None: self._get_default_author(cr, uid, ctx),
'body': '',
'email_from': lambda self, cr, uid, ctx=None: self._get_default_from(cr, uid, ctx),
diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py
index 49ee106bc69..ad59a918203 100644
--- a/addons/mass_mailing/mass_mailing.py
+++ b/addons/mass_mailing/mass_mailing.py
@@ -274,7 +274,7 @@ class MassMailing(osv.Model):
}
_defaults = {
- 'date': fields.datetime.now(),
+ 'date': fields.datetime.now,
}
diff --git a/addons/project/project.py b/addons/project/project.py
index d153a849dc7..a8f198cac3d 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -804,7 +804,7 @@ class task(osv.osv):
_defaults = {
'stage_id': _get_default_stage_id,
'project_id': _get_default_project_id,
- 'date_last_stage_update': lambda *a: fields.datetime.now(),
+ 'date_last_stage_update': fields.datetime.now,
'kanban_state': 'normal',
'priority': '2',
'progress': 0,
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py
index f23f6b6a286..d90d7676ddb 100644
--- a/addons/project_issue/project_issue.py
+++ b/addons/project_issue/project_issue.py
@@ -297,7 +297,7 @@ class project_issue(osv.Model):
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
'priority': crm.AVAILABLE_PRIORITIES[2][0],
'kanban_state': 'normal',
- 'date_last_stage_update': fields.datetime.now(),
+ 'date_last_stage_update': fields.datetime.now,
'user_id': lambda obj, cr, uid, context: uid,
}
From fcd47fbd9f289f3087f865d7ac796666aa9ece38 Mon Sep 17 00:00:00 2001
From: Christophe Simonis
Date: Thu, 19 Sep 2013 16:46:58 +0200
Subject: [PATCH 098/175] [IMP] im: tell orm to rename field user => user_id
bzr revid: chs@openerp.com-20130919144658-tf53x1zimnvbsk0u
---
addons/im/im.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/im/im.py b/addons/im/im.py
index f91017e1712..3c4f0bfcd14 100644
--- a/addons/im/im.py
+++ b/addons/im/im.py
@@ -303,7 +303,7 @@ class im_user(osv.osv):
'name': fields.function(_get_name, type='char', size=200, string="Name", store=True, readonly=True),
'assigned_name': fields.char(string="Assigned Name", size=200, required=False),
'image': fields.related('user_id', 'image_small', type='binary', string="Image", readonly=True),
- 'user_id': fields.many2one("res.users", string="User", select=True, ondelete='cascade'),
+ 'user_id': fields.many2one("res.users", string="User", select=True, ondelete='cascade', oldname='user'),
'uuid': fields.char(string="UUID", size=50, select=True),
'im_last_received': fields.integer(string="Instant Messaging Last Received Message"),
'im_last_status': fields.boolean(strint="Instant Messaging Last Status"),
From b32d7a7351b7c0e9d0951361eb47ca3ae71b71c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?=
Date: Thu, 19 Sep 2013 16:51:33 +0200
Subject: [PATCH 099/175] [FIX] point_of_sale: replaced utf8 special characters
by image as those glyphs were not supported on enough systems
bzr revid: fva@openerp.com-20130919145133-5glux5wmidwddq6u
---
addons/point_of_sale/static/src/img/minus.png | Bin 0 -> 197 bytes
addons/point_of_sale/static/src/img/plus.png | Bin 0 -> 220 bytes
addons/point_of_sale/static/src/xml/pos.xml | 4 ++--
3 files changed, 2 insertions(+), 2 deletions(-)
create mode 100644 addons/point_of_sale/static/src/img/minus.png
create mode 100644 addons/point_of_sale/static/src/img/plus.png
diff --git a/addons/point_of_sale/static/src/img/minus.png b/addons/point_of_sale/static/src/img/minus.png
new file mode 100644
index 0000000000000000000000000000000000000000..507f20384c6d546e0de55eb944001369ae7ab83c
GIT binary patch
literal 197
zcmeAS@N?(olHy`uVBq!ia0vp^AhsX}8<2dWZ2J^Qu_bxCyDx`7I;J!
zGca%qgD@k*tT_@uLG}_)Usv|KoWgv%0#c_VE&zojOI#yLobz*YQ}ap~oQqNuOHxx5
z$}>wc6x=<11Hv2m#DR)*JzX3_G|nd{NU&aE(Uy>q`1kmL7!MHi1hifPQhO|TDo-3Z
g@S)a3=OYutoGBc4c0?ra0cvFMboFyt=akR{05_~Qd;kCd
literal 0
HcmV?d00001
diff --git a/addons/point_of_sale/static/src/img/plus.png b/addons/point_of_sale/static/src/img/plus.png
new file mode 100644
index 0000000000000000000000000000000000000000..041a9d46faf71194a943119f7c1a6e5090be0bea
GIT binary patch
literal 220
zcmeAS@N?(olHy`uVBq!ia0vp^oIotd!3HGxMcSSLDYhhUcNd2LAh=-f^2s121s;*b
z3=G`DAk4@xYmNj^kiEpy*OmP)r!b$EOpHyF4Nyq3#5JPCIX^cyHLrxhxhOTUBsE2$
zJhLQ2!QIn0AiR-J9H_{})5S4F<9u?0gxdoiW@ct?Mc4lqMGYq=9pzlX`Qisih*>#g
zA`_5epHe%wvC(mQW8*`9X6D2EY;0}pSIRF>U}oTF
-
-
+
+
From 90042504911dd9b4213c332f5fba9dd0c3e2dfe4 Mon Sep 17 00:00:00 2001
From: Launchpad Translations on behalf of openerp <>
Date: Fri, 20 Sep 2013 05:38:19 +0000
Subject: [PATCH 100/175] Launchpad automatic translations update.
bzr revid: launchpad_translations_on_behalf_of_openerp-20130920053819-rdw9jnox7816f274
---
addons/auth_signup/i18n/zh_TW.po | 279 +++++++++++++++++++++++++++++
addons/portal_anonymous/i18n/hr.po | 25 +++
2 files changed, 304 insertions(+)
create mode 100644 addons/auth_signup/i18n/zh_TW.po
create mode 100644 addons/portal_anonymous/i18n/hr.po
diff --git a/addons/auth_signup/i18n/zh_TW.po b/addons/auth_signup/i18n/zh_TW.po
new file mode 100644
index 00000000000..b16d2be5abf
--- /dev/null
+++ b/addons/auth_signup/i18n/zh_TW.po
@@ -0,0 +1,279 @@
+# Chinese (Traditional) translation for openobject-addons
+# Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013
+# This file is distributed under the same license as the openobject-addons package.
+# FIRST AUTHOR , 2013.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: openobject-addons\n"
+"Report-Msgid-Bugs-To: FULL NAME \n"
+"POT-Creation-Date: 2012-12-21 17:05+0000\n"
+"PO-Revision-Date: 2013-09-19 09:40+0000\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: Chinese (Traditional) \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Launchpad-Export-Date: 2013-09-20 05:38+0000\n"
+"X-Generator: Launchpad (build 16765)\n"
+
+#. module: auth_signup
+#: field:res.partner,signup_type:0
+msgid "Signup Token Type"
+msgstr ""
+
+#. module: auth_signup
+#: field:base.config.settings,auth_signup_uninvited:0
+msgid "Allow external users to sign up"
+msgstr "允許外部使用者註冊"
+
+#. module: auth_signup
+#. openerp-web
+#: code:addons/auth_signup/static/src/xml/auth_signup.xml:19
+#, python-format
+msgid "Confirm Password"
+msgstr "確認密碼"
+
+#. module: auth_signup
+#: help:base.config.settings,auth_signup_uninvited:0
+msgid "If unchecked, only invited users may sign up."
+msgstr "如果未勾選,只有被邀請的使用者可以註冊"
+
+#. module: auth_signup
+#: model:ir.model,name:auth_signup.model_base_config_settings
+msgid "base.config.settings"
+msgstr ""
+
+#. module: auth_signup
+#: code:addons/auth_signup/res_users.py:266
+#, python-format
+msgid "Cannot send email: user has no email address."
+msgstr "無法送出email:使用者沒有email 地址"
+
+#. module: auth_signup
+#. openerp-web
+#: code:addons/auth_signup/static/src/xml/auth_signup.xml:27
+#: code:addons/auth_signup/static/src/xml/auth_signup.xml:31
+#, python-format
+msgid "Reset password"
+msgstr "重設密碼"
+
+#. module: auth_signup
+#: field:base.config.settings,auth_signup_template_user_id:0
+msgid "Template user for new users created through signup"
+msgstr ""
+
+#. module: auth_signup
+#: model:email.template,subject:auth_signup.reset_password_email
+msgid "Password reset"
+msgstr ""
+
+#. module: auth_signup
+#. openerp-web
+#: code:addons/auth_signup/static/src/js/auth_signup.js:120
+#, python-format
+msgid "Please enter a password and confirm it."
+msgstr ""
+
+#. module: auth_signup
+#: view:res.users:0
+msgid "Send an email to the user to (re)set their password."
+msgstr ""
+
+#. module: auth_signup
+#. openerp-web
+#: code:addons/auth_signup/static/src/xml/auth_signup.xml:26
+#: code:addons/auth_signup/static/src/xml/auth_signup.xml:29
+#, python-format
+msgid "Sign Up"
+msgstr ""
+
+#. module: auth_signup
+#: selection:res.users,state:0
+msgid "New"
+msgstr ""
+
+#. module: auth_signup
+#: code:addons/auth_signup/res_users.py:258
+#, python-format
+msgid "Mail sent to:"
+msgstr ""
+
+#. module: auth_signup
+#: field:res.users,state:0
+msgid "Status"
+msgstr ""
+
+#. module: auth_signup
+#: model:email.template,body_html:auth_signup.reset_password_email
+msgid ""
+"\n"
+"
A password reset was requested for the OpenERP account linked to this "
+"email.
\n"
+"\n"
+"
You may change your password by following this link.
\n"
+"\n"
+"
Note: If you do not expect this, you can safely ignore this email.