From 42ad6511e6cab7631ed51dd23c1760b78da1fc4e Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Thu, 13 Dec 2012 10:56:43 +0100
Subject: [PATCH 01/55] [IMP] email_template: render mako templates with jinja2
sandboxed environment
bzr revid: rco@openerp.com-20121213095643-czuw8ls0he5ru1lx
---
addons/email_template/email_template.py | 44 ++++++++++++++++++-------
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py
index a9bee623f66..826b82186e4 100644
--- a/addons/email_template/email_template.py
+++ b/addons/email_template/email_template.py
@@ -29,12 +29,32 @@ from osv import fields
import tools
from tools.translate import _
from urllib import quote as quote
+
_logger = logging.getLogger(__name__)
try:
- from mako.template import Template as MakoTemplate
+ # We use a jinja2 sandboxed environment to render mako templates.
+ # Note that the rendering does not cover all the mako syntax, in particular
+ # arbitrary Python statements are not accepted, and not all expressions are
+ # allowed: only "public" attributes (not starting with '_') of objects may
+ # be accessed.
+ # This is done on purpose: it prevents incidental or malicious execution of
+ # Python code that may break the security of the server.
+ from jinja2.sandbox import SandboxedEnvironment
+ mako_template_env = SandboxedEnvironment(
+ block_start_string="<%",
+ block_end_string="%>",
+ variable_start_string="${",
+ variable_end_string="}",
+ comment_start_string="<%doc>",
+ comment_end_string="%doc>",
+ line_statement_prefix="%",
+ line_comment_prefix="##",
+ trim_blocks=True, # do not output newline after blocks
+ autoescape=True, # XML/HTML automatic escaping
+ )
except ImportError:
- _logger.warning("email_template: mako templates not available, templating features will not work!")
+ _logger.warning("jinja2 not available, templating features will not work!")
class email_template(osv.osv):
"Templates for sending email"
@@ -55,7 +75,8 @@ class email_template(osv.osv):
: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.
"""
- if not template: return u""
+ if not template:
+ return u""
if context is None:
context = {}
try:
@@ -64,14 +85,15 @@ class email_template(osv.osv):
if res_id:
record = self.pool.get(model).browse(cr, uid, res_id, context=context)
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
- result = MakoTemplate(template).render_unicode(object=record,
- user=user,
- # context kw would clash with mako internals
- ctx=context,
- quote=quote,
- format_exceptions=True)
- if result == u'False':
- result = u''
+ variables = {
+ 'object': record,
+ 'user': user,
+ 'ctx': context, # context kw would clash with mako internals
+ 'quote': quote,
+ }
+ 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)
From 0619510955104a2ce1da973d4d56ca13da36e902 Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Thu, 13 Dec 2012 15:01:05 +0100
Subject: [PATCH 02/55] [IMP] account_followup: adapt email templates
bzr revid: rco@openerp.com-20121213140105-931zv0c5hc9a5yh5
---
.../account_followup_data.xml | 81 +++++++++----------
1 file changed, 40 insertions(+), 41 deletions(-)
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index 62ea7bce9c6..d5b257a052f 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -3,19 +3,19 @@
-
-
+
+
First polite payment follow-up reminder email
- ${user.email or '' | h}
- ${user.company_id.name | h} Payment Reminder
- ${object.email | h}
- ${object.lang | h}
+ ${user.email or ''|safe}
+ ${user.company_id.name} Payment Reminder
+ ${object.email|safe}
+ ${object.lang}
- Dear ${object.name | h},
+ Dear ${object.name},
Exception made if there was a mistake of ours, it seems that the following amount stays unpaid. Please, take
appropriate measures in order to carry out this payment in the next 8 days.
@@ -28,13 +28,13 @@ contact our accounting department.
Best Regards,
-${user.name | h}
+${user.name}
-${ctx.get('followup_table','')}
+${ctx.get('followup_table','') | safe}
@@ -42,23 +42,21 @@ ${ctx.get('followup_table','')}
]]>
-
-
-
-
+
+
A bit urging second payment follow-up reminder email
- ${user.email or '' | h}
- ${user.company_id.name | h} Payment Reminder
- ${object.email | h}
- ${object.lang | h}
+ ${user.email or ''|safe}
+ ${user.company_id.name} Payment Reminder
+ ${object.email|safe}
+ ${object.lang}
- Dear ${object.name | h},
+ Dear ${object.name},
- We are disappointed to see that despite sending a reminder, that your account is now seriously overdue.
+ We are disappointed to see that despite sending a reminder, that your account is now seriously overdue.
It is essential that immediate payment is made, otherwise we will have to consider placing a stop on your account
which means that we will no longer be able to supply your company with (goods/services).
Please, take appropriate measures in order to carry out this payment in the next 8 days.
@@ -71,31 +69,32 @@ Best Regards,
-${user.name | h}
+${user.name}
-${ctx.get('followup_table','')}
+${ctx.get('followup_table','') | safe}
]]>
-
+
+
Urging payment follow-up reminder email
- ${user.email or '' | h}
- ${user.company_id.name | h} Payment Reminder
- ${object.email | h}
- ${object.lang | h}
+ ${user.email or ''|safe}
+ ${user.company_id.name} Payment Reminder
+ ${object.email|safe}
+ ${object.lang}
- Dear ${object.name | h},
+ Dear ${object.name},
Despite several reminders, your account is still not settled.
Unless full payment is made in next 8 days, legal action for the recovery of the debt will be taken without
@@ -107,12 +106,12 @@ In case of any queries concerning this matter, do not hesitate to contact our ac
Best Regards,
-${user.name | h}
+${user.name}
-${ctx.get('followup_table','')}
+${ctx.get('followup_table','') | safe}
@@ -121,19 +120,18 @@ ${ctx.get('followup_table','')}
-
-
+
Default payment follow-up reminder e-mail
- ${user.email or '' | h}
- ${user.company_id.name | h} Payment Reminder
- ${object.email | h}
- ${object.lang | h}
+ ${user.email or ''|safe}
+ ${user.company_id.name} Payment Reminder
+ ${object.email|safe}
+ ${object.lang}
- Dear ${object.name | h},
+ Dear ${object.name},
Exception made if there was a mistake of ours, it seems that the following amount stays unpaid. Please, take
appropriate measures in order to carry out this payment in the next 8 days.
@@ -144,11 +142,11 @@ contact our accounting department.
Best Regards,
-${user.name | h}
+${user.name}
-${ctx.get('followup_table','')}
+${ctx.get('followup_table','') | safe}
@@ -174,7 +172,7 @@ Would your payment have been carried out after this mail was sent, please ignore
Best Regards,
-
+
@@ -198,8 +196,9 @@ If there is a problem with paying invoice that we are not aware of, do not hesit
Details of due payments is printed below.
Best Regards,
-
+
+
Call the customer on the phone
3
@@ -221,7 +220,7 @@ I trust that this action will prove unnecessary and details of due payments is p
In case of any queries concerning this matter, do not hesitate to contact our accounting department.
Best Regards,
-
+
From 33463a6bc3cee1271fc5511b6ad1e8f5b5696ef4 Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Thu, 13 Dec 2012 15:01:35 +0100
Subject: [PATCH 03/55] [IMP] account: adapt edi email template
bzr revid: rco@openerp.com-20121213140135-zw9zhmx85ryucn81
---
addons/account/edi/invoice_action_data.xml | 38 +++++++++++++---------
addons/email_template/email_template.py | 5 ++-
2 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml
index c4b0c8103f1..bdb08d66cfe 100644
--- a/addons/account/edi/invoice_action_data.xml
+++ b/addons/account/edi/invoice_action_data.xml
@@ -22,8 +22,8 @@
Invoice - Send by Email
- ${object.user_id.email or object.company_id.email or 'noreply@localhost'}
- ${object.company_id.name} Invoice (Ref ${object.number or 'n/a' })
+ ${object.user_id.email or object.company_id.email or 'noreply@localhost'|safe}
+ ${object.company_id.name} Invoice (Ref ${object.number or 'n/a'})
${object.partner_id.id}
@@ -33,7 +33,7 @@
- Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
+ Hello ${object.partner_id.name or ''},
A new invoice is available for you:
@@ -46,24 +46,32 @@
Order reference: ${object.origin}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
% if object.company_id.paypal_account and object.type in ('out_invoice'):
- <%
- comp_name = quote(object.company_id.name)
- inv_number = quote(object.number)
- paypal_account = quote(object.company_id.paypal_account)
- inv_amount = quote(str(object.residual))
- cur_name = quote(object.currency_id.name)
- paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Invoice%%20%s&" \
- "invoice=%s&amount=%s¤cy_code=%s&button_subtype=services&no_note=1&bn=OpenERP_Invoice_PayNow_%s" % \
- (paypal_account,comp_name,inv_number,inv_number,inv_amount,cur_name,cur_name)
+ <% set paypal_url = (
+ "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick"
+ "&business=%(paypal_account)s"
+ "&item_name=%(company_name)s%%20Invoice%%20%(inv)s"
+ "&invoice=%(inv)s"
+ "&amount=%(amount)s"
+ "¤cy_code=%(currency)s"
+ "&button_subtype=services"
+ "&no_note=1"
+ "&bn=OpenERP_Invoice_PayNow_%(currency)s"
+ % {
+ 'paypal_account': quote(object.company_id.paypal_account),
+ 'company_name': quote(object.company_id.name),
+ 'inv': quote(object.number),
+ 'amount': quote(str(object.residual)),
+ 'currency': quote(object.currency_id.name),
+ })
%>
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -99,7 +107,7 @@
% endif
% if object.company_id.website:
%endif
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py
index 826b82186e4..e4cbc20f8f6 100644
--- a/addons/email_template/email_template.py
+++ b/addons/email_template/email_template.py
@@ -53,6 +53,10 @@ try:
trim_blocks=True, # do not output newline after blocks
autoescape=True, # XML/HTML automatic escaping
)
+ mako_template_env.globals.update({
+ 'str': str,
+ 'quote': quote,
+ })
except ImportError:
_logger.warning("jinja2 not available, templating features will not work!")
@@ -89,7 +93,6 @@ class email_template(osv.osv):
'object': record,
'user': user,
'ctx': context, # context kw would clash with mako internals
- 'quote': quote,
}
result = mako_template_env.from_string(template).render(variables)
if result == u"False":
From 34cc7611f4e655c5b1762f556594aac1af0816ee Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Thu, 13 Dec 2012 15:17:00 +0100
Subject: [PATCH 04/55] [IMP] sale, purchase: adapt edi email templates
bzr revid: rco@openerp.com-20121213141700-t7glyfnl6gfmr0e2
---
.../edi/purchase_order_action_data.xml | 8 ++---
addons/sale/edi/sale_order_action_data.xml | 36 +++++++++++--------
2 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/addons/purchase/edi/purchase_order_action_data.xml b/addons/purchase/edi/purchase_order_action_data.xml
index 42efd08d44c..f861c025ae8 100644
--- a/addons/purchase/edi/purchase_order_action_data.xml
+++ b/addons/purchase/edi/purchase_order_action_data.xml
@@ -19,7 +19,7 @@
Purchase Order - Send by mail
- ${object.validator.email or ''}
+ ${object.validator.email or ''|safe}
${object.company_id.name} Order (Ref ${object.name or 'n/a' })
${object.partner_id.id}
@@ -30,7 +30,7 @@
- Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
+ Hello$ ${object.partner_id.name or ''},
Here is a ${object.state in ('draft', 'sent') and 'request for quotation' or 'purchase order confirmation'} from ${object.company_id.name}:
@@ -46,7 +46,7 @@
Your reference: ${object.partner_ref}
% endif
% if object.validator:
- Your contact: ${object.validator.name}
+ Your contact: ${object.validator.name}
% endif
@@ -81,7 +81,7 @@
% endif
% if object.company_id.website:
%endif
diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml
index ad96ae39109..2a2061f1e6b 100644
--- a/addons/sale/edi/sale_order_action_data.xml
+++ b/addons/sale/edi/sale_order_action_data.xml
@@ -21,7 +21,7 @@
Sale Order - Send by Email
- ${object.user_id.email or ''}
+ ${object.user_id.email or ''|safe}
${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' })
${object.partner_invoice_id.id}
@@ -32,7 +32,7 @@
- Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
+ Hello ${object.partner_id.name or ''},
Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:
@@ -48,25 +48,31 @@
Your reference: ${object.client_order_ref}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
% if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state != 'draft':
- <%
- comp_name = quote(object.company_id.name)
- order_name = quote(object.name)
- paypal_account = quote(object.company_id.paypal_account)
- order_amount = quote(str(object.amount_total))
- cur_name = quote(object.pricelist_id.currency_id.name)
- paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Order%%20%s" \
- "&invoice=%s&amount=%s¤cy_code=%s&button_subtype=services&no_note=1" \
- "&bn=OpenERP_Order_PayNow_%s" % \
- (paypal_account,comp_name,order_name,order_name,order_amount,cur_name,cur_name)
+ <% set paypal_url = ("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick"
+ "&business=%(paypal_account)s"
+ "&item_name=%(company_name)s%%20Order%%20%(order_name)s"
+ "&invoice=%(order_name)s"
+ "&amount=%(order_amount)s"
+ "¤cy_code=%(currency)s"
+ "&button_subtype=services"
+ "&no_note=1"
+ "&bn=OpenERP_Order_PayNow_%(currency)s"
+ % {
+ 'paypal_account': quote(object.company_id.paypal_account),
+ 'company_name': quote(object.company_id.name),
+ 'order_name': quote(object.name),
+ 'order_amount': quote(str(object.amount_total)),
+ 'currency': quote(object.pricelist_id.currency_id.name),
+ })
%>
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -102,7 +108,7 @@
% endif
% if object.company_id.website:
%endif
From c90e29626456c331cda84996a17d464911dff2a2 Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Thu, 13 Dec 2012 15:38:53 +0100
Subject: [PATCH 05/55] [IMP] portal_sale: move code around, to extend models
in one place
bzr revid: rco@openerp.com-20121213143853-uk5ohmyc4tpqc5qu
---
addons/portal_sale/__init__.py | 2 -
addons/portal_sale/account_invoice.py | 43 ------------------
addons/portal_sale/portal_sale.py | 54 +++++++++++++++++++++++
addons/portal_sale/sale.py | 63 ---------------------------
4 files changed, 54 insertions(+), 108 deletions(-)
delete mode 100644 addons/portal_sale/account_invoice.py
delete mode 100644 addons/portal_sale/sale.py
diff --git a/addons/portal_sale/__init__.py b/addons/portal_sale/__init__.py
index 296de46594a..ba847ba7169 100644
--- a/addons/portal_sale/__init__.py
+++ b/addons/portal_sale/__init__.py
@@ -19,7 +19,5 @@
#
##############################################################################
-import account_invoice
-import sale
import portal_sale
import res_config
diff --git a/addons/portal_sale/account_invoice.py b/addons/portal_sale/account_invoice.py
deleted file mode 100644
index fa81b2049e0..00000000000
--- a/addons/portal_sale/account_invoice.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2011 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 osv import fields,osv
-
-class account_invoice(osv.osv):
- _inherit = 'account.invoice'
-
- def invoice_validate(self, cr, uid, ids, context=None):
- # fetch the partner's id and subscribe the partner to the sale order
- partner = self.browse(cr, uid, ids[0], context=context)['partner_id']
- if partner.id not in self.browse(cr, uid, ids[0], context=context)['message_follower_ids']:
- self.message_subscribe(cr, uid, ids, [partner.id], context=context)
- document = self.browse(cr, uid, ids[0], context=context)
- mail_values = {
- 'email_from': self.pool.get('res.users').browse(cr, uid, uid, context=context)['partner_id']['email'],
- 'email_to': partner.email,
- 'subject': 'Invitation to follow %s' % document.name_get()[0][1],
- 'body_html': 'You have been invited to follow %s' % document.name_get()[0][1],
- 'auto_delete': True,
- }
- mail_obj = self.pool.get('mail.mail')
- mail_id = mail_obj.create(cr, uid, mail_values, context=context)
- mail_obj.send(cr, uid, [mail_id], recipient_ids=[partner.id], context=context)
- return super(account_invoice, self).invoice_validate(cr, uid, ids, context=context)
\ No newline at end of file
diff --git a/addons/portal_sale/portal_sale.py b/addons/portal_sale/portal_sale.py
index 7cda77ed9ea..ba3addfb83a 100644
--- a/addons/portal_sale/portal_sale.py
+++ b/addons/portal_sale/portal_sale.py
@@ -53,6 +53,25 @@ class sale_order(osv.Model):
pass
return action_dict
+ def action_button_confirm(self, cr, uid, ids, context=None):
+ # fetch the partner's id and subscribe the partner to the sale order
+ partner = self.browse(cr, uid, ids[0], context=context)['partner_id']
+ if partner.id not in self.browse(cr, uid, ids[0], context=context)['message_follower_ids']:
+ self.message_subscribe(cr, uid, ids, [partner.id], context=context)
+ document = self.browse(cr, uid, ids[0], context=context)
+ mail_values = {
+ 'email_from': self.pool.get('res.users').browse(cr, uid, uid, context=context)['partner_id']['email'],
+ 'email_to': partner.email,
+ 'subject': 'Invitation to follow %s' % document.name_get()[0][1],
+ 'body_html': 'You have been invited to follow %s' % document.name_get()[0][1],
+ 'auto_delete': True,
+ }
+ mail_obj = self.pool.get('mail.mail')
+ mail_id = mail_obj.create(cr, uid, mail_values, context=context)
+ mail_obj.send(cr, uid, [mail_id], recipient_ids=[partner.id], context=context)
+ return super(sale_order, self).action_button_confirm(cr, uid, ids, context=context)
+
+
class account_invoice(osv.Model):
_inherit = 'account.invoice'
@@ -84,3 +103,38 @@ class account_invoice(osv.Model):
except Exception:
pass
return action_dict
+
+ def invoice_validate(self, cr, uid, ids, context=None):
+ # fetch the partner's id and subscribe the partner to the sale order
+ partner = self.browse(cr, uid, ids[0], context=context)['partner_id']
+ if partner.id not in self.browse(cr, uid, ids[0], context=context)['message_follower_ids']:
+ self.message_subscribe(cr, uid, ids, [partner.id], context=context)
+ document = self.browse(cr, uid, ids[0], context=context)
+ mail_values = {
+ 'email_from': self.pool.get('res.users').browse(cr, uid, uid, context=context)['partner_id']['email'],
+ 'email_to': partner.email,
+ 'subject': 'Invitation to follow %s' % document.name_get()[0][1],
+ 'body_html': 'You have been invited to follow %s' % document.name_get()[0][1],
+ 'auto_delete': True,
+ }
+ mail_obj = self.pool.get('mail.mail')
+ mail_id = mail_obj.create(cr, uid, mail_values, context=context)
+ mail_obj.send(cr, uid, [mail_id], recipient_ids=[partner.id], context=context)
+ return super(account_invoice, self).invoice_validate(cr, uid, ids, context=context)
+
+
+class mail_mail(osv.osv):
+ _inherit = 'mail.mail'
+
+ def _postprocess_sent_message(self, cr, uid, mail, context=None):
+ if mail.model == 'sale.order':
+ so_obj = self.pool.get('sale.order')
+ partner = so_obj.browse(cr, uid, mail.res_id, context=context)['partner_id']
+ # Add the customer in the SO as follower
+ if partner.id not in so_obj.browse(cr, uid, mail.res_id, context=context)['message_follower_ids']:
+ so_obj.message_subscribe(cr, uid, [mail.res_id], [partner.id], context=context)
+ # Add all recipients of the email as followers
+ for p in mail.partner_ids:
+ if p.id not in so_obj.browse(cr, uid, mail.res_id, context=context)['message_follower_ids']:
+ so_obj.message_subscribe(cr, uid, [mail.res_id], [p.id], context=context)
+ return super(mail_mail, self)._postprocess_sent_message(cr, uid, mail=mail, context=context)
diff --git a/addons/portal_sale/sale.py b/addons/portal_sale/sale.py
deleted file mode 100644
index 79fcbdef6fd..00000000000
--- a/addons/portal_sale/sale.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 osv import fields, osv
-
-class sale_order(osv.osv):
- _inherit = 'sale.order'
-
- def action_button_confirm(self, cr, uid, ids, context=None):
- # fetch the partner's id and subscribe the partner to the sale order
- partner = self.browse(cr, uid, ids[0], context=context)['partner_id']
- if partner.id not in self.browse(cr, uid, ids[0], context=context)['message_follower_ids']:
- self.message_subscribe(cr, uid, ids, [partner.id], context=context)
- document = self.browse(cr, uid, ids[0], context=context)
- mail_values = {
- 'email_from': self.pool.get('res.users').browse(cr, uid, uid, context=context)['partner_id']['email'],
- 'email_to': partner.email,
- 'subject': 'Invitation to follow %s' % document.name_get()[0][1],
- 'body_html': 'You have been invited to follow %s' % document.name_get()[0][1],
- 'auto_delete': True,
- }
- mail_obj = self.pool.get('mail.mail')
- mail_id = mail_obj.create(cr, uid, mail_values, context=context)
- mail_obj.send(cr, uid, [mail_id], recipient_ids=[partner.id], context=context)
- return super(sale_order, self).action_button_confirm(cr, uid, ids, context=context)
-
-sale_order()
-
-class mail_mail(osv.osv):
- _inherit = 'mail.mail'
-
- def _postprocess_sent_message(self, cr, uid, mail, context=None):
- if mail.model == 'sale.order':
- so_obj = self.pool.get('sale.order')
- partner = so_obj.browse(cr, uid, mail.res_id, context=context)['partner_id']
- # Add the customer in the SO as follower
- if partner.id not in so_obj.browse(cr, uid, mail.res_id, context=context)['message_follower_ids']:
- so_obj.message_subscribe(cr, uid, [mail.res_id], [partner.id], context=context)
- # Add all recipients of the email as followers
- for p in mail.partner_ids:
- if p.id not in so_obj.browse(cr, uid, mail.res_id, context=context)['message_follower_ids']:
- so_obj.message_subscribe(cr, uid, [mail.res_id], [p.id], context=context)
- return super(mail_mail, self)._postprocess_sent_message(cr, uid, mail=mail, context=context)
-
-mail_mail()
\ No newline at end of file
From e65c73bc952d9905043de8963008b4027595162e Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Thu, 13 Dec 2012 15:50:11 +0100
Subject: [PATCH 06/55] [IMP] portal_sale: refactor and clean up code
bzr revid: rco@openerp.com-20121213145011-2wcif6d2o9dbcqts
---
addons/portal_sale/portal_sale.py | 41 +++++++++++++++++--------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/addons/portal_sale/portal_sale.py b/addons/portal_sale/portal_sale.py
index ba3addfb83a..62f3f1ff9cc 100644
--- a/addons/portal_sale/portal_sale.py
+++ b/addons/portal_sale/portal_sale.py
@@ -21,11 +21,12 @@
from openerp.osv import osv, fields
+
class sale_order(osv.Model):
_inherit = 'sale.order'
# make the real method inheritable
- _payment_block_proxy = lambda self,*a,**kw: self._portal_payment_block(*a, **kw)
+ _payment_block_proxy = lambda self, *a, **kw: self._portal_payment_block(*a, **kw)
_columns = {
'portal_payment_options': fields.function(_payment_block_proxy, type="html", string="Portal Payment Options"),
@@ -35,14 +36,14 @@ class sale_order(osv.Model):
result = dict.fromkeys(ids, False)
payment_acquirer = self.pool.get('portal.payment.acquirer')
for this in self.browse(cr, uid, ids, context=context):
- if this.state not in ('draft','cancel') and not this.invoiced:
+ if this.state not in ('draft', 'cancel') and not this.invoiced:
result[this.id] = payment_acquirer.render_payment_block(cr, uid, this, this.name,
this.pricelist_id.currency_id, this.amount_total, context=context)
return result
def action_quotation_send(self, cr, uid, ids, context=None):
''' Override to use a modified template that includes a portal signup link '''
- action_dict = super(sale_order, self).action_quotation_send(cr, uid, ids, context=context)
+ action_dict = super(sale_order, self).action_quotation_send(cr, uid, ids, context=context)
try:
template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'portal_sale', 'email_template_edi_sale')[1]
# assume context is still a dict, as prepared by super
@@ -55,12 +56,14 @@ class sale_order(osv.Model):
def action_button_confirm(self, cr, uid, ids, context=None):
# fetch the partner's id and subscribe the partner to the sale order
- partner = self.browse(cr, uid, ids[0], context=context)['partner_id']
- if partner.id not in self.browse(cr, uid, ids[0], context=context)['message_follower_ids']:
+ assert len(ids) == 1
+ document = self.browse(cr, uid, ids[0], context=context)
+ partner = document.partner_id
+ if partner.id not in document.message_follower_ids:
self.message_subscribe(cr, uid, ids, [partner.id], context=context)
- document = self.browse(cr, uid, ids[0], context=context)
+ user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
mail_values = {
- 'email_from': self.pool.get('res.users').browse(cr, uid, uid, context=context)['partner_id']['email'],
+ 'email_from': user.partner_id.email,
'email_to': partner.email,
'subject': 'Invitation to follow %s' % document.name_get()[0][1],
'body_html': 'You have been invited to follow %s' % document.name_get()[0][1],
@@ -76,7 +79,7 @@ class account_invoice(osv.Model):
_inherit = 'account.invoice'
# make the real method inheritable
- _payment_block_proxy = lambda self,*a,**kw: self._portal_payment_block(*a, **kw)
+ _payment_block_proxy = lambda self, *a, **kw: self._portal_payment_block(*a, **kw)
_columns = {
'portal_payment_options': fields.function(_payment_block_proxy, type="html", string="Portal Payment Options"),
@@ -86,14 +89,14 @@ class account_invoice(osv.Model):
result = dict.fromkeys(ids, False)
payment_acquirer = self.pool.get('portal.payment.acquirer')
for this in self.browse(cr, uid, ids, context=context):
- if this.type == 'out_invoice' and this.state not in ('draft','done') and not this.reconciled:
+ if this.type == 'out_invoice' and this.state not in ('draft', 'done') and not this.reconciled:
result[this.id] = payment_acquirer.render_payment_block(cr, uid, this, this.number,
this.currency_id, this.residual, context=context)
return result
def action_invoice_sent(self, cr, uid, ids, context=None):
''' Override to use a modified template that includes a portal signup link '''
- action_dict = super(account_invoice, self).action_invoice_sent(cr, uid, ids, context=context)
+ action_dict = super(account_invoice, self).action_invoice_sent(cr, uid, ids, context=context)
try:
template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'portal_sale', 'email_template_edi_invoice')[1]
# assume context is still a dict, as prepared by super
@@ -105,13 +108,14 @@ class account_invoice(osv.Model):
return action_dict
def invoice_validate(self, cr, uid, ids, context=None):
- # fetch the partner's id and subscribe the partner to the sale order
- partner = self.browse(cr, uid, ids[0], context=context)['partner_id']
- if partner.id not in self.browse(cr, uid, ids[0], context=context)['message_follower_ids']:
+ # fetch the partner's id and subscribe the partner to the invoice
+ document = self.browse(cr, uid, ids[0], context=context)
+ partner = document.partner_id
+ if partner.id not in document.message_follower_ids:
self.message_subscribe(cr, uid, ids, [partner.id], context=context)
- document = self.browse(cr, uid, ids[0], context=context)
+ user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
mail_values = {
- 'email_from': self.pool.get('res.users').browse(cr, uid, uid, context=context)['partner_id']['email'],
+ 'email_from': user.partner_id.email,
'email_to': partner.email,
'subject': 'Invitation to follow %s' % document.name_get()[0][1],
'body_html': 'You have been invited to follow %s' % document.name_get()[0][1],
@@ -129,12 +133,13 @@ class mail_mail(osv.osv):
def _postprocess_sent_message(self, cr, uid, mail, context=None):
if mail.model == 'sale.order':
so_obj = self.pool.get('sale.order')
- partner = so_obj.browse(cr, uid, mail.res_id, context=context)['partner_id']
+ order = so_obj.browse(cr, uid, mail.res_id, context=context)
+ partner = order.partner_id
# Add the customer in the SO as follower
- if partner.id not in so_obj.browse(cr, uid, mail.res_id, context=context)['message_follower_ids']:
+ if partner.id not in order.message_follower_ids:
so_obj.message_subscribe(cr, uid, [mail.res_id], [partner.id], context=context)
# Add all recipients of the email as followers
for p in mail.partner_ids:
- if p.id not in so_obj.browse(cr, uid, mail.res_id, context=context)['message_follower_ids']:
+ if p.id not in order.message_follower_ids:
so_obj.message_subscribe(cr, uid, [mail.res_id], [p.id], context=context)
return super(mail_mail, self)._postprocess_sent_message(cr, uid, mail=mail, context=context)
From e07f8a7519330aa7ac1b1ba66293aa71d96cca62 Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Thu, 13 Dec 2012 16:37:28 +0100
Subject: [PATCH 07/55] [IMP] portal_sale: adapt edi email templates
bzr revid: rco@openerp.com-20121213153728-v7yv82x09qtletix
---
addons/portal_sale/portal_sale.py | 16 +++++
addons/portal_sale/portal_sale_data.xml | 89 +++++++++++++------------
2 files changed, 63 insertions(+), 42 deletions(-)
diff --git a/addons/portal_sale/portal_sale.py b/addons/portal_sale/portal_sale.py
index 62f3f1ff9cc..3556fd5ca0e 100644
--- a/addons/portal_sale/portal_sale.py
+++ b/addons/portal_sale/portal_sale.py
@@ -74,6 +74,14 @@ class sale_order(osv.Model):
mail_obj.send(cr, uid, [mail_id], recipient_ids=[partner.id], context=context)
return super(sale_order, self).action_button_confirm(cr, uid, ids, context=context)
+ def get_signup_url(self, cr, uid, ids, context=None):
+ assert len(ids) == 1
+ document = self.browse(cr, uid, ids[0], context=context)
+ partner = document.partner_id
+ action = 'portal_sale.action_quotations_portal' if document.state in ('draft', 'sent') else 'portal_sale.action_orders_portal'
+ partner.signup_prepare()
+ return partner._get_signup_url_for_action(action=action, view_type='form', res_id=document.id)[partner.id]
+
class account_invoice(osv.Model):
_inherit = 'account.invoice'
@@ -126,6 +134,14 @@ class account_invoice(osv.Model):
mail_obj.send(cr, uid, [mail_id], recipient_ids=[partner.id], context=context)
return super(account_invoice, self).invoice_validate(cr, uid, ids, context=context)
+ def get_signup_url(self, cr, uid, ids, context=None):
+ assert len(ids) == 1
+ document = self.browse(cr, uid, ids[0], context=context)
+ partner = document.partner_id
+ action = 'portal_sale.portal_action_invoices'
+ partner.signup_prepare()
+ return partner._get_signup_url_for_action(action=action, view_type='form', res_id=document.id)[partner.id]
+
class mail_mail(osv.osv):
_inherit = 'mail.mail'
diff --git a/addons/portal_sale/portal_sale_data.xml b/addons/portal_sale/portal_sale_data.xml
index f40897f6998..bdf51fd2fe7 100644
--- a/addons/portal_sale/portal_sale_data.xml
+++ b/addons/portal_sale/portal_sale_data.xml
@@ -6,7 +6,7 @@
Sale Order - Send by Email (Portal)
- ${object.user_id.email or ''}
+ ${object.user_id.email or ''|safe}
${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' })
${object.partner_invoice_id.id}
@@ -16,7 +16,7 @@
- Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
+ Hello ${object.partner_id.name or ''},
Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:
@@ -32,38 +32,40 @@
Your reference: ${object.client_order_ref}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
- <%
- action = 'portal_sale.action_quotations_portal' if object.state in ('draft', 'sent') else 'portal_sale.action_orders_portal'
- object.partner_id.signup_prepare()
- signup_url = object.partner_id._get_signup_url_for_action(action=action,view_type='form',res_id=object.id)[object.partner_id.id]
- %>
+ <% set signup_url = object.get_signup_url() %>
% if signup_url:
You can access this document and pay online via our Customer Portal:
View ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'}
+ href="${signup_url|safe}">View ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'}
% endif
% if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state != 'draft':
- <%
- comp_name = quote(object.company_id.name)
- order_name = quote(object.name)
- paypal_account = quote(object.company_id.paypal_account)
- order_amount = quote(str(object.residual))
- cur_name = quote(object.pricelist_id.currency_id.name)
- paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Order%%20%s" \
- "&invoice=%s&amount=%s¤cy_code=%s&button_subtype=services&no_note=1" \
- "&bn=OpenERP_Order_PayNow_%s" % \
- (paypal_account,comp_name,order_name,order_name,order_amount,cur_name,cur_name)
+ <% set paypal_url = ("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick"
+ "&business=%(paypal_account)s"
+ "&item_name=%(company_name)s%%20Order%%20%(order_name)s"
+ "&invoice=%(order_name)s"
+ "&amount=%(order_amount)s"
+ "¤cy_code=%(currency)s"
+ "&button_subtype=services"
+ "&no_note=1"
+ "&bn=OpenERP_Order_PayNow_%(currency)s"
+ % {
+ 'paypal_account': quote(object.company_id.paypal_account),
+ 'company_name': quote(object.company_id.name),
+ 'order_name': quote(object.name),
+ 'order_amount': quote(str(object.residual)),
+ 'currency': quote(object.pricelist_id.currency_id.name),
+ })
%>
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -99,9 +101,9 @@
% endif
% if object.company_id.website:
- %endif
+ % endif
@@ -110,7 +112,7 @@
Invoice - Send by Email (Portal)
- ${object.user_id.email or object.company_id.email or 'noreply@localhost'}
+ ${object.user_id.email or object.company_id.email or 'noreply@localhost'|safe}
${object.company_id.name} Invoice (Ref ${object.number or 'n/a' })
${object.partner_id.id}
@@ -120,7 +122,7 @@
- Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
+ Hello ${object.partner_id.name or ''},
A new invoice is available for you:
@@ -133,15 +135,11 @@
Order reference: ${object.origin}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
- <%
- action = 'portal_sale.portal_action_invoices'
- object.partner_id.signup_prepare()
- signup_url = object.partner_id._get_signup_url_for_action(action=action,view_type='form',res_id=object.id)[object.partner_id.id]
- %>
+ <% set signup_url = object.get_signup_url() %>
% if signup_url:
You can access the invoice document and pay online via our Customer Portal:
@@ -151,19 +149,26 @@
% endif
% if object.company_id.paypal_account and object.type in ('out_invoice'):
- <%
- comp_name = quote(object.company_id.name)
- inv_number = quote(object.number)
- paypal_account = quote(object.company_id.paypal_account)
- inv_amount = quote(str(object.residual))
- cur_name = quote(object.currency_id.name)
- paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Invoice%%20%s&" \
- "invoice=%s&amount=%s¤cy_code=%s&button_subtype=services&no_note=1&bn=OpenERP_Invoice_PayNow_%s" % \
- (paypal_account,comp_name,inv_number,inv_number,inv_amount,cur_name,cur_name)
+ <% set paypal_url = ("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick"
+ "&business=%(paypal_account)s"
+ "&item_name=%(company_name)s%%20Invoice%%20%(inv)s"
+ "&invoice=%(inv)s"
+ "&amount=%(amount)s"
+ "¤cy_code=%(currency)s"
+ "&button_subtype=services"
+ "&no_note=1"
+ "&bn=OpenERP_Invoice_PayNow_%(currency)s"
+ % {
+ 'paypal_account': quote(object.company_id.paypal_account),
+ 'company_name': quote(object.company_id.name),
+ 'inv': quote(object.number),
+ 'amount': quote(str(object.residual)),
+ 'currency': quote(object.currency_id.name),
+ })
%>
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -199,9 +204,9 @@
% endif
% if object.company_id.website:
- %endif
+ % endif
From a261f54c821d92fb6bb5cddf245f0188f157212c Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Fri, 14 Dec 2012 10:03:40 +0100
Subject: [PATCH 08/55] [FIX] email_template: use urlencode to build urls, and
adapt email templates; also fixes incorrect usage of 'safe' in those
templates"
bzr revid: rco@openerp.com-20121214090340-nd3u4ahhb4460r4q
---
addons/account/edi/invoice_action_data.xml | 35 ++++------
.../account_followup_data.xml | 16 ++---
addons/email_template/email_template.py | 3 +-
addons/portal_sale/portal_sale_data.xml | 70 ++++++++-----------
.../edi/purchase_order_action_data.xml | 6 +-
addons/sale/edi/sale_order_action_data.xml | 34 ++++-----
6 files changed, 74 insertions(+), 90 deletions(-)
diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml
index bdb08d66cfe..36bb31b1db3 100644
--- a/addons/account/edi/invoice_action_data.xml
+++ b/addons/account/edi/invoice_action_data.xml
@@ -22,7 +22,7 @@
Invoice - Send by Email
- ${object.user_id.email or object.company_id.email or 'noreply@localhost'|safe}
+ ${object.user_id.email or object.company_id.email or 'noreply@localhost'}
${object.company_id.name} Invoice (Ref ${object.number or 'n/a'})
${object.partner_id.id}
@@ -46,32 +46,27 @@
Order reference: ${object.origin}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
% if object.company_id.paypal_account and object.type in ('out_invoice'):
- <% set paypal_url = (
- "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick"
- "&business=%(paypal_account)s"
- "&item_name=%(company_name)s%%20Invoice%%20%(inv)s"
- "&invoice=%(inv)s"
- "&amount=%(amount)s"
- "¤cy_code=%(currency)s"
- "&button_subtype=services"
- "&no_note=1"
- "&bn=OpenERP_Invoice_PayNow_%(currency)s"
- % {
- 'paypal_account': quote(object.company_id.paypal_account),
- 'company_name': quote(object.company_id.name),
- 'inv': quote(object.number),
- 'amount': quote(str(object.residual)),
- 'currency': quote(object.currency_id.name),
+ <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
+ urlencode({
+ "cmd": "_xclick",
+ "business": object.company_id.paypal_account,
+ "item_name": object.company_id.name + " Invoice " + object.number,
+ "invoice": object.number,
+ "amount": object.residual,
+ "currency_code": object.currency_id.name,
+ "button_subtype": "services",
+ "no_note": "1",
+ "bn": "OpenERP_Invoice_PayNow_" + object.currency_id.name,
})
%>
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -107,7 +102,7 @@
% endif
% if object.company_id.website:
%endif
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index d5b257a052f..c35a0ffcd49 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -6,9 +6,9 @@
First polite payment follow-up reminder email
- ${user.email or ''|safe}
+ ${user.email or ''}
${user.company_id.name} Payment Reminder
- ${object.email|safe}
+ ${object.email}
${object.lang}
@@ -45,9 +45,9 @@ ${ctx.get('followup_table','') | safe}
A bit urging second payment follow-up reminder email
- ${user.email or ''|safe}
+ ${user.email or ''}
${user.company_id.name} Payment Reminder
- ${object.email|safe}
+ ${object.email}
${object.lang}
@@ -85,9 +85,9 @@ ${ctx.get('followup_table','') | safe}
Urging payment follow-up reminder email
- ${user.email or ''|safe}
+ ${user.email or ''}
${user.company_id.name} Payment Reminder
- ${object.email|safe}
+ ${object.email}
${object.lang}
@@ -122,9 +122,9 @@ ${ctx.get('followup_table','') | safe}
Default payment follow-up reminder e-mail
- ${user.email or ''|safe}
+ ${user.email or ''}
${user.company_id.name} Payment Reminder
- ${object.email|safe}
+ ${object.email}
${object.lang}
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py
index e4cbc20f8f6..619569f4c81 100644
--- a/addons/email_template/email_template.py
+++ b/addons/email_template/email_template.py
@@ -28,7 +28,7 @@ from osv import osv
from osv import fields
import tools
from tools.translate import _
-from urllib import quote as quote
+from urllib import quote, urlencode
_logger = logging.getLogger(__name__)
@@ -56,6 +56,7 @@ try:
mako_template_env.globals.update({
'str': str,
'quote': quote,
+ 'urlencode': urlencode,
})
except ImportError:
_logger.warning("jinja2 not available, templating features will not work!")
diff --git a/addons/portal_sale/portal_sale_data.xml b/addons/portal_sale/portal_sale_data.xml
index bdf51fd2fe7..60f11a5f767 100644
--- a/addons/portal_sale/portal_sale_data.xml
+++ b/addons/portal_sale/portal_sale_data.xml
@@ -6,7 +6,7 @@
Sale Order - Send by Email (Portal)
- ${object.user_id.email or ''|safe}
+ ${object.user_id.email or ''}
${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' })
${object.partner_invoice_id.id}
@@ -32,7 +32,7 @@
Your reference: ${object.client_order_ref}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
@@ -42,30 +42,26 @@
You can access this document and pay online via our Customer Portal:
View ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'}
+ href="${signup_url}">View ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'}
% endif
% if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state != 'draft':
- <% set paypal_url = ("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick"
- "&business=%(paypal_account)s"
- "&item_name=%(company_name)s%%20Order%%20%(order_name)s"
- "&invoice=%(order_name)s"
- "&amount=%(order_amount)s"
- "¤cy_code=%(currency)s"
- "&button_subtype=services"
- "&no_note=1"
- "&bn=OpenERP_Order_PayNow_%(currency)s"
- % {
- 'paypal_account': quote(object.company_id.paypal_account),
- 'company_name': quote(object.company_id.name),
- 'order_name': quote(object.name),
- 'order_amount': quote(str(object.residual)),
- 'currency': quote(object.pricelist_id.currency_id.name),
+ <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
+ urlencode({
+ "cmd": "_xclick",
+ "business": object.company_id.paypal_account,
+ "item_name": object.company_id.name + " Order " + object.name,
+ "invoice": object.name,
+ "amount": object.amount_total,
+ "currency_code": object.pricelist_id.currency_id.name,
+ "button_subtype": "services",
+ "no_note": "1",
+ "bn": "OpenERP_Order_PayNow_" + object.pricelist_id.currency_id.name,
})
%>
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -101,7 +97,7 @@
% endif
% if object.company_id.website:
% endif
@@ -112,7 +108,7 @@
Invoice - Send by Email (Portal)
- ${object.user_id.email or object.company_id.email or 'noreply@localhost'|safe}
+ ${object.user_id.email or object.company_id.email or 'noreply@localhost'}
${object.company_id.name} Invoice (Ref ${object.number or 'n/a' })
${object.partner_id.id}
@@ -135,7 +131,7 @@
Order reference: ${object.origin}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
@@ -149,26 +145,22 @@
% endif
% if object.company_id.paypal_account and object.type in ('out_invoice'):
- <% set paypal_url = ("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick"
- "&business=%(paypal_account)s"
- "&item_name=%(company_name)s%%20Invoice%%20%(inv)s"
- "&invoice=%(inv)s"
- "&amount=%(amount)s"
- "¤cy_code=%(currency)s"
- "&button_subtype=services"
- "&no_note=1"
- "&bn=OpenERP_Invoice_PayNow_%(currency)s"
- % {
- 'paypal_account': quote(object.company_id.paypal_account),
- 'company_name': quote(object.company_id.name),
- 'inv': quote(object.number),
- 'amount': quote(str(object.residual)),
- 'currency': quote(object.currency_id.name),
+ <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
+ urlencode({
+ "cmd": "_xclick",
+ "business": object.company_id.paypal_account,
+ "item_name": object.company_id.name + " Invoice " + object.number,
+ "invoice": object.number,
+ "amount": object.residual,
+ "currency_code": object.currency_id.name,
+ "button_subtype": "services",
+ "no_note": "1",
+ "bn": "OpenERP_Invoice_PayNow_" + object.currency_id.name,
})
%>
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -204,7 +196,7 @@
% endif
% if object.company_id.website:
% endif
diff --git a/addons/purchase/edi/purchase_order_action_data.xml b/addons/purchase/edi/purchase_order_action_data.xml
index f861c025ae8..06a68aaab83 100644
--- a/addons/purchase/edi/purchase_order_action_data.xml
+++ b/addons/purchase/edi/purchase_order_action_data.xml
@@ -19,7 +19,7 @@
Purchase Order - Send by mail
- ${object.validator.email or ''|safe}
+ ${object.validator.email or ''}
${object.company_id.name} Order (Ref ${object.name or 'n/a' })
${object.partner_id.id}
@@ -46,7 +46,7 @@
Your reference: ${object.partner_ref}
% endif
% if object.validator:
- Your contact: ${object.validator.name}
+ Your contact: ${object.validator.name}
% endif
@@ -81,7 +81,7 @@
% endif
% if object.company_id.website:
%endif
diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml
index 2a2061f1e6b..eebb63fb624 100644
--- a/addons/sale/edi/sale_order_action_data.xml
+++ b/addons/sale/edi/sale_order_action_data.xml
@@ -21,7 +21,7 @@
Sale Order - Send by Email
- ${object.user_id.email or ''|safe}
+ ${object.user_id.email or ''}
${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' })
${object.partner_invoice_id.id}
@@ -48,31 +48,27 @@
Your reference: ${object.client_order_ref}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
% if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state != 'draft':
- <% set paypal_url = ("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick"
- "&business=%(paypal_account)s"
- "&item_name=%(company_name)s%%20Order%%20%(order_name)s"
- "&invoice=%(order_name)s"
- "&amount=%(order_amount)s"
- "¤cy_code=%(currency)s"
- "&button_subtype=services"
- "&no_note=1"
- "&bn=OpenERP_Order_PayNow_%(currency)s"
- % {
- 'paypal_account': quote(object.company_id.paypal_account),
- 'company_name': quote(object.company_id.name),
- 'order_name': quote(object.name),
- 'order_amount': quote(str(object.amount_total)),
- 'currency': quote(object.pricelist_id.currency_id.name),
+ <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
+ urlencode({
+ "cmd": "_xclick",
+ "business": object.company_id.paypal_account,
+ "item_name": object.company_id.name + " Order " + object.name,
+ "invoice": object.name,
+ "amount": object.amount_total,
+ "currency_code": object.pricelist_id.currency_id.name,
+ "button_subtype": "services",
+ "no_note": "1",
+ "bn": "OpenERP_Order_PayNow_" + object.pricelist_id.currency_id.name,
})
%>
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -108,7 +104,7 @@
% endif
% if object.company_id.website:
%endif
From 157f1db551d4cb11a12856e8ffacbb4adc5a714d Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Fri, 14 Dec 2012 10:10:57 +0100
Subject: [PATCH 09/55] [IMP] email_template: small simplification in email
templates
bzr revid: rco@openerp.com-20121214091057-ztar9xgmxx56cvae
---
addons/account/edi/invoice_action_data.xml | 2 +-
addons/portal_sale/portal_sale_data.xml | 4 ++--
addons/purchase/edi/purchase_order_action_data.xml | 2 +-
addons/sale/edi/sale_order_action_data.xml | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml
index 36bb31b1db3..93c32b1cdc5 100644
--- a/addons/account/edi/invoice_action_data.xml
+++ b/addons/account/edi/invoice_action_data.xml
@@ -33,7 +33,7 @@
- Hello ${object.partner_id.name or ''},
+ Hello ${object.partner_id.name},
A new invoice is available for you:
diff --git a/addons/portal_sale/portal_sale_data.xml b/addons/portal_sale/portal_sale_data.xml
index 60f11a5f767..d2c8d656bcb 100644
--- a/addons/portal_sale/portal_sale_data.xml
+++ b/addons/portal_sale/portal_sale_data.xml
@@ -16,7 +16,7 @@
- Hello ${object.partner_id.name or ''},
+ Hello ${object.partner_id.name},
Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:
@@ -118,7 +118,7 @@
- Hello ${object.partner_id.name or ''},
+ Hello ${object.partner_id.name},
A new invoice is available for you:
diff --git a/addons/purchase/edi/purchase_order_action_data.xml b/addons/purchase/edi/purchase_order_action_data.xml
index 06a68aaab83..d616ff1d116 100644
--- a/addons/purchase/edi/purchase_order_action_data.xml
+++ b/addons/purchase/edi/purchase_order_action_data.xml
@@ -30,7 +30,7 @@
- Hello$ ${object.partner_id.name or ''},
+ Hello$ ${object.partner_id.name},
Here is a ${object.state in ('draft', 'sent') and 'request for quotation' or 'purchase order confirmation'} from ${object.company_id.name}:
diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml
index eebb63fb624..371233b96c7 100644
--- a/addons/sale/edi/sale_order_action_data.xml
+++ b/addons/sale/edi/sale_order_action_data.xml
@@ -32,7 +32,7 @@
- Hello ${object.partner_id.name or ''},
+ Hello ${object.partner_id.name},
Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:
From 95a3a0677b3b3fe7432d08c7c51f03027fcdba9c Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Fri, 14 Dec 2012 10:16:27 +0100
Subject: [PATCH 10/55] [IMP] portal_sale: small improvement in email template
bzr revid: rco@openerp.com-20121214091627-1b1z56vb59kyjzxl
---
addons/portal_sale/portal_sale_data.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/portal_sale/portal_sale_data.xml b/addons/portal_sale/portal_sale_data.xml
index d2c8d656bcb..761733ee31e 100644
--- a/addons/portal_sale/portal_sale_data.xml
+++ b/addons/portal_sale/portal_sale_data.xml
@@ -32,7 +32,7 @@
Your reference: ${object.client_order_ref}
% endif
% if object.user_id:
- Your contact: ${object.user_id.name}
+ Your contact: ${object.user_id.name}
% endif
From 01bffef54898388fdf288b3e367c52d9655e79a8 Mon Sep 17 00:00:00 2001
From: Raphael Collet
Date: Fri, 14 Dec 2012 12:31:32 +0100
Subject: [PATCH 11/55] [IMP] sale, account, portal_sale: factor the paypal_url
in the templates into function fields
bzr revid: rco@openerp.com-20121214113132-skqi1tddmkjybwpn
---
addons/account/edi/invoice.py | 26 ++++++++++++++++-
addons/account/edi/invoice_action_data.xml | 17 ++---------
addons/portal_sale/portal_sale_data.xml | 34 +++-------------------
addons/sale/edi/sale_order.py | 30 +++++++++++++++++--
addons/sale/edi/sale_order_action_data.xml | 17 ++---------
5 files changed, 61 insertions(+), 63 deletions(-)
diff --git a/addons/account/edi/invoice.py b/addons/account/edi/invoice.py
index 3e27bc5ea99..ca25d4e6e90 100644
--- a/addons/account/edi/invoice.py
+++ b/addons/account/edi/invoice.py
@@ -19,7 +19,9 @@
#
##############################################################################
-from openerp.osv import osv
+from urllib import urlencode
+
+from openerp.osv import osv, fields
from edi import EDIMixin
INVOICE_LINE_EDI_STRUCT = {
@@ -258,6 +260,28 @@ class account_invoice(osv.osv, EDIMixin):
pass
return action
+ def _edi_paypal_url(self, cr, uid, ids, field, arg, context=None):
+ res = dict.fromkeys(ids, False)
+ for inv in self.browse(cr, uid, ids, context=context):
+ if inv.type == 'out_invoice' and inv.company_id.paypal_account:
+ params = {
+ "cmd": "_xclick",
+ "business": inv.company_id.paypal_account,
+ "item_name": inv.company_id.name + " Invoice " + inv.number,
+ "invoice": inv.number,
+ "amount": inv.residual,
+ "currency_code": inv.currency_id.name,
+ "button_subtype": "services",
+ "no_note": "1",
+ "bn": "OpenERP_Invoice_PayNow_" + inv.currency_id.name,
+ }
+ res[inv.id] = "https://www.paypal.com/cgi-bin/webscr?" + urlencode(params)
+ return res
+
+ _columns = {
+ 'paypal_url': fields.function(_edi_paypal_url, type='char', string='Paypal Url'),
+ }
+
class account_invoice_line(osv.osv, EDIMixin):
_inherit='account.invoice.line'
diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml
index 93c32b1cdc5..18ac71f55ce 100644
--- a/addons/account/edi/invoice_action_data.xml
+++ b/addons/account/edi/invoice_action_data.xml
@@ -50,23 +50,10 @@
% endif
- % if object.company_id.paypal_account and object.type in ('out_invoice'):
- <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
- urlencode({
- "cmd": "_xclick",
- "business": object.company_id.paypal_account,
- "item_name": object.company_id.name + " Invoice " + object.number,
- "invoice": object.number,
- "amount": object.residual,
- "currency_code": object.currency_id.name,
- "button_subtype": "services",
- "no_note": "1",
- "bn": "OpenERP_Invoice_PayNow_" + object.currency_id.name,
- })
- %>
+ % if object.paypal_url:
It is also possible to directly pay with Paypal:
-
+
% endif
diff --git a/addons/portal_sale/portal_sale_data.xml b/addons/portal_sale/portal_sale_data.xml
index 761733ee31e..0ef9b1ec5cc 100644
--- a/addons/portal_sale/portal_sale_data.xml
+++ b/addons/portal_sale/portal_sale_data.xml
@@ -45,23 +45,10 @@
href="${signup_url}">View ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'}
% endif
- % if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state != 'draft':
- <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
- urlencode({
- "cmd": "_xclick",
- "business": object.company_id.paypal_account,
- "item_name": object.company_id.name + " Order " + object.name,
- "invoice": object.name,
- "amount": object.amount_total,
- "currency_code": object.pricelist_id.currency_id.name,
- "button_subtype": "services",
- "no_note": "1",
- "bn": "OpenERP_Order_PayNow_" + object.pricelist_id.currency_id.name,
- })
- %>
+ % if object.paypal_url:
It is also possible to directly pay with Paypal:
-
+
% endif
@@ -144,23 +131,10 @@
href="${signup_url}">View Invoice
% endif
- % if object.company_id.paypal_account and object.type in ('out_invoice'):
- <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
- urlencode({
- "cmd": "_xclick",
- "business": object.company_id.paypal_account,
- "item_name": object.company_id.name + " Invoice " + object.number,
- "invoice": object.number,
- "amount": object.residual,
- "currency_code": object.currency_id.name,
- "button_subtype": "services",
- "no_note": "1",
- "bn": "OpenERP_Invoice_PayNow_" + object.currency_id.name,
- })
- %>
+ % if object.paypal_url:
It is also possible to directly pay with Paypal:
-
+
% endif
diff --git a/addons/sale/edi/sale_order.py b/addons/sale/edi/sale_order.py
index 15389f1481c..b906f9a6926 100644
--- a/addons/sale/edi/sale_order.py
+++ b/addons/sale/edi/sale_order.py
@@ -19,7 +19,10 @@
#
##############################################################################
-from openerp.osv import osv
+from urllib import urlencode
+
+from openerp.osv import osv, fields
+from openerp.tools.translate import _
from edi import EDIMixin
SALE_ORDER_LINE_EDI_STRUCT = {
@@ -118,7 +121,6 @@ class sale_order(osv.osv, EDIMixin):
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
return partner_id
-
def _edi_get_pricelist(self, cr, uid, partner_id, currency, context=None):
# TODO: refactor into common place for purchase/sale, e.g. into product module
partner_model = self.pool.get('res.partner')
@@ -180,6 +182,30 @@ class sale_order(osv.osv, EDIMixin):
order_line.pop('price_subtotal', None)
return super(sale_order,self).edi_import(cr, uid, edi_document, context=context)
+ def _edi_paypal_url(self, cr, uid, ids, field, arg, context=None):
+ res = dict.fromkeys(ids, False)
+ for order in self.browse(cr, uid, ids, context=context):
+ if order.order_policy in ('prepaid', 'manual') and \
+ order.company_id.paypal_account and order.state != 'draft':
+ params = {
+ "cmd": "_xclick",
+ "business": order.company_id.paypal_account,
+ "item_name": order.company_id.name + " Order " + order.name,
+ "invoice": order.name,
+ "amount": order.amount_total,
+ "currency_code": order.pricelist_id.currency_id.name,
+ "button_subtype": "services",
+ "no_note": "1",
+ "bn": "OpenERP_Order_PayNow_" + order.pricelist_id.currency_id.name,
+ }
+ res[order.id] = "https://www.paypal.com/cgi-bin/webscr?" + urlencode(params)
+ return res
+
+ _columns = {
+ 'paypal_url': fields.function(_edi_paypal_url, type='char', string='Paypal Url'),
+ }
+
+
class sale_order_line(osv.osv, EDIMixin):
_inherit='sale.order.line'
diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml
index 371233b96c7..f031daf8656 100644
--- a/addons/sale/edi/sale_order_action_data.xml
+++ b/addons/sale/edi/sale_order_action_data.xml
@@ -52,23 +52,10 @@
% endif
- % if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state != 'draft':
- <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
- urlencode({
- "cmd": "_xclick",
- "business": object.company_id.paypal_account,
- "item_name": object.company_id.name + " Order " + object.name,
- "invoice": object.name,
- "amount": object.amount_total,
- "currency_code": object.pricelist_id.currency_id.name,
- "button_subtype": "services",
- "no_note": "1",
- "bn": "OpenERP_Order_PayNow_" + object.pricelist_id.currency_id.name,
- })
- %>
+ % if object.paypal_url:
It is also possible to directly pay with Paypal:
-
+
% endif
From 576571bae26e7d13caf382d13370607f9042e7be Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:16:04 +0100
Subject: [PATCH 12/55] [IMP] simplify to chained comparison
bzr revid: xmo@openerp.com-20121214121604-anypg1nudbk0bh9y
---
openerp/report/pyPdf/filters.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/openerp/report/pyPdf/filters.py b/openerp/report/pyPdf/filters.py
index 7fe10fb4819..ebdacd0ee14 100644
--- a/openerp/report/pyPdf/filters.py
+++ b/openerp/report/pyPdf/filters.py
@@ -106,7 +106,7 @@ class FlateDecode(object):
if predictor != 1:
columns = decodeParms["/Columns"]
# PNG prediction:
- if predictor >= 10 and predictor <= 15:
+ if 10 <= predictor <= 15:
output = StringIO()
# PNG prediction can vary from row to row
rowlength = columns + 1
@@ -191,7 +191,7 @@ class ASCII85Decode(object):
break
else:
c = ord(c) - 33
- assert c >= 0 and c < 85
+ assert 0 <= c < 85
group += [ c ]
if len(group) >= 5:
b = group[0] * (85**4) + \
From 4cb3685f7095803250dd30b5746fe8b3ef9e9fc5 Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:16:38 +0100
Subject: [PATCH 13/55] [IMP] compare to None by identity
bzr revid: xmo@openerp.com-20121214121638-6k5h0ztg94i4f5t6
---
openerp/addons/base/ir/ir_ui_menu.py | 2 +-
openerp/osv/orm.py | 4 ++--
openerp/report/custom.py | 12 +++++-----
openerp/report/printscreen/ps_form.py | 2 +-
openerp/report/printscreen/ps_list.py | 4 ++--
openerp/report/pyPdf/generic.py | 6 ++---
openerp/report/pyPdf/pdf.py | 30 ++++++++++++------------
openerp/report/pyPdf/xmp.py | 8 +++----
openerp/report/render/rml2pdf/color.py | 2 +-
openerp/report/render/rml2txt/rml2txt.py | 2 +-
openerp/tools/lru.py | 4 ++--
11 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/openerp/addons/base/ir/ir_ui_menu.py b/openerp/addons/base/ir/ir_ui_menu.py
index 72d01f326b2..2eb17d91fc1 100644
--- a/openerp/addons/base/ir/ir_ui_menu.py
+++ b/openerp/addons/base/ir/ir_ui_menu.py
@@ -144,7 +144,7 @@ class ir_ui_menu(osv.osv):
return res
def _get_full_name(self, cr, uid, ids, name=None, args=None, context=None):
- if context == None:
+ if context is None:
context = {}
res = {}
for elmt in self.browse(cr, uid, ids, context=context):
diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py
index 1968e4b0864..07cf4364f6c 100644
--- a/openerp/osv/orm.py
+++ b/openerp/osv/orm.py
@@ -2675,7 +2675,7 @@ class BaseModel(object):
groupby = group_by
for r in cr.dictfetchall():
for fld, val in r.items():
- if val == None: r[fld] = False
+ if val is None: r[fld] = False
alldata[r['id']] = r
del r['id']
@@ -3584,7 +3584,7 @@ class BaseModel(object):
context = {}
if not ids:
return []
- if fields_to_read == None:
+ if fields_to_read is None:
fields_to_read = self._columns.keys()
# Construct a clause for the security rules.
diff --git a/openerp/report/custom.py b/openerp/report/custom.py
index 596d9a9f1b9..0c572c0c249 100644
--- a/openerp/report/custom.py
+++ b/openerp/report/custom.py
@@ -96,7 +96,7 @@ class report_custom(report_int):
else:
# Process group_by data first
key = []
- if group_by != None and fields[group_by] != None:
+ if group_by is not None and fields[group_by] is not None:
if fields[group_by][0] in levels.keys():
key.append(fields[group_by][0])
for l in levels.keys():
@@ -212,7 +212,7 @@ class report_custom(report_int):
new_res = []
prev = None
- if groupby != None:
+ if groupby is not None:
res_dic = {}
for line in results:
if not line[groupby] and prev in res_dic:
@@ -322,7 +322,7 @@ class report_custom(report_int):
col.attrib.update(para='yes',
tree='yes',
space=str(3*shift)+'mm')
- if line[f] != None:
+ if line[f] is not None:
col.text = prefix+str(line[f]) or ''
else:
col.text = '/'
@@ -381,7 +381,7 @@ class report_custom(report_int):
# plots are usually displayed year by year
# so we do so if the first field is a date
data_by_year = {}
- if date_idx != None:
+ if date_idx is not None:
for r in results:
key = process_date['Y'](r[date_idx])
if key not in data_by_year:
@@ -480,7 +480,7 @@ class report_custom(report_int):
# plot are usually displayed year by year
# so we do so if the first field is a date
data_by_year = {}
- if date_idx != None:
+ if date_idx is not None:
for r in results:
key = process_date['Y'](r[date_idx])
if key not in data_by_year:
@@ -602,7 +602,7 @@ class report_custom(report_int):
node_line = etree.SubElement(lines, 'row')
for f in range(len(fields)):
col = etree.SubElement(node_line, 'col', tree='no')
- if line[f] != None:
+ if line[f] is not None:
col.text = line[f] or ''
else:
col.text = '/'
diff --git a/openerp/report/printscreen/ps_form.py b/openerp/report/printscreen/ps_form.py
index cf6d77cbe26..c3735df2850 100644
--- a/openerp/report/printscreen/ps_form.py
+++ b/openerp/report/printscreen/ps_form.py
@@ -119,7 +119,7 @@ class report_printscreen_list(report_int):
precision=(('digits' in fields[f]) and fields[f]['digits'][1]) or 2
line[f]=round(line[f],precision)
col = etree.SubElement(node_line, 'col', tree='no')
- if line[f] != None:
+ if line[f] is not None:
col.text = tools.ustr(line[f] or '')
else:
col.text = '/'
diff --git a/openerp/report/printscreen/ps_list.py b/openerp/report/printscreen/ps_list.py
index 8f0629462f8..8908577e6ac 100644
--- a/openerp/report/printscreen/ps_list.py
+++ b/openerp/report/printscreen/ps_list.py
@@ -230,7 +230,7 @@ class report_printscreen_list(report_int):
col.text = line[f] = 'Undefined'
col.set('tree', 'undefined')
- if line[f] != None:
+ if line[f] is not None:
col.text = tools.ustr(line[f] or '')
if float_flag:
col.set('tree','float')
@@ -245,7 +245,7 @@ class report_printscreen_list(report_int):
for f in range(0, len(fields_order)):
col = etree.SubElement(node_line, 'col', para='group', tree='no')
col.set('tree', 'float')
- if tsum[f] != None:
+ if tsum[f] is not None:
if tsum[f] != 0.0:
digits = fields[fields_order[f]].get('digits', (16, 2))
prec = '%%.%sf' % (digits[1], )
diff --git a/openerp/report/pyPdf/generic.py b/openerp/report/pyPdf/generic.py
index aaf503180f8..0edb432a69a 100644
--- a/openerp/report/pyPdf/generic.py
+++ b/openerp/report/pyPdf/generic.py
@@ -81,7 +81,7 @@ def readObject(stream, pdf):
return NumberObject.readFromStream(stream)
peek = stream.read(20)
stream.seek(-len(peek), 1) # reset to start
- if re.match(r"(\d+)\s(\d+)\sR[^a-zA-Z]", peek) != None:
+ if re.match(r"(\d+)\s(\d+)\sR[^a-zA-Z]", peek) is not None:
return IndirectObject.readFromStream(stream, pdf)
else:
return NumberObject.readFromStream(stream)
@@ -169,7 +169,7 @@ class IndirectObject(PdfObject):
def __eq__(self, other):
return (
- other != None and
+ other is not None and
isinstance(other, IndirectObject) and
self.idnum == other.idnum and
self.generation == other.generation and
@@ -489,7 +489,7 @@ class DictionaryObject(dict, PdfObject):
# return None if no metadata was found on the document root.
def getXmpMetadata(self):
metadata = self.get("/Metadata", None)
- if metadata == None:
+ if metadata is None:
return None
metadata = metadata.getObject()
import xmp
diff --git a/openerp/report/pyPdf/pdf.py b/openerp/report/pyPdf/pdf.py
index 53c0b428c14..9c4f31c4e41 100644
--- a/openerp/report/pyPdf/pdf.py
+++ b/openerp/report/pyPdf/pdf.py
@@ -197,7 +197,7 @@ class PdfFileWriter(object):
# flag is on.
def encrypt(self, user_pwd, owner_pwd = None, use_128bit = True):
import time, random
- if owner_pwd == None:
+ if owner_pwd is None:
owner_pwd = user_pwd
if use_128bit:
V = 2
@@ -251,7 +251,7 @@ class PdfFileWriter(object):
# copying in a new copy of the page object.
for objIndex in xrange(len(self._objects)):
obj = self._objects[objIndex]
- if isinstance(obj, PageObject) and obj.indirectRef != None:
+ if isinstance(obj, PageObject) and obj.indirectRef is not None:
data = obj.indirectRef
if not externalReferenceMap.has_key(data.pdf):
externalReferenceMap[data.pdf] = {}
@@ -340,7 +340,7 @@ class PdfFileWriter(object):
return data
else:
newobj = externMap.get(data.pdf, {}).get(data.generation, {}).get(data.idnum, None)
- if newobj == None:
+ if newobj is None:
newobj = data.pdf.getObject(data)
self._objects.append(None) # placeholder
idnum = len(self._objects)
@@ -426,7 +426,7 @@ class PdfFileReader(object):
# Stability: Added in v1.0, will exist for all v1.x releases.
# @return Returns an integer.
def getNumPages(self):
- if self.flattenedPages == None:
+ if self.flattenedPages is None:
self._flatten()
return len(self.flattenedPages)
@@ -445,7 +445,7 @@ class PdfFileReader(object):
def getPage(self, pageNumber):
## ensure that we're not trying to access an encrypted PDF
#assert not self.trailer.has_key("/Encrypt")
- if self.flattenedPages == None:
+ if self.flattenedPages is None:
self._flatten()
return self.flattenedPages[pageNumber]
@@ -465,7 +465,7 @@ class PdfFileReader(object):
# @return Returns a dict which maps names to {@link #Destination
# destinations}.
def getNamedDestinations(self, tree=None, retval=None):
- if retval == None:
+ if retval is None:
retval = {}
catalog = self.trailer["/Root"]
@@ -477,7 +477,7 @@ class PdfFileReader(object):
if names.has_key("/Dests"):
tree = names['/Dests']
- if tree == None:
+ if tree is None:
return retval
if tree.has_key("/Kids"):
@@ -493,7 +493,7 @@ class PdfFileReader(object):
if isinstance(val, DictionaryObject) and val.has_key('/D'):
val = val['/D']
dest = self._buildDestination(key, val)
- if dest != None:
+ if dest is not None:
retval[key] = dest
return retval
@@ -511,7 +511,7 @@ class PdfFileReader(object):
# Stability: Added in v1.10, will exist for all future v1.x releases.
# @return Returns a nested list of {@link #Destination destinations}.
def getOutlines(self, node=None, outlines=None):
- if outlines == None:
+ if outlines is None:
outlines = []
catalog = self.trailer["/Root"]
@@ -522,7 +522,7 @@ class PdfFileReader(object):
node = lines["/First"]
self._namedDests = self.getNamedDestinations()
- if node == None:
+ if node is None:
return outlines
# see if there are any more outlines
@@ -588,9 +588,9 @@ class PdfFileReader(object):
NameObject("/Resources"), NameObject("/MediaBox"),
NameObject("/CropBox"), NameObject("/Rotate")
)
- if inherit == None:
+ if inherit is None:
inherit = dict()
- if pages == None:
+ if pages is None:
self.flattenedPages = []
catalog = self.trailer["/Root"].getObject()
pages = catalog["/Pages"].getObject()
@@ -616,7 +616,7 @@ class PdfFileReader(object):
def getObject(self, indirectReference):
retval = self.resolvedObjects.get(indirectReference.generation, {}).get(indirectReference.idnum, None)
- if retval != None:
+ if retval is not None:
return retval
if indirectReference.generation == 0 and \
self.xref_objStm.has_key(indirectReference.idnum):
@@ -959,10 +959,10 @@ def getRectangle(self, name, defaults):
retval = self.get(name)
if isinstance(retval, RectangleObject):
return retval
- if retval == None:
+ if retval is None:
for d in defaults:
retval = self.get(d)
- if retval != None:
+ if retval is not None:
break
if isinstance(retval, IndirectObject):
retval = self.pdf.getObject(retval)
diff --git a/openerp/report/pyPdf/xmp.py b/openerp/report/pyPdf/xmp.py
index 0813b806d45..1b49fd7b2b7 100644
--- a/openerp/report/pyPdf/xmp.py
+++ b/openerp/report/pyPdf/xmp.py
@@ -66,7 +66,7 @@ class XmpInformation(PdfObject):
for desc in self.rdfRoot.getElementsByTagNameNS(RDF_NAMESPACE, "Description"):
if desc.getAttributeNS(RDF_NAMESPACE, "about") == aboutUri:
attr = desc.getAttributeNodeNS(namespace, name)
- if attr != None:
+ if attr is not None:
yield attr
for element in desc.getElementsByTagNameNS(namespace, name):
yield element
@@ -187,7 +187,7 @@ class XmpInformation(PdfObject):
else:
value = self._getText(element)
break
- if value != None:
+ if value is not None:
value = converter(value)
ns_cache = self.cache.setdefault(namespace, {})
ns_cache[name] = value
@@ -353,5 +353,5 @@ class XmpInformation(PdfObject):
custom_properties = property(custom_properties)
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/report/render/rml2pdf/color.py b/openerp/report/render/rml2pdf/color.py
index 69ef56003b1..35dd9637376 100644
--- a/openerp/report/render/rml2pdf/color.py
+++ b/openerp/report/render/rml2pdf/color.py
@@ -28,7 +28,7 @@ regex_t = re.compile('\(([0-9\.]*),([0-9\.]*),([0-9\.]*)\)')
regex_h = re.compile('#([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])')
def get(col_str):
- if col_str == None:
+ if col_str is None:
col_str = ''
global allcols
if col_str in allcols.keys():
diff --git a/openerp/report/render/rml2txt/rml2txt.py b/openerp/report/render/rml2txt/rml2txt.py
index ab1930d81ba..b431904f9c8 100755
--- a/openerp/report/render/rml2txt/rml2txt.py
+++ b/openerp/report/render/rml2txt/rml2txt.py
@@ -220,7 +220,7 @@ class _flowable(object):
def rec_render(self,node):
""" Recursive render: fill outarr with text of current node
"""
- if node.tag != None:
+ if node.tag is not None:
if node.tag in self._tags:
self._tags[node.tag](node)
else:
diff --git a/openerp/tools/lru.py b/openerp/tools/lru.py
index 5e84775a352..13b76f387b7 100644
--- a/openerp/tools/lru.py
+++ b/openerp/tools/lru.py
@@ -77,7 +77,7 @@ class LRU(object):
@synchronized()
def __iter__(self):
cur = self.first
- while cur != None:
+ while cur is not None:
cur2 = cur.next
yield cur.me[1]
cur = cur2
@@ -89,7 +89,7 @@ class LRU(object):
@synchronized()
def iteritems(self):
cur = self.first
- while cur != None:
+ while cur is not None:
cur2 = cur.next
yield cur.me
cur = cur2
From 83c102714f7e033853ead24c35242065c236e78b Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:17:11 +0100
Subject: [PATCH 14/55] [REM] access to deprecated APIs for unsupported Python
versions
bzr revid: xmo@openerp.com-20121214121711-d1r6nx82f0mpwgwy
---
openerp/report/pyPdf/pdf.py | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/openerp/report/pyPdf/pdf.py b/openerp/report/pyPdf/pdf.py
index 9c4f31c4e41..a3dd9f22962 100644
--- a/openerp/report/pyPdf/pdf.py
+++ b/openerp/report/pyPdf/pdf.py
@@ -53,13 +53,7 @@ import utils
from generic import *
from utils import readNonWhitespace, readUntilWhitespace, ConvertFunctionsToVirtualList
-if version_info < ( 2, 4 ):
- from sets import ImmutableSet as frozenset
-
-if version_info < ( 2, 5 ):
- from md5 import md5
-else:
- from hashlib import md5
+from hashlib import md5
##
# This class supports writing PDF files out, given pages produced by another
From 80d97e8d1766180d27e115cb4fa4c5f3d5c465ca Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:17:41 +0100
Subject: [PATCH 15/55] [REM] duplicate dict keys
bzr revid: xmo@openerp.com-20121214121741-lhkqewfw76riqy45
---
openerp/tools/translate.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/openerp/tools/translate.py b/openerp/tools/translate.py
index 0b600c75933..4fc832289d2 100644
--- a/openerp/tools/translate.py
+++ b/openerp/tools/translate.py
@@ -93,7 +93,6 @@ _LOCALE2WIN32 = {
'lt_LT': 'Lithuanian_Lithuania',
'lat': 'Latvian_Latvia',
'ml_IN': 'Malayalam_India',
- 'id_ID': 'Indonesian_indonesia',
'mi_NZ': 'Maori',
'mn': 'Cyrillic_Mongolian',
'no_NO': 'Norwegian_Norway',
@@ -103,7 +102,6 @@ _LOCALE2WIN32 = {
'pt_BR': 'Portuguese_Brazil',
'ro_RO': 'Romanian_Romania',
'ru_RU': 'Russian_Russia',
- 'mi_NZ': 'Maori',
'sr_CS': 'Serbian (Cyrillic)_Serbia and Montenegro',
'sk_SK': 'Slovak_Slovakia',
'sl_SI': 'Slovenian_Slovenia',
@@ -131,7 +129,6 @@ _LOCALE2WIN32 = {
'sv_SE': 'Swedish_Sweden',
'ta_IN': 'English_Australia',
'th_TH': 'Thai_Thailand',
- 'mi_NZ': 'Maori',
'tr_TR': 'Turkish_Turkey',
'uk_UA': 'Ukrainian_Ukraine',
'vi_VN': 'Vietnamese_Viet Nam',
From 2270f8e8ddd882676b5a1383c98c3d2a5975a432 Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:22:23 +0100
Subject: [PATCH 16/55] [IMP] merge extraneous setitem into literal dict
creation
bzr revid: xmo@openerp.com-20121214122223-91elxxp0m6ska8ua
---
.../addons/base/ir/workflow/print_instance.py | 6 ++-
openerp/addons/base_quality_interrogation.py | 5 +--
openerp/report/custom.py | 45 ++++++++++---------
3 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/openerp/addons/base/ir/workflow/print_instance.py b/openerp/addons/base/ir/workflow/print_instance.py
index c14e01b7a19..c9f1dc1c97e 100644
--- a/openerp/addons/base/ir/workflow/print_instance.py
+++ b/openerp/addons/base/ir/workflow/print_instance.py
@@ -77,8 +77,10 @@ def graph_get(cr, graph, wkf_ids, nested, workitem, processed_subflows):
for t in transitions:
if not t['act_to'] in activities:
continue
- args = {}
- args['label'] = str(t['condition']).replace(' or ', '\\nor ').replace(' and ', '\\nand ')
+ args = {
+ 'label': str(t['condition']).replace(' or ', '\\nor ')
+ .replace(' and ','\\nand ')
+ }
if t['signal']:
args['label'] += '\\n'+str(t['signal'])
args['style'] = 'bold'
diff --git a/openerp/addons/base_quality_interrogation.py b/openerp/addons/base_quality_interrogation.py
index ae49996ec95..a1b03b894e6 100755
--- a/openerp/addons/base_quality_interrogation.py
+++ b/openerp/addons/base_quality_interrogation.py
@@ -30,6 +30,7 @@ import time
import pickle
import base64
import socket
+import string
admin_passwd = 'admin'
waittime = 10
@@ -305,13 +306,11 @@ options = {
'port' : opt.port or 8069,
'netport':opt.netport or 8070,
'database': opt.db_name or 'terp',
- 'modules' : opt.modules or [],
+ 'modules' : map(string.strip, opt.modules.split(',')) if opt.modules else [],
'login' : opt.login or 'admin',
'pwd' : opt.pwd or '',
'extra-addons':opt.extra_addons or []
}
-
-options['modules'] = opt.modules and map(lambda m: m.strip(), opt.modules.split(',')) or []
# Hint:i18n-import=purchase:ar_AR.po+sale:fr_FR.po,nl_BE.po
if opt.translate_in:
translate = opt.translate_in
diff --git a/openerp/report/custom.py b/openerp/report/custom.py
index 0c572c0c249..0ae560e1a22 100644
--- a/openerp/report/custom.py
+++ b/openerp/report/custom.py
@@ -144,10 +144,11 @@ class report_custom(report_int):
parent_field = self.pool.get('ir.model.fields').read(cr, uid, [report['field_parent'][0]], ['model'])
model_name = self.pool.get('ir.model').read(cr, uid, [report['model_id'][0]], ['model'], context=context)[0]['model']
- fct = {}
- fct['id'] = lambda x : x
- fct['gety'] = lambda x: x.split('-')[0]
- fct['in'] = lambda x: x.split(',')
+ fct = {
+ 'id': lambda x: x,
+ 'gety': lambda x: x.split('-')[0],
+ 'in': lambda x: x.split(',')
+ }
new_fields = []
new_cond = []
for f in fields:
@@ -350,15 +351,17 @@ class report_custom(report_int):
x_axis = axis.X(label = fields[0]['name'], format="/a-30{}%s"),
y_axis = axis.Y(label = ', '.join(map(lambda x : x['name'], fields[1:]))))
- process_date = {}
- process_date['D'] = lambda x : reduce(lambda xx,yy : xx+'-'+yy,x.split('-')[1:3])
- process_date['M'] = lambda x : x.split('-')[1]
- process_date['Y'] = lambda x : x.split('-')[0]
+ process_date = {
+ 'D': lambda x: reduce(lambda xx, yy: xx + '-' + yy, x.split('-')[1:3]),
+ 'M': lambda x: x.split('-')[1],
+ 'Y': lambda x: x.split('-')[0]
+ }
- order_date = {}
- order_date['D'] = lambda x : time.mktime((2005,int(x.split('-')[0]), int(x.split('-')[1]),0,0,0,0,0,0))
- order_date['M'] = lambda x : x
- order_date['Y'] = lambda x : x
+ order_date = {
+ 'D': lambda x: time.mktime((2005, int(x.split('-')[0]), int(x.split('-')[1]), 0, 0, 0, 0, 0, 0)),
+ 'M': lambda x: x,
+ 'Y': lambda x: x
+ }
abscissa = []
@@ -447,15 +450,17 @@ class report_custom(report_int):
can.show(80,380,'/16/H'+report['title'])
- process_date = {}
- process_date['D'] = lambda x : reduce(lambda xx,yy : xx+'-'+yy,x.split('-')[1:3])
- process_date['M'] = lambda x : x.split('-')[1]
- process_date['Y'] = lambda x : x.split('-')[0]
+ process_date = {
+ 'D': lambda x: reduce(lambda xx, yy: xx + '-' + yy, x.split('-')[1:3]),
+ 'M': lambda x: x.split('-')[1],
+ 'Y': lambda x: x.split('-')[0]
+ }
- order_date = {}
- order_date['D'] = lambda x : time.mktime((2005,int(x.split('-')[0]), int(x.split('-')[1]),0,0,0,0,0,0))
- order_date['M'] = lambda x : x
- order_date['Y'] = lambda x : x
+ order_date = {
+ 'D': lambda x: time.mktime((2005, int(x.split('-')[0]), int(x.split('-')[1]), 0, 0, 0, 0, 0, 0)),
+ 'M': lambda x: x,
+ 'Y': lambda x: x
+ }
ar = area.T(size=(350,350),
x_axis = axis.X(label = fields[0]['name'], format="/a-30{}%s"),
From affda60c8e904c85531bf65f664c2b9a04878c48 Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:24:23 +0100
Subject: [PATCH 17/55] [FIX] spaceify tabs
bzr revid: xmo@openerp.com-20121214122423-j8hla3cf3uir7ypt
---
.../module/report/ir_module_reference.rml | 22 +++++++++----------
openerp/tools/osutil.py | 22 +++++++++----------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/openerp/addons/base/module/report/ir_module_reference.rml b/openerp/addons/base/module/report/ir_module_reference.rml
index 10117c7130a..00030a10596 100644
--- a/openerp/addons/base/module/report/ir_module_reference.rml
+++ b/openerp/addons/base/module/report/ir_module_reference.rml
@@ -3,16 +3,16 @@
-
-
-
- [[ company.name ]]
- Reference Guide
-
-
- 1cm 28cm 20cm 28cm
-
-
+
+
+
+ [[ company.name ]]
+ Reference Guide
+
+
+ 1cm 28cm 20cm 28cm
+
+
@@ -236,7 +236,7 @@
[[ repeatIn(objdoc2(object.model) or [], 'sline') ]]
- [[ sline ]]
+ [[ sline ]]
|
diff --git a/openerp/tools/osutil.py b/openerp/tools/osutil.py
index 3da9fa624a3..67c586ad008 100644
--- a/openerp/tools/osutil.py
+++ b/openerp/tools/osutil.py
@@ -27,16 +27,16 @@ import os
from os.path import join as opj
def listdir(dir, recursive=False):
- """Allow to recursively get the file listing"""
- dir = os.path.normpath(dir)
- if not recursive:
- return os.listdir(dir)
+ """Allow to recursively get the file listing"""
+ dir = os.path.normpath(dir)
+ if not recursive:
+ return os.listdir(dir)
- res = []
- for root, dirs, files in walksymlinks(dir):
- root = root[len(dir)+1:]
- res.extend([opj(root, f) for f in files])
- return res
+ res = []
+ for root, dirs, files in walksymlinks(dir):
+ root = root[len(dir)+1:]
+ res.extend([opj(root, f) for f in files])
+ return res
def walksymlinks(top, topdown=True, onerror=None):
"""
@@ -58,7 +58,7 @@ def walksymlinks(top, topdown=True, onerror=None):
if __name__ == '__main__':
- from pprint import pprint as pp
- pp(listdir('../report', True))
+ from pprint import pprint as pp
+ pp(listdir('../report', True))
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
From a5cb8460c63d840e61b4cb4e510e5147811aa013 Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:25:25 +0100
Subject: [PATCH 18/55] [FIX] __init__ can't return values
bzr revid: xmo@openerp.com-20121214122525-bd5207viiz4vqi8x
---
openerp/addons/base/ir/ir_ui_menu.py | 3 +--
openerp/osv/fields.py | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/openerp/addons/base/ir/ir_ui_menu.py b/openerp/addons/base/ir/ir_ui_menu.py
index 2eb17d91fc1..31d0c6714fb 100644
--- a/openerp/addons/base/ir/ir_ui_menu.py
+++ b/openerp/addons/base/ir/ir_ui_menu.py
@@ -44,9 +44,8 @@ class ir_ui_menu(osv.osv):
def __init__(self, *args, **kwargs):
self.cache_lock = threading.RLock()
self._cache = {}
- r = super(ir_ui_menu, self).__init__(*args, **kwargs)
+ super(ir_ui_menu, self).__init__(*args, **kwargs)
self.pool.get('ir.model.access').register_cache_clearing_method(self._name, 'clear_cache')
- return r
def clear_cache(self):
with self.cache_lock:
diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py
index 3d2c83b2621..52717a40354 100644
--- a/openerp/osv/fields.py
+++ b/openerp/osv/fields.py
@@ -1304,7 +1304,7 @@ class sparse(function):
def __init__(self, serialization_field, **kwargs):
self.serialization_field = serialization_field
- return super(sparse, self).__init__(self._fnct_read, fnct_inv=self._fnct_write, multi='__sparse_multi', **kwargs)
+ super(sparse, self).__init__(self._fnct_read, fnct_inv=self._fnct_write, multi='__sparse_multi', **kwargs)
From e83d61583050ee61736a0dcec752bca2d28e82c3 Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:26:05 +0100
Subject: [PATCH 19/55] [IMP] literalify list creation
bzr revid: xmo@openerp.com-20121214122605-w1danvqxmqm12800
---
openerp/report/interface.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/openerp/report/interface.py b/openerp/report/interface.py
index 334d7d4056a..32091b410e8 100644
--- a/openerp/report/interface.py
+++ b/openerp/report/interface.py
@@ -244,10 +244,10 @@ class report_rml(report_int):
return obj.get()
def _get_path(self):
- ret = []
- ret.append(self.tmpl.replace(os.path.sep, '/').rsplit('/',1)[0]) # Same dir as the report rml
- ret.append('addons')
- ret.append(tools.config['root_path'])
- return ret
+ return [
+ self.tmpl.replace(os.path.sep, '/').rsplit('/', 1)[0],
+ 'addons',
+ tools.config['root_path']
+ ]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
From c6079dd6bbc55849b34326d5d1718a0aa97e2a90 Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Fri, 14 Dec 2012 13:38:03 +0100
Subject: [PATCH 20/55] [REM] unnecessary parens
bzr revid: xmo@openerp.com-20121214123803-6xu2s1ndnoyj4i3e
---
openerp/addons/base/ir/ir_model.py | 10 ++++----
openerp/addons/base/ir/ir_translation.py | 2 +-
.../addons/base/ir/workflow/print_instance.py | 10 ++++----
openerp/addons/base/res/res_config.py | 2 +-
openerp/addons/base/res/res_currency.py | 4 ++--
openerp/addons/base/res/res_lang.py | 4 ++--
openerp/addons/base/res/res_partner.py | 4 ++--
openerp/addons/base/res/res_request.py | 2 +-
openerp/addons/base_quality_interrogation.py | 6 ++---
openerp/loglevels.py | 2 +-
openerp/osv/expression.py | 24 +++++++++----------
openerp/osv/fields.py | 2 +-
openerp/osv/orm.py | 20 ++++++++--------
openerp/osv/query.py | 2 +-
openerp/report/custom.py | 2 +-
openerp/report/int_to_text.py | 2 +-
openerp/report/interface.py | 4 ++--
openerp/report/printscreen/ps_form.py | 2 +-
openerp/report/printscreen/ps_list.py | 2 +-
openerp/report/pyPdf/pdf.py | 2 +-
openerp/report/render/rml2html/rml2html.py | 2 +-
openerp/report/render/rml2pdf/color.py | 2 +-
openerp/report/render/rml2pdf/trml2pdf.py | 12 +++++-----
openerp/report/render/rml2txt/rml2txt.py | 4 ++--
openerp/report/report_sxw.py | 10 ++++----
openerp/service/http_server.py | 2 +-
openerp/service/web_services.py | 6 ++---
openerp/sql_db.py | 4 ++--
openerp/tools/config.py | 2 +-
openerp/tools/convert.py | 2 +-
openerp/tools/func.py | 6 ++---
openerp/tools/graph.py | 14 +++++------
openerp/tools/misc.py | 14 +++++------
openerp/tools/translate.py | 6 ++---
openerp/workflow/workitem.py | 2 +-
35 files changed, 98 insertions(+), 98 deletions(-)
diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py
index fcf1ee92ebd..7cb0e387710 100644
--- a/openerp/addons/base/ir/ir_model.py
+++ b/openerp/addons/base/ir/ir_model.py
@@ -514,7 +514,7 @@ class ir_model_constraint(Model):
# double-check we are really going to delete all the owners of this schema element
cr.execute("""SELECT id from ir_model_constraint where name=%s""", (data.name,))
external_ids = [x[0] for x in cr.fetchall()]
- if (set(external_ids)-ids_set):
+ if set(external_ids)-ids_set:
# as installed modules have defined this element we must not delete it!
continue
@@ -573,7 +573,7 @@ class ir_model_relation(Model):
# double-check we are really going to delete all the owners of this schema element
cr.execute("""SELECT id from ir_model_relation where name = %s""", (data.name,))
external_ids = [x[0] for x in cr.fetchall()]
- if (set(external_ids)-ids_set):
+ if set(external_ids)-ids_set:
# as installed modules have defined this element we must not delete it!
continue
@@ -585,7 +585,7 @@ class ir_model_relation(Model):
# drop m2m relation tables
for table in to_drop_table:
- cr.execute('DROP TABLE %s CASCADE'% (table),)
+ cr.execute('DROP TABLE %s CASCADE'% table,)
_logger.info('Dropped table %s', table)
cr.commit()
@@ -862,7 +862,7 @@ class ir_model_data(osv.osv):
res = self.read(cr, uid, data_id, ['model', 'res_id'])
if not res['res_id']:
raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id))
- return (res['model'], res['res_id'])
+ return res['model'], res['res_id']
def get_object(self, cr, uid, module, xml_id, context=None):
"""Returns a browsable record for the given module name and xml_id or raise ValueError if not found"""
@@ -903,7 +903,7 @@ class ir_model_data(osv.osv):
# records created during module install should not display the messages of OpenChatter
context = dict(context, install_mode=True)
if xml_id and ('.' in xml_id):
- assert len(xml_id.split('.'))==2, _("'%s' contains too many dots. XML ids should not contain dots ! These are used to refer to other modules data, as in module.reference_id") % (xml_id)
+ assert len(xml_id.split('.'))==2, _("'%s' contains too many dots. XML ids should not contain dots ! These are used to refer to other modules data, as in module.reference_id") % xml_id
module, xml_id = xml_id.split('.')
if (not xml_id) and (not self.doinit):
return False
diff --git a/openerp/addons/base/ir/ir_translation.py b/openerp/addons/base/ir/ir_translation.py
index f3985045fb2..f9983b5878b 100644
--- a/openerp/addons/base/ir/ir_translation.py
+++ b/openerp/addons/base/ir/ir_translation.py
@@ -134,7 +134,7 @@ class ir_translation_import_cursor(object):
""" % (self._parent_table, self._table_name, self._parent_table, find_expr))
if self._debug:
- cr.execute('SELECT COUNT(*) FROM ONLY %s' % (self._parent_table))
+ cr.execute('SELECT COUNT(*) FROM ONLY %s' % self._parent_table)
c1 = cr.fetchone()[0]
cr.execute('SELECT COUNT(*) FROM ONLY %s AS irt, %s AS ti WHERE %s' % \
(self._parent_table, self._table_name, find_expr))
diff --git a/openerp/addons/base/ir/workflow/print_instance.py b/openerp/addons/base/ir/workflow/print_instance.py
index c9f1dc1c97e..2ac677b194e 100644
--- a/openerp/addons/base/ir/workflow/print_instance.py
+++ b/openerp/addons/base/ir/workflow/print_instance.py
@@ -101,11 +101,11 @@ def graph_get(cr, graph, wkf_ids, nested, workitem, processed_subflows):
start = cr.fetchone()[0]
cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id in ("+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
stop = cr.fetchall()
- if (stop):
+ if stop:
stop = (stop[0][1], dict(stop))
else:
stop = ("stop",{})
- return ((start,{}),stop)
+ return (start, {}), stop
def graph_instance_get(cr, graph, inst_id, nested=False):
@@ -208,13 +208,13 @@ class report_graph(report.interface.report_int):
def result(self):
if self.obj.is_done():
- return (True, self.obj.get(), 'pdf')
+ return True, self.obj.get(), 'pdf'
else:
- return (False, False, False)
+ return False, False, False
def create(self, cr, uid, ids, data, context=None):
self.obj = report_graph_instance(cr, uid, ids, data)
- return (self.obj.get(), 'pdf')
+ return self.obj.get(), 'pdf'
report_graph('report.workflow.instance.graph', 'ir.workflow')
diff --git a/openerp/addons/base/res/res_config.py b/openerp/addons/base/res/res_config.py
index 1aa108c14d2..98c5ca7e6af 100644
--- a/openerp/addons/base/res/res_config.py
+++ b/openerp/addons/base/res/res_config.py
@@ -309,7 +309,7 @@ class res_config_installer(osv.osv_memory):
hooks_results = set()
for module in base:
- hook = getattr(self, '_if_%s'%(module), None)
+ hook = getattr(self, '_if_%s'% module, None)
if hook:
hooks_results.update(hook(cr, uid, ids, context=None) or set())
diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py
index c1f4bd0b5c3..a95ac454057 100644
--- a/openerp/addons/base/res/res_currency.py
+++ b/openerp/addons/base/res/res_currency.py
@@ -99,7 +99,7 @@ class res_currency(osv.osv):
res = super(res_currency, self).read(cr, user, ids, fields, context, load)
currency_rate_obj = self.pool.get('res.currency.rate')
values = res
- if not isinstance(values, (list)):
+ if not isinstance(values, list):
values = [values]
for r in values:
if r.__contains__('rate_ids'):
@@ -217,7 +217,7 @@ class res_currency(osv.osv):
if round:
return self.round(cr, uid, to_currency, from_amount * rate)
else:
- return (from_amount * rate)
+ return from_amount * rate
res_currency()
diff --git a/openerp/addons/base/res/res_lang.py b/openerp/addons/base/res/res_lang.py
index 6c62877a89a..5f39a7cb703 100644
--- a/openerp/addons/base/res/res_lang.py
+++ b/openerp/addons/base/res/res_lang.py
@@ -168,7 +168,7 @@ class lang(osv.osv):
thousands_sep = lang_obj.thousands_sep or conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
decimal_point = lang_obj.decimal_point
grouping = lang_obj.grouping
- return (grouping, thousands_sep, decimal_point)
+ return grouping, thousands_sep, decimal_point
def write(self, cr, uid, ids, vals, context=None):
for lang_id in ids :
@@ -231,7 +231,7 @@ lang()
def original_group(s, grouping, thousands_sep=''):
if not grouping:
- return (s, 0)
+ return s, 0
result = ""
seps = 0
diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py
index 07dba6b0d32..e44f6340fc8 100644
--- a/openerp/addons/base/res/res_partner.py
+++ b/openerp/addons/base/res/res_partner.py
@@ -309,7 +309,7 @@ class res_partner(osv.osv, format_address):
if default is None:
default = {}
name = self.read(cr, uid, [id], ['name'], context)[0]['name']
- default.update({'name': _('%s (copy)') % (name)})
+ default.update({'name': _('%s (copy)') % name})
return super(res_partner, self).copy(cr, uid, id, default, context)
def onchange_type(self, cr, uid, ids, is_company, context=None):
@@ -519,7 +519,7 @@ class res_partner(osv.osv, format_address):
def view_header_get(self, cr, uid, view_id, view_type, context):
res = super(res_partner, self).view_header_get(cr, uid, view_id, view_type, context)
if res: return res
- if (not context.get('category_id', False)):
+ if not context.get('category_id', False):
return False
return _('Partners: ')+self.pool.get('res.partner.category').browse(cr, uid, context['category_id'], context).name
diff --git a/openerp/addons/base/res/res_request.py b/openerp/addons/base/res/res_request.py
index b1e3bf88505..25db0e43b2e 100644
--- a/openerp/addons/base/res/res_request.py
+++ b/openerp/addons/base/res/res_request.py
@@ -58,7 +58,7 @@ class res_request(osv.osv):
ids = map(lambda x:x[0], cr.fetchall())
cr.execute('select id from res_request where act_from=%s and (act_to<>%s) and (trigger_date<=%s or trigger_date is null) and active=True and state != %s', (uid,uid,time.strftime('%Y-%m-%d'), 'closed'))
ids2 = map(lambda x:x[0], cr.fetchall())
- return (ids, ids2)
+ return ids, ids2
_columns = {
'create_date': fields.datetime('Created Date', readonly=True),
diff --git a/openerp/addons/base_quality_interrogation.py b/openerp/addons/base_quality_interrogation.py
index a1b03b894e6..e89d2206e1f 100755
--- a/openerp/addons/base_quality_interrogation.py
+++ b/openerp/addons/base_quality_interrogation.py
@@ -68,10 +68,10 @@ def execute(connector, method, *args):
except socket.error,e:
if e.args[0] == 111:
if wait_count > wait_limit:
- print "Server is taking too long to start, it has exceeded the maximum limit of %d seconds."%(wait_limit)
+ print "Server is taking too long to start, it has exceeded the maximum limit of %d seconds." % wait_limit
clean()
sys.exit(1)
- print 'Please wait %d sec to start server....'%(waittime)
+ print 'Please wait %d sec to start server....' % waittime
wait_count += 1
time.sleep(waittime)
res = execute(connector, method, *args)
@@ -137,7 +137,7 @@ def check_quality(uri, user, pwd, dbname, modules, quality_logs):
detail_html +='''%s (Score : %s)
%s
%s'''%(test.replace(' ', '-'), test, score, msg, detail.get('detail', ''))
test_detail[test] = (score,msg,detail.get('detail',''))
html += ""
- html += "%s"%(detail_html)
+ html += "%s"% detail_html
html += "