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="", + 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&currency_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" + "&currency_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&currency_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" + "&currency_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&currency_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" + "&currency_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&currency_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" + "&currency_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" - "&currency_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" - "&currency_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" - "&currency_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" - "&currency_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 @@ @@ -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 += "" if not os.path.isdir(quality_logs): os.mkdir(quality_logs) diff --git a/openerp/loglevels.py b/openerp/loglevels.py index f4fa46901dd..f80fd673939 100644 --- a/openerp/loglevels.py +++ b/openerp/loglevels.py @@ -110,7 +110,7 @@ def get_encodings(hint_encoding='utf-8'): # some defaults (also taking care of pure ASCII) for charset in ['utf8','latin1']: - if not (hint_encoding) or (charset.lower() != hint_encoding.lower()): + if not hint_encoding or (charset.lower() != hint_encoding.lower()): yield charset from locale import getpreferredencoding diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index e14e013d536..43717320a48 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -340,11 +340,11 @@ def generate_table_alias(src_table_alias, joined_tables=[]): """ alias = src_table_alias if not joined_tables: - return ('%s' % alias, '%s' % _quote(alias)) + return '%s' % alias, '%s' % _quote(alias) for link in joined_tables: alias += '__' + link[1] - assert len(alias) < 64, 'Table alias name %s is longer than the 64 characters size accepted by default in postgresql.' % (alias) - return ('%s' % alias, '%s as %s' % (_quote(joined_tables[-1][0]), _quote(alias))) + assert len(alias) < 64, 'Table alias name %s is longer than the 64 characters size accepted by default in postgresql.' % alias + return '%s' % alias, '%s as %s' % (_quote(joined_tables[-1][0]), _quote(alias)) def get_alias_from_query(from_query): @@ -356,9 +356,9 @@ def get_alias_from_query(from_query): """ from_splitted = from_query.split(' as ') if len(from_splitted) > 1: - return (from_splitted[0].replace('"', ''), from_splitted[1].replace('"', '')) + return from_splitted[0].replace('"', ''), from_splitted[1].replace('"', '') else: - return (from_splitted[0].replace('"', ''), from_splitted[0].replace('"', '')) + return from_splitted[0].replace('"', ''), from_splitted[0].replace('"', '') def normalize_leaf(element): @@ -377,7 +377,7 @@ def normalize_leaf(element): if isinstance(right, (list, tuple)) and operator in ('=', '!='): _logger.warning("The domain term '%s' should use the 'in' or 'not in' operator." % ((left, original, right),)) operator = 'in' if operator == '=' else 'not in' - return (left, operator, right) + return left, operator, right def is_operator(element): @@ -829,7 +829,7 @@ class expression(object): push(create_substitution_leaf(leaf, AND_OPERATOR, relational_model)) elif len(field_path) > 1 and field._auto_join: - raise NotImplementedError('_auto_join attribute not supported on many2many field %s' % (left)) + raise NotImplementedError('_auto_join attribute not supported on many2many field %s' % left) elif len(field_path) > 1 and field._type == 'many2one': right_ids = relational_model.search(cr, uid, [(field_path[1], operator, right)], context=context) @@ -989,7 +989,7 @@ class expression(object): res_ids = [x[0] for x in relational_model.name_search(cr, uid, right, [], operator, limit=None, context=c)] if operator in NEGATIVE_TERM_OPERATORS: res_ids.append(False) # TODO this should not be appended if False was in 'right' - return (left, 'in', res_ids) + return left, 'in', res_ids # resolve string-based m2o criterion into IDs if isinstance(right, basestring) or \ right and isinstance(right, (tuple, list)) and all(isinstance(item, basestring) for item in right): @@ -1140,8 +1140,8 @@ class expression(object): query = '%s."%s" IS NOT NULL' % (table_alias, left) params = [] - elif (operator == '=?'): - if (right is False or right is None): + elif operator == '=?': + if right is False or right is None: # '=?' is a short-circuit that makes the term TRUE if right is None or False query = 'TRUE' params = [] @@ -1187,7 +1187,7 @@ class expression(object): if isinstance(params, basestring): params = [params] - return (query, params) + return query, params def to_sql(self): stack = [] @@ -1213,6 +1213,6 @@ class expression(object): if joins: query = '(%s) AND %s' % (joins, query) - return (query, tools.flatten(params)) + return query, tools.flatten(params) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 52717a40354..51e49f19558 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -668,7 +668,7 @@ class many2many(_column): col1 = '%s_id' % source_model._table if not col2: col2 = '%s_id' % dest_model._table - return (tbl, col1, col2) + return tbl, col1, col2 def _get_query_and_where_params(self, cr, model, ids, values, where_params): """ Extracted from ``get`` to facilitate fine-tuning of the generated diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 07cf4364f6c..ab9b4873f18 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -454,7 +454,7 @@ class browse_record(object): new_data[field_name] = browse_null() elif field_column._type in ('one2many', 'many2many') and len(result_line[field_name]): new_data[field_name] = self._list_class([browse_record(self._cr, self._uid, id, self._table.pool.get(field_column._obj), self._cache, context=self._context, list_class=self._list_class, fields_process=self._fields_process) for id in result_line[field_name]], self._context) - elif field_column._type in ('reference'): + elif field_column._type in 'reference': if result_line[field_name]: if isinstance(result_line[field_name], browse_record): new_data[field_name] = result_line[field_name] @@ -1741,7 +1741,7 @@ class BaseModel(object): views = {} xml = "
" for f in node: - if f.tag in ('field'): + if f.tag in 'field': xml += etree.tostring(f, encoding="utf-8") xml += "
" new_xml = etree.fromstring(encode(xml)) @@ -2010,7 +2010,7 @@ class BaseModel(object): view = etree.Element('calendar', string=self._description) etree.SubElement(view, 'field', self._rec_name_fallback(cr, user, context)) - if (self._date_name not in self._columns): + if self._date_name not in self._columns: date_found = False for dt in ['date', 'date_start', 'x_date', 'x_date_start']: if dt in self._columns: @@ -2031,7 +2031,7 @@ class BaseModel(object): self._columns, 'date_delay'): raise except_orm( _('Invalid Object Architecture!'), - _("Insufficient fields to generate a Calendar View for %s, missing a date_stop or a date_delay" % (self._name))) + _("Insufficient fields to generate a Calendar View for %s, missing a date_stop or a date_delay" % self._name)) return view @@ -3097,7 +3097,7 @@ class BaseModel(object): else: default = self._defaults[k] - if (default is not None): + if default is not None: ss = self._columns[k]._symbol_set query = 'UPDATE "%s" SET "%s"=%s WHERE "%s" is NULL' % (self._table, k, ss[0], k) cr.execute(query, (ss[1](default),)) @@ -3176,7 +3176,7 @@ class BaseModel(object): # and add constraints if needed if isinstance(f, fields.many2one): if not self.pool.get(f._obj): - raise except_orm('Programming Error', ('There is no reference available for %s') % (f._obj,)) + raise except_orm('Programming Error', 'There is no reference available for %s' % (f._obj,)) dest_model = self.pool.get(f._obj) ref = dest_model._table # ir_actions is inherited so foreign key doesn't work on it @@ -3303,7 +3303,7 @@ class BaseModel(object): # TODO the condition could use fields_get_keys(). if f._fields_id not in other._columns.keys(): if f._fields_id not in other._inherit_fields.keys(): - raise except_orm('Programming Error', ("There is no reference field '%s' found for '%s'") % (f._fields_id, f._obj,)) + raise except_orm('Programming Error', "There is no reference field '%s' found for '%s'" % (f._fields_id, f._obj,)) def _m2m_raise_or_create_relation(self, cr, f): m2m_tbl, col1, col2 = f._sql_names(self) @@ -3311,7 +3311,7 @@ class BaseModel(object): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (m2m_tbl,)) if not cr.dictfetchall(): if not self.pool.get(f._obj): - raise except_orm('Programming Error', ('Many2Many destination model does not exist: `%s`') % (f._obj,)) + raise except_orm('Programming Error', 'Many2Many destination model does not exist: `%s`' % (f._obj,)) dest_model = self.pool.get(f._obj) ref = dest_model._table cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL, "%s" INTEGER NOT NULL, UNIQUE("%s","%s"))' % (m2m_tbl, col1, col2, col1, col2)) @@ -4672,7 +4672,7 @@ class BaseModel(object): new_tables = [] for table in added_tables: # table is just a table name -> switch to the full alias - if table == '"%s"' % (parent_table): + if table == '"%s"' % parent_table: new_tables.append('"%s" as "%s"' % (parent_table, parent_alias)) # table is already a full statement -> replace reference to the table to its alias, is correct with the way aliases are generated else: @@ -4997,7 +4997,7 @@ class BaseModel(object): """ if type(ids) in (int, long): ids = [ids] - query = 'SELECT id FROM "%s"' % (self._table) + query = 'SELECT id FROM "%s"' % self._table cr.execute(query + "WHERE ID IN %s", (tuple(ids),)) return [x[0] for x in cr.fetchall()] diff --git a/openerp/osv/query.py b/openerp/osv/query.py index 5cad7cf96f7..04a0ec5509b 100644 --- a/openerp/osv/query.py +++ b/openerp/osv/query.py @@ -151,7 +151,7 @@ class Query(object): query_from = add_joins_for_table(table_alias, query_from) query_from += ',' query_from = query_from[:-1] # drop last comma - return (query_from, " AND ".join(self.where_clause), self.where_clause_params) + return query_from, " AND ".join(self.where_clause), self.where_clause_params def __str__(self): return '' % self.get_sql() diff --git a/openerp/report/custom.py b/openerp/report/custom.py index 0ae560e1a22..c3d0ff810b7 100644 --- a/openerp/report/custom.py +++ b/openerp/report/custom.py @@ -273,7 +273,7 @@ class report_custom(report_int): res = self._create_bars(cr,uid, ids, report, fields, results2, context) elif report['type']=='line': res = self._create_lines(cr,uid, ids, report, fields, results2, context) - return (self.obj.get(), 'pdf') + return self.obj.get(), 'pdf' def _create_tree(self, uid, ids, report, fields, level, results, context): pageSize=common.pageSize.get(report['print_format'], [210.0,297.0]) diff --git a/openerp/report/int_to_text.py b/openerp/report/int_to_text.py index 52c456a1295..68906b98e72 100644 --- a/openerp/report/int_to_text.py +++ b/openerp/report/int_to_text.py @@ -52,7 +52,7 @@ def _1000_to_text(chiffre): d2 = chiffre/100 if d2>0 and d: return centaine[d2]+' '+d - elif d2>1 and not(d): + elif d2>1 and not d: return centaine[d2]+'s' else: return centaine[d2] or d diff --git a/openerp/report/interface.py b/openerp/report/interface.py index 32091b410e8..c0274e21c3f 100644 --- a/openerp/report/interface.py +++ b/openerp/report/interface.py @@ -85,7 +85,7 @@ class report_rml(report_int): xml = tools.ustr(xml).encode('utf8') report_type = datas.get('report_type', 'pdf') if report_type == 'raw': - return (xml,report_type) + return xml, report_type rml = self.create_rml(cr, xml, uid, context) pool = pooler.get_pool(cr.dbname) ir_actions_report_xml_obj = pool.get('ir.actions.report.xml') @@ -93,7 +93,7 @@ class report_rml(report_int): self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report' create_doc = self.generators[report_type] pdf = create_doc(rml, title=self.title) - return (pdf, report_type) + return pdf, report_type def create_xml(self, cr, uid, ids, datas, context=None): if not context: diff --git a/openerp/report/printscreen/ps_form.py b/openerp/report/printscreen/ps_form.py index c3735df2850..299e0466d8f 100644 --- a/openerp/report/printscreen/ps_form.py +++ b/openerp/report/printscreen/ps_form.py @@ -65,7 +65,7 @@ class report_printscreen_list(report_int): fields_order = self._parse_string(result['arch']) rows = model.read(cr, uid, datas['ids'], result['fields'].keys() ) self._create_table(uid, datas['ids'], result['fields'], fields_order, rows, context, model._description) - return (self.obj.get(), 'pdf') + return self.obj.get(), 'pdf' def _create_table(self, uid, ids, fields, fields_order, results, context, title=''): diff --git a/openerp/report/printscreen/ps_list.py b/openerp/report/printscreen/ps_list.py index 8908577e6ac..021994a732a 100644 --- a/openerp/report/printscreen/ps_list.py +++ b/openerp/report/printscreen/ps_list.py @@ -115,7 +115,7 @@ class report_printscreen_list(report_int): rows_new += [elem for elem in rows if elem['id'] == id] rows = rows_new res = self._create_table(uid, datas['ids'], result['fields'], fields_order, rows, context, model_desc) - return (self.obj.get(), 'pdf') + return self.obj.get(), 'pdf' def _create_table(self, uid, ids, fields, fields_order, results, context, title=''): diff --git a/openerp/report/pyPdf/pdf.py b/openerp/report/pyPdf/pdf.py index a3dd9f22962..5258e43e154 100644 --- a/openerp/report/pyPdf/pdf.py +++ b/openerp/report/pyPdf/pdf.py @@ -299,7 +299,7 @@ class PdfFileWriter(object): trailer.writeToStream(stream, None) # eof - stream.write("\nstartxref\n%s\n%%%%EOF\n" % (xref_location)) + stream.write("\nstartxref\n%s\n%%%%EOF\n" % xref_location) def _sweepIndirectReferences(self, externMap, data): if isinstance(data, DictionaryObject): diff --git a/openerp/report/render/rml2html/rml2html.py b/openerp/report/render/rml2html/rml2html.py index 90bd58af99a..0e82a5d3ea8 100644 --- a/openerp/report/render/rml2html/rml2html.py +++ b/openerp/report/render/rml2html/rml2html.py @@ -391,7 +391,7 @@ class _rml_doc(object): list_story.append(story_text) del f if template.data: - tag = ''''''%(template.data) + tag = ''''''% template.data else: tag = '' self.result +=''' diff --git a/openerp/report/render/rml2pdf/color.py b/openerp/report/render/rml2pdf/color.py index 35dd9637376..4d608c799d8 100644 --- a/openerp/report/render/rml2pdf/color.py +++ b/openerp/report/render/rml2pdf/color.py @@ -35,7 +35,7 @@ def get(col_str): return allcols[col_str] res = regex_t.search(col_str, 0) if res: - return (float(res.group(1)),float(res.group(2)),float(res.group(3))) + return float(res.group(1)), float(res.group(2)), float(res.group(3)) res = regex_h.search(col_str, 0) if res: return tuple([ float(int(res.group(i),16))/255 for i in range(1,4)]) diff --git a/openerp/report/render/rml2pdf/trml2pdf.py b/openerp/report/render/rml2pdf/trml2pdf.py index b8dc9885a4a..f9f060db1b9 100644 --- a/openerp/report/render/rml2pdf/trml2pdf.py +++ b/openerp/report/render/rml2pdf/trml2pdf.py @@ -123,7 +123,7 @@ class PageCount(platypus.Flowable): self.story_count = story_count def draw(self): - self.canv.beginForm("pageCount%d" % (self.story_count)) + self.canv.beginForm("pageCount%d" % self.story_count) self.canv.setFont("Helvetica", utils.unit_get(str(8))) self.canv.drawString(0, 0, str(self.canv.getPageNumber())) self.canv.endForm() @@ -268,18 +268,18 @@ class _rml_doc(object): if fontname not in pdfmetrics._fonts: pdfmetrics.registerFont(TTFont(fontname, filename)) - if (mode == 'all'): + if mode == 'all': addMapping(face, 0, 0, fontname) #normal addMapping(face, 0, 1, fontname) #italic addMapping(face, 1, 0, fontname) #bold addMapping(face, 1, 1, fontname) #italic and bold elif (mode== 'normal') or (mode == 'regular'): addMapping(face, 0, 0, fontname) #normal - elif (mode == 'italic'): + elif mode == 'italic': addMapping(face, 0, 1, fontname) #italic - elif (mode == 'bold'): + elif mode == 'bold': addMapping(face, 1, 0, fontname) #bold - elif (mode == 'bolditalic'): + elif mode == 'bolditalic': addMapping(face, 1, 1, fontname) #italic and bold def _textual_image(self, node): @@ -602,7 +602,7 @@ class _rml_Illustration(platypus.flowables.Flowable): self.height = utils.unit_get(node.get('height')) self.self2 = self2 def wrap(self, *args): - return (self.width, self.height) + return self.width, self.height def draw(self): drw = _rml_draw(self.localcontext ,self.node,self.styles, images=self.self2.images, path=self.self2.path, title=self.self2.title) drw.render(self.canv, None) diff --git a/openerp/report/render/rml2txt/rml2txt.py b/openerp/report/render/rml2txt/rml2txt.py index b431904f9c8..b0de2069c6e 100755 --- a/openerp/report/render/rml2txt/rml2txt.py +++ b/openerp/report/render/rml2txt/rml2txt.py @@ -107,11 +107,11 @@ class textbox(object): def haplines(self,arr,offset,cc= ''): """ Horizontaly append lines """ - while (len(self.lines) < len(arr)): + while len(self.lines) < len(arr): self.lines.append("") for i in range(len(self.lines)): - while (len(self.lines[i]) < offset): + while len(self.lines[i]) < offset: self.lines[i] += " " for i in range(len(arr)): self.lines[i] += cc +arr[i] diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index 27bd5fa5394..e0731b819f5 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -441,7 +441,7 @@ class report_sxw(report_rml, preprocess.report): raise NotImplementedError(_('Unknown report type: %s') % report_type) fnct_ret = fnct(cr, uid, ids, data, report_xml, context) if not fnct_ret: - return (False,False) + return False, False return fnct_ret def create_source_odt(self, cr, uid, ids, data, report_xml, context=None): @@ -531,7 +531,7 @@ class report_sxw(report_rml, preprocess.report): logo = base64.decodestring(rml_parser.logo) create_doc = self.generators[report_xml.report_type] pdf = create_doc(etree.tostring(processed_rml),rml_parser.localcontext,logo,title.encode('utf8')) - return (pdf, report_xml.report_type) + return pdf, report_xml.report_type def create_single_odt(self, cr, uid, ids, data, report_xml, context=None): if not context: @@ -644,7 +644,7 @@ class report_sxw(report_rml, preprocess.report): sxw_z.close() final_op = sxw_io.getvalue() sxw_io.close() - return (final_op, mime_type) + return final_op, mime_type def create_single_html2html(self, cr, uid, ids, data, report_xml, context=None): if not context: @@ -666,7 +666,7 @@ class report_sxw(report_rml, preprocess.report): create_doc = self.generators['html2html'] html = etree.tostring(create_doc(html_dom, html_parser.localcontext)) - return (html.replace('&','&').replace('<', '<').replace('>', '>').replace('
',''), report_type) + return html.replace('&','&').replace('<', '<').replace('>', '>').replace('
',''), report_type def create_single_mako2html(self, cr, uid, ids, data, report_xml, context=None): mako_html = report_xml.report_rml_content @@ -675,7 +675,7 @@ class report_sxw(report_rml, preprocess.report): html_parser.set_context(objs, data, ids, 'html') create_doc = self.generators['makohtml2html'] html = create_doc(mako_html,html_parser.localcontext) - return (html,'html') + return html,'html' # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/service/http_server.py b/openerp/service/http_server.py index 1496ea71646..6134f75f93e 100644 --- a/openerp/service/http_server.py +++ b/openerp/service/http_server.py @@ -139,7 +139,7 @@ class OpenERPAuthProvider(AuthProvider): uid = security.login(db,user,passwd) if uid is False: return False - return (user, passwd, db, uid) + return user, passwd, db, uid except Exception,e: _logger.debug("Fail auth: %s" % e ) return False diff --git a/openerp/service/web_services.py b/openerp/service/web_services.py index 5ce5b546dc7..d393dfa1003 100644 --- a/openerp/service/web_services.py +++ b/openerp/service/web_services.py @@ -172,13 +172,13 @@ class db(netsvc.ExportService): def exp_get_progress(self, id): if self.actions[id]['thread'].isAlive(): # return openerp.modules.init_progress[db_name] - return (min(self.actions[id].get('progress', 0),0.95), []) + return min(self.actions[id].get('progress', 0),0.95), [] else: clean = self.actions[id]['clean'] if clean: users = self.actions[id]['users'] self.actions.pop(id) - return (1.0, users) + return 1.0, users else: e = self.actions[id]['exception'] # TODO this seems wrong: actions[id]['traceback'] is set, but not 'exception'. self.actions.pop(id) @@ -543,7 +543,7 @@ GNU Public Licence. if os.name == 'posix': if platform.system() == 'Linux': lsbinfo = os.popen('lsb_release -a').read() - environment += '%s'%(lsbinfo) + environment += '%s'% lsbinfo else: environment += 'Your System is not lsb compliant\n' environment += 'Operating System Release : %s\n' \ diff --git a/openerp/sql_db.py b/openerp/sql_db.py index f18414bdff8..9848488660f 100644 --- a/openerp/sql_db.py +++ b/openerp/sql_db.py @@ -226,11 +226,11 @@ class Cursor(object): params = params or None res = self._obj.execute(query, params) except psycopg2.ProgrammingError, pe: - if (self._default_log_exceptions if log_exceptions is None else log_exceptions): + if self._default_log_exceptions if log_exceptions is None else log_exceptions: _logger.error("Programming error: %s, in query %s", pe, query) raise except Exception: - if (self._default_log_exceptions if log_exceptions is None else log_exceptions): + if self._default_log_exceptions if log_exceptions is None else log_exceptions: _logger.exception("bad query: %s", self._obj.query or query) raise diff --git a/openerp/tools/config.py b/openerp/tools/config.py index 1ad5f2b4baa..9717792a82a 100644 --- a/openerp/tools/config.py +++ b/openerp/tools/config.py @@ -352,7 +352,7 @@ class configmanager(object): # Check if the config file exists (-c used, but not -s) die(not opt.save and opt.config and not os.path.exists(opt.config), "The config file '%s' selected with -c/--config doesn't exist, "\ - "use -s/--save if you want to generate it"%(opt.config)) + "use -s/--save if you want to generate it"% opt.config) # place/search the config file on Win32 near the server installation # (../etc from the server) diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py index 12ed269db8b..26561fc01f7 100644 --- a/openerp/tools/convert.py +++ b/openerp/tools/convert.py @@ -662,7 +662,7 @@ form: module.record_id""" % (xml_id,) if rec.get('action') and pid: action = "ir.actions.%s,%d" % (a_type, a_id) self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(pid))], action, True, True, xml_id=rec_id) - return ('ir.ui.menu', pid) + return 'ir.ui.menu', pid def _assert_equals(self, f1, f2, prec=4): return not round(f1 - f2, prec) diff --git a/openerp/tools/func.py b/openerp/tools/func.py index d1797e30b9a..4728d971c69 100644 --- a/openerp/tools/func.py +++ b/openerp/tools/func.py @@ -45,7 +45,7 @@ def frame_codeinfo(fframe, back=0): try: if not fframe: - return ("", '') + return "", '' for i in range(back): fframe = fframe.f_back try: @@ -53,8 +53,8 @@ def frame_codeinfo(fframe, back=0): except TypeError: fname = '' lineno = fframe.f_lineno or '' - return (fname, lineno) + return fname, lineno except Exception: - return ("", '') + return "", '' # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/tools/graph.py b/openerp/tools/graph.py index 1b039ce97c6..5eb69c793b0 100755 --- a/openerp/tools/graph.py +++ b/openerp/tools/graph.py @@ -70,7 +70,7 @@ class graph(object): for edge in list_edge: if ((self.reachable_nodes.__contains__(edge[0]) and edge[1] not in self.reachable_nodes) or (self.reachable_nodes.__contains__(edge[1]) and edge[0] not in self.reachable_nodes)): - if(slack>self.edge_wt[edge]-1): + if slack > self.edge_wt[edge]-1: slack = self.edge_wt[edge]-1 new_edge = edge @@ -243,7 +243,7 @@ class graph(object): if source_node in self.head_nodes: for dest_node in self.transitions[source_node]: if dest_node not in self.head_nodes: - if(slack>(self.edge_wt[edge]-1)): + if slack>(self.edge_wt[edge]-1): slack = self.edge_wt[edge]-1 new_edge = (source_node, dest_node) @@ -276,7 +276,7 @@ class graph(object): least_rank = min(map(lambda x: x['x'], self.result.values())) - if(least_rank!=0): + if least_rank!=0: for node in self.result: self.result[node]['x']-=least_rank @@ -377,7 +377,7 @@ class graph(object): if pre_level_nodes: for src in pre_level_nodes: - if (self.transitions.get(src) and self.transitions[src].__contains__(node)): + if self.transitions.get(src) and self.transitions[src].__contains__(node): adj_nodes.append(self.result[src]['y']) return adj_nodes @@ -455,7 +455,7 @@ class graph(object): mid_node = l[no/2] self.result[mid_node]['y'] = mid_pos - if self.transitions.get((mid_node), False): + if self.transitions.get(mid_node, False): if last: self.result[mid_node]['y'] = last + len(self.transitions[mid_node])/2 + 1 if node!=mid_node: @@ -494,7 +494,7 @@ class graph(object): if max_level%2: self.result[self.start]['y'] = (max_level+1)/2 + self.max_order + (self.max_order and 1) else: - self.result[self.start]['y'] = (max_level)/2 + self.max_order + (self.max_order and 1) + self.result[self.start]['y'] = max_level /2 + self.max_order + (self.max_order and 1) self.graph_order() @@ -716,7 +716,7 @@ class graph(object): #for flat edges ie. source an destination nodes are on the same rank for src in self.transitions: for des in self.transitions[src]: - if (self.result[des]['x'] - self.result[src]['x'] == 0): + if self.result[des]['x'] - self.result[src]['x'] == 0: self.result[src]['x'] += 0.08 self.result[des]['x'] -= 0.08 diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index 209e4aaebdf..1b84e3a5eb7 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -92,7 +92,7 @@ def exec_pg_command_pipe(name, *args): pop = subprocess.Popen((prog,) + args, bufsize= -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=(os.name=="posix")) - return (pop.stdin, pop.stdout) + return pop.stdin, pop.stdout def exec_command_pipe(name, *args): prog = find_in_path(name) @@ -103,7 +103,7 @@ def exec_command_pipe(name, *args): pop = subprocess.Popen((prog,) + args, bufsize= -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=(os.name=="posix")) - return (pop.stdin, pop.stdout) + return pop.stdin, pop.stdout #---------------------------------------------------------- # File paths @@ -181,7 +181,7 @@ def _fileopen(path, mode, basedir, pathinfo, basename=None): if os.path.isfile(name): fo = open(name, mode) if pathinfo: - return (fo, name) + return fo, name return fo # Support for loading modules in zipped form. @@ -208,7 +208,7 @@ def _fileopen(path, mode, basedir, pathinfo, basename=None): os.sep, '/'))) fo.seek(0) if pathinfo: - return (fo, name) + return fo, name return fo except Exception: pass @@ -725,7 +725,7 @@ def get_win32_timezone(): @return the standard name of the current win32 timezone, or False if it cannot be found. """ res = False - if (sys.platform == "win32"): + if sys.platform == "win32": try: import _winreg hklm = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE) @@ -756,7 +756,7 @@ def detect_server_timezone(): (time.tzname[0], 'time.tzname'), (os.environ.get('TZ',False),'TZ environment variable'), ] # Option 4: OS-specific: /etc/timezone on Unix - if (os.path.exists("/etc/timezone")): + if os.path.exists("/etc/timezone"): tz_value = False try: f = open("/etc/timezone") @@ -767,7 +767,7 @@ def detect_server_timezone(): f.close() sources.append((tz_value,"/etc/timezone file")) # Option 5: timezone info from registry on Win32 - if (sys.platform == "win32"): + if sys.platform == "win32": # Timezone info is stored in windows registry. # However this is not likely to work very well as the standard name # of timezones in windows is rarely something that is known to pytz. diff --git a/openerp/tools/translate.py b/openerp/tools/translate.py index 4fc832289d2..35f54a5151e 100644 --- a/openerp/tools/translate.py +++ b/openerp/tools/translate.py @@ -288,7 +288,7 @@ class TinyPoFile(object): return lines def cur_line(self): - return (self.lines_count - len(self.lines)) + return self.lines_count - len(self.lines) def next(self): trans_type = name = res_id = source = trad = None @@ -301,7 +301,7 @@ class TinyPoFile(object): targets = [] line = None fuzzy = False - while (not line): + while not line: if 0 == len(self.lines): raise StopIteration() line = self.lines.pop(0).strip() @@ -861,7 +861,7 @@ def trans_generate(lang, modules, cr): frelativepath = fabsolutepath[len(path):] display_path = "addons%s" % frelativepath module = get_module_from_path(fabsolutepath, mod_paths=mod_paths) - if (('all' in modules) or (module in modules)) and module in installed_modules: + if ('all' in modules or module in modules) and module in installed_modules: return module, fabsolutepath, frelativepath, display_path return None, None, None, None diff --git a/openerp/workflow/workitem.py b/openerp/workflow/workitem.py index ac783b76a30..60c03ea9da5 100644 --- a/openerp/workflow/workitem.py +++ b/openerp/workflow/workitem.py @@ -126,7 +126,7 @@ def _execute(cr, workitem, activity, ident, stack): _state_set(cr, workitem, activity, 'running', ident) if activity.get('action', False): id_new = wkf_expr.execute(cr, ident, workitem, activity) - if not (id_new): + if not id_new: cr.execute('delete from wkf_workitem where id=%s', (workitem['id'],)) return False assert type(id_new)==type(1) or type(id_new)==type(1L), 'Wrong return value: '+str(id_new)+' '+str(type(id_new)) From a34a16703737388d647221d250d39b3fe0ba86f2 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 13:41:11 +0100 Subject: [PATCH 21/55] [FIX] crazy direct calls to dunder methods bzr revid: xmo@openerp.com-20121214124111-xk1wq0xh0gzgx8oh --- openerp/tools/graph.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/openerp/tools/graph.py b/openerp/tools/graph.py index 5eb69c793b0..4e336818638 100755 --- a/openerp/tools/graph.py +++ b/openerp/tools/graph.py @@ -51,7 +51,7 @@ class graph(object): for link in self.links: self.edge_wt[link] = self.result[link[1]]['x'] - self.result[link[0]]['x'] - tot_node = self.partial_order.__len__() + tot_node = len(self.partial_order) #do until all the nodes in the component are searched while self.tight_tree() self.edge_wt[edge]-1: slack = self.edge_wt[edge]-1 new_edge = edge @@ -93,7 +93,7 @@ class graph(object): self.reachable_nodes = [] self.tree_edges = [] self.reachable_node(self.start) - return self.reachable_nodes.__len__() + return len(self.reachable_nodes) def reachable_node(self, node): @@ -123,7 +123,7 @@ class graph(object): self.head_nodes = [] rest_edges = [] rest_edges += self.tree_edges - rest_edges.__delitem__(i) + del rest_edges[i] self.head_component(self.start, rest_edges) i+=1 positive = 0 @@ -197,7 +197,7 @@ class graph(object): des = link[1] edge_len = self.partial_order[des]['level'] - self.partial_order[src]['level'] if edge_len < 0: - self.links.__delitem__(i) + del self.links[i] self.links.insert(i, (des, src)) self.transitions[src].remove(des) self.transitions.setdefault(des, []).append(src) @@ -213,7 +213,7 @@ class graph(object): @param edge edge with negative cut-value @param edge new edge with minimum slack-value """ - self.tree_edges.__delitem__(self.tree_edges.index(e)) + del self.tree_edges[self.tree_edges.index(e)] self.tree_edges.append(f) self.init_cutvalues() @@ -227,13 +227,13 @@ class graph(object): self.head_nodes = [] rest_edges = [] rest_edges += self.tree_edges - rest_edges.__delitem__(rest_edges.index(edge)) + del rest_edges[rest_edges.index(edge)] self.head_component(self.start, rest_edges) - if self.head_nodes.__contains__(edge[1]): + if edge[1] in self.head_nodes: l = [] for node in self.result: - if not self.head_nodes.__contains__(node): + if node not in self.head_nodes: l.append(node) self.head_nodes = l @@ -377,7 +377,7 @@ class graph(object): if pre_level_nodes: for src in pre_level_nodes: - if self.transitions.get(src) and self.transitions[src].__contains__(node): + if self.transitions.get(src) and node in self.transitions[src]: adj_nodes.append(self.result[src]['y']) return adj_nodes @@ -511,7 +511,7 @@ class graph(object): for start in self.start_nodes[:index]: same = True for edge in self.tree_list[start][1:]: - if self.tree_list[self.start].__contains__(edge): + if edge in self.tree_list[self.start]: continue else: same = False @@ -590,9 +590,9 @@ class graph(object): for edge in largest_tree: - if rem_nodes.__contains__(edge[0]): + if edge[0] in rem_nodes: rem_nodes.remove(edge[0]) - if rem_nodes.__contains__(edge[1]): + if edge[1] in rem_nodes: rem_nodes.remove(edge[1]) if not rem_nodes: From 90a687ab7af38c4f1b957815a360682e8c582833 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 13:42:43 +0100 Subject: [PATCH 22/55] [FIX] misplaced docstrings bzr revid: xmo@openerp.com-20121214124243-kvg2cg00k0a4518p --- openerp/report/interface.py | 11 +++++------ openerp/sql_db.py | 7 +------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/openerp/report/interface.py b/openerp/report/interface.py index c0274e21c3f..88331db1f4d 100644 --- a/openerp/report/interface.py +++ b/openerp/report/interface.py @@ -55,13 +55,12 @@ class report_int(netsvc.Service): def create(self, cr, uid, ids, datas, context=None): return False -""" - Class to automatically build a document using the transformation process: - XML -> DATAS -> RML -> PDF - -> HTML - using a XSL:RML transformation -""" class report_rml(report_int): + """ + Automatically builds a document using the transformation process: + XML -> DATAS -> RML -> PDF -> HTML + using a XSL:RML transformation + """ def __init__(self, name, table, tmpl, xsl): super(report_rml, self).__init__(name) self.table = table diff --git a/openerp/sql_db.py b/openerp/sql_db.py index 9848488660f..31f45f879da 100644 --- a/openerp/sql_db.py +++ b/openerp/sql_db.py @@ -357,11 +357,6 @@ class Cursor(object): def __getattr__(self, name): return getattr(self._obj, name) - """ Set the mode of postgres operations for all cursors - """ - """Obtain the mode of postgres operations for all cursors - """ - class PsycoConnection(psycopg2.extensions.connection): pass @@ -521,8 +516,8 @@ def db_connect(db_name): return Connection(_Pool, db_name) def close_db(db_name): - global _Pool """ You might want to call openerp.modules.registry.RegistryManager.delete(db_name) along this function.""" + global _Pool if _Pool: _Pool.close_all(dsn(db_name)) ct = currentThread() From b6ece5d65f895a2d9ab4b1a5130594de3d80d95f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 13:43:10 +0100 Subject: [PATCH 23/55] [REM] trailing semicolons bzr revid: xmo@openerp.com-20121214124310-wfdkhmcwxnyqu30m --- openerp/osv/orm.py | 2 +- openerp/report/printscreen/ps_list.py | 4 ++-- openerp/report/render/rml2txt/rml2txt.py | 3 ++- openerp/sql_db.py | 4 ++-- openerp/tools/graph.py | 2 +- openerp/tools/translate.py | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index ab9b4873f18..ab9d8df85a6 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -2411,7 +2411,7 @@ class BaseModel(object): :rtype: tuple :return: the :meth:`~.name_get` pair value for the newly-created record. """ - rec_id = self.create(cr, uid, {self._rec_name: name}, context); + rec_id = self.create(cr, uid, {self._rec_name: name}, context) return self.name_get(cr, uid, [rec_id], context)[0] # private implementation of name_search, allows passing a dedicated user for the name_get part to diff --git a/openerp/report/printscreen/ps_list.py b/openerp/report/printscreen/ps_list.py index 021994a732a..51882b6c81a 100644 --- a/openerp/report/printscreen/ps_list.py +++ b/openerp/report/printscreen/ps_list.py @@ -147,7 +147,7 @@ class report_printscreen_list(report_int): for i in range(0, len(fields_order)): temp.append(0) tsum.append(0) - ince = -1; + ince = -1 for f in fields_order: s = 0 ince += 1 @@ -237,7 +237,7 @@ class report_printscreen_list(report_int): if line.get('__no_leaf') and temp[count] == 1 and f != 'id' and not line['__context']['group_by']: tsum[count] = float(tsum[count]) + float(line[f]) if not line.get('__group') and f != 'id' and temp[count] == 1: - tsum[count] = float(tsum[count]) + float(line[f]); + tsum[count] = float(tsum[count]) + float(line[f]) else: col.text = '/' diff --git a/openerp/report/render/rml2txt/rml2txt.py b/openerp/report/render/rml2txt/rml2txt.py index b0de2069c6e..f86fee00713 100755 --- a/openerp/report/render/rml2txt/rml2txt.py +++ b/openerp/report/render/rml2txt/rml2txt.py @@ -29,7 +29,8 @@ import utils Font_size= 10.0 def verbose(text): - sys.stderr.write(text+"\n"); + sys.stderr.write(text+"\n") + class textbox(object): """A box containing plain text. diff --git a/openerp/sql_db.py b/openerp/sql_db.py index 31f45f879da..337964f3368 100644 --- a/openerp/sql_db.py +++ b/openerp/sql_db.py @@ -74,8 +74,8 @@ import threading from inspect import currentframe import re -re_from = re.compile('.* from "?([a-zA-Z_0-9]+)"? .*$'); -re_into = re.compile('.* into "?([a-zA-Z_0-9]+)"? .*$'); +re_from = re.compile('.* from "?([a-zA-Z_0-9]+)"? .*$') +re_into = re.compile('.* into "?([a-zA-Z_0-9]+)"? .*$') sql_counter = 0 diff --git a/openerp/tools/graph.py b/openerp/tools/graph.py index 4e336818638..d26355e177d 100755 --- a/openerp/tools/graph.py +++ b/openerp/tools/graph.py @@ -117,7 +117,7 @@ class graph(object): """ self.cut_edges = {} self.head_nodes = [] - i=0; + i=0 for edge in self.tree_edges: self.head_nodes = [] diff --git a/openerp/tools/translate.py b/openerp/tools/translate.py index 35f54a5151e..405566e37e7 100644 --- a/openerp/tools/translate.py +++ b/openerp/tools/translate.py @@ -272,7 +272,7 @@ class TinyPoFile(object): def __iter__(self): self.buffer.seek(0) self.lines = self._get_lines() - self.lines_count = len(self.lines); + self.lines_count = len(self.lines) self.first = True self.extra_lines= [] From fb6f4bcfbde3de656aa95c60853bc6979d715e03 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 13:46:06 +0100 Subject: [PATCH 24/55] [REM] unreachable code bzr revid: xmo@openerp.com-20121214124606-nccvun2sf12gu7c7 --- openerp/report/pyPdf/pdf.py | 1 - openerp/report/render/rml2txt/rml2txt.py | 30 +----------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/openerp/report/pyPdf/pdf.py b/openerp/report/pyPdf/pdf.py index 5258e43e154..50317efcec1 100644 --- a/openerp/report/pyPdf/pdf.py +++ b/openerp/report/pyPdf/pdf.py @@ -838,7 +838,6 @@ class PdfFileReader(object): else: # no xref table found at specified location assert False - break def _pairs(self, array): i = 0 diff --git a/openerp/report/render/rml2txt/rml2txt.py b/openerp/report/render/rml2txt/rml2txt.py index f86fee00713..0237a2a5df8 100755 --- a/openerp/report/render/rml2txt/rml2txt.py +++ b/openerp/report/render/rml2txt/rml2txt.py @@ -256,12 +256,10 @@ class _rml_tmpl_frame(_rml_tmpl_tag): self.posx = posx def tag_start(self): return "frame start" - return '
 ' % (self.width+self.posx,self.posx) def tag_end(self): return True def tag_stop(self): return "frame stop" - return '

' def tag_mergeable(self): return False @@ -283,24 +281,7 @@ class _rml_tmpl_draw_string(_rml_tmpl_tag): def tag_start(self): return "draw string \"%s\" @(%d,%d)..\n" %("txt",self.posx,self.posy) - self.pos.sort() - res = '\\table ...' - posx = 0 - i = 0 - for (x,y,align,txt, style, fs) in self.pos: - if align=="left": - pos2 = len(txt)*fs - res+='%s' % (x - posx, style, pos2, txt) - posx = x+pos2 - if align=="right": - res+='%s' % (x - posx, style, txt) - posx = x - if align=="center": - res+='%s' % ((x - posx)*2, style, txt) - posx = 2*x-posx - i+=1 - res+='\\table end' - return res + def merge(self, ds): self.pos+=ds.pos @@ -317,10 +298,6 @@ class _rml_tmpl_draw_lines(_rml_tmpl_tag): def tag_start(self): return "draw lines..\n" - if self.ok: - return '

' % (self.posx+self.width,self.posx,self.style) - else: - return '' class _rml_stylesheet(object): def __init__(self, stylesheet, doc): @@ -457,11 +434,6 @@ class _rml_template(object): def end(self): return "template end\n" - result = '' - while not self.loop: - result += self.frame_start() - result += self.frame_stop() - return result class _rml_doc(object): def __init__(self, node, localcontext=None, images=None, path='.', title=None): From 1954c7ae2b8d3e3048e244f6443dd931fdc27a83 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:05:07 +0100 Subject: [PATCH 25/55] [FIX] unresolved reference: 'model' not available inside test body if generator used bzr revid: xmo@openerp.com-20121214130507-qc1fqzbdttb2a0n2 --- openerp/addons/base/ir/ir_model.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 7cb0e387710..4e21f83992e 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -158,9 +158,10 @@ class ir_model(osv.osv): if context is None: context = {} if isinstance(ids, (int, long)): ids = [ids] - if not context.get(MODULE_UNINSTALL_FLAG) and \ - any(model.state != 'manual' for model in self.browse(cr, user, ids, context)): - raise except_orm(_('Error'), _("Model '%s' contains module data and cannot be removed!") % (model.name,)) + if not context.get(MODULE_UNINSTALL_FLAG): + for model in self.browse(cr, user, ids, context): + if model.state != 'manual': + raise except_orm(_('Error'), _("Model '%s' contains module data and cannot be removed!") % (model.name,)) self._drop_table(cr, user, ids, context) res = super(ir_model, self).unlink(cr, user, ids, context) From d0a377cb1c7b4b8d24db3209cbd5a23c52c41896 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:07:58 +0100 Subject: [PATCH 26/55] [FIX] incorrect docstrings or docstring param names not matching actual param names bzr revid: xmo@openerp.com-20121214130758-a2wp963w4djmb02k --- openerp/addons/base/ir/ir_mail_server.py | 2 +- openerp/loglevels.py | 2 +- openerp/osv/expression.py | 26 +++++++++++++++--------- openerp/osv/orm.py | 4 ++-- openerp/service/websrv_lib.py | 6 +++--- openerp/tools/graph.py | 8 ++------ 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/openerp/addons/base/ir/ir_mail_server.py b/openerp/addons/base/ir/ir_mail_server.py index 1f5c14209a9..b30efef1b14 100644 --- a/openerp/addons/base/ir/ir_mail_server.py +++ b/openerp/addons/base/ir/ir_mail_server.py @@ -228,7 +228,7 @@ class ir_mail_server(osv.osv): :param int port: SMTP port to connect to :param user: optional username to authenticate with :param password: optional password to authenticate with - :param string encryption: optional: ``'ssl'`` | ``'starttls'`` + :param string encryption: optional, ``'ssl'`` | ``'starttls'`` :param bool smtp_debug: toggle debugging of SMTP sessions (all i/o will be output in logs) """ diff --git a/openerp/loglevels.py b/openerp/loglevels.py index f80fd673939..75dca53bb6a 100644 --- a/openerp/loglevels.py +++ b/openerp/loglevels.py @@ -129,7 +129,7 @@ def ustr(value, hint_encoding='utf-8', errors='strict'): :param: value: the value to convert :param: hint_encoding: an optional encoding that was detecte upstream and should be tried first to decode ``value``. - :param str error: optional `errors` flag to pass to the unicode + :param str errors: optional `errors` flag to pass to the unicode built-in to indicate how illegal character values should be treated when converting a string: 'strict', 'ignore' or 'replace' (see ``unicode()`` constructor). diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index 43717320a48..cca376994ec 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -332,9 +332,9 @@ def generate_table_alias(src_table_alias, joined_tables=[]): - src_model='res_users', join_tables=[(res.partner, 'parent_id')] alias = ('res_users__parent_id', '"res_partner" as "res_users__parent_id"') - :param model src_model: model source of the alias - :param list join_tables: list of tuples - (dst_model, link_field) + :param model src_table_alias: model source of the alias + :param list joined_tables: list of tuples + (dst_model, link_field) :return tuple: (table_alias, alias statement for from clause with quotes added) """ @@ -351,8 +351,6 @@ def get_alias_from_query(from_query): """ :param string from_query: is something like : - '"res_partner"' OR - '"res_partner" as "res_users__partner_id"'' - :param tuple result: (unquoted table name, unquoted alias) - i.e. (res_partners, res_partner) OR (res_partner, res_users__partner_id) """ from_splitted = from_query.split(' as ') if len(from_splitted) > 1: @@ -497,11 +495,19 @@ class ExtendedLeaf(object): adding joins :attr list join_context: list of join contexts. This is a list of tuples like ``(lhs, table, lhs_col, col, link)`` - :param obj lhs: source (left hand) model - :param obj model: destination (right hand) model - :param string lhs_col: source model column for join condition - :param string col: destination model column for join condition - :param link: link column between source and destination model + + where + + lhs + source (left hand) model + model + destination (right hand) model + lhs_col + source model column for join condition + col + destination model column for join condition + link + link column between source and destination model that is not necessarily (but generally) a real column used in the condition (i.e. in many2one); this link is used to compute aliases diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index ab9d8df85a6..2e02132d31e 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3485,7 +3485,7 @@ class BaseModel(object): :param cr: database cursor :param user: current user id - :param fields: list of fields + :param allfields: list of fields :param context: context arguments, like lang, time zone :return: dictionary of field dictionaries, each one describing a field of the business object :raise AccessError: * if user has no create/write rights on the requested object @@ -4838,7 +4838,7 @@ class BaseModel(object): Copy given record's data with all its fields values :param cr: database cursor - :param user: current user id + :param uid: current user id :param id: id of the record to copy :param default: field values to override in the original values of the copied record :type default: dictionary diff --git a/openerp/service/websrv_lib.py b/openerp/service/websrv_lib.py index d9f654f4edb..2ce6d3fa09d 100644 --- a/openerp/service/websrv_lib.py +++ b/openerp/service/websrv_lib.py @@ -226,9 +226,9 @@ class HttpOptions: Sometimes, like in special DAV folders, the OPTIONS may contain extra keywords, perhaps also dependant on the request url. - @param the options already. MUST be copied before being altered - @return the updated options. - + :param opts: MUST be copied before being altered + :returns: the updated options. + """ return opts diff --git a/openerp/tools/graph.py b/openerp/tools/graph.py index d26355e177d..7c1f00c45d0 100755 --- a/openerp/tools/graph.py +++ b/openerp/tools/graph.py @@ -210,8 +210,8 @@ class graph(object): def exchange(self, e, f): """Exchange edges to make feasible-tree optimized - @param edge edge with negative cut-value - @param edge new edge with minimum slack-value + :param e: edge with negative cut-value + :param f: new edge with minimum slack-value """ del self.tree_edges[self.tree_edges.index(e)] self.tree_edges.append(f) @@ -601,8 +601,6 @@ class graph(object): def rank(self): """Finds the optimized rank of the nodes using Network-simplex algorithm - - @param start starting node of the component """ self.levels = {} self.critical_edges = [] @@ -641,8 +639,6 @@ class graph(object): def order_in_rank(self): """Finds optimized order of the nodes within their ranks using median heuristic - - @param start: starting node of the component """ self.make_chain() From 8d238252ccbe6b1432f182790ffa8388ede86c47 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:13:10 +0100 Subject: [PATCH 27/55] [REM] unused and broken base.module.scan bzr revid: xmo@openerp.com-20121214131310-k9yuwqoau6a8e89u --- .../base/module/wizard/base_module_scan.py | 75 ------------------- .../module/wizard/base_module_scan_view.xml | 31 -------- 2 files changed, 106 deletions(-) delete mode 100644 openerp/addons/base/module/wizard/base_module_scan.py delete mode 100644 openerp/addons/base/module/wizard/base_module_scan_view.xml diff --git a/openerp/addons/base/module/wizard/base_module_scan.py b/openerp/addons/base/module/wizard/base_module_scan.py deleted file mode 100644 index 3e03c57ea9b..00000000000 --- a/openerp/addons/base/module/wizard/base_module_scan.py +++ /dev/null @@ -1,75 +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 . -# -############################################################################## -import os -import glob -import imp - -import tools - -import zipfile -from osv import osv - -class base_module_scan(osv.osv_memory): - """ scan module """ - - _name = "base.module.scan" - _description = "scan module" - - def watch_dir(self, cr, uid, ids, context): - mod_obj = self.pool.get('ir.module.module') - all_mods = mod_obj.read(cr, uid, mod_obj.search(cr, uid, []), ['name', 'state']) - known_modules = [x['name'] for x in all_mods] - ls_ad = glob.glob(os.path.join(tools.config['addons_path'], '*', '__terp__.py')) - modules = [module_name_re.match(name).group(1) for name in ls_ad] - for fname in os.listdir(tools.config['addons_path']): - if zipfile.is_zipfile(fname): - modules.append( fname.split('.')[0]) - for module in modules: - if module in known_modules: - continue - terp = mod_obj.get_module_info(module) - if not terp.get('installable', True): - continue - - # XXX check if this code is correct... - fm = imp.find_module(module) - try: - imp.load_module(module, *fm) - finally: - if fm[0]: - fm[0].close() - - values = mod_obj.get_values_from_terp(terp) - mod_id = mod_obj.create(cr, uid, dict(name=module, state='uninstalled', **values)) - dependencies = terp.get('depends', []) - for d in dependencies: - cr.execute('insert into ir_module_module_dependency (module_id,name) values (%s, %s)', (mod_id, d)) - for module in known_modules: - terp = mod_obj.get_module_info(module) - if terp.get('installable', True): - for mod in all_mods: - if mod['name'] == module and mod['state'] == 'uninstallable': - mod_obj.write(cr, uid, [mod['id']], {'state': 'uninstalled'}) - return {} - -base_module_scan() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/addons/base/module/wizard/base_module_scan_view.xml b/openerp/addons/base/module/wizard/base_module_scan_view.xml deleted file mode 100644 index f6f72eac483..00000000000 --- a/openerp/addons/base/module/wizard/base_module_scan_view.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - Module Scan - base.module.scan - -
-
-
- - - Module Scan - ir.actions.act_window - base.module.scan - form - form - new - - -
-
- From 91f441d0cd02466dbe28d4691f4ef46f04342340 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:17:20 +0100 Subject: [PATCH 28/55] [FIX] mutable default argument values bzr revid: xmo@openerp.com-20121214131720-jll2i2y0ph7aexox --- openerp/addons/base/ir/ir_model.py | 2 +- openerp/addons/base/ir/ir_needaction.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 4e21f83992e..e0158609e1c 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -257,7 +257,7 @@ class ir_model_fields(osv.osv): 'selection': "", 'domain': "[]", 'name': 'x_', - 'state': lambda self,cr,uid,ctx={}: (ctx and ctx.get('manual',False)) and 'manual' or 'base', + 'state': lambda self,cr,uid,ctx=None: (ctx and ctx.get('manual',False)) and 'manual' or 'base', 'on_delete': 'set null', 'select_level': '0', 'size': 64, diff --git a/openerp/addons/base/ir/ir_needaction.py b/openerp/addons/base/ir/ir_needaction.py index 39432ca6792..12f0fccee8a 100644 --- a/openerp/addons/base/ir/ir_needaction.py +++ b/openerp/addons/base/ir/ir_needaction.py @@ -56,7 +56,7 @@ class ir_needaction_mixin(osv.AbstractModel): # "Need action" API #------------------------------------------------------ - def _needaction_count(self, cr, uid, domain=[], context=None): + def _needaction_count(self, cr, uid, domain=None, context=None): """ Get the number of actions uid has to perform. """ dom = self._needaction_domain_get(cr, uid, context=context) if not dom: From 5d3d3868f6f78556164e382c3160b1bc8fde66ea Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:19:24 +0100 Subject: [PATCH 29/55] [IMP] use augmented assignments bzr revid: xmo@openerp.com-20121214131924-bpl48ht21ic4g34b --- openerp/addons/base/ir/ir_ui_menu.py | 2 +- openerp/addons/base/ir/ir_ui_view.py | 2 +- openerp/addons/base/ir/ir_values.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/ir/ir_ui_menu.py b/openerp/addons/base/ir/ir_ui_menu.py index 31d0c6714fb..9b945da5fe3 100644 --- a/openerp/addons/base/ir/ir_ui_menu.py +++ b/openerp/addons/base/ir/ir_ui_menu.py @@ -181,7 +181,7 @@ class ir_ui_menu(osv.osv): next_num=int(concat[0])+1 datas['name']=rex.sub(('(%d)'%next_num),datas['name']) else: - datas['name']=datas['name']+'(1)' + datas['name'] += '(1)' self.write(cr,uid,[res],{'name':datas['name']}) ids = ir_values_obj.search(cr, uid, [ ('model', '=', 'ir.ui.menu'), diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py index 2f2a610877d..83a1a9a8bcb 100644 --- a/openerp/addons/base/ir/ir_ui_view.py +++ b/openerp/addons/base/ir/ir_ui_view.py @@ -254,7 +254,7 @@ class view(osv.osv): if label: for lbl in eval(label): if t.has_key(tools.ustr(lbl)) and tools.ustr(t[lbl])=='False': - label_string = label_string + ' ' + label_string += ' ' else: label_string = label_string + " " + tools.ustr(t[lbl]) labels[str(t['id'])] = (a['id'],label_string) diff --git a/openerp/addons/base/ir/ir_values.py b/openerp/addons/base/ir/ir_values.py index 7af11789225..af7751c950b 100644 --- a/openerp/addons/base/ir/ir_values.py +++ b/openerp/addons/base/ir/ir_values.py @@ -307,10 +307,10 @@ class ir_values(osv.osv): ORDER BY v.user_id, u.company_id""" params = ('default', model, uid, uid) if condition: - query = query % 'AND v.key2 = %s' + query %= 'AND v.key2 = %s' params += (condition[:200],) else: - query = query % 'AND v.key2 is NULL' + query %= 'AND v.key2 is NULL' cr.execute(query, params) # keep only the highest priority default for each field From 0051f993c03a5e66fe41b25dcde018a78888f0a8 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:20:07 +0100 Subject: [PATCH 30/55] [FIX] single-quoted docstrings should use double quotes removed a completely useless docstring bzr revid: xmo@openerp.com-20121214132007-he0yvpmgjw4rwykb --- openerp/addons/base/ir/ir_filters.py | 3 --- openerp/addons/base/ir/ir_needaction.py | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/openerp/addons/base/ir/ir_filters.py b/openerp/addons/base/ir/ir_filters.py index 7c03341b55f..96021ee5d05 100644 --- a/openerp/addons/base/ir/ir_filters.py +++ b/openerp/addons/base/ir/ir_filters.py @@ -24,9 +24,6 @@ from osv import osv, fields from tools.translate import _ class ir_filters(osv.osv): - ''' - Filters - ''' _name = 'ir.filters' _description = 'Filters' diff --git a/openerp/addons/base/ir/ir_needaction.py b/openerp/addons/base/ir/ir_needaction.py index 12f0fccee8a..042283fcea0 100644 --- a/openerp/addons/base/ir/ir_needaction.py +++ b/openerp/addons/base/ir/ir_needaction.py @@ -23,7 +23,7 @@ from osv import osv class ir_needaction_mixin(osv.AbstractModel): - '''Mixin class for objects using the need action feature. + """Mixin class for objects using the need action feature. Need action feature can be used by models that have to be able to signal that an action is required on a particular record. If in @@ -37,7 +37,7 @@ class ir_needaction_mixin(osv.AbstractModel): This class also offers several global services: - ``_needaction_count``: returns the number of actions uid has to perform - ''' + """ _name = 'ir.needaction_mixin' _needaction = True From 3ee178ab2c7aee65155972e3ee04687811e3c3f8 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:21:13 +0100 Subject: [PATCH 31/55] [FIX] unnecessary backslashes bzr revid: xmo@openerp.com-20121214132113-1ofmm5x0ua3l2q5d --- openerp/addons/base/ir/ir_model.py | 2 +- openerp/addons/base/ir/ir_translation.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index e0158609e1c..4b56ae06ea7 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -272,7 +272,7 @@ class ir_model_fields(osv.osv): except Exception: _logger.warning('Invalid selection list definition for fields.selection', exc_info=True) raise except_orm(_('Error'), - _("The Selection Options expression is not a valid Pythonic expression." \ + _("The Selection Options expression is not a valid Pythonic expression." "Please provide an expression in the [('key','Label'), ...] format.")) check = True diff --git a/openerp/addons/base/ir/ir_translation.py b/openerp/addons/base/ir/ir_translation.py index f9983b5878b..a9712756b88 100644 --- a/openerp/addons/base/ir/ir_translation.py +++ b/openerp/addons/base/ir/ir_translation.py @@ -217,11 +217,11 @@ class ir_translation(osv.osv): def _get_ids(self, cr, uid, name, tt, lang, ids): translations = dict.fromkeys(ids, False) if ids: - cr.execute('select res_id,value ' \ - 'from ir_translation ' \ - 'where lang=%s ' \ - 'and type=%s ' \ - 'and name=%s ' \ + cr.execute('select res_id,value ' + 'from ir_translation ' + 'where lang=%s ' + 'and type=%s ' + 'and name=%s ' 'and res_id IN %s', (lang,tt,name,tuple(ids))) for res_id, value in cr.fetchall(): @@ -237,10 +237,10 @@ class ir_translation(osv.osv): self._get_ids.clear_cache(self, uid, name, tt, lang, res_id) self._get_source.clear_cache(self, uid, name, tt, lang) - cr.execute('delete from ir_translation ' \ - 'where lang=%s ' \ - 'and type=%s ' \ - 'and name=%s ' \ + cr.execute('delete from ir_translation ' + 'where lang=%s ' + 'and type=%s ' + 'and name=%s ' 'and res_id IN %s', (lang,tt,name,tuple(ids),)) for id in ids: From 5155f303032b21e84ff24a885fc73a92b78211f9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:25:33 +0100 Subject: [PATCH 32/55] [REM] unused local variables bzr revid: xmo@openerp.com-20121214132533-aafgbov19ckb9ksp --- openerp/addons/base/ir/ir_actions.py | 6 ++---- openerp/addons/base/ir/ir_cron.py | 2 +- openerp/addons/base/ir/ir_model.py | 2 -- openerp/addons/base/ir/ir_sequence.py | 2 +- openerp/addons/base/ir/ir_values.py | 2 +- openerp/addons/base/ir/workflow/print_instance.py | 5 ++--- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index 633977452a5..66d676088f7 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -671,7 +671,7 @@ class actions_server(osv.osv): context['object'] = obj for i in expr: context['active_id'] = i.id - result = self.run(cr, uid, [action.loop_action.id], context) + self.run(cr, uid, [action.loop_action.id], context) if action.state == 'object_write': res = {} @@ -716,8 +716,6 @@ class actions_server(osv.osv): expr = exp.value res[exp.col1.name] = expr - obj_pool = None - res_id = False obj_pool = self.pool.get(action.srcmodel_id.model) res_id = obj_pool.create(cr, uid, res) if action.record_id: @@ -736,7 +734,7 @@ class actions_server(osv.osv): model = action.copy_object.split(',')[0] cid = action.copy_object.split(',')[1] obj_pool = self.pool.get(model) - res_id = obj_pool.copy(cr, uid, int(cid), res) + obj_pool.copy(cr, uid, int(cid), res) return False diff --git a/openerp/addons/base/ir/ir_cron.py b/openerp/addons/base/ir/ir_cron.py index e2d791281d7..aaff5b3510b 100644 --- a/openerp/addons/base/ir/ir_cron.py +++ b/openerp/addons/base/ir/ir_cron.py @@ -231,7 +231,7 @@ class ir_cron(osv.osv): _logger.warning('Tried to poll an undefined table on database %s.', db_name) else: raise - except Exception, ex: + except Exception: _logger.warning('Exception in cron:', exc_info=True) finally: diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 4b56ae06ea7..ff43a15692f 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -568,7 +568,6 @@ class ir_model_relation(Model): ids.reverse() for data in self.browse(cr, uid, ids, context): model = data.model - model_obj = self.pool.get(model) name = openerp.tools.ustr(data.name) # double-check we are really going to delete all the owners of this schema element @@ -1074,7 +1073,6 @@ class ir_model_data(osv.osv): if model == 'ir.model.fields') ir_model_relation = self.pool.get('ir.model.relation') - relation_ids = ir_model_relation.search(cr, uid, [('module', 'in', modules_to_remove)]) ir_module_module = self.pool.get('ir.module.module') modules_to_remove_ids = ir_module_module.search(cr, uid, [('name', 'in', modules_to_remove)]) relation_ids = ir_model_relation.search(cr, uid, [('module', 'in', modules_to_remove_ids)]) diff --git a/openerp/addons/base/ir/ir_sequence.py b/openerp/addons/base/ir/ir_sequence.py index f6f9e58ca90..13035f41cec 100644 --- a/openerp/addons/base/ir/ir_sequence.py +++ b/openerp/addons/base/ir/ir_sequence.py @@ -140,7 +140,7 @@ class ir_sequence(openerp.osv.osv.osv): values = self._add_missing_default_values(cr, uid, values, context) values['id'] = super(ir_sequence, self).create(cr, uid, values, context) if values['implementation'] == 'standard': - f = self._create_sequence(cr, values['id'], values['number_increment'], values['number_next']) + self._create_sequence(cr, values['id'], values['number_increment'], values['number_next']) return values['id'] def unlink(self, cr, uid, ids, context=None): diff --git a/openerp/addons/base/ir/ir_values.py b/openerp/addons/base/ir/ir_values.py index af7751c950b..8b9d44da6f7 100644 --- a/openerp/addons/base/ir/ir_values.py +++ b/openerp/addons/base/ir/ir_values.py @@ -417,7 +417,7 @@ class ir_values(osv.osv): continue # keep only the first action registered for each action name results[action['name']] = (action['id'], action['name'], action_def) - except except_orm, e: + except except_orm: continue return sorted(results.values()) diff --git a/openerp/addons/base/ir/workflow/print_instance.py b/openerp/addons/base/ir/workflow/print_instance.py index 2ac677b194e..4e2f30ca03a 100644 --- a/openerp/addons/base/ir/workflow/print_instance.py +++ b/openerp/addons/base/ir/workflow/print_instance.py @@ -96,7 +96,7 @@ def graph_get(cr, graph, wkf_ids, nested, workitem, processed_subflows): activity_from = actfrom[t['act_from']][1].get(t['signal'], actfrom[t['act_from']][0]) activity_to = actto[t['act_to']][1].get(t['signal'], actto[t['act_to']][0]) graph.add_edge(pydot.Edge( str(activity_from) ,str(activity_to), fontsize='10', **args)) - nodes = cr.dictfetchall() + cr.execute('select * from wkf_activity where flow_start=True and wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids) 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) @@ -109,7 +109,6 @@ def graph_get(cr, graph, wkf_ids, nested, workitem, processed_subflows): def graph_instance_get(cr, graph, inst_id, nested=False): - workitems = {} cr.execute('select wkf_id from wkf_instance where id=%s', (inst_id,)) inst = cr.fetchall() @@ -171,7 +170,7 @@ showpage''' inst_id = inst_id[0] graph_instance_get(cr, graph, inst_id, data.get('nested', False)) ps_string = graph.create(prog='dot', format='ps') - except Exception, e: + except Exception: _logger.exception('Exception in call:') # string is in PS, like the success message would have been ps_string = '''%PS-Adobe-3.0 From d02fc09bb9e52e705b542cd43f36f2dc99a10bbc Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Dec 2012 14:44:55 +0100 Subject: [PATCH 33/55] [IMP] more augmented assignments bzr revid: xmo@openerp.com-20121214134455-c1o7ehlot6vdwioe --- openerp/report/pyPdf/utils.py | 2 +- openerp/report/render/rml2pdf/trml2pdf.py | 4 ++-- openerp/tools/amount_to_text.py | 8 ++++---- openerp/tools/amount_to_text_en.py | 4 ++-- openerp/tools/graph.py | 2 +- openerp/tools/misc.py | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openerp/report/pyPdf/utils.py b/openerp/report/pyPdf/utils.py index 7c1d472d0b7..98eb7a2a2a9 100644 --- a/openerp/report/pyPdf/utils.py +++ b/openerp/report/pyPdf/utils.py @@ -78,7 +78,7 @@ class ConvertFunctionsToVirtualList(object): len_self = len(self) if index < 0: # support negative indexes - index = len_self + index + index += len_self if index < 0 or index >= len_self: raise IndexError, "sequence index out of range" return self.getFunction(index) diff --git a/openerp/report/render/rml2pdf/trml2pdf.py b/openerp/report/render/rml2pdf/trml2pdf.py index f9f060db1b9..81faef88a93 100644 --- a/openerp/report/render/rml2pdf/trml2pdf.py +++ b/openerp/report/render/rml2pdf/trml2pdf.py @@ -96,7 +96,7 @@ class NumberedCanvas(canvas.Canvas): key=self._pageCounter if not self.pages.get(key,False): while not self.pages.get(key,False): - key = key + 1 + key += 1 self.setFont("Helvetica", 8) self.drawRightString((self._pagesize[0]-30), (self._pagesize[1]-40), " %(this)i / %(total)i" % { @@ -890,7 +890,7 @@ class TinyDocTemplate(platypus.BaseDocTemplate): self.canv._storyCount = 0 def ___handle_pageBegin(self): - self.page = self.page + 1 + self.page += 1 self.pageTemplate.beforeDrawPage(self.canv,self) self.pageTemplate.checkPageSize(self.canv,self) self.pageTemplate.onPage(self.canv,self) diff --git a/openerp/tools/amount_to_text.py b/openerp/tools/amount_to_text.py index 331640a2c28..1dd8f7a6074 100644 --- a/openerp/tools/amount_to_text.py +++ b/openerp/tools/amount_to_text.py @@ -57,9 +57,9 @@ def _convert_nnn_fr(val): if rem > 0: word = to_19_fr[rem] + ' Cent' if mod > 0: - word = word + ' ' + word += ' ' if mod > 0: - word = word + _convert_nn_fr(mod) + word += _convert_nn_fr(mod) return word def french_number(val): @@ -125,9 +125,9 @@ def _convert_nnn_nl(val): if rem > 0: word = to_19_nl[rem] + ' Honderd' if mod > 0: - word = word + ' ' + word += ' ' if mod > 0: - word = word + _convert_nn_nl(mod) + word += _convert_nn_nl(mod) return word def dutch_number(val): diff --git a/openerp/tools/amount_to_text_en.py b/openerp/tools/amount_to_text_en.py index 97d690c70e2..94550588aad 100644 --- a/openerp/tools/amount_to_text_en.py +++ b/openerp/tools/amount_to_text_en.py @@ -60,9 +60,9 @@ def _convert_nnn(val): if rem > 0: word = to_19[rem] + ' Hundred' if mod > 0: - word = word + ' ' + word += ' ' if mod > 0: - word = word + _convert_nn(mod) + word += _convert_nn(mod) return word def english_number(val): diff --git a/openerp/tools/graph.py b/openerp/tools/graph.py index 7c1f00c45d0..785b3b8fee2 100755 --- a/openerp/tools/graph.py +++ b/openerp/tools/graph.py @@ -310,7 +310,7 @@ class graph(object): """ if not self.result[node]['y']: self.result[node]['y'] = self.order[level] - self.order[level] = self.order[level]+1 + self.order[level] += 1 for sec_end in self.transitions.get(node, []): if node!=sec_end: diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index 1b84e3a5eb7..372b048c4d9 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -561,8 +561,8 @@ def human_size(sz): sz=len(sz) s, i = float(sz), 0 while s >= 1024 and i < len(units)-1: - s = s / 1024 - i = i + 1 + s /= 1024 + i += 1 return "%0.2f %s" % (s, units[i]) def logged(f): From 8fb701d0b33ba21b65eb18985015b8335994618a Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 14 Dec 2012 15:06:36 +0100 Subject: [PATCH 34/55] [IMP] account_followup: simplify code in report bzr revid: rco@openerp.com-20121214140636-34i98k29ldl15z3h --- .../report/account_followup_print.py | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py index f101aeaa369..67ce062dcd1 100644 --- a/addons/account_followup/report/account_followup_print.py +++ b/addons/account_followup/report/account_followup_print.py @@ -20,6 +20,7 @@ ############################################################################## import time +from collections import defaultdict import pooler from report import report_sxw @@ -50,36 +51,30 @@ class report_rappel(report_sxw.rml_parse): def _lines_get_with_partner(self, partner, company_id): pool = pooler.get_pool(self.cr.dbname) moveline_obj = pool.get('account.move.line') - company_obj = pool.get('res.company') - obj_currency = pool.get('res.currency') - movelines = moveline_obj.search(self.cr, self.uid, - [('partner_id', '=', partner.id), - ('account_id.type', '=', 'receivable'), - ('reconcile_id', '=', False), ('state', '<>', 'draft'),('company_id','=', company_id)]) - movelines = moveline_obj.browse(self.cr, self.uid, movelines) - base_currency = movelines[0].company_id.currency_id - final_res = [] - line_cur = {base_currency.id: {'line': []}} + moveline_ids = moveline_obj.search(self.cr, self.uid, [ + ('partner_id', '=', partner.id), + ('account_id.type', '=', 'receivable'), + ('reconcile_id', '=', False), + ('state', '!=', 'draft'), + ('company_id', '=', company_id), + ]) - for line in movelines: - if line.currency_id and (not line.currency_id.id in line_cur): - line_cur[line.currency_id.id] = {'line': []} + # lines_per_currency = {currency: [line data, ...], ...} + lines_per_currency = defaultdict(list) + for line in moveline_obj.browse(self.cr, self.uid, moveline_ids): currency = line.currency_id or line.company_id.currency_id line_data = { - 'name': line.move_id.name, - 'ref': line.ref, - 'date':line.date, - 'date_maturity': line.date_maturity, - 'balance': currency.id <> line.company_id.currency_id.id and line.amount_currency or (line.debit - line.credit), - 'blocked': line.blocked, - 'currency_id': currency, - } - line_cur[currency.id]['line'].append(line_data) + 'name': line.move_id.name, + 'ref': line.ref, + 'date': line.date, + 'date_maturity': line.date_maturity, + 'balance': line.amount_currency if currency != line.company_id.currency_id else line.debit - line.credit, + 'blocked': line.blocked, + 'currency_id': currency, + } + lines_per_currency[currency].append(line_data) - for cur in line_cur: - if line_cur[cur]['line']: - final_res.append({'line': line_cur[cur]['line']}) - return final_res + return [{'line': lines} for lines in lines_per_currency.values()] def _get_text(self, stat_line, followup_id, context=None): if context is None: From 8e43af0e70cf1ad0bd2ed397c8548c5d559dda8a Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 14 Dec 2012 15:16:54 +0100 Subject: [PATCH 35/55] [IMP] account_followup: in email templates, move the followup_table from the context to a partner method bzr revid: rco@openerp.com-20121214141654-ksmjs6t73wzwedvl --- addons/account_followup/account_followup.py | 106 ++++++++---------- .../account_followup_data.xml | 8 +- 2 files changed, 50 insertions(+), 64 deletions(-) diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py index 17a09d51e6e..30bd543f7ca 100644 --- a/addons/account_followup/account_followup.py +++ b/addons/account_followup/account_followup.py @@ -113,66 +113,6 @@ class account_move_line(osv.osv): } - -class email_template(osv.osv): - _inherit = 'email.template' - - def _get_followup_table_html(self, cr, uid, res_id, context=None): - ''' - Build the html tables to be included in emails send to partners, when reminding them their - overdue invoices. - - :param res_id: ID of the partner for whom we are building the tables - :rtype: string - ''' - from report import account_followup_print - - partner = self.pool.get('res.partner').browse(cr, uid, res_id, context=context) - followup_table = '' - if partner.unreconciled_aml_ids: - company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id - current_date = fields.date.context_today(cr, uid, context) - rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser") - final_res = rml_parse._lines_get_with_partner(partner, company.id) - - for currency_dict in final_res: - currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id'] - followup_table += ''' - - - - - - - - - ''' % (currency.symbol) - total = 0 - for aml in currency_dict['line']: - block = aml['blocked'] and 'X' or ' ' - total += aml['balance'] - strbegin = "" - date = aml['date_maturity'] or aml['date'] - if date <= current_date and aml['balance'] > 0: - strbegin = "" - followup_table +="" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "" - total = rml_parse.formatLang(total, dp='Account', currency_obj=currency) - followup_table += ''' -
Invoice dateReferenceDue dateAmount (%s)Lit.
" - strend = "" - strend = "
-
Amount due: %s
''' % (total) - return followup_table - - - def render_template(self, cr, uid, template, model, res_id, context=None): - if model == 'res.partner' and context.get('followup'): - context['followup_table'] = self._get_followup_table_html(cr, uid, res_id, context=context) - # Adds current_date to the context. That way it can be used to put - # the account move lines in bold that are overdue in the email - context['current_date'] = fields.date.context_today(cr, uid, context) - return super(email_template, self).render_template(cr, uid, template, model, res_id, context=context) - class res_partner(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type=None, context=None, toolbar=False, submenu=False): @@ -289,6 +229,52 @@ class res_partner(osv.osv): 'payment_next_action': payment_next_action}, context=ctx) return unknown_mails + def get_followup_table_html(self, cr, uid, ids, context=None): + """ Build the html tables to be included in emails send to partners, + when reminding them their overdue invoices. + :param ids: [id] of the partner for whom we are building the tables + :rtype: string + """ + from report import account_followup_print + + assert len(ids) == 1 + partner = self.browse(cr, uid, ids[0], context=context) + followup_table = '' + if partner.unreconciled_aml_ids: + company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id + current_date = fields.date.context_today(cr, uid, context) + rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser") + final_res = rml_parse._lines_get_with_partner(partner, company.id) + + for currency_dict in final_res: + currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id'] + followup_table += ''' + + + + + + + + + ''' % (currency.symbol) + total = 0 + for aml in currency_dict['line']: + block = aml['blocked'] and 'X' or ' ' + total += aml['balance'] + strbegin = "" + date = aml['date_maturity'] or aml['date'] + if date <= current_date and aml['balance'] > 0: + strbegin = "" + followup_table +="" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "" + total = rml_parse.formatLang(total, dp='Account', currency_obj=currency) + followup_table += ''' +
Invoice dateReferenceDue dateAmount (%s)Lit.
" + strend = "" + strend = "
+
Amount due: %s
''' % (total) + return followup_table + def action_done(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'payment_next_action_date': False, 'payment_next_action':'', 'payment_responsible_id': False}, context=context) diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml index c35a0ffcd49..d7e6d029ae9 100644 --- a/addons/account_followup/account_followup_data.xml +++ b/addons/account_followup/account_followup_data.xml @@ -34,7 +34,7 @@ ${user.name}
-${ctx.get('followup_table','') | safe} +${object.get_followup_table_html() | safe}
@@ -74,7 +74,7 @@ ${user.name}

-${ctx.get('followup_table','') | safe} +${object.get_followup_table_html() | safe}
@@ -111,7 +111,7 @@ ${user.name}
-${ctx.get('followup_table','') | safe} +${object.get_followup_table_html() | safe}
@@ -146,7 +146,7 @@ ${user.name}

-${ctx.get('followup_table','') | safe} +${object.get_followup_table_html() | safe}
From 73157e4889f87bcab6a8b080d906137f890aa368 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 08:57:14 +0100 Subject: [PATCH 36/55] [FIX] Fixed name and email fields of the contact form now are required bzr revid: vta@openerp.com-20121217075714-tz6sazy167fava58 --- addons/portal_crm/contact_view.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/portal_crm/contact_view.xml b/addons/portal_crm/contact_view.xml index 8fcd2e9b08f..06ca0dbe8e2 100644 --- a/addons/portal_crm/contact_view.xml +++ b/addons/portal_crm/contact_view.xml @@ -43,15 +43,15 @@
- +
- - - + + + From d9333329a6baf93672f1466784560fac08dee307 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 09:57:59 +0100 Subject: [PATCH 37/55] [FIX] Anonymous login css bzr revid: vta@openerp.com-20121217085759-dpxwrkh4pa81k0pb --- addons/web/static/src/css/base.css | 35 ++++++++++++++++++++++++++++- addons/web/static/src/css/base.sass | 22 ++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 6e5c73d7bce..2665ee263a9 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -30,7 +30,7 @@ text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5); /* http://www.quirksmode.org/dom/inputfile.html * http://stackoverflow.com/questions/2855589/replace-input-type-file-by-an-image - */ */ + */ } .openerp.openerp_webclient_container { height: 100%; @@ -998,6 +998,39 @@ background-image: -o-linear-gradient(top, #646060, #262626); background-image: linear-gradient(to bottom, #646060, #262626); } +.openerp .oe_topbar .oe_topbar_anonymous_login { + background-color: #dc5f59; + color: #eeeeee; + background-color: #fc8787; + background-image: -webkit-gradient(linear, left top, left bottom, from(#fc8787), to(maroon)); + background-image: -webkit-linear-gradient(top, #fc8787, maroon); + background-image: -moz-linear-gradient(top, #fc8787, maroon); + background-image: -ms-linear-gradient(top, #fc8787, maroon); + background-image: -o-linear-gradient(top, #fc8787, maroon); + background-image: linear-gradient(to bottom, #fc8787, maroon); +} +.openerp .oe_topbar .oe_topbar_anonymous_login a { + display: block; + padding: 5px 10px 7px; + line-height: 20px; + height: 20px; + text-decoration: none; + color: white; + background: transparent; + -webkit-transition: all 0.2s ease-out; + -moz-transition: all 0.2s ease-out; + -ms-transition: all 0.2s ease-out; + -o-transition: all 0.2s ease-out; + transition: all 0.2s ease-out; +} +.openerp .oe_topbar .oe_topbar_anonymous_login a:hover { + background: rgba(0, 0, 0, 0.1); + color: white; + text-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) inset; + -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) inset; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) inset; +} .openerp .oe_topbar .oe_topbar_item { display: block; padding: 5px 10px 7px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index c9eb21435cb..a8445f0ff06 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -827,6 +827,24 @@ $sheet-padding: 16px height: 32px background-color: #414141 @include vertical-gradient(#646060, #262626) + .oe_topbar_anonymous_login + background-color: #dc5f59 + color: #eeeeee + @include vertical-gradient(#FC8787, #800000) + a + display: block + padding: 5px 10px 7px + line-height: 20px + height: 20px + text-decoration: none + color: white + background: transparent + @include transition(all 0.2s ease-out) + a:hover + background: rgba(0,0,0,0.1) + color: white + text-shadow: 0px 0px 3px rgba(0,0,0,0.2) + @include box-shadow(0 1px 2px rgba(0,0,0,0.2) inset) .oe_topbar_item display: block padding: 5px 10px 7px @@ -1670,7 +1688,7 @@ $sheet-padding: 16px width: 400px padding-bottom: 0 div.oe_chatter - box-sizing: border-box + box-sizing: border-box min-width: $sheet-min-width + 2* $sheet-padding max-width: $sheet-max-width + 2* $sheet-padding margin: 0 auto @@ -1942,7 +1960,7 @@ $sheet-padding: 16px overflow: hidden width: 24px overflow: hidden - background: transparent + background: transparent color: #7C7BAD box-shadow: none border: none From 13514c5985fcf186bf71c0044ad87a1e8e08767d Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 09:59:03 +0100 Subject: [PATCH 38/55] [FIX] Anonymous menu template bzr revid: vta@openerp.com-20121217085903-6zm2qecp16n9v8xc --- addons/portal_anonymous/static/src/xml/portal_anonymous.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/portal_anonymous/static/src/xml/portal_anonymous.xml b/addons/portal_anonymous/static/src/xml/portal_anonymous.xml index 07653ccf44c..b412d4a9dc6 100644 --- a/addons/portal_anonymous/static/src/xml/portal_anonymous.xml +++ b/addons/portal_anonymous/static/src/xml/portal_anonymous.xml @@ -4,8 +4,8 @@ -
- From b897974d61a496f25a90923401d69da2a90a2c53 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 10:08:57 +0100 Subject: [PATCH 39/55] [FIX] do not show timezone if anonymous bzr revid: vta@openerp.com-20121217090857-m2ye3pm0bjdm341d --- addons/web/static/src/js/chrome.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 17116f18d3f..d6c0bbf08f9 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -811,7 +811,7 @@ instance.web.Menu = instance.web.Widget.extend({ }); } }); - + }, start: function() { this._super.apply(this, arguments); @@ -1200,7 +1200,7 @@ instance.web.WebClient = instance.web.Client.extend({ var browser_offset = (offset < 0) ? "-" : "+"; browser_offset += _.str.sprintf("%02d", Math.abs(offset / 60)); browser_offset += _.str.sprintf("%02d", Math.abs(offset % 60)); - if (browser_offset !== user_offset) { + if (browser_offset !== user_offset && self.session.username !== 'anonymous') { var $icon = $(QWeb.render('WebClient.timezone_systray')); $icon.on('click', function() { var notification = self.do_warn(_t("Timezone mismatch"), QWeb.render('WebClient.timezone_notification', { From 5e2a77f589480c8d263980cf600cc89353978802 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 10:32:49 +0100 Subject: [PATCH 40/55] [FIX] remove previous change bzr revid: vta@openerp.com-20121217093249-vilaitfirtnc7mvw --- addons/web/static/src/js/chrome.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index d6c0bbf08f9..ea605e562d9 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1200,7 +1200,7 @@ instance.web.WebClient = instance.web.Client.extend({ var browser_offset = (offset < 0) ? "-" : "+"; browser_offset += _.str.sprintf("%02d", Math.abs(offset / 60)); browser_offset += _.str.sprintf("%02d", Math.abs(offset % 60)); - if (browser_offset !== user_offset && self.session.username !== 'anonymous') { + if (browser_offset !== user_offset) { var $icon = $(QWeb.render('WebClient.timezone_systray')); $icon.on('click', function() { var notification = self.do_warn(_t("Timezone mismatch"), QWeb.render('WebClient.timezone_notification', { From b5648aa982885a63582ba79b08b7ad23d4b4142a Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 10:48:27 +0100 Subject: [PATCH 41/55] [FIX] Don't show timezone warning if user anonymous, also fixed click event handler on login bzr revid: vta@openerp.com-20121217094827-digf2qlawxbjfo09 --- .../static/src/js/portal_anonymous.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/portal_anonymous/static/src/js/portal_anonymous.js b/addons/portal_anonymous/static/src/js/portal_anonymous.js index 173e098a7bb..1a5b8e4d0c6 100644 --- a/addons/portal_anonymous/static/src/js/portal_anonymous.js +++ b/addons/portal_anonymous/static/src/js/portal_anonymous.js @@ -26,7 +26,7 @@ openerp.portal_anonymous = function(instance) { start: function() { var self = this; this._super.apply(this, arguments); - this.$el.find('.oe_topbar_anonymous_login').click(function() { + this.$el.click(function() { var p = self.getParent(); var am = p.action_manager; p.$el.find('.oe_leftbar').hide(); @@ -44,4 +44,13 @@ openerp.portal_anonymous = function(instance) { } }); + instance.web.WebClient.include({ + check_timezone: function() { + if (this.session.username !== 'anonymous') { + return this._super.apply(this, arguments); + } + return false; + }, + }); + }; From 49dad6b17af2efb45e1636deaf8ab80e84a67367 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 10:49:48 +0100 Subject: [PATCH 42/55] [FIX] Do not show actions in message threads like news or jobs bzr revid: vta@openerp.com-20121217094948-cv9orodo4rge0ev2 --- addons/portal/portal_data.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/portal/portal_data.xml b/addons/portal/portal_data.xml index e7085b0e442..5fc1e07982c 100644 --- a/addons/portal/portal_data.xml +++ b/addons/portal/portal_data.xml @@ -32,6 +32,7 @@ 'default_model': 'mail.group', 'default_res_id': ref('company_news_feed'), }, + 'readonly': True, 'show_link': False, 'res_model': 'mail.message', 'thread_level': 1, @@ -64,6 +65,7 @@ 'default_model': 'mail.group', 'default_res_id': ref('company_jobs'), }, + 'readonly': True, 'show_link': False, 'res_model': 'mail.message', 'thread_level': 1, From 1260f7059f4fb63b4d9cbfb8325e65b4dcdcf854 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 10:53:23 +0100 Subject: [PATCH 43/55] [FIX] argh bzr revid: vta@openerp.com-20121217095323-p9r0p2jps01i8orl --- addons/web/static/src/js/chrome.js | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index ea605e562d9..6101a712458 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -811,7 +811,6 @@ instance.web.Menu = instance.web.Widget.extend({ }); } }); - }, start: function() { this._super.apply(this, arguments); From 3e8d5d9bad421b975059a0e4a93e40502f3065b8 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 17 Dec 2012 11:14:25 +0100 Subject: [PATCH 44/55] [FIX] Login template and click event handler bzr revid: vta@openerp.com-20121217101425-8elexsj8leayyba5 --- addons/portal_anonymous/static/src/js/portal_anonymous.js | 2 +- addons/portal_anonymous/static/src/xml/portal_anonymous.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/portal_anonymous/static/src/js/portal_anonymous.js b/addons/portal_anonymous/static/src/js/portal_anonymous.js index 1a5b8e4d0c6..35c9e57d46c 100644 --- a/addons/portal_anonymous/static/src/js/portal_anonymous.js +++ b/addons/portal_anonymous/static/src/js/portal_anonymous.js @@ -26,7 +26,7 @@ openerp.portal_anonymous = function(instance) { start: function() { var self = this; this._super.apply(this, arguments); - this.$el.click(function() { + this.$el.find('a.login').click(function() { var p = self.getParent(); var am = p.action_manager; p.$el.find('.oe_leftbar').hide(); diff --git a/addons/portal_anonymous/static/src/xml/portal_anonymous.xml b/addons/portal_anonymous/static/src/xml/portal_anonymous.xml index b412d4a9dc6..b4c5b7d7471 100644 --- a/addons/portal_anonymous/static/src/xml/portal_anonymous.xml +++ b/addons/portal_anonymous/static/src/xml/portal_anonymous.xml @@ -5,7 +5,7 @@ From 2679a49af41a45bd7cf806aa44e6a47f037b8c22 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 17 Dec 2012 11:47:21 +0100 Subject: [PATCH 45/55] [FIX] orm: replace incorrect usage of 'in' by '==' bzr revid: rco@openerp.com-20121217104721-miqmtw2zm7r7lxrs --- openerp/osv/orm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 2e02132d31e..bcb6b0ca299 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -454,7 +454,7 @@ class browse_record(object): new_data[field_name] = browse_null() elif field_column._type in ('one2many', 'many2many') and len(result_line[field_name]): new_data[field_name] = self._list_class([browse_record(self._cr, self._uid, id, self._table.pool.get(field_column._obj), self._cache, context=self._context, list_class=self._list_class, fields_process=self._fields_process) for id in result_line[field_name]], self._context) - elif field_column._type in 'reference': + elif field_column._type == 'reference': if result_line[field_name]: if isinstance(result_line[field_name], browse_record): new_data[field_name] = result_line[field_name] @@ -1741,7 +1741,7 @@ class BaseModel(object): views = {} xml = "
" for f in node: - if f.tag in 'field': + if f.tag == 'field': xml += etree.tostring(f, encoding="utf-8") xml += "
" new_xml = etree.fromstring(encode(xml)) From ad46970208adbaa886c87bce8136765a72272a60 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 17 Dec 2012 12:13:37 +0100 Subject: [PATCH 46/55] [FIX] hr_timesheet_sheet: revert stupid fix in 8095.1.1 that created very obvious bug. bzr revid: nicolas.vanhoren@openerp.com-20121217111337-uisq0ym13vhzye8b --- addons/hr_timesheet_sheet/static/src/js/timesheet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js index b5ba7f74101..fe7d0c82767 100644 --- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js +++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js @@ -14,7 +14,7 @@ openerp.hr_timesheet_sheet = function(instance) { date_to: false, date_from: false, }); - this.updating = true; + this.updating = false; this.field_manager.on("field_changed:timesheet_ids", this, this.query_sheets); this.field_manager.on("field_changed:date_from", this, function() { this.set({"date_from": instance.web.str_to_date(this.field_manager.get_field_value("date_from"))}); From 1a7e8558320df53451c56e0c19624a1d1e2c0fd9 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 17 Dec 2012 12:13:40 +0100 Subject: [PATCH 47/55] [IMP] Calendar view mode does not scroll on overflow bzr revid: fme@openerp.com-20121217111340-osr4mid4f2uhvvb4 --- .../web_calendar/static/src/css/web_calendar.css | 14 +------------- .../web_calendar/static/src/css/web_calendar.sass | 12 +----------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/addons/web_calendar/static/src/css/web_calendar.css b/addons/web_calendar/static/src/css/web_calendar.css index 96651bdc358..d40a7a2940a 100644 --- a/addons/web_calendar/static/src/css/web_calendar.css +++ b/addons/web_calendar/static/src/css/web_calendar.css @@ -9,18 +9,9 @@ } .openerp .oe_calendar { background-color: white; - height: 600px; + min-height: 600px; border-right: 1px solid #eeeeee; } -.openerp .oe_calendar .oe_calendar_table { - position: absolute; - left: 0px; - right: 0px; - top: 0px; - border-top: 3px solid #eeeeee; - width: 100%; - overflow: hidden; -} .openerp .oe_calendar .oe_calendar_filter { padding: 0 10px; } @@ -30,9 +21,6 @@ .openerp .oe_calendar .dhx_cal_navline { z-index: auto; } -.openerp .oe_calendar.oe_cal_month .dhx_cal_data { - overflow-y: hidden; -} .openerp .oe_calendar.oe_cal_month .dhx_cal_data table tr td:last-child div.dhx_month_body { padding-right: 5px; } diff --git a/addons/web_calendar/static/src/css/web_calendar.sass b/addons/web_calendar/static/src/css/web_calendar.sass index d383841eb6d..f6b6a1a5eeb 100644 --- a/addons/web_calendar/static/src/css/web_calendar.sass +++ b/addons/web_calendar/static/src/css/web_calendar.sass @@ -11,18 +11,9 @@ .oe_calendar background-color: white - height: 600px + min-height: 600px border-right: 1px solid #eee - .oe_calendar_table - position: absolute - left: 0px - right: 0px - top: 0px - border-top: 3px solid #eee - width: 100% - overflow: hidden - .oe_calendar_filter padding: 0 10px @@ -36,7 +27,6 @@ z-index: auto &.oe_cal_month .dhx_cal_data - overflow-y: hidden table tr td:last-child div.dhx_month_body padding-right: 5px From 55f782a8c32ba9d7bbcd6403db76a432a0ceb9d6 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 17 Dec 2012 12:14:02 +0100 Subject: [PATCH 48/55] [IMP] hr_timesheet_sheet: set the timesheet widget to readonly in some states bzr revid: nicolas.vanhoren@openerp.com-20121217111402-tmcxinz3oxsbfmfg --- addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 1dd9d8323bf..644586ec502 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -99,7 +99,7 @@ - + From 356fd3466ed45fbc2e589226b2a27dab9946b13a Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 17 Dec 2012 12:16:56 +0100 Subject: [PATCH 49/55] [IMP] sale: remove size=... on text field bzr revid: rco@openerp.com-20121217111656-ob89xgqy4409k6fg --- addons/sale/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 6f4d38685a6..9a7ae8878c6 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -714,7 +714,7 @@ class sale_order_line(osv.osv): _description = 'Sales Order Line' _columns = { 'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}), - 'name': fields.text('Description', size=256, required=True, select=True, readonly=True, states={'draft': [('readonly', False)]}), + 'name': fields.text('Description', required=True, select=True, readonly=True, states={'draft': [('readonly', False)]}), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of sales order lines."), 'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True), 'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True), From 380ca73fd9ed2e19cc90c1b08b8eb1ccf2d0506f Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Mon, 17 Dec 2012 12:22:52 +0100 Subject: [PATCH 50/55] [FIX] jinja2 deps for debian bzr revid: al@openerp.com-20121217112252-c1kt0j0bmzu31bzo --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index acd4a72c44b..d5980232b73 100644 --- a/debian/control +++ b/debian/control @@ -19,6 +19,7 @@ Depends: python-docutils, python-feedparser, python-gdata, + python-jinja2, python-ldap, python-libxslt1, python-lxml, From 1df1574c7a1355a7d44831d1af5355833f66229a Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 17 Dec 2012 12:50:48 +0100 Subject: [PATCH 51/55] [IMP] mail module should not be auto_install bzr revid: fp@tinyerp.com-20121217115048-whmaqy933pqj7xdc --- addons/mail/__openerp__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py index ff86b7945ac..12fdc62c260 100644 --- a/addons/mail/__openerp__.py +++ b/addons/mail/__openerp__.py @@ -69,7 +69,6 @@ Main Features 'data/mail_group_demo_data.xml', ], 'installable': True, - 'auto_install': True, 'application': True, 'images': [ 'images/customer_history.jpeg', From 34c88ccefc830db81eb5b75a0a1ef5d805593a40 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 17 Dec 2012 13:00:42 +0100 Subject: [PATCH 52/55] [REM] auth_anonymous was merged into portal_anonymous, remove LP translations after disabling LP template bzr revid: odo@openerp.com-20121217120042-mbrfh3z740f4p1ql --- addons/auth_anonymous/i18n/de.po | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 addons/auth_anonymous/i18n/de.po diff --git a/addons/auth_anonymous/i18n/de.po b/addons/auth_anonymous/i18n/de.po deleted file mode 100644 index 78e3abfd1cc..00000000000 --- a/addons/auth_anonymous/i18n/de.po +++ /dev/null @@ -1,30 +0,0 @@ -# German translation for openobject-addons -# Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 -# This file is distributed under the same license as the openobject-addons package. -# FIRST AUTHOR , 2012. -# -msgid "" -msgstr "" -"Project-Id-Version: openobject-addons\n" -"Report-Msgid-Bugs-To: FULL NAME \n" -"POT-Creation-Date: 2012-11-24 02:52+0000\n" -"PO-Revision-Date: 2012-12-16 11:31+0000\n" -"Last-Translator: Felix Schubert \n" -"Language-Team: German \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2012-12-17 04:47+0000\n" -"X-Generator: Launchpad (build 16372)\n" - -#. module: auth_anonymous -#. openerp-web -#: code:addons/auth_anonymous/static/src/xml/auth_anonymous.xml:9 -#, python-format -msgid "Login" -msgstr "Anmelden" - -#. module: auth_anonymous -#: model:res.groups,name:auth_anonymous.group_anonymous -msgid "Anonymous Group" -msgstr "" From fe48c4eaa9487e7573bec4bf2dd597e29f74883c Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 17 Dec 2012 14:02:49 +0100 Subject: [PATCH 53/55] [FIX] res_country_data: fix US postal address format bzr revid: rco@openerp.com-20121217130249-w2wanhy1b7wsgbra --- openerp/addons/base/res/res_country_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/res/res_country_data.xml b/openerp/addons/base/res/res_country_data.xml index 068850727e8..a7cfb961af1 100644 --- a/openerp/addons/base/res/res_country_data.xml +++ b/openerp/addons/base/res/res_country_data.xml @@ -1186,7 +1186,7 @@ United States us - + From d7461fb1c813590d70ddecaeff65c02a1029d61b Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Mon, 17 Dec 2012 14:20:45 +0100 Subject: [PATCH 54/55] [FIX]fleet: setting group for user_demo should be done in demo data instead of data bzr revid: csn@openerp.com-20121217132045-lt0b2aeubty1hrkn --- addons/fleet/fleet_demo.xml | 4 ++++ addons/fleet/security/fleet_security.xml | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/fleet/fleet_demo.xml b/addons/fleet/fleet_demo.xml index 50eb8a3fab1..a8d70eb06fa 100644 --- a/addons/fleet/fleet_demo.xml +++ b/addons/fleet/fleet_demo.xml @@ -1,6 +1,10 @@ + + + + In shop 1 diff --git a/addons/fleet/security/fleet_security.xml b/addons/fleet/security/fleet_security.xml index 6c718f4cdd7..c9b86799b5c 100644 --- a/addons/fleet/security/fleet_security.xml +++ b/addons/fleet/security/fleet_security.xml @@ -8,7 +8,6 @@ User - Manager From 39fe69babe7e2f05330de6829a2843f91a04f440 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 17 Dec 2012 14:45:59 +0100 Subject: [PATCH 55/55] [FIX] expression: avoid delitem on a tuple bzr revid: rco@openerp.com-20121217134559-cjc0b4ncs1drupn7 --- openerp/osv/expression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index cca376994ec..899279c8015 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -1104,7 +1104,7 @@ class expression(object): query = '(%s."%s" IS %s)' % (table_alias, left, r) params = [] elif isinstance(right, (list, tuple)): - params = right[:] + params = list(right) check_nulls = False for i in range(len(params))[::-1]: if params[i] == False: