From a2c3aad8c1628423df8ae66df943026338bf2889 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 5 Mar 2012 18:14:23 +0100 Subject: [PATCH 01/55] [FIX] unmutable default in sale/sale.py bzr revid: ls@numerigraphe.fr-20120305171423-5opxnru256g4mm9c --- addons/sale/sale.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 82bfda7b580..9606b1fd004 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -326,7 +326,7 @@ class sale_order(osv.osv): self.log(cr, uid, id, message) return True - def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context={}): + def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None): if (not pricelist_id) or (not order_lines): return {} warning = { @@ -335,7 +335,7 @@ class sale_order(osv.osv): } return {'warning': warning} - def onchange_partner_order_id(self, cr, uid, ids, order_id, invoice_id=False, shipping_id=False, context={}): + def onchange_partner_order_id(self, cr, uid, ids, order_id, invoice_id=False, shipping_id=False, context=None): if not order_id: return {} val = {} @@ -501,7 +501,9 @@ class sale_order(osv.osv): 'res_id': inv_ids and inv_ids[0] or False, } - def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None): + def action_invoice_create(self, cr, uid, ids, grouped=False, states=None, date_inv=False, context=None): + if states is None: + states = ['confirmed', 'done', 'exception'] res = False invoices = {} invoice_ids = [] From 5e4446f483acaf15aa85cbd339911d2711dae9f1 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 5 Mar 2012 18:32:36 +0100 Subject: [PATCH 02/55] [FIX] unmutable default in account/account.py bzr revid: ls@numerigraphe.fr-20120305173236-wdnj66ti4bopedzp --- addons/account/account.py | 52 +++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index c1a30967aea..46b1374ccd0 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -591,12 +591,15 @@ class account_account(osv.osv): res.append((record['id'], name)) return res - def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False): + def copy(self, cr, uid, id, None, context=None, done_list=None, local=False): + if default is None: + default = {} + else: + default = default.copy() + if done_list is None: + done_list = [] account = self.browse(cr, uid, id, context=context) new_child_ids = [] - if not default: - default = {} - default = default.copy() default['code'] = (account['code'] or '') + '(copy)' if not local: done_list = [] @@ -765,11 +768,14 @@ class account_journal(osv.osv): (_check_currency, 'Configuration error! The currency chosen should be shared by the default accounts too.', ['currency','default_debit_account_id','default_credit_account_id']), ] - def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False): - journal = self.browse(cr, uid, id, context=context) - if not default: + def copy(self, cr, uid, id, default=None, context=None, done_list=None, local=False): + if default is None: default = {} - default = default.copy() + else: + default = default.copy() + if done_list is None: + done_list = [] + journal = self.browse(cr, uid, id, context=context) default['code'] = (journal['code'] or '') + '(copy)' default['name'] = (journal['name'] or '') + '(copy)' default['sequence_id'] = False @@ -1161,7 +1167,7 @@ class account_fiscalyear(osv.osv): 'end_journal_period_id':fields.many2one('account.journal.period','End of Year Entries Journal', readonly=True), } - def copy(self, cr, uid, id, default={}, context=None): + def copy(self, cr, uid, id, default=None, context=None): default.update({ 'period_ids': [], 'end_journal_period_id': False @@ -1420,9 +1426,15 @@ class account_move(osv.osv): result = super(account_move, self).create(cr, uid, vals, context) return result - def copy(self, cr, uid, id, default={}, context=None): + def copy(self, cr, uid, id, default=None, context=None): + if context is None: + default = {} + else: + default = default.copy() if context is None: context = {} + else: + context = context.copy() default.update({ 'state':'draft', 'name':'/', @@ -2239,7 +2251,9 @@ class account_model(osv.osv): _defaults = { 'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s: To Specify Year \n%(month)s: To Specify Month \n%(date)s: Current Date\n\ne.g. My model on %(date)s'), } - def generate(self, cr, uid, ids, datas={}, context=None): + def generate(self, cr, uid, ids, datas=None, context=None): + if datas is None: + datas = {} move_ids = [] entry = {} account_move_obj = self.pool.get('account.move') @@ -3193,7 +3207,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): property_obj.create(cr, uid, vals, context=context) return True - def _install_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, acc_ref={}, taxes_ref={}, tax_code_ref={}, context=None): + def _install_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, acc_ref=None, taxes_ref=None, tax_code_ref=None, context=None): ''' This function recursively loads the template objects and create the real objects from them. @@ -3211,6 +3225,12 @@ class wizard_multi_charts_accounts(osv.osv_memory): * a last identical containing the mapping of tax code templates and tax codes :rtype: tuple(dict, dict, dict) ''' + if acc_ref is None: + acc_ref = {} + if taxes_ref is None: + taxes_ref = {} + if tax_code_ref is None: + tax_code_ref = {} template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context) if template.parent_id: tmp1, tmp2, tmp3 = self._install_template(cr, uid, template.parent_id.id, company_id, code_digits=code_digits, acc_ref=acc_ref, taxes_ref=taxes_ref, tax_code_ref=tax_code_ref, context=context) @@ -3223,7 +3243,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): tax_code_ref.update(tmp3) return acc_ref, taxes_ref, tax_code_ref - def _load_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, account_ref={}, taxes_ref={}, tax_code_ref={}, context=None): + def _load_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, account_ref=None, taxes_ref=None, tax_code_ref=None, context=None): ''' This function generates all the objects from the templates @@ -3241,6 +3261,12 @@ class wizard_multi_charts_accounts(osv.osv_memory): * a last identical containing the mapping of tax code templates and tax codes :rtype: tuple(dict, dict, dict) ''' + if account_ref is None: + account_ref = {} + if taxes_ref is None: + taxes_ref = {} + if tax_code_ref is None: + tax_code_ref = {} template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context) obj_tax_code_template = self.pool.get('account.tax.code.template') obj_acc_tax = self.pool.get('account.tax') From f120f5aa5bd406b32839586d19555b1e629aec4d Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 5 Mar 2012 18:41:11 +0100 Subject: [PATCH 03/55] [FIX] unmutable default in account bzr revid: ls@numerigraphe.fr-20120305174111-zf5j02cm7veyvzs4 --- addons/account/account_bank.py | 6 +++--- addons/account/account_move_line.py | 2 +- addons/account/project/wizard/account_analytic_chart.py | 2 +- .../wizard/account_analytic_inverted_balance_report.py | 2 +- .../project/wizard/project_account_analytic_line.py | 2 +- addons/account/report/account_balance.py | 2 +- addons/account/report/account_central_journal.py | 2 +- addons/account/report/account_general_journal.py | 2 +- addons/account/report/account_report.py | 2 +- addons/account/report/account_tax_report.py | 8 ++++++-- addons/account/res_currency.py | 2 +- addons/account/wizard/account_invoice_state.py | 2 +- addons/account/wizard/account_journal_select.py | 2 +- addons/account/wizard/account_move_bank_reconcile.py | 2 +- addons/account/wizard/account_move_journal.py | 2 +- .../account/wizard/account_move_line_reconcile_select.py | 2 +- addons/account/wizard/account_move_line_select.py | 2 +- .../wizard/account_move_line_unreconcile_select.py | 2 +- addons/account/wizard/account_period_close.py | 2 +- addons/account/wizard/account_reconcile.py | 2 +- .../account/wizard/account_reconcile_partner_process.py | 2 +- addons/account/wizard/account_state_open.py | 2 +- addons/account/wizard/account_subscription_generate.py | 2 +- addons/account/wizard/account_unreconcile.py | 2 +- 24 files changed, 31 insertions(+), 27 deletions(-) diff --git a/addons/account/account_bank.py b/addons/account/account_bank.py index 5a84dee53de..ebd9fd80f1a 100644 --- a/addons/account/account_bank.py +++ b/addons/account/account_bank.py @@ -29,12 +29,12 @@ class bank(osv.osv): 'currency_id': fields.related('journal_id', 'currency', type="many2one", relation='res.currency', readonly=True, string="Currency", help="Currency of the related account journal."), } - def create(self, cr, uid, data, context={}): + def create(self, cr, uid, data, context=None): result = super(bank, self).create(cr, uid, data, context=context) self.post_write(cr, uid, [result], context=context) return result - def write(self, cr, uid, ids, data, context={}): + def write(self, cr, uid, ids, data, context=None): result = super(bank, self).write(cr, uid, ids, data, context=context) self.post_write(cr, uid, ids, context=context) return result @@ -43,7 +43,7 @@ class bank(osv.osv): "Return the name to use when creating a bank journal" return (bank.bank_name or '') + ' ' + bank.acc_number - def post_write(self, cr, uid, ids, context={}): + def post_write(self, cr, uid, ids, context=None): if isinstance(ids, (int, long)): ids = [ids] diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 17120ee265e..50fbf08cc2d 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -1097,7 +1097,7 @@ class account_move_line(osv.osv): 'has been confirmed!') % res[2]) return res - def _remove_move_reconcile(self, cr, uid, move_ids=[], context=None): + def _remove_move_reconcile(self, cr, uid, move_ids=None, context=None): # Function remove move rencocile ids related with moves obj_move_line = self.pool.get('account.move.line') obj_move_rec = self.pool.get('account.move.reconcile') diff --git a/addons/account/project/wizard/account_analytic_chart.py b/addons/account/project/wizard/account_analytic_chart.py index a10e938e293..92367e27da5 100644 --- a/addons/account/project/wizard/account_analytic_chart.py +++ b/addons/account/project/wizard/account_analytic_chart.py @@ -47,4 +47,4 @@ class account_analytic_chart(osv.osv_memory): return result account_analytic_chart() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/account_analytic_inverted_balance_report.py b/addons/account/project/wizard/account_analytic_inverted_balance_report.py index 2c9690fee50..95365716a22 100644 --- a/addons/account/project/wizard/account_analytic_inverted_balance_report.py +++ b/addons/account/project/wizard/account_analytic_inverted_balance_report.py @@ -52,4 +52,4 @@ class account_analytic_inverted_balance(osv.osv_memory): } account_analytic_inverted_balance() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/project_account_analytic_line.py b/addons/account/project/wizard/project_account_analytic_line.py index e49fbe911cb..54979d79b8a 100644 --- a/addons/account/project/wizard/project_account_analytic_line.py +++ b/addons/account/project/wizard/project_account_analytic_line.py @@ -55,4 +55,4 @@ class project_account_analytic_line(osv.osv_memory): project_account_analytic_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index c3117e60379..fdda9cb11ce 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -68,7 +68,7 @@ class account_balance(report_sxw.rml_parse, common_report_header): return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['id']).company_id.name return super(account_balance ,self)._get_account(data) - def lines(self, form, ids=[], done=None):#, level=1): + def lines(self, form, ids=None, done=None): def _process_child(accounts, disp_acc, parent): account_rec = [acct for acct in accounts if acct['id']==parent][0] currency_obj = self.pool.get('res.currency') diff --git a/addons/account/report/account_central_journal.py b/addons/account/report/account_central_journal.py index d3113b63133..a42712f40d7 100644 --- a/addons/account/report/account_central_journal.py +++ b/addons/account/report/account_central_journal.py @@ -105,4 +105,4 @@ class journal_print(report_sxw.rml_parse, common_report_header): report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/account_central_journal.rml', parser=journal_print, header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_general_journal.py b/addons/account/report/account_general_journal.py index 9eb81157dba..0ffa08b31ef 100644 --- a/addons/account/report/account_general_journal.py +++ b/addons/account/report/account_general_journal.py @@ -158,4 +158,4 @@ class journal_print(report_sxw.rml_parse, common_report_header): report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print, header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_report.py b/addons/account/report/account_report.py index 9f81f295d74..92d0fc95b85 100644 --- a/addons/account/report/account_report.py +++ b/addons/account/report/account_report.py @@ -283,4 +283,4 @@ class report_account_sales(osv.osv): )""") report_account_sales() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_tax_report.py b/addons/account/report/account_tax_report.py index 2a0c5987b47..cef1cf54af0 100644 --- a/addons/account/report/account_tax_report.py +++ b/addons/account/report/account_tax_report.py @@ -160,7 +160,7 @@ class tax_report(report_sxw.rml_parse, common_report_header): i+=1 return res - def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=[], context=None): + def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=None, context=None): obj_tc = self.pool.get('account.tax.code') ids = obj_tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)], order='sequence', context=context) @@ -171,7 +171,11 @@ class tax_report(report_sxw.rml_parse, common_report_header): res += self._get_codes(based_on, company_id, code.id, level+1, context=context) return res - def _add_codes(self, based_on, account_list=[], period_list=[], context=None): + def _add_codes(self, based_on, account_list=None, period_list=None, context=None): + if account_list is None: + account_list = [] + if period_list is None: + period_list = [] res = [] obj_tc = self.pool.get('account.tax.code') for account in account_list: diff --git a/addons/account/res_currency.py b/addons/account/res_currency.py index 8c9c6a8b103..ce781a1e11a 100644 --- a/addons/account/res_currency.py +++ b/addons/account/res_currency.py @@ -44,4 +44,4 @@ class res_currency_account(osv.osv): res_currency_account() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_invoice_state.py b/addons/account/wizard/account_invoice_state.py index 7adcb908a34..4924f6762d5 100644 --- a/addons/account/wizard/account_invoice_state.py +++ b/addons/account/wizard/account_invoice_state.py @@ -71,4 +71,4 @@ class account_invoice_cancel(osv.osv_memory): account_invoice_cancel() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_journal_select.py b/addons/account/wizard/account_journal_select.py index 98099925e29..b91c195f6b3 100644 --- a/addons/account/wizard/account_journal_select.py +++ b/addons/account/wizard/account_journal_select.py @@ -47,4 +47,4 @@ class account_journal_select(osv.osv_memory): account_journal_select() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_move_bank_reconcile.py b/addons/account/wizard/account_move_bank_reconcile.py index 9be351ed440..65ff3f4501e 100644 --- a/addons/account/wizard/account_move_bank_reconcile.py +++ b/addons/account/wizard/account_move_bank_reconcile.py @@ -61,4 +61,4 @@ the bank account\nin the journal definition for reconciliation.')) account_move_bank_reconcile() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_move_journal.py b/addons/account/wizard/account_move_journal.py index 6756e0d06c6..4be80bd1bc3 100644 --- a/addons/account/wizard/account_move_journal.py +++ b/addons/account/wizard/account_move_journal.py @@ -38,7 +38,7 @@ class account_move_journal(osv.osv_memory): _defaults = { 'target_move': 'all' } - def _get_period(self, cr, uid, context={}): + def _get_period(self, cr, uid, context=None): """ Return default account period value """ diff --git a/addons/account/wizard/account_move_line_reconcile_select.py b/addons/account/wizard/account_move_line_reconcile_select.py index 8e57c57884d..e23212c514c 100644 --- a/addons/account/wizard/account_move_line_reconcile_select.py +++ b/addons/account/wizard/account_move_line_reconcile_select.py @@ -52,4 +52,4 @@ class account_move_line_reconcile_select(osv.osv_memory): account_move_line_reconcile_select() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_move_line_select.py b/addons/account/wizard/account_move_line_select.py index 4a2f40ec708..a99750a36fe 100644 --- a/addons/account/wizard/account_move_line_select.py +++ b/addons/account/wizard/account_move_line_select.py @@ -69,4 +69,4 @@ class account_move_line_select(osv.osv_memory): account_move_line_select() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_move_line_unreconcile_select.py b/addons/account/wizard/account_move_line_unreconcile_select.py index ad59493503d..26421eb4c0c 100644 --- a/addons/account/wizard/account_move_line_unreconcile_select.py +++ b/addons/account/wizard/account_move_line_unreconcile_select.py @@ -41,4 +41,4 @@ class account_move_line_unreconcile_select(osv.osv_memory): account_move_line_unreconcile_select() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_period_close.py b/addons/account/wizard/account_period_close.py index fecf43f07ab..6b070808bbd 100644 --- a/addons/account/wizard/account_period_close.py +++ b/addons/account/wizard/account_period_close.py @@ -60,4 +60,4 @@ class account_period_close(osv.osv_memory): account_period_close() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_reconcile.py b/addons/account/wizard/account_reconcile.py index 729792e2222..99a57f8f556 100644 --- a/addons/account/wizard/account_reconcile.py +++ b/addons/account/wizard/account_reconcile.py @@ -173,4 +173,4 @@ class account_move_line_reconcile_writeoff(osv.osv_memory): account_move_line_reconcile_writeoff() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_reconcile_partner_process.py b/addons/account/wizard/account_reconcile_partner_process.py index 7cfeff70891..fd34a222f1d 100644 --- a/addons/account/wizard/account_reconcile_partner_process.py +++ b/addons/account/wizard/account_reconcile_partner_process.py @@ -100,4 +100,4 @@ class account_partner_reconcile_process(osv.osv_memory): account_partner_reconcile_process() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_state_open.py b/addons/account/wizard/account_state_open.py index 62e837b7366..efa4baff3cc 100644 --- a/addons/account/wizard/account_state_open.py +++ b/addons/account/wizard/account_state_open.py @@ -41,4 +41,4 @@ class account_state_open(osv.osv_memory): account_state_open() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_subscription_generate.py b/addons/account/wizard/account_subscription_generate.py index 8efcd25b789..b14da9b4403 100644 --- a/addons/account/wizard/account_subscription_generate.py +++ b/addons/account/wizard/account_subscription_generate.py @@ -50,4 +50,4 @@ class account_subscription_generate(osv.osv_memory): account_subscription_generate() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_unreconcile.py b/addons/account/wizard/account_unreconcile.py index 0e6c38f9d7c..5494875cf26 100644 --- a/addons/account/wizard/account_unreconcile.py +++ b/addons/account/wizard/account_unreconcile.py @@ -50,4 +50,4 @@ class account_unreconcile_reconcile(osv.osv_memory): account_unreconcile_reconcile() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 559843258e2955edd0a7081eb5bc1f4c438a74fb Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 5 Mar 2012 18:53:10 +0100 Subject: [PATCH 04/55] [FIX] unmutable default in stock bzr revid: ls@numerigraphe.fr-20120305175310-l3jcpsf3u0jtf2id --- addons/stock/report/product_stock.py | 4 +++- addons/stock/report/report_stock.py | 4 ++-- addons/stock/report/stock_by_location.py | 2 +- addons/stock/stock.py | 14 ++++++++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/addons/stock/report/product_stock.py b/addons/stock/report/product_stock.py index b7dd254234c..1d882ad632b 100644 --- a/addons/stock/report/product_stock.py +++ b/addons/stock/report/product_stock.py @@ -42,7 +42,9 @@ class external_pdf(render): class report_stock(report_int): - def create(self, cr, uid, ids, datas, context={}): + def create(self, cr, uid, ids, datas, context=None): + if context is None: + context = {} product_ids = ids if 'location_id' in context: location_id = context['location_id'] diff --git a/addons/stock/report/report_stock.py b/addons/stock/report/report_stock.py index 37e4f28c858..d11589ae462 100644 --- a/addons/stock/report/report_stock.py +++ b/addons/stock/report/report_stock.py @@ -74,7 +74,7 @@ class stock_report_prodlots(osv.osv): group by location_id, product_id, prodlot_id )""") - def unlink(self, cr, uid, ids, context={}): + def unlink(self, cr, uid, ids, context=None): raise osv.except_osv(_('Error !'), _('You cannot delete any record!')) @@ -131,7 +131,7 @@ class stock_report_tracklots(osv.osv): group by location_id, product_id, tracking_id )""") - def unlink(self, cr, uid, ids, context={}): + def unlink(self, cr, uid, ids, context=None): raise osv.except_osv(_('Error !'), _('You cannot delete any record!')) stock_report_tracklots() diff --git a/addons/stock/report/stock_by_location.py b/addons/stock/report/stock_by_location.py index 2dbe03a347e..8ed8800fb29 100644 --- a/addons/stock/report/stock_by_location.py +++ b/addons/stock/report/stock_by_location.py @@ -26,7 +26,7 @@ from report.interface import toxml #FIXME: we should use toxml class report_custom(report_rml): - def create_xml(self, cr, uid, ids, datas, context={}): + def create_xml(self, cr, uid, ids, datas, context=None): config = """ 09/09/2005 diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 885f7cd2077..9a0bc8ebfd2 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -345,22 +345,28 @@ class stock_location(osv.osv): }) return product_obj.get_product_available(cr, uid, product_ids, context=context) - def _product_get(self, cr, uid, id, product_ids=False, context=None, states=['done']): + def _product_get(self, cr, uid, id, product_ids=False, context=None, states=None): """ @param product_ids: @param states: @return: """ + if states is None: + states = ['done'] ids = id and [id] or [] return self._product_get_multi_location(cr, uid, ids, product_ids, context=context, states=states) - def _product_all_get(self, cr, uid, id, product_ids=False, context=None, states=['done']): + def _product_all_get(self, cr, uid, id, product_ids=False, context=None, states=None): + if states is None: + states = ['done'] # build the list of ids of children of the location given by id ids = id and [id] or [] location_ids = self.search(cr, uid, [('location_id', 'child_of', ids)]) return self._product_get_multi_location(cr, uid, location_ids, product_ids, context, states) - def _product_virtual_get(self, cr, uid, id, product_ids=False, context=None, states=['done']): + def _product_virtual_get(self, cr, uid, id, product_ids=False, context=None, states=None): + if states is None: + states = ['done'] return self._product_all_get(cr, uid, id, product_ids, context, ['confirmed', 'waiting', 'assigned', 'done']) def _product_reserve(self, cr, uid, ids, product_id, product_qty, context=None, lock=False): @@ -518,7 +524,7 @@ class stock_tracking(osv.osv): def unlink(self, cr, uid, ids, context=None): raise osv.except_osv(_('Error'), _('You can not remove a lot line !')) - def action_traceability(self, cr, uid, ids, context={}): + def action_traceability(self, cr, uid, ids, context=None): """ It traces the information of a product @param self: The object pointer. @param cr: A database cursor From 520e2c680f927f16cfb97f543e2f73f7ab9ae7ac Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 5 Mar 2012 18:58:42 +0100 Subject: [PATCH 05/55] [FIX] unmutable default in account_analytic_plans bzr revid: ls@numerigraphe.fr-20120305175842-zpbl324ihaz7vj39 --- addons/account_analytic_plans/report/crossovered_analytic.py | 4 +++- .../wizard/analytic_plan_create_model.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account_analytic_plans/report/crossovered_analytic.py b/addons/account_analytic_plans/report/crossovered_analytic.py index e2ad9e05b04..f1d8d67f445 100644 --- a/addons/account_analytic_plans/report/crossovered_analytic.py +++ b/addons/account_analytic_plans/report/crossovered_analytic.py @@ -113,7 +113,9 @@ class crossovered_analytic(report_sxw.rml_parse): result.append(res) return result - def _lines(self, form, ids={}): + def _lines(self, form, ids=None): + if ids is None: + ids = {} if not ids: ids = self.ids diff --git a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py index 1cd3022f60b..ed5259f50bf 100644 --- a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py +++ b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py @@ -57,4 +57,4 @@ class analytic_plan_create_model(osv.osv_memory): analytic_plan_create_model() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 2d2a44dcf2e3b29e4fef4000792a064862967769 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 5 Mar 2012 19:40:03 +0100 Subject: [PATCH 06/55] [FIX] unmutable default in the remaining modules [REF] coding style consistency lp bug: https://launchpad.net/bugs/525808 fixed bzr revid: ls@numerigraphe.fr-20120305184003-er00xtj9vtcw7gna --- .../report/crossovered_analytic.py | 6 +-- addons/account_anglo_saxon/__init__.py | 2 +- addons/account_anglo_saxon/sale.py | 43 ---------------- addons/account_asset/account_asset.py | 8 +-- .../report/analytic_account_budget_report.py | 8 +-- addons/account_budget/report/budget_report.py | 4 +- .../report/crossovered_budget_report.py | 4 +- .../wizard/account_budget_analytic.py | 2 +- .../account_budget_crossovered_report.py | 2 +- .../wizard/account_budget_report.py | 2 +- addons/account_coda/account_coda.py | 6 ++- addons/account_followup/__init__.py | 2 +- addons/account_followup/wizard/__init__.py | 2 +- .../wizard/account_followup_print.py | 2 +- .../wizard/account_invoice_special_message.py | 2 +- addons/account_payment/__init__.py | 2 +- addons/account_payment/account_invoice.py | 2 +- addons/account_payment/account_move_line.py | 4 +- addons/account_payment/account_payment.py | 4 +- addons/account_payment/report/__init__.py | 2 +- .../account_payment/report/payment_order.py | 4 +- addons/account_payment/wizard/__init__.py | 2 +- .../wizard/account_payment_order.py | 2 +- .../wizard/account_payment_pay.py | 2 +- .../account_payment_populate_statement.py | 2 +- addons/account_sequence/__init__.py | 2 +- addons/account_voucher/__init__.py | 2 +- addons/account_voucher/account_voucher.py | 6 ++- addons/account_voucher/report/__init__.py | 2 +- .../account_voucher/report/account_voucher.py | 2 +- .../report/account_voucher_print.py | 2 +- addons/account_voucher/wizard/__init__.py | 2 +- .../wizard/account_voucher_unreconcile.py | 2 +- addons/analytic/analytic.py | 2 +- addons/anonymization/anonymization.py | 4 +- addons/auction/auction.py | 2 +- addons/auction/barcode/code39.py | 2 +- addons/auction/barcode/common.py | 2 +- addons/auction/report/auction_invoice.py | 2 +- addons/auction/report/auction_total_rml.py | 8 +-- addons/auction/report/buyer_form_report.py | 2 +- addons/auction/report/buyer_list.py | 2 +- addons/auction/report/huissier.py | 2 +- addons/auction/report/photo_shadow.py | 2 +- addons/auction/report/seller_form_report.py | 2 +- addons/audittrail/audittrail.py | 10 ++-- addons/base_contact/base_contact.py | 6 +-- addons/base_crypt/crypt.py | 4 +- .../report/ir_module_reference_print_graph.py | 2 +- addons/base_module_quality/__init__.py | 2 +- .../base_module_quality.py | 18 +++++-- .../method_test/method_test.py | 2 +- .../object_test/object_test.py | 2 +- .../pep8_test/pep8_test.py | 2 +- .../structure_test/structure_test.py | 2 +- .../unit_test/unit_test.py | 2 +- .../wizard/module_quality_check.py | 2 +- .../wizard/quality_save_report.py | 2 +- .../workflow_test/workflow_test.py | 2 +- .../wizard/base_module_record_objects.py | 2 +- .../wizard/base_module_save.py | 2 +- .../openerp_sxw2rml/openerp_sxw2rml.py | 32 ++++++------ .../bin/script/About.py | 2 +- .../bin/script/AddAttachment.py | 16 +++--- .../bin/script/Change.py | 4 +- .../bin/script/ConvertBracesToField.py | 6 +-- .../bin/script/ConvertFieldsToBraces.py | 2 +- .../bin/script/ExportToRML.py | 2 +- .../bin/script/Expression.py | 6 +-- .../bin/script/Fields.py | 12 ++--- .../bin/script/ModifyExistingReport.py | 6 +-- .../bin/script/NewReport.py | 6 +-- .../bin/script/Repeatln.py | 8 +-- .../bin/script/SendToServer.py | 8 +-- .../bin/script/ServerParameter.py | 8 +-- .../bin/script/Translation.py | 12 ++--- .../bin/script/lib/error.py | 2 +- .../bin/script/lib/functions.py | 22 +++++--- .../bin/script/lib/logreport.py | 2 +- .../bin/script/lib/rpc.py | 4 +- .../bin/script/lib/tools.py | 6 +-- .../bin/script/modify.py | 2 +- .../test/test_fields.py | 6 ++- addons/base_setup/base_setup.py | 2 +- addons/base_synchro/base_synchro_obj.py | 8 +-- addons/base_vat/__init__.py | 2 +- addons/base_vat/res_company.py | 2 +- addons/caldav/caldav_node.py | 22 ++++---- addons/crm/crm.py | 4 +- addons/crm/crm_lead.py | 2 +- addons/crm_claim/crm_claim.py | 2 +- addons/crm_helpdesk/crm_helpdesk.py | 2 +- addons/crm_profiling/crm_profiling.py | 2 +- addons/delivery/wizard/delivery_sale_order.py | 2 +- addons/document/content_index.py | 8 +-- addons/document/document.py | 2 +- addons/document/document_directory.py | 6 +-- addons/document/nodes.py | 50 ++++++++++--------- addons/document/odt2txt.py | 6 +-- addons/document/std_index.py | 16 +++--- addons/document_webdav/document_webdav.py | 2 +- addons/document_webdav/redirect.py | 2 +- addons/document_webdav/test_davclient.py | 2 +- addons/document_webdav/webdav.py | 2 +- addons/document_webdav/webdav_server.py | 12 ++--- addons/email_template/html2text.py | 7 +-- .../wizard/mail_compose_message.py | 2 +- addons/event/event.py | 2 +- addons/event/report/__init__.py | 2 +- addons/event/res_partner.py | 2 +- addons/event/wizard/event_confirm.py | 2 +- addons/event_moodle/event_moodle.py | 2 +- addons/event_project/event_project.py | 2 +- .../wizard/event_project_retro.py | 2 +- addons/hr_attendance/wizard/__init__.py | 2 +- .../wizard/hr_attendance_bymonth.py | 2 +- .../wizard/hr_attendance_byweek.py | 2 +- .../wizard/hr_attendance_error.py | 2 +- addons/hr_evaluation/hr_evaluation.py | 2 +- .../report/report_contribution_register.py | 2 +- addons/hr_payroll/report/report_payslip.py | 2 +- .../report/report_payslip_details.py | 2 +- addons/hr_payroll_account/__init__.py | 2 +- addons/hr_payroll_account/wizard/__init__.py | 2 +- .../hr_payroll_payslips_by_employees.py | 2 +- addons/hr_recruitment/hr_recruitment.py | 2 +- .../hr_recruitment_create_partner_job.py | 4 +- .../wizard/hr_recruitment_employee_hired.py | 4 +- .../hr_timesheet_invoice.py | 2 +- .../report/account_analytic_profit.py | 2 +- .../wizard/hr_timesheet_invoice_create.py | 2 +- .../hr_timesheet_sheet/hr_timesheet_sheet.py | 4 +- .../wizard/hr_timesheet_current.py | 2 +- addons/idea/idea.py | 2 +- addons/import_base/import_framework.py | 2 +- addons/import_sugarcrm/import_sugarcrm.py | 6 +-- addons/l10n_be/__init__.py | 2 +- addons/l10n_be_invoice_bba/invoice.py | 12 ++--- addons/l10n_br/l10n_br.py | 2 +- addons/l10n_ch/partner.py | 2 +- addons/l10n_ch/payment.py | 2 +- addons/l10n_ch/report/report_webkit_html.py | 2 +- addons/l10n_ch/wizard/create_dta.py | 2 +- addons/l10n_fr/l10n_fr.py | 2 +- addons/l10n_fr/report/base_report.py | 2 +- addons/l10n_fr/wizard/fr_report_bilan.py | 2 +- .../wizard/fr_report_compute_resultant.py | 2 +- addons/l10n_lu/wizard/pdf_ext.py | 2 +- addons/lunch/report/order.py | 4 +- addons/mail/mail_thread.py | 2 +- .../mail/static/scripts/openerp_mailgate.py | 0 addons/membership/report/__init__.py | 2 +- addons/membership/report/report_membership.py | 2 +- addons/membership/wizard/__init__.py | 2 +- addons/mrp/mrp.py | 8 +-- addons/mrp/procurement.py | 2 +- addons/mrp/report/bom_structure.py | 4 +- addons/mrp/stock.py | 2 +- addons/mrp_operations/mrp_operations.py | 2 +- addons/plugin/plugin_handler.py | 2 +- .../point_of_sale/report/account_statement.py | 2 +- .../report/all_closed_cashbox_of_the_day.py | 18 +++---- addons/point_of_sale/report/pos_details.py | 6 +-- .../report/pos_details_summary.py | 4 +- addons/point_of_sale/report/pos_lines.py | 4 +- .../report/pos_payment_report.py | 6 +-- .../report/pos_payment_report_user.py | 4 +- addons/point_of_sale/report/pos_receipt.py | 2 +- addons/point_of_sale/report/pos_sales_user.py | 4 +- .../report/pos_sales_user_today.py | 4 +- .../point_of_sale/report/pos_users_product.py | 4 +- .../report/report_cash_register.py | 2 +- addons/procurement/company.py | 2 +- addons/product/product.py | 4 +- addons/product/report/product_pricelist.py | 8 +-- .../product_manufacturer.py | 2 +- addons/product_visible_discount/__init__.py | 2 +- addons/project/project.py | 24 +++++---- .../project/wizard/project_task_reevaluate.py | 2 +- addons/project_gtd/project_gtd.py | 2 +- .../project_gtd/wizard/project_gtd_empty.py | 2 +- addons/project_mailgate/project_mailgate.py | 4 +- addons/project_mrp/project_procurement.py | 2 +- addons/project_timesheet/project_timesheet.py | 2 +- .../project_timesheet/report/task_report.py | 4 +- addons/purchase/purchase.py | 4 +- .../purchase/wizard/purchase_order_group.py | 2 +- .../purchase_requisition.py | 2 +- addons/report_webkit/ir_report.py | 2 +- addons/report_webkit/report_helper.py | 2 +- addons/resource/faces/task.py | 3 +- addons/resource/resource.py | 2 +- addons/sale/edi/sale_order.py | 2 +- addons/sale/report/__init__.py | 2 +- addons/sale/wizard/__init__.py | 2 +- addons/sale/wizard/sale_make_invoice.py | 2 +- addons/sale_crm/__init__.py | 2 +- addons/sale_layout/sale_layout.py | 2 +- addons/sale_order_dates/sale_order_dates.py | 2 +- addons/stock/report/lot_overview.py | 2 +- addons/stock/report/lot_overview_all.py | 2 +- .../report/stock_inventory_move_report.py | 2 +- .../wizard/stock_invoice.py | 2 +- addons/stock_location/procurement_pull.py | 2 +- addons/stock_planning/stock_planning.py | 2 +- .../wizard/stock_planning_createlines.py | 2 +- addons/survey/survey.py | 4 +- addons/survey/wizard/__init__.py | 2 +- addons/survey/wizard/survey_answer.py | 10 ++-- addons/wiki/web/widgets/rss/feedparser.py | 4 +- .../wiki/web/widgets/wikimarkup/__init__.py | 6 ++- 211 files changed, 461 insertions(+), 440 deletions(-) delete mode 100644 addons/account_anglo_saxon/sale.py mode change 100755 => 100644 addons/document/odt2txt.py mode change 100755 => 100644 addons/document_webdav/test_davclient.py mode change 100755 => 100644 addons/email_template/html2text.py mode change 100755 => 100644 addons/mail/static/scripts/openerp_mailgate.py mode change 100755 => 100644 addons/wiki/web/widgets/rss/feedparser.py diff --git a/addons/account_analytic_plans/report/crossovered_analytic.py b/addons/account_analytic_plans/report/crossovered_analytic.py index f1d8d67f445..f990ade55a3 100644 --- a/addons/account_analytic_plans/report/crossovered_analytic.py +++ b/addons/account_analytic_plans/report/crossovered_analytic.py @@ -34,7 +34,7 @@ class crossovered_analytic(report_sxw.rml_parse): }) self.base_amount = 0.00 - def find_children(self,ref_ids): + def find_children(self, ref_ids): to_return_ids = [] final_list = [] parent_list = [] @@ -53,7 +53,7 @@ class crossovered_analytic(report_sxw.rml_parse): final_list.extend(set_list) return final_list #to_return_ids[0] - def set_account(self,cats): + def set_account(self, cats): lst = [] category = self.pool.get('account.analytic.account').read(self.cr, self.uid, cats) for cat in category: @@ -62,7 +62,7 @@ class crossovered_analytic(report_sxw.rml_parse): lst.extend(self.set_account(cat['child_ids'])) return lst - def _ref_lines(self,form): + def _ref_lines(self, form): result = [] res = {} acc_pool = self.pool.get('account.analytic.account') diff --git a/addons/account_anglo_saxon/__init__.py b/addons/account_anglo_saxon/__init__.py index 07b514d0327..440f8e87df7 100644 --- a/addons/account_anglo_saxon/__init__.py +++ b/addons/account_anglo_saxon/__init__.py @@ -23,4 +23,4 @@ import stock import purchase import invoice -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_anglo_saxon/sale.py b/addons/account_anglo_saxon/sale.py deleted file mode 100644 index e2cfa7bbb3b..00000000000 --- a/addons/account_anglo_saxon/sale.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 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_line(osv.osv): -# _name = 'sale.order.line' -# _description = 'Sale Order line' -# _inherit = 'sale.order.line' -# -# def invoice_line_create(self, cr, uid, ids, context={}): -# line_ids = super('sale_order_line',self).invoice_line_create(cr, uid, ids, context) -# invoice_line_obj = self.pool.get('account.invoice.line') -# for line in invoice_line_obj.browse(cr, uid, line_ids): -# if line.product_id: -# a = line.product_id.product_tmpl_id.property_stock_account_output and line.product_id.product_tmpl_id.property_stock_account_output.id -# if not a: -# a = line.product_id.categ_id.property_stock_account_output_categ and line.product_id.categ_id.property_stock_account_output_categ.id -# if a: -# a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, a) -# invoice_line_obj.write(cr, uid, line.id, {'account_id':a}) -# -#sale_order_line() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index 97aec1d8487..48f41df1ef4 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -75,7 +75,7 @@ class account_asset_asset(osv.osv): _name = 'account.asset.asset' _description = 'Asset' - def _get_period(self, cr, uid, context={}): + def _get_period(self, cr, uid, context=None): periods = self.pool.get('account.period').find(cr, uid) if periods: return periods[0] @@ -176,7 +176,9 @@ class account_asset_asset(osv.osv): year = depreciation_date.year return True - def validate(self, cr, uid, ids, context={}): + def validate(self, cr, uid, ids, context=None): + if context is None: + context = {} return self.write(cr, uid, ids, { 'state':'open' }, context) @@ -304,7 +306,7 @@ class account_asset_asset(osv.osv): default.update({'depreciation_line_ids': [], 'state': 'draft'}) return super(account_asset_asset, self).copy(cr, uid, id, default, context=context) - def _compute_entries(self, cr, uid, ids, period_id, context={}): + def _compute_entries(self, cr, uid, ids, period_id, context=None): result = [] period_obj = self.pool.get('account.period') depreciation_obj = self.pool.get('account.asset.depreciation.line') diff --git a/addons/account_budget/report/analytic_account_budget_report.py b/addons/account_budget/report/analytic_account_budget_report.py index aa5d39f8d49..e29af98b6a3 100644 --- a/addons/account_budget/report/analytic_account_budget_report.py +++ b/addons/account_budget/report/analytic_account_budget_report.py @@ -35,7 +35,9 @@ class analytic_account_budget_report(report_sxw.rml_parse): }) self.context = context - def funct(self, object, form, ids={}, done=None, level=1): + def funct(self, object, form, ids=None, done=None, level=1): + if ids is None: + ids = {} if not ids: ids = self.ids if not done: @@ -153,7 +155,7 @@ class analytic_account_budget_report(report_sxw.rml_parse): tot['perc'] = float(tot['prac'] / tot['theo']) * 100 return result - def funct_total(self,form): + def funct_total(self, form): result = [] res = {} res = { @@ -167,4 +169,4 @@ class analytic_account_budget_report(report_sxw.rml_parse): report_sxw.report_sxw('report.account.analytic.account.budget', 'account.analytic.account', 'addons/account_budget/report/analytic_account_budget_report.rml',parser=analytic_account_budget_report,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/report/budget_report.py b/addons/account_budget/report/budget_report.py index 7681f9268d9..c7d4ba58f68 100644 --- a/addons/account_budget/report/budget_report.py +++ b/addons/account_budget/report/budget_report.py @@ -34,7 +34,9 @@ class budget_report(report_sxw.rml_parse): }) self.context = context - def funct(self, object, form, ids={}, done=None, level=1): + def funct(self, object, form, ids=None, done=None, level=1): + if ids is None: + ids = {} if not ids: ids = self.ids if not done: diff --git a/addons/account_budget/report/crossovered_budget_report.py b/addons/account_budget/report/crossovered_budget_report.py index b70b7da34bb..9f2f59fe715 100644 --- a/addons/account_budget/report/crossovered_budget_report.py +++ b/addons/account_budget/report/crossovered_budget_report.py @@ -37,7 +37,9 @@ class budget_report(report_sxw.rml_parse): }) self.context = context - def funct(self, object, form, ids={}, done=None, level=1): + def funct(self, object, form, ids=None, done=None, level=1): + if ids is None: + ids = {} if not ids: ids = self.ids if not done: diff --git a/addons/account_budget/wizard/account_budget_analytic.py b/addons/account_budget/wizard/account_budget_analytic.py index 3e3b4b0fa9d..6397ee87c76 100644 --- a/addons/account_budget/wizard/account_budget_analytic.py +++ b/addons/account_budget/wizard/account_budget_analytic.py @@ -52,4 +52,4 @@ class account_budget_analytic(osv.osv_memory): account_budget_analytic() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/wizard/account_budget_crossovered_report.py b/addons/account_budget/wizard/account_budget_crossovered_report.py index ff6b6492a5a..e120bc47caa 100644 --- a/addons/account_budget/wizard/account_budget_crossovered_report.py +++ b/addons/account_budget/wizard/account_budget_crossovered_report.py @@ -53,4 +53,4 @@ class account_budget_crossvered_report(osv.osv_memory): account_budget_crossvered_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/wizard/account_budget_report.py b/addons/account_budget/wizard/account_budget_report.py index fdae4c94adf..6ef22c649e9 100644 --- a/addons/account_budget/wizard/account_budget_report.py +++ b/addons/account_budget/wizard/account_budget_report.py @@ -54,4 +54,4 @@ class account_budget_report(osv.osv_memory): account_budget_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_coda/account_coda.py b/addons/account_coda/account_coda.py index e3cc6f40a0c..48fc491bee9 100644 --- a/addons/account_coda/account_coda.py +++ b/addons/account_coda/account_coda.py @@ -217,7 +217,9 @@ class coda_bank_statement(osv.osv): _name = 'coda.bank.statement' _description = 'CODA Bank Statement' - def _default_journal_id(self, cr, uid, context={}): + def _default_journal_id(self, cr, uid, context=None): + if context is None: + context = {} if context.get('journal_id', False): return context['journal_id'] return False @@ -233,7 +235,7 @@ class coda_bank_statement(osv.osv): res[r] = round(res[r], 2) return res - def _get_period(self, cr, uid, context={}): + def _get_period(self, cr, uid, context=None): periods = self.pool.get('account.period').find(cr, uid) if periods: return periods[0] diff --git a/addons/account_followup/__init__.py b/addons/account_followup/__init__.py index 4bfe3186298..ffa88c40a32 100644 --- a/addons/account_followup/__init__.py +++ b/addons/account_followup/__init__.py @@ -23,4 +23,4 @@ import account_followup import wizard import report -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_followup/wizard/__init__.py b/addons/account_followup/wizard/__init__.py index aea714d2a86..ad072c5b7d8 100644 --- a/addons/account_followup/wizard/__init__.py +++ b/addons/account_followup/wizard/__init__.py @@ -21,4 +21,4 @@ import account_followup_print -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index 1a5f3c0b60b..5ad3846dd71 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -209,7 +209,7 @@ class account_followup_print_all(osv.osv_memory): to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': stat_line_id} return {'partner_ids': partner_list, 'to_update': to_update} - def do_mail(self ,cr, uid, ids, context=None): + def do_mail(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') move_obj = self.pool.get('account.move.line') user_obj = self.pool.get('res.users') diff --git a/addons/account_invoice_layout/wizard/account_invoice_special_message.py b/addons/account_invoice_layout/wizard/account_invoice_special_message.py index 27f6044a964..68edaf7cbe7 100644 --- a/addons/account_invoice_layout/wizard/account_invoice_special_message.py +++ b/addons/account_invoice_layout/wizard/account_invoice_special_message.py @@ -47,4 +47,4 @@ class account_invoice_special_msg(osv.osv_memory): account_invoice_special_msg() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/__init__.py b/addons/account_payment/__init__.py index 6188de6a9da..82a05aa73e9 100644 --- a/addons/account_payment/__init__.py +++ b/addons/account_payment/__init__.py @@ -29,4 +29,4 @@ import account_move_line import account_invoice import report -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/account_invoice.py b/addons/account_payment/account_invoice.py index fd787863c7d..7138540fa3b 100644 --- a/addons/account_payment/account_invoice.py +++ b/addons/account_payment/account_invoice.py @@ -50,4 +50,4 @@ class Invoice(osv.osv): Invoice() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index 24f9486be95..d01157a8a98 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -26,7 +26,7 @@ from tools.translate import _ class account_move_line(osv.osv): _inherit = "account.move.line" - def amount_to_pay(self, cr, uid, ids, name, arg={}, context=None): + def amount_to_pay(self, cr, uid, ids, name, arg=None, context=None): """ Return the amount still to pay regarding all the payemnt orders (excepting cancelled orders)""" if not ids: @@ -117,4 +117,4 @@ class account_move_line(osv.osv): account_move_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index 1de715dc777..c4257bf6f89 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -139,7 +139,9 @@ class payment_order(osv.osv): wf_service.trg_validate(uid, 'payment.order', ids[0], 'done', cr) return True - def copy(self, cr, uid, id, default={}, context=None): + def copy(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} default.update({ 'state': 'draft', 'line_ids': [], diff --git a/addons/account_payment/report/__init__.py b/addons/account_payment/report/__init__.py index e9d7f4013ac..c73a5f33001 100644 --- a/addons/account_payment/report/__init__.py +++ b/addons/account_payment/report/__init__.py @@ -20,4 +20,4 @@ ############################################################################## import payment_order -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/report/payment_order.py b/addons/account_payment/report/payment_order.py index 0b2a8061906..6872bbe3516 100644 --- a/addons/account_payment/report/payment_order.py +++ b/addons/account_payment/report/payment_order.py @@ -77,7 +77,7 @@ class payment_order(report_sxw.rml_parse): user = pool.get('res.users').browse(self.cr, self.uid, self.uid) return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False - def _get_account_name(self,bank_id): + def _get_account_name(self, bank_id): if bank_id: pool = pooler.get_pool(self.cr.dbname) value_name = pool.get('res.partner.bank').name_get(self.cr, self.uid, [bank_id]) @@ -87,4 +87,4 @@ class payment_order(report_sxw.rml_parse): report_sxw.report_sxw('report.payment.order', 'payment.order', 'addons/account_payment/report/payment_order.rml', parser=payment_order, header="external") -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/wizard/__init__.py b/addons/account_payment/wizard/__init__.py index 1c5aefacc78..35b907cd337 100644 --- a/addons/account_payment/wizard/__init__.py +++ b/addons/account_payment/wizard/__init__.py @@ -23,4 +23,4 @@ import account_payment_order import account_payment_populate_statement import account_payment_pay -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/wizard/account_payment_order.py b/addons/account_payment/wizard/account_payment_order.py index 613b049a412..fc421abe085 100644 --- a/addons/account_payment/wizard/account_payment_order.py +++ b/addons/account_payment/wizard/account_payment_order.py @@ -119,4 +119,4 @@ class payment_order_create(osv.osv_memory): payment_order_create() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/wizard/account_payment_pay.py b/addons/account_payment/wizard/account_payment_pay.py index 6bcb04fa490..3c16618f3d2 100644 --- a/addons/account_payment/wizard/account_payment_pay.py +++ b/addons/account_payment/wizard/account_payment_pay.py @@ -56,4 +56,4 @@ class account_payment_make_payment(osv.osv_memory): account_payment_make_payment() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/wizard/account_payment_populate_statement.py b/addons/account_payment/wizard/account_payment_populate_statement.py index 6f2d9d02dbc..ecfd4988329 100644 --- a/addons/account_payment/wizard/account_payment_populate_statement.py +++ b/addons/account_payment/wizard/account_payment_populate_statement.py @@ -120,4 +120,4 @@ class account_payment_populate_statement(osv.osv_memory): account_payment_populate_statement() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_sequence/__init__.py b/addons/account_sequence/__init__.py index b6707106d4b..e85a910f037 100644 --- a/addons/account_sequence/__init__.py +++ b/addons/account_sequence/__init__.py @@ -22,4 +22,4 @@ import account_sequence import account_sequence_installer -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/__init__.py b/addons/account_voucher/__init__.py index 9796f81d5e5..2b1478d9fa0 100644 --- a/addons/account_voucher/__init__.py +++ b/addons/account_voucher/__init__.py @@ -24,4 +24,4 @@ import invoice import report import wizard -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 3ed173cca85..59a42ab3b24 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -830,7 +830,7 @@ class account_voucher(osv.osv): res['account_id'] = account_id return {'value':res} - def _sel_context(self, cr, uid, voucher_id,context=None): + def _sel_context(self, cr, uid, voucher_id, context=None): """ Select the context to use accordingly if it needs to be multicurrency or not. @@ -1251,7 +1251,9 @@ class account_voucher(osv.osv): move_line_pool.reconcile_partial(cr, uid, rec_ids, writeoff_acc_id=voucher.writeoff_acc_id.id, writeoff_period_id=voucher.period_id.id, writeoff_journal_id=voucher.journal_id.id) return True - def copy(self, cr, uid, id, default={}, context=None): + def copy(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} default.update({ 'state': 'draft', 'number': False, diff --git a/addons/account_voucher/report/__init__.py b/addons/account_voucher/report/__init__.py index caeb155adbe..862843352a8 100644 --- a/addons/account_voucher/report/__init__.py +++ b/addons/account_voucher/report/__init__.py @@ -23,4 +23,4 @@ import account_voucher import account_voucher_print import account_voucher_sales_receipt -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/report/account_voucher.py b/addons/account_voucher/report/account_voucher.py index e44adee974e..146fcbc258a 100644 --- a/addons/account_voucher/report/account_voucher.py +++ b/addons/account_voucher/report/account_voucher.py @@ -72,4 +72,4 @@ report_sxw.report_sxw( parser=report_voucher,header="external" ) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/report/account_voucher_print.py b/addons/account_voucher/report/account_voucher_print.py index 8bd8644c03c..6a5762be493 100644 --- a/addons/account_voucher/report/account_voucher_print.py +++ b/addons/account_voucher/report/account_voucher_print.py @@ -93,4 +93,4 @@ report_sxw.report_sxw( parser=report_voucher_print,header="external" ) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/wizard/__init__.py b/addons/account_voucher/wizard/__init__.py index bfe32ba4b83..cc2f39f9d37 100644 --- a/addons/account_voucher/wizard/__init__.py +++ b/addons/account_voucher/wizard/__init__.py @@ -22,4 +22,4 @@ import account_voucher_unreconcile import account_statement_from_invoice -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/wizard/account_voucher_unreconcile.py b/addons/account_voucher/wizard/account_voucher_unreconcile.py index 42a9e1c5ec2..204839e3439 100644 --- a/addons/account_voucher/wizard/account_voucher_unreconcile.py +++ b/addons/account_voucher/wizard/account_voucher_unreconcile.py @@ -59,4 +59,4 @@ class account_voucher_unreconcile(osv.osv_memory): account_voucher_unreconcile() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 6241b6e06f0..6583de992b2 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -219,7 +219,7 @@ class account_analytic_account(osv.osv): default['line_ids'] = [] return super(account_analytic_account, self).copy(cr, uid, id, default, context=context) - def on_change_partner_id(self, cr, uid, id, partner_id, context={}): + def on_change_partner_id(self, cr, uid, id, partner_id, context=None): if not partner_id: return {'value': {'contact_id': False}} addr = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['invoice']) diff --git a/addons/anonymization/anonymization.py b/addons/anonymization/anonymization.py index 39fb415e9e1..6e94838a4e7 100644 --- a/addons/anonymization/anonymization.py +++ b/addons/anonymization/anonymization.py @@ -350,7 +350,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory): }) raise osv.except_osv(error_type, error_msg) - def anonymize_database(self,cr, uid, ids, context=None): + def anonymize_database(self, cr, uid, ids, context=None): """Sets the 'anonymized' state to defined fields""" # create a new history record: @@ -485,7 +485,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory): 'target':'new', } - def reverse_anonymize_database(self,cr, uid, ids, context=None): + def reverse_anonymize_database(self, cr, uid, ids, context=None): """Set the 'clear' state to defined fields""" ir_model_fields_anonymization_model = self.pool.get('ir.model.fields.anonymization') diff --git a/addons/auction/auction.py b/addons/auction/auction.py index e701e399acf..03e6c805d78 100644 --- a/addons/auction/auction.py +++ b/addons/auction/auction.py @@ -533,7 +533,7 @@ class auction_lots(osv.osv): return self._sum_taxes_by_type_and_id(costs) # sum remise limite net and ristourne - def compute_seller_costs_summed(self, cr, uid, ids): #ach_pay_id + def compute_seller_costs_summed(self, cr, uid, ids): """This Fuction sum Net remittance limit and refund""" diff --git a/addons/auction/barcode/code39.py b/addons/auction/barcode/code39.py index a3926c6c48d..7dd7e5fca54 100644 --- a/addons/auction/barcode/code39.py +++ b/addons/auction/barcode/code39.py @@ -114,7 +114,7 @@ def _encode39(str, cksum): class _Code39Base(Barcode): - def __init__(self, value = "", **args): + def __init__(self, value="", **args): self.xdim = inch * 0.0075 self.lquiet = None self.rquiet = None diff --git a/addons/auction/barcode/common.py b/addons/auction/barcode/common.py index e6933fd1673..aa03b1079ca 100644 --- a/addons/auction/barcode/common.py +++ b/addons/auction/barcode/common.py @@ -39,7 +39,7 @@ class Barcode(Flowable): """Abstract Base for barcodes. Includes implementations of some methods suitable for the more primitive barcode types""" - def __init__(self, value = ''): + def __init__(self, value=''): self.value = value if not hasattr(self, 'gap'): diff --git a/addons/auction/report/auction_invoice.py b/addons/auction/report/auction_invoice.py index 40ca8498756..172c7dc73d3 100644 --- a/addons/auction/report/auction_invoice.py +++ b/addons/auction/report/auction_invoice.py @@ -26,7 +26,7 @@ class auction_invoice(report_int): def __init__(self, name): report_int.__init__(self, name) - def create(self,cr, uid, ids, datas, context): + def create(self, cr, uid, ids, datas, context): lots = self.pool.get('auction.lots').read(cr, uid, ids, ['ach_inv_id'], context=context) invoices = {} diff --git a/addons/auction/report/auction_total_rml.py b/addons/auction/report/auction_total_rml.py index 610cb108cc4..38f9adaa040 100644 --- a/addons/auction/report/auction_total_rml.py +++ b/addons/auction/report/auction_total_rml.py @@ -65,7 +65,7 @@ class auction_total_rml(report_sxw.rml_parse): return auct_dat - def sum_taxes(self,auction_id): + def sum_taxes(self, auction_id): self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s group by auction_id ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return res[0] @@ -105,17 +105,17 @@ class auction_total_rml(report_sxw.rml_parse): res = self.cr.fetchone() return str(res[0]) or 0.0 - def sum_credit(self,auction_id): + def sum_credit(self, auction_id): self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) - def sum_debit_buyer(self,auction_id): + def sum_debit_buyer(self, auction_id): self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0] or 0) - def sum_debit(self,object_id): + def sum_debit(self, object_id): self.cr.execute("select sum(seller_price) from auction_lots where auction_id=%s", (object_id,)) res = self.cr.fetchone() return str(res[0] or 0) diff --git a/addons/auction/report/buyer_form_report.py b/addons/auction/report/buyer_form_report.py index 37b82cd872e..dea4c836f2b 100644 --- a/addons/auction/report/buyer_form_report.py +++ b/addons/auction/report/buyer_form_report.py @@ -58,7 +58,7 @@ class buyer_form_report(report_sxw.rml_parse): lots.append(object) return ret_dict.values() - def grand_buyer_total(self,o): + def grand_buyer_total(self, o): grand_total = 0 for oo in o: grand_total =grand_total + oo['obj_price'] +self.sum_taxes(oo) diff --git a/addons/auction/report/buyer_list.py b/addons/auction/report/buyer_list.py index 3829238a43f..1b088e40330 100644 --- a/addons/auction/report/buyer_list.py +++ b/addons/auction/report/buyer_list.py @@ -62,7 +62,7 @@ class buyer_list(report_sxw.rml_parse): auct_dat.append(auc_dates_fields) return auct_dat - def lines_lots_auct_lot(self,obj): + def lines_lots_auct_lot(self, obj): auc_date_ids = self.pool.get('auction.dates').search(self.cr, self.uid, ([('name','like',obj['name'])])) diff --git a/addons/auction/report/huissier.py b/addons/auction/report/huissier.py index 1d680548886..e9d7cc145da 100644 --- a/addons/auction/report/huissier.py +++ b/addons/auction/report/huissier.py @@ -30,7 +30,7 @@ class report_custom(report_rml): def __init__(self, name, table, tmpl, xsl): report_rml.__init__(self, name, table, tmpl, xsl) - def create_xml(self,cr, uid, ids, datas, context=None): + def create_xml(self, cr, uid, ids, datas, context=None): pool= pooler.get_pool(cr.dbname) lots = pool.get('auction.lots').browse(cr, uid, ids, context=context) auction = lots[0].auction_id diff --git a/addons/auction/report/photo_shadow.py b/addons/auction/report/photo_shadow.py index 919fa701e23..fb9cfe4f893 100644 --- a/addons/auction/report/photo_shadow.py +++ b/addons/auction/report/photo_shadow.py @@ -19,7 +19,7 @@ # ############################################################################## -def convert_catalog(from_file, to_file, size=220) : +def convert_catalog(from_file, to_file, size=220): return __convert(from_file, to_file, size) def convert(from_file, to_file): diff --git a/addons/auction/report/seller_form_report.py b/addons/auction/report/seller_form_report.py index 06ff021dcc1..c602cce0714 100644 --- a/addons/auction/report/seller_form_report.py +++ b/addons/auction/report/seller_form_report.py @@ -58,7 +58,7 @@ class seller_form_report(report_sxw.rml_parse): lots = partner.get('lots') lots.append(object) return ret_dict.values() - def grand_seller_total(self,o): + def grand_seller_total(self, o): grand_total = 0 for oo in o: grand_total =grand_total + oo['obj_price']+ self.sum_taxes(oo) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 302d6e146bd..25ba8e1c8b6 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -201,7 +201,7 @@ class audittrail_objects_proxy(object_proxy): res = value return res - def create_log_line(self, cr, uid, log_id, model, lines=[]): + def create_log_line(self, cr, uid, log_id, model, lines=None): """ Creates lines for changed fields with its old and new values @@ -210,6 +210,8 @@ class audittrail_objects_proxy(object_proxy): @param model: Object which values are being changed @param lines: List of values for line is to be created """ + if lines is None: + lines = [] pool = pooler.get_pool(cr.dbname) obj_pool = pool.get(model.model) model_pool = pool.get('ir.model') @@ -348,7 +350,7 @@ class audittrail_objects_proxy(object_proxy): data[(model.id, resource_id)] = {'text':values_text, 'value': values} return data - def prepare_audittrail_log_line(self, cr, uid, pool, model, resource_id, method, old_values, new_values, field_list=[]): + def prepare_audittrail_log_line(self, cr, uid, pool, model, resource_id, method, old_values, new_values, field_list=None): """ This function compares the old data (i.e before the method was executed) and the new data (after the method was executed) and returns a structure with all the needed information to @@ -378,6 +380,8 @@ class audittrail_objects_proxy(object_proxy): record (res.partner, for example), we may have to log a change done in a x2many field (on res.partner.address, for example) """ + if field_list is None: + field_list = [] key = (model.id, resource_id) lines = { key: [] @@ -416,7 +420,7 @@ class audittrail_objects_proxy(object_proxy): lines[key].append(data) return lines - def process_data(self, cr, uid, pool, res_ids, model, method, old_values={}, new_values={}, field_list=[]): + def process_data(self, cr, uid, pool, res_ids, model, method, old_values=None, new_values=None, field_list=None): """ This function processes and iterates recursively to log the difference between the old data (i.e before the method was executed) and the new data and creates audittrail log diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index 59ac8a0b4df..0106ce6ae2c 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -175,7 +175,7 @@ class res_partner_address(osv.osv): ids = self.pool.get('res.partner.location').search(cr, uid, [('partner_id','=',context['default_partner_id'])], context=context) return ids and ids[0] or False - def onchange_location_id(self,cr, uid, ids, location_id=False, context={}): + def onchange_location_id(self, cr, uid, ids, location_id=False, context=None): if not location_id: return {} location = self.pool.get('res.partner.location').browse(cr, uid, location_id, context=context) @@ -209,7 +209,7 @@ class res_partner_address(osv.osv): 'name' : fields.related('contact_id', 'name', type='char', size=64, string="Contact Name", store=True), 'title' : fields.related('contact_id', 'title', type='many2one', relation='res.partner.title', string="Title", store=True), } - def create(self, cr, uid, data, context={}): + def create(self, cr, uid, data, context=None): if not data.get('location_id', False): loc_id = self.pool.get('res.partner.location').create(cr, uid, { 'street': data.get('street',''), @@ -241,7 +241,7 @@ class res_partner_address(osv.osv): 'location_id': _default_location_id } - def default_get(self, cr, uid, fields=[], context=None): + def default_get(self, cr, uid, fields=None, context=None): if context is None: context = {} if 'default_type' in context: diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py index c2fd0a25ef8..82cd939a015 100644 --- a/addons/base_crypt/crypt.py +++ b/addons/base_crypt/crypt.py @@ -45,7 +45,9 @@ from service import security magic_md5 = '$1$' -def gen_salt( length=8, symbols=ascii_letters + digits ): +def gen_salt( length=8, symbols=None): + if symbols is None: + symbols = ascii_letters + digits seed() return ''.join( sample( symbols, length ) ) diff --git a/addons/base_module_doc_rst/report/ir_module_reference_print_graph.py b/addons/base_module_doc_rst/report/ir_module_reference_print_graph.py index 62848383000..e70b2da63b1 100644 --- a/addons/base_module_doc_rst/report/ir_module_reference_print_graph.py +++ b/addons/base_module_doc_rst/report/ir_module_reference_print_graph.py @@ -79,4 +79,4 @@ report_sxw.report_sxw('report.ir.module.reference.graph', 'ir.module.module', 'addons/base_module_doc_rst/report/ir_module_reference_graph.rml', parser=ir_module_reference_print_graph, header=False) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/__init__.py b/addons/base_module_quality/__init__.py index 8ff78f7c202..602710fb602 100644 --- a/addons/base_module_quality/__init__.py +++ b/addons/base_module_quality/__init__.py @@ -22,4 +22,4 @@ import base_module_quality import wizard -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/base_module_quality.py b/addons/base_module_quality/base_module_quality.py index bbe20bc0b4f..349821f1081 100644 --- a/addons/base_module_quality/base_module_quality.py +++ b/addons/base_module_quality/base_module_quality.py @@ -115,7 +115,9 @@ class abstract_quality_check(object): self.log.debug('get_objects() obj_list: %s', ','.join(obj_list)) return obj_list - def get_model_ids(self, cr, uid, models=[]): + def get_model_ids(self, cr, uid, models=None): + if models is None: + models = [] # This function returns all ids of the given objects.. if not models: return [] @@ -133,7 +135,12 @@ class abstract_quality_check(object): result_ids[obj] = ids return result_ids - def format_table(self, header=[], data_list={}): #This function can work forwidget="text_wiki" + def format_table(self, header=None, data_list=None): + #This function can work forwidget="text_wiki" + if header is None: + header = [] + if data_list is None: + data_list = {} detail = "" detail += (header[0]) % tuple(header[1]) frow = '\n|-' @@ -144,7 +151,12 @@ class abstract_quality_check(object): detail = detail + '\n|}' return detail - def format_html_table(self, header=[], data_list=[]): #This function can work for widget="html_tag" + def format_html_table(self, header=None, data_list=None): + #This function can work for widget="html_tag" + if header is None: + header = [] + if data_list is None: + data_list = [] # function create html table.... detail = "" detail += (header[0]) % tuple(header[1]) diff --git a/addons/base_module_quality/method_test/method_test.py b/addons/base_module_quality/method_test/method_test.py index 2884e064b54..a708c088b80 100644 --- a/addons/base_module_quality/method_test/method_test.py +++ b/addons/base_module_quality/method_test/method_test.py @@ -85,4 +85,4 @@ This test checks if the module classes are raising exception when calling basic detail += self.format_table(header, dict_method) return detail -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/object_test/object_test.py b/addons/base_module_quality/object_test/object_test.py index 0a3f8ce379d..810b0a215a8 100644 --- a/addons/base_module_quality/object_test/object_test.py +++ b/addons/base_module_quality/object_test/object_test.py @@ -208,4 +208,4 @@ Test checks for fields, views, security rules, dependancy level return res return "" -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/pep8_test/pep8_test.py b/addons/base_module_quality/pep8_test/pep8_test.py index 4aaaaa7bddc..ef347cdaad4 100644 --- a/addons/base_module_quality/pep8_test/pep8_test.py +++ b/addons/base_module_quality/pep8_test/pep8_test.py @@ -278,4 +278,4 @@ PEP-8 Test , copyright of py files check, method can not call from loops return res return "" -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/structure_test/structure_test.py b/addons/base_module_quality/structure_test/structure_test.py index 2238d5f3a93..f8fef4d46f4 100644 --- a/addons/base_module_quality/structure_test/structure_test.py +++ b/addons/base_module_quality/structure_test/structure_test.py @@ -176,4 +176,4 @@ This test checks if the module satisfy tiny structure return res return "" -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/unit_test/unit_test.py b/addons/base_module_quality/unit_test/unit_test.py index 248f647310c..be378ced45f 100644 --- a/addons/base_module_quality/unit_test/unit_test.py +++ b/addons/base_module_quality/unit_test/unit_test.py @@ -111,4 +111,4 @@ This test checks the Unit Test(PyUnit) Cases of the module. Note that 'unit_test return detail + html +'' return '' -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/wizard/module_quality_check.py b/addons/base_module_quality/wizard/module_quality_check.py index 8b6f1157a29..6d03843e8b5 100644 --- a/addons/base_module_quality/wizard/module_quality_check.py +++ b/addons/base_module_quality/wizard/module_quality_check.py @@ -49,4 +49,4 @@ class quality_check(osv.osv_memory): quality_check() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/wizard/quality_save_report.py b/addons/base_module_quality/wizard/quality_save_report.py index e4286e92237..d9e7c08b424 100644 --- a/addons/base_module_quality/wizard/quality_save_report.py +++ b/addons/base_module_quality/wizard/quality_save_report.py @@ -49,4 +49,4 @@ class quality_save_report(osv.osv_memory): quality_save_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/workflow_test/workflow_test.py b/addons/base_module_quality/workflow_test/workflow_test.py index 11f7bcf12c3..5b27689eb2f 100644 --- a/addons/base_module_quality/workflow_test/workflow_test.py +++ b/addons/base_module_quality/workflow_test/workflow_test.py @@ -155,4 +155,4 @@ class quality_test(base_module_quality.abstract_quality_check): count = self.count_button(node, count) return count -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_record/wizard/base_module_record_objects.py b/addons/base_module_record/wizard/base_module_record_objects.py index e822c68c8fe..868a377a106 100644 --- a/addons/base_module_record/wizard/base_module_record_objects.py +++ b/addons/base_module_record/wizard/base_module_record_objects.py @@ -127,7 +127,7 @@ class base_module_record_objects(osv.osv_memory): _name = 'base.module.record.objects' _description = "Base Module Record Objects" - def inter_call(self,cr,uid,data,context=None): + def inter_call(self, cr, uid, data, context=None): res=base_module_save._create_module(self, cr, uid, data, context) mod_obj = self.pool.get('ir.model.data') model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'module_create_form_view')], context=context) diff --git a/addons/base_module_record/wizard/base_module_save.py b/addons/base_module_record/wizard/base_module_save.py index 1d54e212a28..914e5cbddac 100644 --- a/addons/base_module_record/wizard/base_module_save.py +++ b/addons/base_module_record/wizard/base_module_save.py @@ -167,4 +167,4 @@ class base_module_save(osv.osv_memory): base_module_save() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_report_designer/openerp_sxw2rml/openerp_sxw2rml.py b/addons/base_report_designer/openerp_sxw2rml/openerp_sxw2rml.py index 4819007f1d0..32c05a2c768 100644 --- a/addons/base_report_designer/openerp_sxw2rml/openerp_sxw2rml.py +++ b/addons/base_report_designer/openerp_sxw2rml/openerp_sxw2rml.py @@ -42,11 +42,11 @@ import copy class DomApiGeneral: """General DOM API utilities.""" - def __init__(self,content_string="",file=""): + def __init__(self, content_string="", file=""): self.content_string = content_string self.re_digits = re.compile(r"(.*?\d)(pt|cm|mm|inch|in)") - def _unitTuple(self,string): + def _unitTuple(self, string): """Split values and units to a tuple.""" temp = self.re_digits.findall(string) if not temp: @@ -54,13 +54,15 @@ class DomApiGeneral: else: return (temp[0]) - def stringPercentToFloat(self,string): + def stringPercentToFloat(self, string): temp = string.replace("""%""","") return float(temp)/100 - def findChildrenByName(self,parent,name,attr_dict={}): + def findChildrenByName(self, parent, name, attr_dict=None): """Helper functions. Does not work recursively. Optional: also test for certain attribute/value pairs.""" + if attr_dict is None: + attr_dict = {} children = [] for c in parent.childNodes: if c.nodeType == c.ELEMENT_NODE and c.nodeName == name: @@ -70,7 +72,7 @@ class DomApiGeneral: else: return self._selectForAttributes(nodelist=children,attr_dict=attr_dict) - def _selectForAttributes(self,nodelist,attr_dict): + def _selectForAttributes(self, nodelist, attr_dict): "Helper function.""" selected_nodes = [] for n in nodelist: @@ -83,7 +85,7 @@ class DomApiGeneral: selected_nodes.append(n) return selected_nodes - def _stringToTuple(self,s): + def _stringToTuple(self, s): """Helper function.""" try: temp = string.split(s,",") @@ -91,13 +93,13 @@ class DomApiGeneral: except: return None - def _tupleToString(self,t): + def _tupleToString(self, t): try: return self.openOfficeStringUtf8("%s,%s" % (t[0],t[1])) except: return None - def _lengthToFloat(self,value): + def _lengthToFloat(self, value): v = value if not self.re_digits.search(v): return v @@ -113,7 +115,7 @@ class DomApiGeneral: except: return v - def openOfficeStringUtf8(self,string): + def openOfficeStringUtf8(self, string): if type(string) == unicode: return string.encode("utf-8") tempstring = unicode(string,"cp1252").encode("utf-8") @@ -121,7 +123,7 @@ class DomApiGeneral: class DomApi(DomApiGeneral): """This class provides a DOM-API for XML-Files from an SXW-Archive.""" - def __init__(self,xml_content,xml_styles): + def __init__(self, xml_content, xml_styles): DomApiGeneral.__init__(self) self.content_dom = xml.dom.minidom.parseString(xml_content) self.styles_dom = xml.dom.minidom.parseString(xml_styles) @@ -145,7 +147,7 @@ class DomApi(DomApiGeneral): for s in self.style_dict.keys(): self.style_properties_dict[s] = self.getStylePropertiesDict(s) - def updateWithPercents(self,dict,updatedict): + def updateWithPercents(self, dict, updatedict): """Sometimes you find values like "115%" in the style hierarchy.""" if not updatedict: # no style hierarchies for this style? => @@ -244,7 +246,7 @@ class DomApi(DomApiGeneral): def toxml(self): return self.content_dom.toxml(encoding="utf-8") - def getStylePropertiesDict(self,style_name): + def getStylePropertiesDict(self, style_name): res = {} if self.style_dict[style_name].hasAttribute("style:parent-style-name"): @@ -265,7 +267,7 @@ class PyOpenOffice(object): self.save_pict = save_pict self.images = {} - def oo_read(self,fname): + def oo_read(self, fname): z = zipfile.ZipFile(fname,"r") content = z.read('content.xml') style = z.read('styles.xml') @@ -281,7 +283,7 @@ class PyOpenOffice(object): z.close() return content,style - def oo_replace(self,content): + def oo_replace(self, content): regex = [ (r"]*/>", ""), (r"(.*?)]*/>", "$2"), @@ -290,7 +292,7 @@ class PyOpenOffice(object): content = re.sub(key, val, content) return content - def unpackNormalize(self,sourcefile): + def unpackNormalize(self, sourcefile): c,s = self.oo_read(sourcefile) c = self.oo_replace(c) dom = DomApi(c,s) diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/About.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/About.py index 401cf88b418..43b452b82e2 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/About.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/About.py @@ -52,7 +52,7 @@ if __name__<>'package': from lib.gui import * class About(unohelper.Base, XJobExecutor): - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/AddAttachment.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/AddAttachment.py index c65ba32e6bf..69e297ab4c0 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/AddAttachment.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/AddAttachment.py @@ -64,7 +64,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ): 'PDF' : 'pdf', 'OpenOffice': 'sxw', } - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" @@ -132,7 +132,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ): self.win.addButton('btnCancel', -2 - 27 , -5 , 30 , 15, 'Cancel' ,actionListenerProc = self.btnCancel_clicked ) self.win.doModalDialog("lstResourceType", self.Kind.keys()[0]) - def btnSearch_clicked( self, oActionEvent ): + def btnSearch_clicked(self, oActionEvent): modelSelectedItem = self.win.getListBoxSelectedItem("lstmodel") if modelSelectedItem == "": return @@ -151,7 +151,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ): for result in self.aSearchResult: self.lstResource.addItem(result[1],result[0]) - def _send_attachment( self, name, data, res_model, res_id ): + def _send_attachment(self, name, data, res_model, res_id): desktop = getDesktop() oDoc2 = desktop.getCurrentComponent() docinfo = oDoc2.getDocumentInfo() @@ -166,7 +166,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ): return self.sock.execute( database, uid, self.password, 'ir.attachment', 'create', params ) - def send_attachment( self, model, resource_id ): + def send_attachment(self, model, resource_id): desktop = getDesktop() oDoc2 = desktop.getCurrentComponent() docinfo = oDoc2.getDocumentInfo() @@ -187,7 +187,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ): data = read_data_from_file( get_absolute_file_path( url ) ) return self._send_attachment( os.path.basename( url ), data, model, resource_id ) - def btnOkWithoutInformation_clicked( self, oActionEvent ): + def btnOkWithoutInformation_clicked(self, oActionEvent): desktop = getDesktop() oDoc2 = desktop.getCurrentComponent() docinfo = oDoc2.getDocumentInfo() @@ -199,7 +199,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ): res = self.send_attachment( docinfo.getUserFieldValue(3), docinfo.getUserFieldValue(2) ) self.win.endExecute() - def btnOkWithInformation_clicked(self,oActionEvent): + def btnOkWithInformation_clicked(self, oActionEvent): if self.win.getListBoxSelectedItem("lstResourceType") == "": ErrorDialog( "Please select resource type", "", "Selection ERROR" ) return @@ -221,7 +221,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ): res = self.send_attachment( self.dModel[self.win.getListBoxSelectedItem('lstmodel')], resourceid ) self.win.endExecute() - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() def doc2pdf(self, strFile): @@ -262,7 +262,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ): # Can be None if len(strFilterSubName) <= 0 return filename - def _MakePropertyValue(self, cName = "", uValue = u"" ): + def _MakePropertyValue(self, cName="", uValue=u"" ): oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" ) if cName: oPropertyValue.Name = cName diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Change.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Change.py index cdc5c7553b1..3c76ac90207 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Change.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Change.py @@ -59,7 +59,7 @@ if __name__<>"package": database="test" class Change( unohelper.Base, XJobExecutor ): - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" @@ -107,7 +107,7 @@ class Change( unohelper.Base, XJobExecutor ): self.lstProtocol.addItem(i,self.lstProtocol.getItemCount() ) self.win.doModalDialog( "lstProtocol", protocol) - def btnNext_clicked(self,oActionEvent): + def btnNext_clicked(self, oActionEvent): global url aVal='' #aVal= Fetature used diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ConvertBracesToField.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ConvertBracesToField.py index bb80c3ecd61..49844b4bfe3 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ConvertBracesToField.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ConvertBracesToField.py @@ -63,7 +63,7 @@ if __name__<>"package": class ConvertBracesToField( unohelper.Base, XJobExecutor ): - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" @@ -198,7 +198,7 @@ class ConvertBracesToField( unohelper.Base, XJobExecutor ): info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) self.logobj.log_write('ConvertBraceToField', LOG_ERROR, info) - def getRes(self,sock,sObject,sVar): + def getRes(self, sock, sObject, sVar): desktop=getDesktop() doc =desktop.getCurrentComponent() docinfo=doc.getDocumentInfo() @@ -215,7 +215,7 @@ class ConvertBracesToField( unohelper.Base, XJobExecutor ): sObject = self.getRes(sock,res[myval]['relation'], sVar[sVar.find("/")+1:]) return sObject - def getBraces(self,aReportSyntex=[]): + def getBraces(self, aReportSyntex=None): desktop=getDesktop() doc = desktop.getCurrentComponent() aSearchString=[] diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ConvertFieldsToBraces.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ConvertFieldsToBraces.py index 892061c56b4..ffa88a8cd06 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ConvertFieldsToBraces.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ConvertFieldsToBraces.py @@ -57,7 +57,7 @@ if __name__<>"package": uid = 3 class ConvertFieldsToBraces( unohelper.Base, XJobExecutor ): - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py index dd00f1719e1..293fee7388b 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py @@ -67,7 +67,7 @@ if __name__<>"package": class ExportToRML( unohelper.Base, XJobExecutor ): - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Expression.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Expression.py index ecdf13454dc..aaedb30e8fd 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Expression.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Expression.py @@ -57,7 +57,7 @@ if __name__<>"package": uid = 3 class Expression(unohelper.Base, XJobExecutor ): - def __init__(self,sExpression="",sName="", bFromModify=False): + def __init__(self, sExpression="", sName="", bFromModify=False): LoginTest() if not loginstatus and __name__=="package": exit(1) @@ -75,7 +75,7 @@ class Expression(unohelper.Base, XJobExecutor ): self.win.doModalDialog("",None) - def btnOk_clicked( self, oActionEvent ): + def btnOk_clicked(self, oActionEvent): desktop=getDesktop() doc = desktop.getCurrentComponent() text = doc.Text @@ -105,7 +105,7 @@ class Expression(unohelper.Base, XJobExecutor ): else: ErrorDialog("Please Fill appropriate data in Name field or \nExpression field") - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() if __name__<>"package" and __name__=="__main__": diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Fields.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Fields.py index 92044f78fe1..d480d683868 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Fields.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Fields.py @@ -64,7 +64,7 @@ if __name__<>"package": class Fields(unohelper.Base, XJobExecutor ): - def __init__(self,sVariable="",sFields="",sDisplayName="",bFromModify=False): + def __init__(self, sVariable="", sFields="", sDisplayName="", bFromModify=False): LoginTest() if not loginstatus and __name__=="package": exit(1) @@ -177,7 +177,7 @@ class Fields(unohelper.Base, XJobExecutor ): ErrorDialog("Please insert user define field Field-1 or Field-4","Just go to File->Properties->User Define \nField-1 Eg. http://localhost:8069 \nOR \nField-4 Eg. account.invoice") self.win.endExecute() - def lstbox_selected(self,oItemEvent): + def lstbox_selected(self, oItemEvent): try: desktop=getDesktop() @@ -200,7 +200,7 @@ class Fields(unohelper.Base, XJobExecutor ): if self.bModify: self.win.setEditText("txtUName",self.sGDisplayName) - def getRes(self,sock ,sObject,sVar): + def getRes(self, sock, sObject, sVar): desktop=getDesktop() doc =desktop.getCurrentComponent() docinfo=doc.getDocumentInfo() @@ -219,7 +219,7 @@ class Fields(unohelper.Base, XJobExecutor ): else: return sObject - def cmbVariable_selected(self,oItemEvent): + def cmbVariable_selected(self, oItemEvent): if self.count > 0 : try: desktop=getDesktop() @@ -246,7 +246,7 @@ class Fields(unohelper.Base, XJobExecutor ): info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) self.logobj.log_write('Fields', LOG_ERROR, info) - def btnOk_clicked( self, oActionEvent ): + def btnOk_clicked(self, oActionEvent): desktop=getDesktop() doc = desktop.getCurrentComponent() cursor = doc.getCurrentController().getViewCursor() @@ -281,7 +281,7 @@ class Fields(unohelper.Base, XJobExecutor ): else: ErrorDialog("Please Fill appropriate data in Name field \nor select perticular value from the list of fields") - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() if __name__<>"package" and __name__=="__main__": diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ModifyExistingReport.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ModifyExistingReport.py index 2ccd8358c97..d93dc3521e4 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ModifyExistingReport.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ModifyExistingReport.py @@ -66,7 +66,7 @@ if __name__<>'package': # class ModifyExistingReport(unohelper.Base, XJobExecutor): - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" @@ -178,10 +178,10 @@ class ModifyExistingReport(unohelper.Base, XJobExecutor): self.win.endExecute() - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() - def btnDelete_clicked( self, oActionEvent ): + def btnDelete_clicked(self, oActionEvent): desktop=getDesktop() doc = desktop.getCurrentComponent() docinfo=doc.getDocumentInfo() diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/NewReport.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/NewReport.py index 6022e44df7a..138c68b690e 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/NewReport.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/NewReport.py @@ -66,7 +66,7 @@ if __name__<>"package": # # class NewReport(unohelper.Base, XJobExecutor): - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" @@ -99,7 +99,7 @@ class NewReport(unohelper.Base, XJobExecutor): self.win.addButton('btnCancel',-2 - 70 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked ) self.win.doModalDialog("",None) - def btnOk_clicked(self,oActionEvent): + def btnOk_clicked(self, oActionEvent): desktop=getDesktop() doc = desktop.getCurrentComponent() docinfo=doc.getDocumentInfo() @@ -107,7 +107,7 @@ class NewReport(unohelper.Base, XJobExecutor): self.logobj.log_write('Module Name',LOG_INFO, ':Module use in creating a report %s using database %s' % (self.aModuleName[self.lstModule.getSelectedItemPos()], database)) self.win.endExecute() - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() if __name__<>"package" and __name__=="__main__": diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Repeatln.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Repeatln.py index 0eab6d1710c..50af718849e 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Repeatln.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Repeatln.py @@ -64,7 +64,7 @@ if __name__<>"package": #class RepeatIn: class RepeatIn( unohelper.Base, XJobExecutor ): - def __init__(self,sObject="",sVariable="",sFields="",sDisplayName="",bFromModify=False): + def __init__(self, sObject="", sVariable="", sFields="", sDisplayName="", bFromModify=False): # Interface Design LoginTest() self.logobj=Logger() @@ -204,7 +204,7 @@ class RepeatIn( unohelper.Base, XJobExecutor ): ErrorDialog("Please Select Appropriate module" ,"Create new report from: \nOpenERP -> Open a New Report") self.win.endExecute() - def lstbox_selected(self,oItemEvent): + def lstbox_selected(self, oItemEvent): sItem=self.win.getListBoxSelectedItem("lstFields") sMain=self.aListRepeatIn[self.win.getListBoxSelectedItemPos("lstFields")] @@ -215,7 +215,7 @@ class RepeatIn( unohelper.Base, XJobExecutor ): self.win.setEditText("txtName",sMain[sMain.rfind("/")+1:]) self.win.setEditText("txtUName","|-."+sItem[sItem.rfind("/")+1:]+".-|") - def cmbVariable_selected(self,oItemEvent): + def cmbVariable_selected(self, oItemEvent): if self.count > 0 : @@ -290,7 +290,7 @@ class RepeatIn( unohelper.Base, XJobExecutor ): else: ErrorDialog("Please Fill appropriate data in Object Field or Name field \nor select perticular value from the list of fields") - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() if __name__<>"package" and __name__=="__main__": diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/SendToServer.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/SendToServer.py index 3a6d799f8a5..dcc0aa6f632 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/SendToServer.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/SendToServer.py @@ -74,7 +74,7 @@ class SendtoServer(unohelper.Base, XJobExecutor): 'HTML' : 'html' } - def __init__(self,ctx): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" @@ -138,10 +138,10 @@ class SendtoServer(unohelper.Base, XJobExecutor): self.win.doModalDialog("lstResourceType", self.Kind.keys()[0]) - def lstbox_selected(self,oItemEvent): + def lstbox_selected(self, oItemEvent): pass - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() def btnOk_clicked(self, oActionEvent): @@ -223,7 +223,7 @@ class SendtoServer(unohelper.Base, XJobExecutor): id=self.sock.execute(database, uid, self.password, 'ir.actions.report.xml' ,'create', params) return id - def getInverseFieldsRecord(self,nVal): + def getInverseFieldsRecord(self, nVal): desktop=getDesktop() doc = desktop.getCurrentComponent() count=0 diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ServerParameter.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ServerParameter.py index 9b69e4a5c15..cb87d0fc5c7 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ServerParameter.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/ServerParameter.py @@ -59,7 +59,7 @@ if __name__<>"package": database="test" class ServerParameter( unohelper.Base, XJobExecutor ): - def __init__(self, aVal= None, sURL=""): + def __init__(self, aVal=None, sURL=""): self.module = "openerp_report" self.version = "0.1" desktop=getDesktop() @@ -116,7 +116,7 @@ class ServerParameter( unohelper.Base, XJobExecutor ): #self.win.doModalDialog("lstDatabase",docinfo.getUserFieldValue(2)) - def btnOk_clicked(self,oActionEvent): + def btnOk_clicked(self, oActionEvent): sLogin=self.win.getEditText("txtLoginName") sPassword=self.win.getEditText("txtPassword") @@ -158,10 +158,10 @@ class ServerParameter( unohelper.Base, XJobExecutor ): self.win.endExecute() - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() - def btnPrevious_clicked(self,oActionEvent): + def btnPrevious_clicked(self, oActionEvent): self.win.endExecute() Change(None) self.win.endExecute() diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Translation.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Translation.py index 73146f1b68a..576bc0c3134 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Translation.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/Translation.py @@ -61,7 +61,7 @@ if __name__<>"package": class AddLang(unohelper.Base, XJobExecutor ): - def __init__(self,sVariable="",sFields="",sDisplayName="",bFromModify=False): + def __init__(self, sVariable="", sFields="", sDisplayName="", bFromModify=False): LoginTest() if not loginstatus and __name__=="package": exit(1) @@ -157,7 +157,7 @@ class AddLang(unohelper.Base, XJobExecutor ): ErrorDialog("Please insert user define field Field-1 or Field-4","Just go to File->Properties->User Define \nField-1 Eg. http://localhost:8069 \nOR \nField-4 Eg. account.invoice") self.win.endExecute() - def lstbox_selected(self,oItemEvent): + def lstbox_selected(self, oItemEvent): try: desktop=getDesktop() @@ -183,7 +183,7 @@ class AddLang(unohelper.Base, XJobExecutor ): if self.bModify: self.win.setEditText("txtUName",self.sGDisplayName) - def getRes(self,sock ,sObject,sVar): + def getRes(self, sock, sObject, sVar): desktop=getDesktop() doc =desktop.getCurrentComponent() docinfo=doc.getDocumentInfo() @@ -203,7 +203,7 @@ class AddLang(unohelper.Base, XJobExecutor ): return sObject - def cmbVariable_selected(self,oItemEvent): + def cmbVariable_selected(self, oItemEvent): if self.count > 0 : try: desktop=getDesktop() @@ -229,7 +229,7 @@ class AddLang(unohelper.Base, XJobExecutor ): except: import traceback;traceback.print_exc() - def btnOk_clicked( self, oActionEvent ): + def btnOk_clicked(self, oActionEvent): self.bOkay = True desktop=getDesktop() doc = desktop.getCurrentComponent() @@ -263,7 +263,7 @@ class AddLang(unohelper.Base, XJobExecutor ): else: ErrorDialog("Please Fill appropriate data in Name field \nor select perticular value from the list of fields") - def btnCancel_clicked( self, oActionEvent ): + def btnCancel_clicked(self, oActionEvent): self.win.endExecute() diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/error.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/error.py index c0a3e5b5d63..cb86f5f429a 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/error.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/error.py @@ -48,7 +48,7 @@ if __name__<>"package": from gui import * class ErrorDialog: - def __init__(self,sErrorMsg, sErrorHelpMsg="",sTitle="Error Message"): + def __init__(self, sErrorMsg, sErrorHelpMsg="", sTitle="Error Message"): self.win = DBModalDialog(50, 50, 150, 90, sTitle) self.win.addFixedText("lblErrMsg", 5, 5, 190, 25, sErrorMsg) self.win.addFixedText("lblErrHelpMsg", 5, 30, 190, 25, sErrorHelpMsg) diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/functions.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/functions.py index 29f1cd87e46..1b614224147 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/functions.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/functions.py @@ -59,7 +59,13 @@ if __name__<>"package": database="test" uid = 1 -def genTree(object,aList,insField,host,level=3, ending=[], ending_excl=[], recur=[], root='', actualroot=""): +def genTree(object, aList, insField, host, level=3, ending=None, ending_excl=None, recur=None, root='', actualroot=""): + if ending is None: + ending = [] + if ending_excl is None: + ending_excl = [] + if recur is None: + recur = [] try: global url sock=RPCSession(url) @@ -79,7 +85,7 @@ def genTree(object,aList,insField,host,level=3, ending=[], ending_excl=[], recur info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) obj.log_write('Function', LOG_ERROR, info) -def VariableScope(oTcur,insVariable,aObjectList,aComponentAdd,aItemList,sTableName=""): +def VariableScope(oTcur, insVariable, aObjectList, aComponentAdd, aItemList, sTableName=""): if sTableName.find(".") != -1: for i in range(len(aItemList)): if aComponentAdd[i]==sTableName: @@ -96,7 +102,7 @@ def VariableScope(oTcur,insVariable,aObjectList,aComponentAdd,aItemList,sTableNa if aObjectList[j][:aObjectList[j].find("(")] == sLVal and sLVal!="": insVariable.append(aObjectList[j]) -def getList(aObjectList,host,count): +def getList(aObjectList, host, count): desktop=getDesktop() doc =desktop.getCurrentComponent() docinfo=doc.getDocumentInfo() @@ -128,7 +134,7 @@ def getList(aObjectList,host,count): else: aObjectList.append("List of " + docinfo.getUserFieldValue(3)) -def getRelation(sRelName, sItem, sObjName, aObjectList, host ): +def getRelation(sRelName, sItem, sObjName, aObjectList, host): global url sock=RPCSession(url) global passwd @@ -143,7 +149,7 @@ def getRelation(sRelName, sItem, sObjName, aObjectList, host ): getRelation(res[k]['relation'], sItem[sItem.find(".")+1:], sObjName,aObjectList,host) -def getPath(sPath,sMain): +def getPath(sPath, sMain): desktop=getDesktop() doc =desktop.getCurrentComponent() oParEnum = doc.getTextFields().createEnumeration() @@ -161,7 +167,7 @@ def getPath(sPath,sMain): getPath(sPath, sMain) return sPath -def EnumDocument(aItemList,aComponentAdd): +def EnumDocument(aItemList, aComponentAdd): desktop = getDesktop() parent="" bFlag = False @@ -183,7 +189,7 @@ def EnumDocument(aItemList,aComponentAdd): aItemList.append( templist ) aComponentAdd.append( parent ) -def getChildTable(oPar,aItemList,aComponentAdd,sTableName=""): +def getChildTable(oPar, aItemList, aComponentAdd, sTableName=""): sNames = oPar.getCellNames() bEmptyTableFlag=True for val in sNames: @@ -229,7 +235,7 @@ def getChildTable(oPar,aItemList,aComponentAdd,sTableName=""): aComponentAdd.append(sTableName+"."+oPar.Name) return 0 -def getRecersiveSection(oCurrentSection,aSectionList): +def getRecersiveSection(oCurrentSection, aSectionList): desktop=getDesktop() doc =desktop.getCurrentComponent() oParEnum=doc.getText().createEnumeration() diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py index 2aab8596862..b03c1360cad 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py @@ -39,7 +39,7 @@ def log_detail(self): logger.setLevel(logging.INFO) class Logger(object): - def log_write(self,name,level,msg): + def log_write(self, name, level, msg): log = logging.getLogger(name) getattr(log,level)(msg) diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/rpc.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/rpc.py index f7c7f636485..5d6f8ca6dbc 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/rpc.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/rpc.py @@ -52,7 +52,7 @@ class RPCGateway(object): class RPCSession(object): - def __init__(self,url): + def __init__(self, url): m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', url or '') @@ -152,7 +152,7 @@ class XMLRPCGateway(RPCGateway): return res - def execute(self, sDatabase,UID,sPassword,obj, method, *args): + def execute(self, sDatabase, UID, sPassword, obj, method, *args): global rpc_url sock = xmlrpclib.ServerProxy(rpc_url + 'object') diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/tools.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/tools.py index ef22a3a0d51..53dc81f5bc3 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/tools.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/tools.py @@ -21,19 +21,19 @@ ############################################################################## import urllib -def get_absolute_file_path( url ): +def get_absolute_file_path(url): url_unquoted = urllib.unquote(url) return os.name == 'nt' and url_unquoted[1:] or url_unquoted # This function reads the content of a file and return it to the caller -def read_data_from_file( filename ): +def read_data_from_file(filename): fp = file( filename, "rb" ) data = fp.read() fp.close() return data # This function writes the content to a file -def write_data_to_file( filename, data ): +def write_data_to_file(filename, data): fp = file( filename, 'wb' ) fp.write( data ) fp.close() diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/modify.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/modify.py index fc3d6672b79..41f00de7183 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/modify.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/modify.py @@ -61,7 +61,7 @@ if __name__<>"package": uid = 3 class modify(unohelper.Base, XJobExecutor ): - def __init__( self, ctx ): + def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" diff --git a/addons/base_report_designer/plugin/openerp_report_designer/test/test_fields.py b/addons/base_report_designer/plugin/openerp_report_designer/test/test_fields.py index 8954aa8d7a8..ac2b2fb2881 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/test/test_fields.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/test/test_fields.py @@ -10,7 +10,11 @@ import time sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object') -def get(object, level=3, ending=[], ending_excl=[], recur=[], root=''): +def get(object, level=3, ending=None, ending_excl=None, recur=None, root=''): + if ending is None: + ending = [] + if ending_excl is None: + ending_excl = [] res = sock.execute('terp', 3, 'admin', 'account.invoice', 'fields_get') key = res.keys() key.sort() diff --git a/addons/base_setup/base_setup.py b/addons/base_setup/base_setup.py index c10dee7b14b..3d624e9f33a 100644 --- a/addons/base_setup/base_setup.py +++ b/addons/base_setup/base_setup.py @@ -84,7 +84,7 @@ def _lang_get(self, cr, uid, context=None): res = [(r['code'], r['name']) for r in res] return res -def _tz_get(self,cr,uid, context=None): +def _tz_get(self, cr, uid, context=None): return [(x, x) for x in pytz.all_timezones] class user_preferences_config(osv.osv_memory): diff --git a/addons/base_synchro/base_synchro_obj.py b/addons/base_synchro/base_synchro_obj.py index 78df80591bc..f35275b3c44 100644 --- a/addons/base_synchro/base_synchro_obj.py +++ b/addons/base_synchro/base_synchro_obj.py @@ -65,10 +65,12 @@ class base_synchro_obj(osv.osv): # Return a list of changes: [ (date, id) ] # - def get_ids(self, cr, uid, object, dt, domain=[], context=None): - return self._get_ids(cr, uid, object, dt, domain, context=context) + def get_ids(self, cr, uid, object, dt, domain=None, context=None): + return self._get_ids(cr, uid, object, dt, domain=domain, context=context) - def _get_ids(self, cr, uid, object, dt, domain=[], context=None): + def _get_ids(self, cr, uid, object, dt, domain=None, context=None): + if domain is None: + domain = [] result = [] if dt: domain2 = domain+[('write_date','>=',dt)] diff --git a/addons/base_vat/__init__.py b/addons/base_vat/__init__.py index 1d7c143b7dc..2331d5661c1 100644 --- a/addons/base_vat/__init__.py +++ b/addons/base_vat/__init__.py @@ -22,4 +22,4 @@ import res_company import base_vat -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_vat/res_company.py b/addons/base_vat/res_company.py index e7641db9c68..1c63aa20f07 100644 --- a/addons/base_vat/res_company.py +++ b/addons/base_vat/res_company.py @@ -29,4 +29,4 @@ class res_company_vat (osv.osv): "rather than via a simple format validation (checksum)."), } - \ No newline at end of file + diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py index 71e9bdc2468..211fcd3da95 100644 --- a/addons/caldav/caldav_node.py +++ b/addons/caldav/caldav_node.py @@ -42,7 +42,7 @@ class node_calendar_collection(nodes.node_dir): DAV_M_NS = dict_merge2(nodes.node_dir.DAV_M_NS, { "http://calendarserver.org/ns/" : '_get_dav', } ) - def _file_get(self,cr, nodename=False): + def _file_get(self, cr, nodename=False): return [] def _child_get(self, cr, name=False, parent_id=False, domain=None): @@ -99,7 +99,7 @@ class node_calendar_res_col(nodes.node_res_obj): DAV_M_NS = dict_merge2(nodes.node_res_obj.DAV_M_NS, { "http://calendarserver.org/ns/" : '_get_dav', } ) - def _file_get(self,cr, nodename=False): + def _file_get(self, cr, nodename=False): return [] def _child_get(self, cr, name=False, parent_id=False, domain=None): @@ -180,7 +180,7 @@ class node_calendar(nodes.node_class): http_options = { 'DAV': ['calendar-access'] } - def __init__(self,path, parent, context, calendar): + def __init__(self, path, parent, context, calendar): super(node_calendar,self).__init__(path, parent,context) self.calendar_id = calendar.id self.mimetype = 'application/x-directory' @@ -271,7 +271,7 @@ class node_calendar(nodes.node_class): def children(self, cr, domain=None): return self._child_get(cr, domain=domain) - def child(self,cr, name, domain=None): + def child(self, cr, name, domain=None): res = self._child_get(cr, name, domain=domain) if res: return res[0] @@ -353,16 +353,16 @@ class node_calendar(nodes.node_class): return None - def set_data(self, cr, data, fil_obj = None): + def set_data(self, cr, data, fil_obj=None): uid = self.context.uid calendar_obj = self.context._dirobj.pool.get('basic.calendar') res = calendar_obj.import_cal(cr, uid, data, self.calendar_id) return res - def get_data_len(self, cr, fil_obj = None): + def get_data_len(self, cr, fil_obj=None): return self.content_length - def _get_ttag(self,cr): + def _get_ttag(self, cr): return 'calendar-%d' % (self.calendar_id,) def rmcol(self, cr): @@ -441,7 +441,7 @@ class res_node_calendar(nodes.node_class): http_options = { 'DAV': ['calendar-access'] } - def __init__(self,path, parent, context, res_obj, res_model=None, res_id=None): + def __init__(self, path, parent, context, res_obj, res_model=None, res_id=None): super(res_node_calendar,self).__init__(path, parent, context) self.mimetype = 'text/calendar' self.create_date = parent.create_date @@ -474,10 +474,10 @@ class res_node_calendar(nodes.node_class): def _get_caldav_calendar_data(self, cr): return self.get_data(cr) - def get_data_len(self, cr, fil_obj = None): + def get_data_len(self, cr, fil_obj=None): return self.content_length - def set_data(self, cr, data, fil_obj = None): + def set_data(self, cr, data, fil_obj=None): uid = self.context.uid context = self.context.context.copy() context.update(self.dctx) @@ -486,7 +486,7 @@ class res_node_calendar(nodes.node_class): res = calendar_obj.import_cal(cr, uid, data, self.calendar_id, context=context) return res - def _get_ttag(self,cr): + def _get_ttag(self, cr): res = False if self.model and self.res_id: res = '%s_%d' % (self.model, self.res_id) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 4ebb0b4796d..a12c1662c0f 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -331,7 +331,9 @@ class crm_case(crm_base): And object that inherit (orm inheritance) from a class the overwrite copy """ - def stage_find(self, cr, uid, section_id, domain=[], order='sequence'): + def stage_find(self, cr, uid, section_id, domain=None, order='sequence'): + if domain is None: + domain = [] domain = list(domain) if section_id: domain.append(('section_ids', '=', section_id)) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b17fa31ac91..a93ae8b4de2 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -239,7 +239,7 @@ class crm_lead(crm_case, osv.osv): def on_change_optout(self, cr, uid, ids, optout): return {'value':{'optout':optout,'optin':False}} - def onchange_stage_id(self, cr, uid, ids, stage_id, context={}): + def onchange_stage_id(self, cr, uid, ids, stage_id, context=None): if not stage_id: return {'value':{}} stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context) diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index fb6b8f90bda..1ee431cd77a 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -157,7 +157,7 @@ class crm_claim(crm.crm_case, osv.osv): self.write(cr, uid, [res_id], vals, context=context) return res_id - def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): + def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None): if isinstance(ids, (str, int, long)): ids = [ids] diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py index 97ed007f456..f60e0e112b3 100644 --- a/addons/crm_helpdesk/crm_helpdesk.py +++ b/addons/crm_helpdesk/crm_helpdesk.py @@ -112,7 +112,7 @@ class crm_helpdesk(crm.crm_case, osv.osv): self.write(cr, uid, [res_id], vals, context) return res_id - def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): + def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None): if isinstance(ids, (str, int, long)): ids = [ids] diff --git a/addons/crm_profiling/crm_profiling.py b/addons/crm_profiling/crm_profiling.py index 587ddbe0b52..83d19b14d97 100644 --- a/addons/crm_profiling/crm_profiling.py +++ b/addons/crm_profiling/crm_profiling.py @@ -77,7 +77,7 @@ def _get_parents(cr, uid, ids): return ids_to_check -def test_prof(cr, uid, seg_id, pid, answers_ids = []): +def test_prof(cr, uid, seg_id, pid, answers_ids=None): """ return True if the partner pid fetch the segmentation rule seg_id @param cr: the current row, from the database cursor, diff --git a/addons/delivery/wizard/delivery_sale_order.py b/addons/delivery/wizard/delivery_sale_order.py index 80b3431f2a7..a8339ce800a 100644 --- a/addons/delivery/wizard/delivery_sale_order.py +++ b/addons/delivery/wizard/delivery_sale_order.py @@ -44,7 +44,7 @@ class make_delivery(osv.osv_memory): return res - def view_init(self, cr , uid , fields, context=None): + def view_init(self, cr, uid, fields, context=None): if context is None: context = {} order_obj = self.pool.get('sale.order') diff --git a/addons/document/content_index.py b/addons/document/content_index.py index 64b480ee736..88767f7fed9 100644 --- a/addons/document/content_index.py +++ b/addons/document/content_index.py @@ -51,7 +51,7 @@ class indexer(object): return mts[0] return None - def indexContent(self, content, filename=None, realfile = None): + def indexContent(self, content, filename=None, realfile=None): """ Use either content or the real file, to index. Some parsers will work better with the actual content, others parse a file easier. Try the @@ -95,10 +95,10 @@ class indexer(object): raise NhException('No appropriate method to index file') - def _doIndexContent(self,content): + def _doIndexContent(self, content): raise NhException("Content not handled here") - def _doIndexFile(self,fpath): + def _doIndexFile(self, fpath): raise NhException("Content not handled here") def __repr__(self): @@ -136,7 +136,7 @@ class contentIndex(object): if not f: raise Exception("Your indexer should at least suport a mimetype or extension") - def doIndex(self, content, filename=None, content_type=None, realfname = None, debug=False): + def doIndex(self, content, filename=None, content_type=None, realfname=None, debug=False): fobj = None fname = None mime = None diff --git a/addons/document/document.py b/addons/document/document.py index 9ea7f97a321..5e95eee241c 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -146,7 +146,7 @@ class document_file(osv.osv): _sql_constraints = [ # filename_uniq is not possible in pure SQL ] - def _check_duplication(self, cr, uid, vals, ids=[], op='create'): + def _check_duplication(self, cr, uid, vals, ids=None, op='create'): name = vals.get('name', False) parent_id = vals.get('parent_id', False) res_model = vals.get('res_model', False) diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index d09d2cc86d5..33f1da1125b 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -69,7 +69,7 @@ class document_directory(osv.osv): } - def _get_root_directory(self, cr,uid, context=None): + def _get_root_directory(self, cr, uid, context=None): objid=self.pool.get('ir.model.data') try: mid = objid._get_id(cr, uid, 'document', 'dir_root') @@ -224,7 +224,7 @@ class document_directory(osv.osv): pass return res - def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): + def _locate_child(self, cr, uid, root_id, uri, nparent, ncontext): """ try to locate the node in uri, Return a tuple (node_dir, remaining_path) """ @@ -237,7 +237,7 @@ class document_directory(osv.osv): default.update({'name': name+ " (copy)"}) return super(document_directory,self).copy(cr, uid, id, default, context=context) - def _check_duplication(self, cr, uid, vals, ids=[], op='create'): + def _check_duplication(self, cr, uid, vals, ids=None, op='create'): name=vals.get('name',False) parent_id=vals.get('parent_id',False) ressource_parent_type_id=vals.get('ressource_parent_type_id',False) diff --git a/addons/document/nodes.py b/addons/document/nodes.py index ee89f3d4c6c..21e5029bd39 100644 --- a/addons/document/nodes.py +++ b/addons/document/nodes.py @@ -104,7 +104,7 @@ class node_context(object): def get(self, name, default=None): return self.context.get(name, default) - def get_uri(self, cr, uri): + def get_uri(self, cr, uri): """ Although this fn passes back to doc.dir, it is needed since it is a potential caching point. """ @@ -253,7 +253,7 @@ class node_class(object): print "node_class.children()" return [] #stub - def child(self,cr, name, domain=None): + def child(self, cr, name, domain=None): print "node_class.child()" return None @@ -271,7 +271,7 @@ class node_class(object): print "node_class.path_get()" return False - def get_data(self,cr): + def get_data(self, cr): raise TypeError('no data for %s'% self.type) def open_data(self, cr, mode): @@ -288,10 +288,10 @@ class node_class(object): """ raise TypeError('no data for %s' % self.type) - def _get_storage(self,cr): + def _get_storage(self, cr): raise RuntimeError("no storage for base class") - def get_etag(self,cr): + def get_etag(self, cr): """ Get a tag, unique per object + modification. see. http://tools.ietf.org/html/rfc2616#section-13.3.3 """ @@ -435,7 +435,9 @@ class node_database(node_class): """ our_type = 'database' - def __init__(self, path=[], parent=False, context=None): + def __init__(self, path=None, parent=False, context=None): + if path is None: + path = [] super(node_database,self).__init__(path, parent, context) self.unixperms = 040750 self.uidperms = 5 @@ -478,11 +480,11 @@ class node_database(node_class): return res - def _file_get(self,cr, nodename=False): + def _file_get(self, cr, nodename=False): res = [] return res - def _get_ttag(self,cr): + def _get_ttag(self, cr): return 'db-%s' % cr.dbname def mkdosname(company_name, default='noname'): @@ -694,7 +696,7 @@ class node_dir(node_database): fnode.set_data(cr, data, fil) return fnode - def _get_ttag(self,cr): + def _get_ttag(self, cr): return 'dir-%d' % self.dir_id def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): @@ -803,7 +805,7 @@ class node_res_dir(node_class): def children(self, cr, domain=None): return self._child_get(cr, domain=domain) - def child(self,cr, name, domain=None): + def child(self, cr, name, domain=None): res = self._child_get(cr, name, domain=domain) if res: return res[0] @@ -879,7 +881,7 @@ class node_res_dir(node_class): res.append(self.res_obj_class(res_name, self.dir_id, self, self.context, self.res_model, bo)) return res - def _get_ttag(self,cr): + def _get_ttag(self, cr): return 'rdir-%d' % self.dir_id class node_res_obj(node_class): @@ -890,7 +892,7 @@ class node_res_obj(node_class): node_dirs (with limited domain). """ our_type = 'collection' - def __init__(self, path, dir_id, parent, context, res_model, res_bo, res_id = None): + def __init__(self, path, dir_id, parent, context, res_model, res_bo, res_id=None): super(node_res_obj,self).__init__(path, parent,context) assert parent #todo: more info from dirr @@ -959,7 +961,7 @@ class node_res_obj(node_class): return res[0] return None - def _file_get(self,cr, nodename=False): + def _file_get(self, cr, nodename=False): res = [] is_allowed = self.check_perms((nodename and 1) or 5) if not is_allowed: @@ -1161,7 +1163,7 @@ class node_res_obj(node_class): fnode.set_data(cr, data, fil) return fnode - def _get_ttag(self,cr): + def _get_ttag(self, cr): return 'rodir-%d-%d' % (self.dir_id, self.res_id) node_res_dir.res_obj_class = node_res_obj @@ -1263,7 +1265,7 @@ class node_file(node_class): else: self.path = dirpath[0] - def get_data(self, cr, fil_obj = None): + def get_data(self, cr, fil_obj=None): """ Retrieve the data for some file. fil_obj may optionally be specified, and should be a browse object for the file. This is useful when the caller has already initiated @@ -1279,14 +1281,14 @@ class node_file(node_class): stobj = self.context._dirobj.pool.get('document.storage') return stobj.get_data(cr, self.context.uid,stor, self,self.context.context, fil_obj) - def get_data_len(self, cr, fil_obj = None): + def get_data_len(self, cr, fil_obj=None): # TODO: verify with the storage object! bin_size = self.context.context.get('bin_size', False) if bin_size and not self.content_length: self.content_length = fil_obj.db_datas return self.content_length - def set_data(self, cr, data, fil_obj = None): + def set_data(self, cr, data, fil_obj=None): """ Store data at some file. fil_obj may optionally be specified, and should be a browse object for the file. This is useful when the caller has already initiated @@ -1300,7 +1302,7 @@ class node_file(node_class): stobj = self.context._dirobj.pool.get('document.storage') return stobj.set_data(cr, self.context.uid,stor, self, data, self.context.context, fil_obj) - def _get_ttag(self,cr): + def _get_ttag(self, cr): return 'file-%d' % self.file_id def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): @@ -1363,7 +1365,7 @@ class node_file(node_class): class node_content(node_class): our_type = 'content' - def __init__(self, path, parent, context, cnt, dctx = None, act_id=None): + def __init__(self, path, parent, context, cnt, dctx=None, act_id=None): super(node_content,self).__init__(path, parent,context) self.cnt_id = cnt.id self.create_date = False @@ -1383,7 +1385,7 @@ class node_content(node_class): self.dctx.update(dctx) self.act_id = act_id - def fill_fields(self, cr, dctx = None): + def fill_fields(self, cr, dctx=None): """ Try to read the object and fill missing fields, like mimetype, dates etc. This function must be different from the constructor, because @@ -1397,7 +1399,7 @@ class node_content(node_class): self.mimetype = str(res[0][0]) - def get_data(self, cr, fil_obj = None): + def get_data(self, cr, fil_obj=None): cntobj = self.context._dirobj.pool.get('document.directory.content') if not self.check_perms(4): raise IOError(errno.EPERM, "Permission denied") @@ -1427,7 +1429,7 @@ class node_content(node_class): return nodefd_content(self, cr, mode, ctx) - def get_data_len(self, cr, fil_obj = None): + def get_data_len(self, cr, fil_obj=None): # FIXME : here, we actually generate the content twice!! # we should have cached the generated content, but it is # not advisable to do keep it in memory, until we have a cache @@ -1436,7 +1438,7 @@ class node_content(node_class): self.get_data(cr,fil_obj) return self.content_length - def set_data(self, cr, data, fil_obj = None): + def set_data(self, cr, data, fil_obj=None): cntobj = self.context._dirobj.pool.get('document.directory.content') if not self.check_perms(2): raise IOError(errno.EPERM, "Permission denied") @@ -1445,7 +1447,7 @@ class node_content(node_class): ctx.update(self.dctx) return cntobj.process_write(cr, self.context.uid, self, data, ctx) - def _get_ttag(self,cr): + def _get_ttag(self, cr): return 'cnt-%d%s' % (self.cnt_id,(self.act_id and ('-' + str(self.act_id))) or '') def get_dav_resourcetype(self, cr): diff --git a/addons/document/odt2txt.py b/addons/document/odt2txt.py old mode 100755 new mode 100644 index 9ca9b6e596f..8a3dc59d9ed --- a/addons/document/odt2txt.py +++ b/addons/document/odt2txt.py @@ -24,11 +24,11 @@ import sys, zipfile, xml.dom.minidom import StringIO class OpenDocumentTextFile : - def __init__ (self, filepath) : + def __init__ (self, filepath): zip = zipfile.ZipFile(filepath) self.content = xml.dom.minidom.parseString(zip.read("content.xml")) - def toString (self) : + def toString (self): """ Converts the document to a string. """ buffer = u"" for val in ["text:p", "text:h", "text:list"]: @@ -36,7 +36,7 @@ class OpenDocumentTextFile : buffer += self.textToString(paragraph) + "\n" return buffer - def textToString(self, element) : + def textToString(self, element): buffer = u"" for node in element.childNodes : if node.nodeType == xml.dom.Node.TEXT_NODE : diff --git a/addons/document/std_index.py b/addons/document/std_index.py index e153d018bf0..eb1da1a86e9 100644 --- a/addons/document/std_index.py +++ b/addons/document/std_index.py @@ -38,7 +38,7 @@ def _to_unicode(s): except UnicodeError: return s -def textToString(element) : +def textToString(element): buffer = u"" for node in element.childNodes : if node.nodeType == xml.dom.Node.TEXT_NODE : @@ -55,7 +55,7 @@ class TxtIndex(indexer): def _getExtensions(self): return ['.txt', '.py'] - def _doIndexContent(self,content): + def _doIndexContent(self, content): return content cntIndex.register(TxtIndex()) @@ -67,7 +67,7 @@ class PptxIndex(indexer): def _getExtensions(self): return ['.pptx'] - def _doIndexFile(self,fname): + def _doIndexFile(self, fname): def toString () : """ Converts the document to a string. """ buffer = u"" @@ -95,7 +95,7 @@ class DocIndex(indexer): def _getExtensions(self): return ['.doc'] - def _doIndexFile(self,fname): + def _doIndexFile(self, fname): try: pop = Popen(['antiword', fname], shell=False, stdout=PIPE) (data, _) = pop.communicate() @@ -115,7 +115,7 @@ class DocxIndex(indexer): def _getExtensions(self): return ['.docx'] - def _doIndexFile(self,fname): + def _doIndexFile(self, fname): zip = zipfile.ZipFile(fname) content = xml.dom.minidom.parseString(zip.read("word/document.xml")) def toString () : @@ -140,7 +140,7 @@ class XlsxIndex(indexer): def _getExtensions(self): return ['.xlsx'] - def _doIndexFile(self,fname): + def _doIndexFile(self, fname): zip = zipfile.ZipFile(fname) content = xml.dom.minidom.parseString(zip.read("xl/sharedStrings.xml")) def toString () : @@ -164,7 +164,7 @@ class PdfIndex(indexer): def _getExtensions(self): return ['.pdf'] - def _doIndexFile(self,fname): + def _doIndexFile(self, fname): pop = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE) (data, _) = pop.communicate() return _to_unicode(data) @@ -180,7 +180,7 @@ class ImageNoIndex(indexer): return [] #return ['.png','.jpg','.gif','.jpeg','.bmp','.tiff'] - def _doIndexContent(self,content): + def _doIndexContent(self, content): return 'image' diff --git a/addons/document_webdav/document_webdav.py b/addons/document_webdav/document_webdav.py index da463c9eb1b..0cc4c919ff2 100644 --- a/addons/document_webdav/document_webdav.py +++ b/addons/document_webdav/document_webdav.py @@ -57,7 +57,7 @@ class document_davdir(osv.osv): # TODO group return - def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): + def _locate_child(self, cr, uid, root_id, uri, nparent, ncontext): """ try to locate the node in uri, Return a tuple (node_dir, remaining_path) """ diff --git a/addons/document_webdav/redirect.py b/addons/document_webdav/redirect.py index 7bc0883f9e8..7f419fadf52 100644 --- a/addons/document_webdav/redirect.py +++ b/addons/document_webdav/redirect.py @@ -30,7 +30,7 @@ class RedirectHTTPHandler(HttpLogHandler, FixSendError, HttpOptions, HTTPHandler _HTTP_OPTIONS = { 'Allow': ['OPTIONS', 'GET', 'HEAD', 'PROPFIND'] } redirect_paths = {} - def __init__(self,request, client_address, server): + def __init__(self, request, client_address, server): HTTPHandler.__init__(self,request,client_address,server) def send_head(self): diff --git a/addons/document_webdav/test_davclient.py b/addons/document_webdav/test_davclient.py old mode 100755 new mode 100644 index 3c20cfed5b8..306a058c574 --- a/addons/document_webdav/test_davclient.py +++ b/addons/document_webdav/test_davclient.py @@ -682,7 +682,7 @@ class DAVClient(object): assert d2 == d, "Data does not match" return ctype, rrange, d - def gd_put(self, path, body=None, srcpath=None, mime=None, noclobber=False, ): + def gd_put(self, path, body=None, srcpath=None, mime=None, noclobber=False): """ HTTP PUT @param noclobber will prevent overwritting a resource (If-None-Match) @param mime will set the content-type diff --git a/addons/document_webdav/webdav.py b/addons/document_webdav/webdav.py index baa394e94a1..8ad1932a317 100644 --- a/addons/document_webdav/webdav.py +++ b/addons/document_webdav/webdav.py @@ -236,7 +236,7 @@ def mk_prop_response(self, uri, good_props, bad_props, doc): return re -def mk_propname_response(self,uri,propnames,doc): +def mk_propname_response(self, uri, propnames, doc): """ make a new result element for a PROPNAME request This will simply format the propnames list. diff --git a/addons/document_webdav/webdav_server.py b/addons/document_webdav/webdav_server.py index ae75d0b80fc..5218f55b396 100644 --- a/addons/document_webdav/webdav_server.py +++ b/addons/document_webdav/webdav_server.py @@ -81,7 +81,7 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler): 'DELETE', 'TRACE', 'REPORT', ] } - def get_userinfo(self,user,pw): + def get_userinfo(self, user, pw): return False def _log(self, message): @@ -167,7 +167,7 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler): self.close_connection = 1 DAVRequestHandler.send_header(self, key, value) - def send_body(self, DATA, code = None, msg = None, desc = None, ctype='application/octet-stream', headers=None): + def send_body(self, DATA, code=None, msg=None, desc=None, ctype='application/octet-stream', headers=None): if headers and 'Connection' in headers: pass elif self.request_version in ('HTTP/1.0', 'HTTP/0.9'): @@ -441,10 +441,10 @@ class dummy_dav_interface(object): def __init__(self, parent): self.parent = parent - def get_propnames(self,uri): + def get_propnames(self, uri): return self.PROPS - def get_prop(self,uri,ns,propname): + def get_prop(self, uri, ns, propname): if self.M_NS.has_key(ns): prefix=self.M_NS[ns] else: @@ -460,10 +460,10 @@ class dummy_dav_interface(object): def get_data(self, uri, range=None): raise DAV_NotFound - def _get_dav_creationdate(self,uri): + def _get_dav_creationdate(self, uri): return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) - def _get_dav_getlastmodified(self,uri): + def _get_dav_getlastmodified(self, uri): return time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()) def _get_dav_displayname(self, uri): diff --git a/addons/email_template/html2text.py b/addons/email_template/html2text.py old mode 100755 new mode 100644 index 745381850e3..9cb3a3fe5ac --- a/addons/email_template/html2text.py +++ b/addons/email_template/html2text.py @@ -158,7 +158,7 @@ class _html2text(sgmllib.SGMLParser): self.abbr_list = {} # stack of abbreviations to write later self.baseurl = baseurl - def outtextf(self, s): + def outtextf(self, s): self.outtext += s def close(self): @@ -338,7 +338,7 @@ class _html2text(sgmllib.SGMLParser): def pbr(self): if self.p_p == 0: self.p_p = 1 - def p(self): self.p_p = 2 + def p(self): def o(self, data, puredata=0, force=0): if self.abbr_data is not None: self.abbr_data += data @@ -411,7 +411,8 @@ class _html2text(sgmllib.SGMLParser): if r'\/script>' in data: self.quiet -= 1 self.o(data, 1) - def unknown_decl(self, data): pass + def unknown_decl(self, data): + pass def wrapwrite(text): sys.stdout.write(text.encode('utf8')) diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index ef4572429a1..0338c22870c 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -27,7 +27,7 @@ from tools.translate import _ import tools -def _reopen(self,res_id,model): +def _reopen(self, res_id, model): return {'type': 'ir.actions.act_window', 'view_mode': 'form', 'view_type': 'form', diff --git a/addons/event/event.py b/addons/event/event.py index 133d29281f1..a66c73dc909 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -66,7 +66,7 @@ class event_event(osv.osv): res.append((record['id'], name)) return res - def _name_get_fnc(self, cr, uid, ids,prop,unknow, context=None): + def _name_get_fnc(self, cr, uid, ids, prop, unknow, context=None): res = self.name_get(cr, uid, ids, context=context) return dict(res) diff --git a/addons/event/report/__init__.py b/addons/event/report/__init__.py index 1c60e2715df..4f2516e5615 100644 --- a/addons/event/report/__init__.py +++ b/addons/event/report/__init__.py @@ -21,4 +21,4 @@ import report_event_registration -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event/res_partner.py b/addons/event/res_partner.py index 1d5582f7929..3952f2f82b6 100644 --- a/addons/event/res_partner.py +++ b/addons/event/res_partner.py @@ -32,4 +32,4 @@ class res_partner(osv.osv): res_partner() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event/wizard/event_confirm.py b/addons/event/wizard/event_confirm.py index e21d523bb12..e001aac9937 100644 --- a/addons/event/wizard/event_confirm.py +++ b/addons/event/wizard/event_confirm.py @@ -34,4 +34,4 @@ class event_confirm(osv.osv_memory): event_confirm() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event_moodle/event_moodle.py b/addons/event_moodle/event_moodle.py index 59d3e530b44..8ae59ae8faa 100644 --- a/addons/event_moodle/event_moodle.py +++ b/addons/event_moodle/event_moodle.py @@ -125,7 +125,7 @@ class event_moodle(osv.osv): passwd = passwd + '+' return passwd - def check_email(self,email): + def check_email(self, email): """ check if email is correct diff --git a/addons/event_project/event_project.py b/addons/event_project/event_project.py index 8590b84c4ad..34892b56f39 100644 --- a/addons/event_project/event_project.py +++ b/addons/event_project/event_project.py @@ -55,4 +55,4 @@ class event(osv.osv): event() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event_project/wizard/event_project_retro.py b/addons/event_project/wizard/event_project_retro.py index c7eba5e0ec1..a794749701b 100644 --- a/addons/event_project/wizard/event_project_retro.py +++ b/addons/event_project/wizard/event_project_retro.py @@ -80,4 +80,4 @@ class event_project(osv.osv_memory): event_project() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_attendance/wizard/__init__.py b/addons/hr_attendance/wizard/__init__.py index a414c9a8798..98944cc9fff 100644 --- a/addons/hr_attendance/wizard/__init__.py +++ b/addons/hr_attendance/wizard/__init__.py @@ -24,4 +24,4 @@ import hr_attendance_error import hr_attendance_byweek import hr_attendance_bymonth -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_attendance/wizard/hr_attendance_bymonth.py b/addons/hr_attendance/wizard/hr_attendance_bymonth.py index 40dca536d7d..03e1db5dc3a 100644 --- a/addons/hr_attendance/wizard/hr_attendance_bymonth.py +++ b/addons/hr_attendance/wizard/hr_attendance_bymonth.py @@ -50,4 +50,4 @@ class hr_attendance_bymonth(osv.osv_memory): hr_attendance_bymonth() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_attendance/wizard/hr_attendance_byweek.py b/addons/hr_attendance/wizard/hr_attendance_byweek.py index 139ff94cd5a..9ee69a937d1 100644 --- a/addons/hr_attendance/wizard/hr_attendance_byweek.py +++ b/addons/hr_attendance/wizard/hr_attendance_byweek.py @@ -48,4 +48,4 @@ class hr_attendance_byweek(osv.osv_memory): hr_attendance_byweek() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_attendance/wizard/hr_attendance_error.py b/addons/hr_attendance/wizard/hr_attendance_error.py index bb181268195..a3e3f63aa27 100644 --- a/addons/hr_attendance/wizard/hr_attendance_error.py +++ b/addons/hr_attendance/wizard/hr_attendance_error.py @@ -66,4 +66,4 @@ class hr_attendance_error(osv.osv_memory): hr_attendance_error() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 6e1983d7a11..ecca6714cbd 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -244,7 +244,7 @@ class hr_evaluation(osv.osv): raise osv.except_osv(_('Warning !'),_("You cannot change state, because some appraisal in waiting answer or draft state")) return True - def button_done(self,cr, uid, ids, context=None): + def button_done(self, cr, uid, ids, context=None): self.write(cr, uid, ids,{'progress': 1 * 100}, context=context) self.write(cr, uid, ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')}, context=context) return True diff --git a/addons/hr_payroll/report/report_contribution_register.py b/addons/hr_payroll/report/report_contribution_register.py index e32e93532b5..c0285f3de50 100644 --- a/addons/hr_payroll/report/report_contribution_register.py +++ b/addons/hr_payroll/report/report_contribution_register.py @@ -72,4 +72,4 @@ class contribution_register_report(report_sxw.rml_parse): report_sxw.report_sxw('report.contribution.register.lines', 'hr.contribution.register', 'hr_payroll/report/report_contribution_register.rml', parser=contribution_register_report) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/report/report_payslip.py b/addons/hr_payroll/report/report_payslip.py index e2ef7dab974..df4c729b298 100644 --- a/addons/hr_payroll/report/report_payslip.py +++ b/addons/hr_payroll/report/report_payslip.py @@ -46,4 +46,4 @@ class payslip_report(report_sxw.rml_parse): report_sxw.report_sxw('report.payslip', 'hr.payslip', 'hr_payroll/report/report_payslip.rml', parser=payslip_report) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/report/report_payslip_details.py b/addons/hr_payroll/report/report_payslip_details.py index 1e9839eaa6f..5a110cbfdcd 100644 --- a/addons/hr_payroll/report/report_payslip_details.py +++ b/addons/hr_payroll/report/report_payslip_details.py @@ -116,4 +116,4 @@ class payslip_details_report(report_sxw.rml_parse): report_sxw.report_sxw('report.paylip.details', 'hr.payslip', 'hr_payroll/report/report_payslip_details.rml', parser=payslip_details_report) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll_account/__init__.py b/addons/hr_payroll_account/__init__.py index ffe4b707ac0..ceb8531473b 100644 --- a/addons/hr_payroll_account/__init__.py +++ b/addons/hr_payroll_account/__init__.py @@ -23,4 +23,4 @@ import hr_payroll_account import wizard -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll_account/wizard/__init__.py b/addons/hr_payroll_account/wizard/__init__.py index 27128f05597..ee460faefb8 100644 --- a/addons/hr_payroll_account/wizard/__init__.py +++ b/addons/hr_payroll_account/wizard/__init__.py @@ -22,4 +22,4 @@ import hr_payroll_payslips_by_employees -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py b/addons/hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py index a00ff97ef6b..f608b88fece 100644 --- a/addons/hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py +++ b/addons/hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py @@ -37,4 +37,4 @@ class hr_payslip_employees(osv.osv_memory): hr_payslip_employees() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 68855b79d7d..e4328589676 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -213,7 +213,7 @@ class hr_applicant(crm.crm_case, osv.osv): } - def onchange_job(self,cr, uid, ids, job, context=None): + def onchange_job(self, cr, uid, ids, job, context=None): result = {} if job: diff --git a/addons/hr_recruitment/wizard/hr_recruitment_create_partner_job.py b/addons/hr_recruitment/wizard/hr_recruitment_create_partner_job.py index dd1667aecef..0015de25aee 100644 --- a/addons/hr_recruitment/wizard/hr_recruitment_create_partner_job.py +++ b/addons/hr_recruitment/wizard/hr_recruitment_create_partner_job.py @@ -29,7 +29,7 @@ class hr_recruitment_partner_create(osv.osv_memory): 'close': fields.boolean('Close job request'), } - def view_init(self, cr , uid , fields_list, context=None): + def view_init(self, cr, uid, fields_list, context=None): case_obj = self.pool.get('hr.applicant') if context is None: context = {} @@ -88,4 +88,4 @@ class hr_recruitment_partner_create(osv.osv_memory): hr_recruitment_partner_create() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py b/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py index 291c16a7644..0b57082c019 100644 --- a/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py +++ b/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py @@ -26,7 +26,7 @@ class hired_employee(osv.osv_memory): _name = 'hired.employee' _description = 'Create Employee' - def case_close(self, cr, uid,ids, context=None): + def case_close(self, cr, uid, ids, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @@ -39,7 +39,7 @@ class hired_employee(osv.osv_memory): self.pool.get('hr.applicant').case_close(cr, uid,context.get('active_ids',[])) return {} - def case_close_with_emp(self, cr, uid,ids, context=None): + def case_close_with_emp(self, cr, uid, ids, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 11b7bb771fa..74b4375da6f 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -77,7 +77,7 @@ class account_analytic_account(osv.osv): _defaults = { 'pricelist_id': lambda self, cr, uid, ctx: ctx.get('pricelist_id', False), } - def on_change_partner_id(self, cr, uid, id, partner_id, context={}): + def on_change_partner_id(self, cr, uid, id, partner_id, context=None): res = super(account_analytic_account, self).on_change_partner_id(cr, uid, id, partner_id, context) if (not res.get('value', False)) or not partner_id: return res diff --git a/addons/hr_timesheet_invoice/report/account_analytic_profit.py b/addons/hr_timesheet_invoice/report/account_analytic_profit.py index 8b6cd7f9fbd..fc44089bf9e 100644 --- a/addons/hr_timesheet_invoice/report/account_analytic_profit.py +++ b/addons/hr_timesheet_invoice/report/account_analytic_profit.py @@ -120,4 +120,4 @@ class account_analytic_profit(report_sxw.rml_parse): report_sxw.report_sxw('report.account.analytic.profit', 'account.analytic.line', 'addons/hr_timesheet_invoice/report/account_analytic_profit.rml', parser=account_analytic_profit) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py index 134bde8a872..b5b31b7b74c 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -38,7 +38,7 @@ class account_analytic_line(osv.osv): # 'price': boolean # 'product': many2one id # } - def invoice_cost_create(self, cr, uid, ids, data={}, context=None): + def invoice_cost_create(self, cr, uid, ids, data=None, context=None): analytic_account_obj = self.pool.get('account.analytic.account') res_partner_obj = self.pool.get('res.partner') account_payment_term_obj = self.pool.get('account.payment.term') diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index f18adbadbf8..fc4133dec87 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -374,7 +374,7 @@ class hr_timesheet_sheet(osv.osv): 'department_id':fields.many2one('hr.department','Department'), } - def _default_date_from(self,cr, uid, context=None): + def _default_date_from(self, cr, uid, context=None): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) r = user.company_id and user.company_id.timesheet_range or 'month' if r=='month': @@ -385,7 +385,7 @@ class hr_timesheet_sheet(osv.osv): return time.strftime('%Y-01-01') return time.strftime('%Y-%m-%d') - def _default_date_to(self,cr, uid, context=None): + def _default_date_to(self, cr, uid, context=None): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) r = user.company_id and user.company_id.timesheet_range or 'month' if r=='month': diff --git a/addons/hr_timesheet_sheet/wizard/hr_timesheet_current.py b/addons/hr_timesheet_sheet/wizard/hr_timesheet_current.py index 5a8fa2c59b3..69e38f90fc5 100644 --- a/addons/hr_timesheet_sheet/wizard/hr_timesheet_current.py +++ b/addons/hr_timesheet_sheet/wizard/hr_timesheet_current.py @@ -61,4 +61,4 @@ class hr_timesheet_current_open(osv.osv_memory): hr_timesheet_current_open() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/idea/idea.py b/addons/idea/idea.py index 57b7c84351c..3c9b70c1a8d 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -234,7 +234,7 @@ class idea_idea(osv.osv): res_id = super(idea_idea, self).create(cr, user, vals, context=context) return res_id - def copy(self, cr, uid, id, default={}, context=None): + def copy(self, cr, uid, id, default=None, context=None): """ Create the new record in idea_idea model from existing one @param cr: A database cursor diff --git a/addons/import_base/import_framework.py b/addons/import_base/import_framework.py index 44243aa952c..c4038b6c582 100644 --- a/addons/import_base/import_framework.py +++ b/addons/import_base/import_framework.py @@ -228,7 +228,7 @@ class import_framework(Thread): return map - def _fields_mapp(self,dict_sugar, openerp_dict, table): + def _fields_mapp(self, dict_sugar, openerp_dict, table): """ call all the mapper and transform data to be compatible with import_data diff --git a/addons/import_sugarcrm/import_sugarcrm.py b/addons/import_sugarcrm/import_sugarcrm.py index d6e43866bf2..af5ea6d9b62 100644 --- a/addons/import_sugarcrm/import_sugarcrm.py +++ b/addons/import_sugarcrm/import_sugarcrm.py @@ -253,7 +253,7 @@ class sugar_import(import_framework): val['datas_fname'] = Filename return val - def get_history_mapping(self): + def get_history_mapping(self): return { 'model' : 'ir.attachment', 'dependencies' : [self.TABLE_USER, self.TABLE_ACCOUNT, self.TABLE_CONTACT, self.TABLE_LEAD, self.TABLE_OPPORTUNITY, self.TABLE_MEETING, self.TABLE_CALL, self.TABLE_EMAIL], @@ -301,7 +301,7 @@ class sugar_import(import_framework): val['email_from'] = partner_email return val - def get_crm_claim_mapping(self): + def get_crm_claim_mapping(self): return { 'model' : 'crm.claim', 'dependencies' : [self.TABLE_USER, self.TABLE_ACCOUNT, self.TABLE_CONTACT, self.TABLE_LEAD], @@ -604,7 +604,7 @@ class sugar_import(import_framework): partner_contact_email = address.email return partner_contact_id, partner_contact_email - def import_opp(self, val): + def import_opp(self, val): partner_contact_id, partner_contact_email = self.import_opportunity_contact(val) val['partner_address_id/id'] = partner_contact_id val['email_from'] = partner_contact_email diff --git a/addons/l10n_be/__init__.py b/addons/l10n_be/__init__.py index 1b2677d295e..0aeeb2be23b 100644 --- a/addons/l10n_be/__init__.py +++ b/addons/l10n_be/__init__.py @@ -22,4 +22,4 @@ import company import wizard -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_be_invoice_bba/invoice.py b/addons/l10n_be_invoice_bba/invoice.py index 997036c0cec..da2545669ad 100644 --- a/addons/l10n_be_invoice_bba/invoice.py +++ b/addons/l10n_be_invoice_bba/invoice.py @@ -35,7 +35,7 @@ account.invoice object: class account_invoice(osv.osv): _inherit = 'account.invoice' - def _get_reference_type(self, cursor, user, context=None): + def _get_reference_type(self, cursor, user, context=None): """Add BBA Structured Communication Type and change labels from 'reference' into 'communication' """ res = super(account_invoice, self)._get_reference_type(cursor, user, context=context) @@ -44,7 +44,7 @@ class account_invoice(osv.osv): #logger.notifyChannel('addons.'+self._name, netsvc.LOG_WARNING, 'reference_type = %s' %res ) return res - def check_bbacomm(self, val): + def check_bbacomm(self, val): supported_chars = '0-9+*/ ' pattern = re.compile('[^' + supported_chars + ']') if pattern.findall(val or ''): @@ -57,7 +57,7 @@ class account_invoice(osv.osv): return True return False - def _check_communication(self, cr, uid, ids): + def _check_communication(self, cr, uid, ids): for inv in self.browse(cr, uid, ids): if inv.reference_type == 'bba': return self.check_bbacomm(inv.reference) @@ -86,7 +86,7 @@ class account_invoice(osv.osv): result['value'].update(res_update) return result - def generate_bbacomm(self, cr, uid, ids, type, reference_type, algorithm, partner_id, reference): + def generate_bbacomm(self, cr, uid, ids, type, reference_type, algorithm, partner_id, reference): partner_obj = self.pool.get('res.partner') reference = reference or '' if (type == 'out_invoice'): @@ -157,7 +157,7 @@ class account_invoice(osv.osv): "\nPlease contact your OpenERP support channel.") % algorithm) return {'value': {'reference': reference}} - def create(self, cr, uid, vals, context=None): + def create(self, cr, uid, vals, context=None): if vals.has_key('reference_type'): reference_type = vals['reference_type'] if reference_type == 'bba': @@ -179,7 +179,7 @@ class account_invoice(osv.osv): '\nPlease create manually a unique BBA Structured Communication.')) return super(account_invoice, self).create(cr, uid, vals, context=context) - def write(self, cr, uid, ids, vals, context={}): + def write(self, cr, uid, ids, vals, context=None): if isinstance(ids, (int, long)): ids = [ids] for inv in self.browse(cr, uid, ids, context): diff --git a/addons/l10n_br/l10n_br.py b/addons/l10n_br/l10n_br.py index af387334cd1..f35ced7ea09 100644 --- a/addons/l10n_br/l10n_br.py +++ b/addons/l10n_br/l10n_br.py @@ -81,4 +81,4 @@ class l10n_br_account_cst(osv.osv): l10n_br_account_cst() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_ch/partner.py b/addons/l10n_ch/partner.py index 9301c564227..aba9ea7b204 100644 --- a/addons/l10n_ch/partner.py +++ b/addons/l10n_ch/partner.py @@ -30,4 +30,4 @@ class res_partner(osv.osv): } res_partner() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_ch/payment.py b/addons/l10n_ch/payment.py index aba757502b0..a681daf569d 100644 --- a/addons/l10n_ch/payment.py +++ b/addons/l10n_ch/payment.py @@ -24,7 +24,7 @@ from osv import osv class payment_order(osv.osv): _inherit = 'payment.order' - def get_wizard(self,mode): + def get_wizard(self, mode): if mode == 'dta': return 'l10n_ch', 'action_dta_create' diff --git a/addons/l10n_ch/report/report_webkit_html.py b/addons/l10n_ch/report/report_webkit_html.py index d930258f4a7..7f6bc739e6b 100644 --- a/addons/l10n_ch/report/report_webkit_html.py +++ b/addons/l10n_ch/report/report_webkit_html.py @@ -67,7 +67,7 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse): self._check(ids) return super(l10n_ch_report_webkit_html, self).set_context(objects, data, ids, report_type=report_type) - def police_absolute_path(self, inner_path) : + def police_absolute_path(self, inner_path): """Will get the ocrb police absolute path""" path = addons.get_module_resource(os.path.join('l10n_ch', 'report', inner_path)) return path diff --git a/addons/l10n_ch/wizard/create_dta.py b/addons/l10n_ch/wizard/create_dta.py index e9b0585d4c8..a94ac70afde 100644 --- a/addons/l10n_ch/wizard/create_dta.py +++ b/addons/l10n_ch/wizard/create_dta.py @@ -41,7 +41,7 @@ TRANS=[ (u'ä','a'), ] -def _u2a(text) : +def _u2a(text): """Tries to convert unicode charactere to asci equivalence""" if not text : return "" txt = "" diff --git a/addons/l10n_fr/l10n_fr.py b/addons/l10n_fr/l10n_fr.py index 573f4f7519e..8cf237d03f0 100644 --- a/addons/l10n_fr/l10n_fr.py +++ b/addons/l10n_fr/l10n_fr.py @@ -51,4 +51,4 @@ class l10n_fr_line(osv.osv): l10n_fr_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_fr/report/base_report.py b/addons/l10n_fr/report/base_report.py index 2c44b062f45..c93d5308901 100644 --- a/addons/l10n_fr/report/base_report.py +++ b/addons/l10n_fr/report/base_report.py @@ -117,4 +117,4 @@ class base_report(report_sxw.rml_parse): break self._set_variable(code, sum) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_fr/wizard/fr_report_bilan.py b/addons/l10n_fr/wizard/fr_report_bilan.py index cec2e513a6a..1ed2389671d 100644 --- a/addons/l10n_fr/wizard/fr_report_bilan.py +++ b/addons/l10n_fr/wizard/fr_report_bilan.py @@ -54,4 +54,4 @@ class account_bilan_report(osv.osv_memory): account_bilan_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_fr/wizard/fr_report_compute_resultant.py b/addons/l10n_fr/wizard/fr_report_compute_resultant.py index d90466ea6c4..b29789bdd04 100644 --- a/addons/l10n_fr/wizard/fr_report_compute_resultant.py +++ b/addons/l10n_fr/wizard/fr_report_compute_resultant.py @@ -54,4 +54,4 @@ class account_cdr_report(osv.osv_memory): account_cdr_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_lu/wizard/pdf_ext.py b/addons/l10n_lu/wizard/pdf_ext.py index 3b58fab5b68..e90cf0527d2 100644 --- a/addons/l10n_lu/wizard/pdf_ext.py +++ b/addons/l10n_lu/wizard/pdf_ext.py @@ -57,7 +57,7 @@ trailer %%EOF """ -def output_field( f ): +def output_field(f): return "\xfe\xff" + "".join( [ "\x00"+c for c in f ] ) def extract_keys(lines): diff --git a/addons/lunch/report/order.py b/addons/lunch/report/order.py index 11ca7f79dbc..b1745f7d5f5 100644 --- a/addons/lunch/report/order.py +++ b/addons/lunch/report/order.py @@ -26,14 +26,14 @@ from osv import osv class order(report_sxw.rml_parse): - def get_lines(self, user,objects): + def get_lines(self, user, objects): lines=[] for obj in objects: if user.id==obj.user_id.id: lines.append(obj) return lines - def get_total(self, user,objects): + def get_total(self, user, objects): lines=[] for obj in objects: if user.id==obj.user_id.id: diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 70b536296bf..cbd165a772d 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -134,7 +134,7 @@ class mail_thread(osv.osv): self.message_append_dict(cr, uid, [res_id], msg_dict, context=context) return res_id - def message_update(self, cr, uid, ids, msg_dict, vals={}, default_act=None, context=None): + def message_update(self, cr, uid, ids, msg_dict, vals=None, default_act=None, context=None): """Called by ``message_process`` when a new message is received for an existing thread. The default behavior is to create a new mail.message in the given thread (by calling diff --git a/addons/mail/static/scripts/openerp_mailgate.py b/addons/mail/static/scripts/openerp_mailgate.py old mode 100755 new mode 100644 diff --git a/addons/membership/report/__init__.py b/addons/membership/report/__init__.py index 05c893ae400..84dc92c63f0 100644 --- a/addons/membership/report/__init__.py +++ b/addons/membership/report/__init__.py @@ -20,4 +20,4 @@ ############################################################################## import report_membership -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/membership/report/report_membership.py b/addons/membership/report/report_membership.py index 631acab46b1..ef7b790aeca 100644 --- a/addons/membership/report/report_membership.py +++ b/addons/membership/report/report_membership.py @@ -141,4 +141,4 @@ class report_membership(osv.osv): report_membership() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/membership/wizard/__init__.py b/addons/membership/wizard/__init__.py index 7ad7cc32008..a15a0a7329f 100644 --- a/addons/membership/wizard/__init__.py +++ b/addons/membership/wizard/__init__.py @@ -20,4 +20,4 @@ ############################################################################## import membership_invoice -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 8a25af01e7b..a6f58833df0 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -271,13 +271,15 @@ class mrp_bom(osv.osv): return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}} return {} - def _bom_find(self, cr, uid, product_id, product_uom, properties=[]): + def _bom_find(self, cr, uid, product_id, product_uom, properties=None): """ Finds BoM for particular product and product uom. @param product_id: Selected product. @param product_uom: Unit of measure of a product. @param properties: List of related properties. @return: False or BoM id. """ + if properties is None: + properties = [] cr.execute('select id from mrp_bom where product_id=%s and bom_id is null order by sequence', (product_id,)) ids = map(lambda x: x[0], cr.fetchall()) max_prop = 0 @@ -292,7 +294,7 @@ class mrp_bom(osv.osv): max_prop = prop return result - def _bom_explode(self, cr, uid, bom, factor, properties=[], addthis=False, level=0, routing_id=False): + def _bom_explode(self, cr, uid, bom, factor, properties=None, addthis=False, level=0, routing_id=False): """ Finds Products and Work Centers for related BoM for manufacturing order. @param bom: BoM of particular product. @param factor: Factor of product UoM. @@ -577,7 +579,7 @@ class mrp_production(osv.osv): self.write(cr, uid, ids, {'state': 'picking_except'}) return True - def action_compute(self, cr, uid, ids, properties=[], context=None): + def action_compute(self, cr, uid, ids, properties=None, context=None): """ Computes bills of material of a product. @param properties: List containing dictionaries of properties. @return: No. of products. diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 4086a401f56..6e523f7592b 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -33,7 +33,7 @@ class procurement_order(osv.osv): 'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'), } - def check_produce_product(self, cr, uid, procurement, context=[]): + def check_produce_product(self, cr, uid, procurement, context=None): """ Finds the bill of material for the product from procurement order. @return: True or False """ diff --git a/addons/mrp/report/bom_structure.py b/addons/mrp/report/bom_structure.py index a5b43c19f01..458a0c19649 100644 --- a/addons/mrp/report/bom_structure.py +++ b/addons/mrp/report/bom_structure.py @@ -35,7 +35,7 @@ class bom_structure(report_sxw.rml_parse): def get_children(self, object, level=0): result = [] - def _get_rec(object,level): + def _get_rec(object, level): for l in object: res = {} res['name'] = l.name @@ -61,4 +61,4 @@ class bom_structure(report_sxw.rml_parse): report_sxw.report_sxw('report.bom.structure','mrp.bom','mrp/report/bom_structure.rml',parser=bom_structure,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index d5ddc7f0280..fdfe09f35b4 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -102,7 +102,7 @@ class StockMove(osv.osv): wf_service.trg_validate(uid, 'procurement.order', m, 'button_wait_done', cr) return processed_ids - def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None): + def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None): """ Consumed product with specific quatity from specific source location. @param product_qty: Consumed product quantity @param location_id: Source location diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index fbf307e860e..28610d89a5b 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -372,7 +372,7 @@ class mrp_production(osv.osv): pass return result - def action_compute(self, cr, uid, ids, properties=[], context=None): + def action_compute(self, cr, uid, ids, properties=None, context=None): """ Computes bills of material of a product and planned date of work order. @param properties: List containing dictionaries of properties. @return: No. of products. diff --git a/addons/plugin/plugin_handler.py b/addons/plugin/plugin_handler.py index ef990170e64..3c81edae2fa 100644 --- a/addons/plugin/plugin_handler.py +++ b/addons/plugin/plugin_handler.py @@ -132,7 +132,7 @@ class plugin_handler(osv.osv_memory): return ('res.partner', partner_id, url) # Specific to outlook rfc822 is not available so we split in arguments headerd,body,attachemnts - def push_message_outlook(self, cr, uid, model, headers,res_id=0 ,body_text=False, body_html=False, attachments=False): + def push_message_outlook(self, cr, uid, model, headers, res_id=0 , body_text=False, body_html=False, attachments=False): # ---------------------------------------- # solution 1 # construct a fake rfc822 from the separated arguement diff --git a/addons/point_of_sale/report/account_statement.py b/addons/point_of_sale/report/account_statement.py index be5d4b3a330..c1fc73a35d7 100644 --- a/addons/point_of_sale/report/account_statement.py +++ b/addons/point_of_sale/report/account_statement.py @@ -48,4 +48,4 @@ class account_statement(report_sxw.rml_parse): report_sxw.report_sxw('report.account.statement', 'account.bank.statement', 'addons/statement/report/account_statement.rml', parser=account_statement,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py b/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py index 4f342099a59..0e75e7f7ae1 100644 --- a/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py +++ b/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py @@ -38,13 +38,13 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): 'get_net_total_starting':self._get_net_total_starting, }) - def _get_user(self,line_ids): + def _get_user(self, line_ids): sql = "select name from res_users where id = %d"%(line_ids['create_uid']) self.cr.execute(sql) user = self.cr.fetchone() return user[0] - def _get_data(self,user): + def _get_data(self, user): data = {} sql = """ SELECT abs.journal_id,abs.id,abs.date,abs.closing_date,abs.name as statement,aj.name as journal,ap.name as period,ru.name as user,rc.name as company, abs.state,abs.balance_end_real FROM account_bank_statement as abs @@ -57,7 +57,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): data = self.cr.dictfetchall() return data - def _get_lines(self,statement): + def _get_lines(self, statement): data = {} sql = """ select absl.* from account_bank_statement_line as absl, account_bank_statement as abs where absl.statement_id = abs.id and abs.id = %d"""%(statement['id']) @@ -65,7 +65,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): data = self.cr.dictfetchall() return data - def _get_bal(self,data): + def _get_bal(self, data): res = {} sql =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d """%(data['id']) self.cr.execute(sql) @@ -75,7 +75,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): else: return False - def _get_sub_total(self,user,data,date): + def _get_sub_total(self, user, data, date): res={} self.cr.execute(""" select sum(absl.amount) from account_bank_statement as abs LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id @@ -90,7 +90,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): else: return False - def _get_partner(self,statement): + def _get_partner(self, statement): res = {} if statement['pos_statement_id']: sql =""" select rp.name from account_bank_statement_line as absl,res_partner as rp @@ -102,7 +102,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): else: return 0.00 - def _get_net_total_starting(self,user): + def _get_net_total_starting(self, user): lst = [] res={} total_ending_bal = 0.0 @@ -124,7 +124,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): lst.append(total_starting_bal) return lst - def _get_net_total(self,user): + def _get_net_total(self, user): res={} sql = """select sum(absl.amount) as net_total from account_bank_statement as abs LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id @@ -137,4 +137,4 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): report_sxw.report_sxw('report.all.closed.cashbox.of.the.day', 'account.bank.statement', 'addons/point_of_sale/report/all_closed_cashbox_of_the_day.rml', parser=all_closed_cashbox_of_the_day,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/pos_details.py b/addons/point_of_sale/report/pos_details.py index d13c127165e..f8565a8776a 100644 --- a/addons/point_of_sale/report/pos_details.py +++ b/addons/point_of_sale/report/pos_details.py @@ -24,7 +24,7 @@ from report import report_sxw class pos_details(report_sxw.rml_parse): - def _get_invoice(self,inv_id): + def _get_invoice(self, inv_id): res={} if inv_id: self.cr.execute("select number from account_invoice as ac where id = %s", (inv_id,)) @@ -37,7 +37,7 @@ class pos_details(report_sxw.rml_parse): user_obj = self.pool.get('res.users') return user_obj.search(self.cr, self.uid, []) - def _pos_sales_details(self,form): + def _pos_sales_details(self, form): pos_obj = self.pool.get('pos.order') user_obj = self.pool.get('res.users') data = [] @@ -74,7 +74,7 @@ class pos_details(report_sxw.rml_parse): def _get_sales_total_2(self): return self.total - def _get_sum_invoice_2(self,form): + def _get_sum_invoice_2(self, form): pos_obj = self.pool.get('pos.order') user_obj = self.pool.get('res.users') user_ids = form['user_ids'] or self._get_all_users() diff --git a/addons/point_of_sale/report/pos_details_summary.py b/addons/point_of_sale/report/pos_details_summary.py index 2801dcf43f3..c811d6543ba 100644 --- a/addons/point_of_sale/report/pos_details_summary.py +++ b/addons/point_of_sale/report/pos_details_summary.py @@ -42,7 +42,7 @@ class pos_details_summary(report_sxw.rml_parse): 'getcompany':self.get_company }) - def get_company(self,objects): + def get_company(self, objects): comp=[obj.company_id.name for obj in objects] return '%s' % (comp[0]) @@ -136,4 +136,4 @@ report_sxw.report_sxw('report.pos.details_summary', parser=pos_details_summary, header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/pos_lines.py b/addons/point_of_sale/report/pos_lines.py index 66b52d6ce01..6c48d9e9733 100644 --- a/addons/point_of_sale/report/pos_lines.py +++ b/addons/point_of_sale/report/pos_lines.py @@ -41,7 +41,7 @@ class pos_lines(report_sxw.rml_parse): self.total = tot return self.total - def __taxes__(self,obj): + def __taxes__(self, obj): self.cr.execute ( " Select acct.name from pos_order as po " \ " LEFT JOIN pos_order_line as pol ON po.id = pol.order_id " \ " LEFT JOIN product_taxes_rel as ptr ON pol.product_id = ptr.prod_id " \ @@ -52,4 +52,4 @@ class pos_lines(report_sxw.rml_parse): report_sxw.report_sxw('report.pos.lines', 'pos.order', 'addons/point_of_sale/report/pos_lines.rml', parser=pos_lines,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/pos_payment_report.py b/addons/point_of_sale/report/pos_payment_report.py index beadd2d5cb6..1fed98a4852 100644 --- a/addons/point_of_sale/report/pos_payment_report.py +++ b/addons/point_of_sale/report/pos_payment_report.py @@ -33,7 +33,7 @@ class pos_payment_report(report_sxw.rml_parse): 'pos_payment_total':self._pos_payment_total, }) - def _pos_payment(self,obj): + def _pos_payment(self, obj): data={} sql = """ select id from pos_order where id = %d"""%(obj.id) self.cr.execute(sql) @@ -56,9 +56,9 @@ class pos_payment_report(report_sxw.rml_parse): self.total += d['price_unit'] * d['qty'] return data - def _pos_payment_total(self,o): + def _pos_payment_total(self, o): return self.total report_sxw.report_sxw('report.pos.payment.report', 'pos.order', 'addons/point_of_sale/report/pos_payment_report.rml', parser=pos_payment_report,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/pos_payment_report_user.py b/addons/point_of_sale/report/pos_payment_report_user.py index c90387e4f7a..b347c86da2a 100644 --- a/addons/point_of_sale/report/pos_payment_report_user.py +++ b/addons/point_of_sale/report/pos_payment_report_user.py @@ -33,7 +33,7 @@ class pos_payment_report_user(report_sxw.rml_parse): 'pos_payment_user_total':self.__pos_payment_user__total__, }) - def __pos_payment_user__(self,form): + def __pos_payment_user__(self, form): data={} ids = form['user_id'] sql = "select pt.name,pp.default_code as code,pol.qty,pu.name as uom,pol.discount,pol.price_unit, " \ @@ -61,4 +61,4 @@ class pos_payment_report_user(report_sxw.rml_parse): report_sxw.report_sxw('report.pos.payment.report.user', 'pos.order', 'addons/point_of_sale/report/pos_payment_report_user.rml', parser=pos_payment_report_user,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/pos_receipt.py b/addons/point_of_sale/report/pos_receipt.py index 721f4bc86e2..966bdd42259 100644 --- a/addons/point_of_sale/report/pos_receipt.py +++ b/addons/point_of_sale/report/pos_receipt.py @@ -74,4 +74,4 @@ class order(report_sxw.rml_parse): report_sxw.report_sxw('report.pos.receipt', 'pos.order', 'addons/point_of_sale/report/pos_receipt.rml', parser=order, header=False) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/pos_sales_user.py b/addons/point_of_sale/report/pos_sales_user.py index e49528441b9..f40b9f1c630 100644 --- a/addons/point_of_sale/report/pos_sales_user.py +++ b/addons/point_of_sale/report/pos_sales_user.py @@ -33,7 +33,7 @@ class pos_sales_user(report_sxw.rml_parse): }) - def _get_data(self,form): + def _get_data(self, form): dt1 = form['date_start'] + ' 00:00:00' dt2 = form['date_end'] + ' 23:59:59' data={} @@ -47,4 +47,4 @@ class pos_sales_user(report_sxw.rml_parse): report_sxw.report_sxw('report.pos.sales.user', 'pos.order', 'addons/point_of_sale/report/pos_sales_user.rml', parser=pos_sales_user,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/pos_sales_user_today.py b/addons/point_of_sale/report/pos_sales_user_today.py index 9696d036959..35bc61efea8 100644 --- a/addons/point_of_sale/report/pos_sales_user_today.py +++ b/addons/point_of_sale/report/pos_sales_user_today.py @@ -33,7 +33,7 @@ class pos_sales_user_today(report_sxw.rml_parse): }) - def _get_data(self,form): + def _get_data(self, form): data={} ids = form['user_id'] @@ -47,4 +47,4 @@ class pos_sales_user_today(report_sxw.rml_parse): report_sxw.report_sxw('report.pos.sales.user.today', 'pos.order', 'addons/point_of_sale/report/pos_sales_user_today.rml', parser=pos_sales_user_today,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/pos_users_product.py b/addons/point_of_sale/report/pos_users_product.py index 87cf306990a..032a25043e8 100644 --- a/addons/point_of_sale/report/pos_users_product.py +++ b/addons/point_of_sale/report/pos_users_product.py @@ -60,9 +60,9 @@ class pos_user_product(report_sxw.rml_parse): data = self.cr.fetchone() return data[0] - def _get_total(self,o): + def _get_total(self, o): return self.total report_sxw.report_sxw('report.pos.user.product', 'account.bank.statement', 'addons/statement/report/pos_users_product.rml', parser=pos_user_product,header='internal') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/report/report_cash_register.py b/addons/point_of_sale/report/report_cash_register.py index c86c40bb32f..ff3823a4386 100644 --- a/addons/point_of_sale/report/report_cash_register.py +++ b/addons/point_of_sale/report/report_cash_register.py @@ -65,4 +65,4 @@ class report_cash_register(osv.osv): report_cash_register() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/procurement/company.py b/addons/procurement/company.py index d544181a6e8..23a0214f1c6 100644 --- a/addons/procurement/company.py +++ b/addons/procurement/company.py @@ -35,4 +35,4 @@ class company(osv.osv): company() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product/product.py b/addons/product/product.py index 0d5fa31ac11..42f587a91a4 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -349,7 +349,7 @@ class product_template(osv.osv): res = False return res - def onchange_uom(self, cursor, user, ids, uom_id,uom_po_id): + def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id): if uom_id: return {'value': {'uom_po_id': uom_id}} return {} @@ -540,7 +540,7 @@ class product_product(osv.osv): self.pool.get('product.template').unlink(cr, uid, unlink_product_tmpl_ids, context=context) return super(product_product, self).unlink(cr, uid, unlink_ids, context=context) - def onchange_uom(self, cursor, user, ids, uom_id,uom_po_id): + def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id): if uom_id and uom_po_id: uom_obj=self.pool.get('product.uom') uom=uom_obj.browse(cursor,user,[uom_id])[0] diff --git a/addons/product/report/product_pricelist.py b/addons/product/report/product_pricelist.py index 7e9748c2523..f2b5a57f472 100644 --- a/addons/product/report/product_pricelist.py +++ b/addons/product/report/product_pricelist.py @@ -39,7 +39,7 @@ class product_pricelist(report_sxw.rml_parse): 'get_titles': self._get_titles, }) - def _get_titles(self,form): + def _get_titles(self, form): lst = [] vals = {} qtys = 1 @@ -51,7 +51,7 @@ class product_pricelist(report_sxw.rml_parse): lst.append(vals) return lst - def _set_quantity(self,form): + def _set_quantity(self, form): for i in range(1,6): q = 'qty%d'%i if form[q] >0 and form[q] not in self.quantity: @@ -76,7 +76,7 @@ class product_pricelist(report_sxw.rml_parse): symbol = pool.get('res.currency').read(self.cr, self.uid, [pricelist['currency_id'][0]], ['symbol'], context=self.localcontext)[0] return symbol['symbol'] or '' - def _get_categories(self, products,form): + def _get_categories(self, products, form): cat_ids=[] res=[] self.pricelist = form['price_list'] @@ -111,7 +111,7 @@ class product_pricelist(report_sxw.rml_parse): res.append({'name':cat[1],'products': products}) return res - def _get_price(self,pricelist_id, product_id,qty): + def _get_price(self, pricelist_id, product_id, qty): sale_price_digits = self.get_digits(dp='Sale Price') pool = pooler.get_pool(self.cr.dbname) price_dict = pool.get('product.pricelist').price_get(self.cr, self.uid, [pricelist_id], product_id, qty, context=self.localcontext) diff --git a/addons/product_manufacturer/product_manufacturer.py b/addons/product_manufacturer/product_manufacturer.py index 93f4a6f1a8e..1aeff8d4f78 100644 --- a/addons/product_manufacturer/product_manufacturer.py +++ b/addons/product_manufacturer/product_manufacturer.py @@ -40,4 +40,4 @@ class product_attribute(osv.osv): } product_attribute() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product_visible_discount/__init__.py b/addons/product_visible_discount/__init__.py index 4abaf54aa85..b1dda0c009e 100644 --- a/addons/product_visible_discount/__init__.py +++ b/addons/product_visible_discount/__init__.py @@ -20,4 +20,4 @@ import product_visible_discount -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project/project.py b/addons/project/project.py index 9966ad02ee8..bdc5338b802 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -265,7 +265,7 @@ class project(osv.osv): task_obj.duplicate_task(cr, uid, map_task_id, context=context) return True - def copy(self, cr, uid, id, default={}, context=None): + def copy(self, cr, uid, id, default=None, context=None): if context is None: context = {} @@ -545,12 +545,12 @@ class task(osv.osv): return res - def onchange_remaining(self, cr, uid, ids, remaining=0.0, planned = 0.0): + def onchange_remaining(self, cr, uid, ids, remaining=0.0, planned=0.0): if remaining and not planned: return {'value':{'planned_hours': remaining}} return {} - def onchange_planned(self, cr, uid, ids, planned = 0.0, effective = 0.0): + def onchange_planned(self, cr, uid, ids, planned=0.0, effective=0.0): return {'value':{'remaining_hours': planned - effective}} def onchange_project(self, cr, uid, id, project_id): @@ -581,7 +581,9 @@ class task(osv.osv): #FIXME why there is already the copy and the old one self.write(cr, uid, new, {'parent_ids':[(6,0,set(parent_ids))], 'child_ids':[(6,0, set(child_ids))]}) - def copy_data(self, cr, uid, id, default={}, context=None): + def copy_data(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} default = default or {} default.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False}) if not default.get('remaining_hours', False): @@ -810,7 +812,7 @@ class task(osv.osv): } return res - def do_close(self, cr, uid, ids, context={}): + def do_close(self, cr, uid, ids, context=None): """ Close Task """ @@ -868,7 +870,7 @@ class task(osv.osv): self.write(cr, uid, [task.id], {'state': 'open'}, context=context) return True - def do_cancel(self, cr, uid, ids, context={}): + def do_cancel(self, cr, uid, ids, context=None): request = self.pool.get('res.request') tasks = self.browse(cr, uid, ids, context=context) self._check_child_task(cr, uid, ids, context=context) @@ -889,7 +891,7 @@ class task(osv.osv): self.write(cr, uid, [task.id], {'state': 'cancelled', 'remaining_hours':0.0}, context=context) return True - def do_open(self, cr, uid, ids, context={}): + def do_open(self, cr, uid, ids, context=None): if not isinstance(ids,list): ids = [ids] tasks= self.browse(cr, uid, ids, context=context) for t in tasks: @@ -901,7 +903,7 @@ class task(osv.osv): self.log(cr, uid, t.id, message) return True - def do_draft(self, cr, uid, ids, context={}): + def do_draft(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state': 'draft'}, context=context) return True @@ -915,10 +917,12 @@ class task(osv.osv): return new_attachment_ids - def do_delegate(self, cr, uid, ids, delegate_data={}, context=None): + def do_delegate(self, cr, uid, ids, delegate_data=None, context=None): """ Delegate Task to another users. """ + if delegate_data is None: + delegate_data = {} assert delegate_data['user_id'], _("Delegated User should be specified") delegated_tasks = {} for task in self.browse(cr, uid, ids, context=context): @@ -950,7 +954,7 @@ class task(osv.osv): delegated_tasks[task.id] = delegated_task_id return delegated_tasks - def do_pending(self, cr, uid, ids, context={}): + def do_pending(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state': 'pending'}, context=context) for (id, name) in self.name_get(cr, uid, ids): message = _("The task '%s' is pending.") % name diff --git a/addons/project/wizard/project_task_reevaluate.py b/addons/project/wizard/project_task_reevaluate.py index 382c9d64361..b00c531717f 100644 --- a/addons/project/wizard/project_task_reevaluate.py +++ b/addons/project/wizard/project_task_reevaluate.py @@ -26,7 +26,7 @@ from tools.translate import _ class project_task_reevaluate(osv.osv_memory): _name = 'project.task.reevaluate' - def _get_remaining(self,cr, uid, context=None): + def _get_remaining(self, cr, uid, context=None): if context is None: context = {} active_id = context.get('active_id', False) diff --git a/addons/project_gtd/project_gtd.py b/addons/project_gtd/project_gtd.py index bec70779551..e11ce1339de 100644 --- a/addons/project_gtd/project_gtd.py +++ b/addons/project_gtd/project_gtd.py @@ -67,7 +67,7 @@ class project_task(osv.osv): default['context_id'] = False return super(project_task,self).copy_data(cr, uid, id, default, context) - def _get_context(self,cr, uid, context=None): + def _get_context(self, cr, uid, context=None): ids = self.pool.get('project.gtd.context').search(cr, uid, [], context=context) return ids and ids[0] or False diff --git a/addons/project_gtd/wizard/project_gtd_empty.py b/addons/project_gtd/wizard/project_gtd_empty.py index 373c8425a8c..268dfd26917 100644 --- a/addons/project_gtd/wizard/project_gtd_empty.py +++ b/addons/project_gtd/wizard/project_gtd_empty.py @@ -30,7 +30,7 @@ class project_timebox_empty(osv.osv_memory): 'name': fields.char('Name', size=32) } - def view_init(self, cr , uid , fields_list, context=None): + def view_init(self, cr, uid, fields_list, context=None): if context is None: context = {} self._empty(cr, uid, context=context) diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py index 9715a32c151..1243d8f759d 100644 --- a/addons/project_mailgate/project_mailgate.py +++ b/addons/project_mailgate/project_mailgate.py @@ -47,7 +47,9 @@ class project_tasks(osv.osv): self.write(cr, uid, [res_id], data, context) return res_id - def message_update(self, cr, uid, ids, msg, data={}, default_act='pending'): + def message_update(self, cr, uid, ids, msg, data=None, default_act='pending'): + if data is None: + data = {} data.update({ 'description': msg['body_text'], }) diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index 7d3045aede0..ab545adfe48 100644 --- a/addons/project_mrp/project_procurement.py +++ b/addons/project_mrp/project_procurement.py @@ -40,7 +40,7 @@ class procurement_order(osv.osv): return all(proc.product_id.type != 'service' or (proc.task_id and proc.task_id.state in ('done', 'cancelled')) \ for proc in self.browse(cr, uid, ids, context=context)) - def check_produce_service(self, cr, uid, procurement, context=None): + def check_produce_service(self, cr, uid, procurement, context=None): return True def _convert_qty_company_hours(self, cr, uid, procurement, context=None): diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index db7066505e1..c38b6b6258e 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -197,7 +197,7 @@ class task(osv.osv): return super(task,self).unlink(cr, uid, ids, *args, **kwargs) - def write(self, cr, uid, ids,vals,context=None): + def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} if vals.get('project_id',False) or vals.get('name',False): diff --git a/addons/project_timesheet/report/task_report.py b/addons/project_timesheet/report/task_report.py index 3c223ab6b07..a181c4a12d2 100644 --- a/addons/project_timesheet/report/task_report.py +++ b/addons/project_timesheet/report/task_report.py @@ -29,7 +29,7 @@ class report_timesheet_task_user(osv.osv): _auto = False _order = "name" - def _get_task_hours(self, cr, uid, ids, name,args,context): + def _get_task_hours(self, cr, uid, ids, name, args, context): result = {} for record in self.browse(cr, uid, ids,context): last_date = datetime.strptime(record.name, '%Y-%m-%d') + relativedelta(months=1) - relativedelta(days=1) @@ -42,7 +42,7 @@ class report_timesheet_task_user(osv.osv): result[record.id] = total return result - def get_hrs_timesheet(self, cr, uid, ids, name,args,context): + def get_hrs_timesheet(self, cr, uid, ids, name, args, context): result = {} sum = 0.0 for record in self.browse(cr, uid, ids, context): diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 3d909c1085e..cb485ebc26c 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -395,7 +395,7 @@ class purchase_order(osv.osv): res = inv_id return res - def has_stockable_product(self,cr, uid, ids, *args): + def has_stockable_product(self, cr, uid, ids, *args): for order in self.browse(cr, uid, ids): for order_line in order.order_line: if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'): @@ -498,7 +498,7 @@ class purchase_order(osv.osv): wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) return [picking_id] - def action_picking_create(self,cr, uid, ids, context=None): + def action_picking_create(self, cr, uid, ids, context=None): picking_ids = [] for order in self.browse(cr, uid, ids): picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, context=context)) diff --git a/addons/purchase/wizard/purchase_order_group.py b/addons/purchase/wizard/purchase_order_group.py index 427c9c165fc..e5c0eb81bb4 100644 --- a/addons/purchase/wizard/purchase_order_group.py +++ b/addons/purchase/wizard/purchase_order_group.py @@ -88,4 +88,4 @@ class purchase_order_group(osv.osv_memory): purchase_order_group() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index c43bd524090..a753f5d7e1a 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -183,7 +183,7 @@ class purchase_requisition_line(osv.osv): 'company_id': fields.related('requisition_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True), } - def onchange_product_id(self, cr, uid, ids, product_id,product_uom_id, context=None): + def onchange_product_id(self, cr, uid, ids, product_id, product_uom_id, context=None): """ Changes UoM and name if product_id changes. @param name: Name of the field @param product_id: Changed product_id diff --git a/addons/report_webkit/ir_report.py b/addons/report_webkit/ir_report.py index d2709ea6fc2..68e129d021d 100644 --- a/addons/report_webkit/ir_report.py +++ b/addons/report_webkit/ir_report.py @@ -35,7 +35,7 @@ from webkit_report import WebKitParser from report.report_sxw import rml_parse def register_report(name, model, tmpl_path, parser=rml_parse): - "Register the report into the services" + """Register the report into the services""" name = 'report.%s' % name if netsvc.Service._services.get(name, False): service = netsvc.Service._services[name] diff --git a/addons/report_webkit/report_helper.py b/addons/report_webkit/report_helper.py index 12651f308dc..8d0a27998b0 100644 --- a/addons/report_webkit/report_helper.py +++ b/addons/report_webkit/report_helper.py @@ -75,7 +75,7 @@ class WebKitHelper(object): head = header_obj.browse(self.cursor, self.uid, header_img_id) return (head.img, head.type) - def embed_logo_by_name(self, name, width=0, height=0) : + def embed_logo_by_name(self, name, width=0, height=0): """Return HTML embedded logo by name""" img, type = self.get_logo_by_name(name) return self.embed_image(type, img, width, height) diff --git a/addons/resource/faces/task.py b/addons/resource/faces/task.py index f5240112277..53360fa047b 100644 --- a/addons/resource/faces/task.py +++ b/addons/resource/faces/task.py @@ -567,7 +567,8 @@ class _ValueWrapper(object): return result #@-node:_cmp #@+node:__getattr__ - def __getattr__(self, name): return getattr(self._value, name) + def __getattr__(self, name): + return getattr(self._value, name) #@-node:__getattr__ #@+node:__getitem__ def __getitem__(self, slice): diff --git a/addons/resource/resource.py b/addons/resource/resource.py index fb3d8c0980e..7a9ca30c68b 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -438,7 +438,7 @@ class resource_calendar_leaves(osv.osv): (check_dates, 'Error! leave start-date must be lower then leave end-date.', ['date_from', 'date_to']) ] - def onchange_resource(self,cr, uid, ids, resource, context=None): + def onchange_resource(self, cr, uid, ids, resource, context=None): result = {} if resource: resource_pool = self.pool.get('resource.resource') diff --git a/addons/sale/edi/sale_order.py b/addons/sale/edi/sale_order.py index d40d0b613ed..327d7602c4f 100644 --- a/addons/sale/edi/sale_order.py +++ b/addons/sale/edi/sale_order.py @@ -219,4 +219,4 @@ class sale_order_line(osv.osv, EDIMixin): edi_doc_list.append(edi_doc) return edi_doc_list -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/report/__init__.py b/addons/sale/report/__init__.py index 0248595f4da..6986639d942 100644 --- a/addons/sale/report/__init__.py +++ b/addons/sale/report/__init__.py @@ -22,4 +22,4 @@ import sale_order import sale_report -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/wizard/__init__.py b/addons/sale/wizard/__init__.py index 6cf076164d8..bfc8679de16 100644 --- a/addons/sale/wizard/__init__.py +++ b/addons/sale/wizard/__init__.py @@ -23,4 +23,4 @@ import sale_make_invoice import sale_line_invoice import sale_make_invoice_advance -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/wizard/sale_make_invoice.py b/addons/sale/wizard/sale_make_invoice.py index 5265afb9bff..b4b3772a91a 100644 --- a/addons/sale/wizard/sale_make_invoice.py +++ b/addons/sale/wizard/sale_make_invoice.py @@ -68,4 +68,4 @@ class sale_make_invoice(osv.osv_memory): sale_make_invoice() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale_crm/__init__.py b/addons/sale_crm/__init__.py index f5db3f4333b..ac44586e7db 100644 --- a/addons/sale_crm/__init__.py +++ b/addons/sale_crm/__init__.py @@ -22,4 +22,4 @@ import wizard import sale_crm -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale_layout/sale_layout.py b/addons/sale_layout/sale_layout.py index 15531e76e1d..f369cc0ef6c 100644 --- a/addons/sale_layout/sale_layout.py +++ b/addons/sale_layout/sale_layout.py @@ -53,7 +53,7 @@ class sale_order_line(osv.osv): seq += 1 return invoice_line_ids - def onchange_sale_order_line_view(self, cr, uid, id, type, context={}, *args): + def onchange_sale_order_line_view(self, cr, uid, id, type, context=None, *args): temp = {} temp['value'] = {} if (not type): diff --git a/addons/sale_order_dates/sale_order_dates.py b/addons/sale_order_dates/sale_order_dates.py index ceb6d48755c..1b069cb2bed 100644 --- a/addons/sale_order_dates/sale_order_dates.py +++ b/addons/sale_order_dates/sale_order_dates.py @@ -61,4 +61,4 @@ class sale_order_dates(osv.osv): sale_order_dates() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/report/lot_overview.py b/addons/stock/report/lot_overview.py index 89974fa122b..bf2fd32e32c 100644 --- a/addons/stock/report/lot_overview.py +++ b/addons/stock/report/lot_overview.py @@ -34,7 +34,7 @@ class lot_overview(report_sxw.rml_parse): 'grand_total_price':self._grand_total, }) - def process(self,location_id): + def process(self, location_id): location_obj = pooler.get_pool(self.cr.dbname).get('stock.location') data = location_obj._product_get_report(self.cr,self.uid, [location_id]) diff --git a/addons/stock/report/lot_overview_all.py b/addons/stock/report/lot_overview_all.py index 0b4edcaecf4..552949ec4b2 100644 --- a/addons/stock/report/lot_overview_all.py +++ b/addons/stock/report/lot_overview_all.py @@ -34,7 +34,7 @@ class lot_overview_all(report_sxw.rml_parse): 'grand_total_price':self._grand_total, }) - def process(self,location_id): + def process(self, location_id): location_obj = pooler.get_pool(self.cr.dbname).get('stock.location') data = location_obj._product_get_all_report(self.cr,self.uid, [location_id]) data['location_name'] = location_obj.read(self.cr, self.uid, [location_id],['complete_name'])[0]['complete_name'] diff --git a/addons/stock/report/stock_inventory_move_report.py b/addons/stock/report/stock_inventory_move_report.py index e8c0d44bcc1..762373f1250 100644 --- a/addons/stock/report/stock_inventory_move_report.py +++ b/addons/stock/report/stock_inventory_move_report.py @@ -30,7 +30,7 @@ class stock_inventory_move(report_sxw.rml_parse): 'qty_total':self._qty_total }) - def _qty_total(self,objects): + def _qty_total(self, objects): total = 0.0 uom = objects[0].product_uom.name for obj in objects: diff --git a/addons/stock_invoice_directly/wizard/stock_invoice.py b/addons/stock_invoice_directly/wizard/stock_invoice.py index 3725d9b6d7f..4bb0ab41d88 100644 --- a/addons/stock_invoice_directly/wizard/stock_invoice.py +++ b/addons/stock_invoice_directly/wizard/stock_invoice.py @@ -47,4 +47,4 @@ class invoice_directly(osv.osv_memory): invoice_directly() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock_location/procurement_pull.py b/addons/stock_location/procurement_pull.py index 0846fe067eb..93531596688 100644 --- a/addons/stock_location/procurement_pull.py +++ b/addons/stock_location/procurement_pull.py @@ -45,7 +45,7 @@ class procurement_order(osv.osv): return (line.type_proc=='move') and (line.location_src_id) return False - def action_move_create(self, cr, uid, ids,context=None): + def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') diff --git a/addons/stock_planning/stock_planning.py b/addons/stock_planning/stock_planning.py index d104d57c62b..05a8cb50486 100644 --- a/addons/stock_planning/stock_planning.py +++ b/addons/stock_planning/stock_planning.py @@ -406,7 +406,7 @@ class stock_planning(osv.osv): res[val.id] = 'Future' return res - def _get_op(self, cr, uid, ids, field_names, arg, context=None): # op = OrderPoint + def _get_op(self, cr, uid, ids, field_names, arg, context=None): res = {} for val in self.browse(cr, uid, ids, context=context): res[val.id]={} diff --git a/addons/stock_planning/wizard/stock_planning_createlines.py b/addons/stock_planning/wizard/stock_planning_createlines.py index a6e12ad4bc7..24b6fd4a8ab 100644 --- a/addons/stock_planning/wizard/stock_planning_createlines.py +++ b/addons/stock_planning/wizard/stock_planning_createlines.py @@ -49,7 +49,7 @@ class stock_planning_createlines(osv.osv_memory): 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.planning', context=c), } - def create_planning(self,cr, uid, ids, context=None): + def create_planning(self, cr, uid, ids, context=None): if context is None: context = {} product_obj = self.pool.get('product.product') diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 0101cef17b8..7d1d9801ada 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -514,7 +514,7 @@ class survey_question_column_heading(osv.osv): _description = 'Survey Question Column Heading' _rec_name = 'title' - def _get_in_visible_rating_weight(self,cr, uid, context=None): + def _get_in_visible_rating_weight(self, cr, uid, context=None): if context is None: context = {} if context.get('in_visible_rating_weight', False): @@ -567,7 +567,7 @@ class survey_answer(osv.osv): } return val - def _get_in_visible_answer_type(self,cr, uid, context=None): + def _get_in_visible_answer_type(self, cr, uid, context=None): if context is None: context = {} return context.get('in_visible_answer_type', False) diff --git a/addons/survey/wizard/__init__.py b/addons/survey/wizard/__init__.py index aa1270da751..0ea0e5cd424 100644 --- a/addons/survey/wizard/__init__.py +++ b/addons/survey/wizard/__init__.py @@ -27,4 +27,4 @@ import survey_selection import survey_answer import survey_print -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 86380e98037..ec40cc9b8d2 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -997,7 +997,7 @@ class survey_question_wiz(osv.osv_memory): return survey_question_wiz_id - def action_new_question(self,cr, uid, ids, context=None): + def action_new_question(self, cr, uid, ids, context=None): """ New survey.Question form. """ @@ -1039,7 +1039,7 @@ class survey_question_wiz(osv.osv_memory): 'context': context } - def action_edit_page(self,cr, uid, ids, context=None): + def action_edit_page(self, cr, uid, ids, context=None): """ Edit survey.page. """ @@ -1061,7 +1061,7 @@ class survey_question_wiz(osv.osv_memory): 'context': context } - def action_delete_page(self,cr, uid, ids, context=None): + def action_delete_page(self, cr, uid, ids, context=None): """ Delete survey.page. """ @@ -1087,7 +1087,7 @@ class survey_question_wiz(osv.osv_memory): 'context': context } - def action_edit_question(self,cr, uid, ids, context=None): + def action_edit_question(self, cr, uid, ids, context=None): """ Edit survey.question. """ @@ -1109,7 +1109,7 @@ class survey_question_wiz(osv.osv_memory): 'context': context } - def action_delete_question(self,cr, uid, ids, context=None): + def action_delete_question(self, cr, uid, ids, context=None): """ Delete survey.question. """ diff --git a/addons/wiki/web/widgets/rss/feedparser.py b/addons/wiki/web/widgets/rss/feedparser.py old mode 100755 new mode 100644 index 885050d49f8..ad1265a7043 --- a/addons/wiki/web/widgets/rss/feedparser.py +++ b/addons/wiki/web/widgets/rss/feedparser.py @@ -2446,8 +2446,10 @@ def _stripDoctype(data): data = doctype_pattern.sub('', data) return version, data -def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, referrer=None, handlers=[]): +def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, referrer=None, handlers=None): '''Parse a feed from a URL, file, stream, or string''' + if handlers is None: + handlers = [] result = FeedParserDict() result['feed'] = FeedParserDict() result['entries'] = [] diff --git a/addons/wiki/web/widgets/wikimarkup/__init__.py b/addons/wiki/web/widgets/wikimarkup/__init__.py index f5fe67fada1..d62b7ae42bb 100644 --- a/addons/wiki/web/widgets/wikimarkup/__init__.py +++ b/addons/wiki/web/widgets/wikimarkup/__init__.py @@ -489,7 +489,7 @@ class BaseParser(object): return text.encode("utf-8") return text - def strip(self, text, stripcomments=False, dontstrip=[]): + def strip(self, text, stripcomments=False, dontstrip=None): render = True commentState = {} @@ -2087,7 +2087,9 @@ mTagHooks = {} # quote from cgi import escape -def hook_quote(env, body, attributes={}): +def hook_quote(env, body, attributes=None): + if attributes is None: + attributes = {} text = [u'
'] if 'cite' in attributes: text.append(u"%s wrote:\n" % escape(attributes['cite'])) From 48166edeb8b950dd085dc7bb31f664f663a620fd Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 8 Jun 2012 12:17:10 +0200 Subject: [PATCH 07/55] [FIX] rename ir.actions.url to match action's type bzr revid: xmo@openerp.com-20120608101710-ncwcmu9u72u7mxcy --- openerp/addons/base/ir/ir_actions.py | 2 +- openerp/addons/base/ir/ir_ui_menu.py | 2 +- openerp/tools/convert.py | 12 +++++++----- openerp/tools/yaml_import.py | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index c74a5128bbf..88e70d4befb 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -375,7 +375,7 @@ class act_wizard(osv.osv): act_wizard() class act_url(osv.osv): - _name = 'ir.actions.url' + _name = 'ir.actions.act_url' _table = 'ir_act_url' _sequence = 'ir_actions_id_seq' _order = 'name' diff --git a/openerp/addons/base/ir/ir_ui_menu.py b/openerp/addons/base/ir/ir_ui_menu.py index 15d250a7489..1ab2a88af9e 100644 --- a/openerp/addons/base/ir/ir_ui_menu.py +++ b/openerp/addons/base/ir/ir_ui_menu.py @@ -293,7 +293,7 @@ class ir_ui_menu(osv.osv): ('ir.actions.report.xml', 'ir.actions.report.xml'), ('ir.actions.act_window', 'ir.actions.act_window'), ('ir.actions.wizard', 'ir.actions.wizard'), - ('ir.actions.url', 'ir.actions.url'), + ('ir.actions.act_url', 'ir.actions.act_url'), ('ir.actions.server', 'ir.actions.server'), ('ir.actions.client', 'ir.actions.client'), ]), diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py index c2c610c16af..0ac51266b07 100644 --- a/openerp/tools/convert.py +++ b/openerp/tools/convert.py @@ -384,18 +384,20 @@ form: module.record_id""" % (xml_id,) res = {'name': name, 'url': url, 'target':target} - id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.url", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) + act_url = "ir.actions.act_url" + id = self.pool.get('ir.model.data')._update(cr, self.uid, act_url, self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) self.idref[xml_id] = int(id) # ir_set if (not rec.get('menu') or eval(rec.get('menu','False'))) and id: keyword = str(rec.get('keyword','') or 'client_action_multi') - value = 'ir.actions.url,'+str(id) + value = act_url + ',' + str(id) replace = rec.get("replace",'') or True - self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, url, ["ir.actions.url"], value, replace=replace, isobject=True, xml_id=xml_id) + self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, url, [ + act_url], value, replace=replace, isobject=True, xml_id=xml_id) elif self.mode=='update' and (rec.get('menu') and eval(rec.get('menu','False'))==False): # Special check for URL having attribute menu=False on update - value = 'ir.actions.url,'+str(id) - self._remove_ir_values(cr, url, value, "ir.actions.url") + value = act_url + ',' + str(id) + self._remove_ir_values(cr, url, value, act_url) def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') diff --git a/openerp/tools/yaml_import.py b/openerp/tools/yaml_import.py index 136d1bcee7b..37fcae60113 100644 --- a/openerp/tools/yaml_import.py +++ b/openerp/tools/yaml_import.py @@ -728,15 +728,15 @@ class YamlInterpreter(object): res = {'name': node.name, 'url': node.url, 'target': node.target} id = self.pool.get('ir.model.data')._update(self.cr, 1, \ - "ir.actions.url", self.module, res, node.id, mode=self.mode) + "ir.actions.act_url", self.module, res, node.id, mode=self.mode) self.id_map[node.id] = int(id) # ir_set if (not node.menu or eval(node.menu)) and id: keyword = node.keyword or 'client_action_multi' - value = 'ir.actions.url,%s' % id + value = 'ir.actions.act_url,%s' % id replace = node.replace or True self.pool.get('ir.model.data').ir_set(self.cr, 1, 'action', \ - keyword, node.url, ["ir.actions.url"], value, replace=replace, \ + keyword, node.url, ["ir.actions.act_url"], value, replace=replace, \ noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id) def process_ir_set(self, node): From 4ed79f3457a0252dcee4780385dc474ff2af356e Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 8 Jun 2012 12:17:14 +0200 Subject: [PATCH 08/55] [FIX] rename ir.actions.url to match action's type bzr revid: xmo@openerp.com-20120608101714-lf3o4mmvllmi4ge0 --- addons/web/controllers/main.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 1ccba0c9867..6eb8ed94909 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1467,10 +1467,6 @@ class Binary(openerpweb.Controller): class Action(openerpweb.Controller): _cp_path = "/web/action" - - action_mapping = { - "ir.actions.act_url": "ir.actions.url", - } @openerpweb.jsonrequest def load(self, req, action_id, do_not_eval=False): @@ -1483,9 +1479,7 @@ class Action(openerpweb.Controller): if action_type[0]['type'] == 'ir.actions.report.xml': ctx.update({'bin_size': True}) ctx.update(context) - action_model = action_type[0]['type'] - action_model = Action.action_mapping.get(action_model, action_model) - action = req.session.model(action_model).read([action_id], False, ctx) + action = req.session.model(action_type[0]['type']).read([action_id], False, ctx) if action: value = clean_action(req, action[0], do_not_eval) return {'result': value} From a59da4d4767b6778769dfd276ab6044aac1fe6f1 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 8 Jun 2012 12:38:15 +0200 Subject: [PATCH 09/55] [REM] ir_set from _tag_url's convert Hinges on @menu (not allowed on the url tag), @keyword (not allowed either) and sets the url on the url bzr revid: xmo@openerp.com-20120608103815-n20dhponzinhr7xf --- openerp/tools/convert.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py index 0ac51266b07..bc16bba1591 100644 --- a/openerp/tools/convert.py +++ b/openerp/tools/convert.py @@ -384,20 +384,8 @@ form: module.record_id""" % (xml_id,) res = {'name': name, 'url': url, 'target':target} - act_url = "ir.actions.act_url" - id = self.pool.get('ir.model.data')._update(cr, self.uid, act_url, self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) + id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.act_url", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) self.idref[xml_id] = int(id) - # ir_set - if (not rec.get('menu') or eval(rec.get('menu','False'))) and id: - keyword = str(rec.get('keyword','') or 'client_action_multi') - value = act_url + ',' + str(id) - replace = rec.get("replace",'') or True - self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, url, [ - act_url], value, replace=replace, isobject=True, xml_id=xml_id) - elif self.mode=='update' and (rec.get('menu') and eval(rec.get('menu','False'))==False): - # Special check for URL having attribute menu=False on update - value = act_url + ',' + str(id) - self._remove_ir_values(cr, url, value, act_url) def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') From b773ed3fafdd1d7773a8ae8fae0377304a988a65 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 8 Jun 2012 13:31:07 +0200 Subject: [PATCH 10/55] [FIX] model access for act_url bzr revid: xmo@openerp.com-20120608113107-nelgblnh0w1cff0q --- openerp/addons/base/security/ir.model.access.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/security/ir.model.access.csv b/openerp/addons/base/security/ir.model.access.csv index 8b906ba48a5..9e9c8abe513 100644 --- a/openerp/addons/base/security/ir.model.access.csv +++ b/openerp/addons/base/security/ir.model.access.csv @@ -98,8 +98,8 @@ "access_workflow_workitem_all","workflow_workitem_all","model_workflow_workitem",,1,1,1,1 "access_ir_actions_act_window_view_all","ir_actions_act_window_view_all","model_ir_actions_act_window_view",,1,0,0,0 "access_ir_actions_act_window_view_group_system","ir_actions_act_window_view_group_system","model_ir_actions_act_window_view","group_system",1,1,1,1 -"access_ir_actions_url_all","ir_actions_url_all","model_ir_actions_url",,1,0,0,0 -"access_ir_actions_url_group_system","ir_actions_url_group_system","model_ir_actions_url","group_system",1,1,1,1 +"access_ir_actions_act_url_all","ir_actions_act_url_all","model_ir_actions_act_url",,1,0,0,0 +"access_ir_actions_act_url_group_system","ir_actions_act_url_group_system","model_ir_actions_act_url","group_system",1,1,1,1 "access_ir_server_object_lines_all","ir_server_object_lines_all","model_ir_server_object_lines",,1,0,0,0 "access_ir_server_object_lines_group_system","ir_server_object_lines_group_system","model_ir_server_object_lines","group_system",1,1,1,1 "access_ir_actions_server_all","ir_actions_server_all","model_ir_actions_server",,1,0,0,0 From 968325cb39e3b98993948040c8dcbe25fbbc3f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Tue, 18 Sep 2012 15:37:32 +0200 Subject: [PATCH 11/55] [WIP] point_of_sale: first test of new TPE API bzr revid: fva@openerp.com-20120918133732-q7za0r3dcggem8mw --- addons/point_of_sale/controllers/main.py | 16 +- addons/point_of_sale/static/src/js/devices.js | 104 +++++----- addons/point_of_sale/static/src/js/screens.js | 181 ++++++++++++++---- addons/point_of_sale/static/src/js/widgets.js | 6 +- addons/point_of_sale/static/src/xml/pos.xml | 11 +- 5 files changed, 222 insertions(+), 96 deletions(-) diff --git a/addons/point_of_sale/controllers/main.py b/addons/point_of_sale/controllers/main.py index e6976dd319c..3d80fd53e24 100644 --- a/addons/point_of_sale/controllers/main.py +++ b/addons/point_of_sale/controllers/main.py @@ -119,21 +119,21 @@ class PointOfSaleController(openerpweb.Controller): return @openerpweb.jsonrequest - def payment_request(self, request, price, method, info): + def payment_request(self, request, price): """ The PoS will activate the method payment """ - print "payment_request: price:"+str(price)+" method:"+str(method)+" info:"+str(info) - return + print "payment_request: price:"+str(price) + return 'ok' @openerpweb.jsonrequest - def is_payment_accepted(self, request): - print "is_payment_accepted" - return 'waiting_for_payment' + def payment_status(self, request): + print "payment_status" + return { 'status':'waiting' } @openerpweb.jsonrequest - def payment_canceled(self, request): - print "payment_canceled" + def payment_cancel(self, request): + print "payment_cancel" return @openerpweb.jsonrequest diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index a26d8ca7154..142d35bd340 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -14,7 +14,14 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal this.weighting = false; this.paying = false; - this.payment_status = 'waiting_for_payment'; + this.default_payment_status = { + status: 'waiting', + message: '', + payment_method: undefined, + receipt_client: undefined, + receipt_shop: undefined, + }; + this.custom_payment_status = this.default_payment_status; this.connection = new instance.web.JsonRPC(); this.connection.setup(url); @@ -23,16 +30,21 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal this.notifications = {}; }, - message : function(name,params,success_callback, error_callback){ - success_callback = success_callback || function(){}; - error_callback = error_callback || function(){}; - + message : function(name,params){ + var ret = new $.Deferred(); var callbacks = this.notifications[name] || []; for(var i = 0; i < callbacks.length; i++){ callbacks[i](params); } - this.connection.rpc('/pos/'+name, params || {}, success_callback, error_callback); + this.connection.rpc('/pos/'+name, params || {}, + function(result){ + ret.resolve(result); + }, + function(error){ + ret.reject(error); + }); + return ret; }, // this allows the client to be notified when a proxy call is made. The notification @@ -47,23 +59,23 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal //a product has been scanned and recognized with success // ean is a parsed ean object scan_item_success: function(ean){ - this.message('scan_item_success',{ean: ean}); + return this.message('scan_item_success',{ean: ean}); }, // a product has been scanned but not recognized // ean is a parsed ean object scan_item_error_unrecognized: function(ean){ - this.message('scan_item_error_unrecognized',{ean: ean}); + return this.message('scan_item_error_unrecognized',{ean: ean}); }, //the client is asking for help help_needed: function(){ - this.message('help_needed'); + return this.message('help_needed'); }, //the client does not need help anymore help_canceled: function(){ - this.message('help_canceled'); + return this.message('help_canceled'); }, //the client is starting to weight @@ -72,7 +84,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal this.weight = 0; this.weighting = true; this.bypass_proxy = false; - this.message('weighting_start'); + return this.message('weighting_start'); } }, @@ -84,11 +96,12 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal if(this.bypass_proxy){ return this.weight; }else{ - this.message('weighting_read_kg',{},function(weight){ - if(self.weighting && !self.bypass_proxy){ - self.weight = weight; - } - }); + this.message('weighting_read_kg',{}) + .then(function(weight){ + if(self.weighting && !self.bypass_proxy){ + self.weight = weight; + } + }); return this.weight; } }, @@ -104,77 +117,76 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal this.weight = 0; this.weighting = false; this.bypass_proxy = false; - this.message('weighting_end'); + return this.message('weighting_end'); }, // the pos asks the client to pay 'price' units - // method: 'mastercard' | 'cash' | ... ? TBD - // info: 'extra information to display on the payment terminal' ... ? TBD - payment_request: function(price, method, info){ + payment_request: function(price){ + var ret = new $.Deferred(); this.paying = true; - this.payment_status = 'waiting_for_payment'; - this.message('payment_request',{'price':price,'method':method,'info':info}); + this.custom_payment_status = this.default_payment_status; + return this.message('payment_request',{'price':price}); }, - // is called at regular interval after a payment request to see if the client - // has paid the required money - // returns 'waiting_for_payment' | 'payment_accepted' | 'payment_rejected' - is_payment_accepted: function(){ - var self = this; + payment_status: function(){ if(this.bypass_proxy){ this.bypass_proxy = false; - return this.payment_status; + return (new $.Deferred()).resolve(this.custom_payment_status); }else{ - this.message('is_payment_accepted', {}, function(payment_status){ - if(self.paying){ - self.payment_status = payment_status; - } - }); - return this.payment_status; + return this.message('payment_status'); } }, // override what the proxy says and accept the payment debug_accept_payment: function(){ this.bypass_proxy = true; - this.payment_status = 'payment_accepted'; + this.custom_payment_status = { + status: 'paid', + message: 'Successfull Payment, have a nice day', + payment_method: 'AMEX', + receipt_client: 'bla', + receipt_shop: 'bla', + }; }, // override what the proxy says and reject the payment debug_reject_payment: function(){ this.bypass_proxy = true; - this.payment_status = 'payment_rejected'; + this.custom_payment_status = { + status: 'error-rejected', + message: 'Sorry you don\'t have enough money :(', + }; }, // the client cancels his payment - payment_canceled: function(){ + payment_cancel: function(){ this.paying = false; - this.payment_status = 'waiting_for_payment'; - this.message('payment_canceled'); + this.custom_payment_status = 'waiting_for_payment'; + return this.message('payment_cancel'); }, // called when the client logs in or starts to scan product transaction_start: function(){ - this.message('transaction_start'); + return this.message('transaction_start'); }, // called when the clients has finished his interaction with the machine transaction_end: function(){ - this.message('transaction_end'); + return this.message('transaction_end'); }, // called when the POS turns to cashier mode cashier_mode_activated: function(){ - this.message('cashier_mode_activated'); + return this.message('cashier_mode_activated'); }, // called when the POS turns to client mode cashier_mode_deactivated: function(){ - this.message('cashier_mode_deactivated'); + return this.message('cashier_mode_deactivated'); }, // ask for the cashbox (the physical box where you store the cash) to be opened open_cashbox: function(){ - this.message('open_cashbox'); + return this.message('open_cashbox'); }, /* ask the printer to print a receipt @@ -216,12 +228,12 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal * } */ print_receipt: function(receipt){ - this.message('print_receipt',{receipt: receipt}); + return this.message('print_receipt',{receipt: receipt}); }, // asks the proxy to print an invoice in pdf form ( used to print invoices generated by the server ) print_pdf_invoice: function(pdfinvoice){ - this.message('print_pdf_invoice',{pdfinvoice: pdfinvoice}); + return this.message('print_pdf_invoice',{pdfinvoice: pdfinvoice}); }, }); diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index d2c79f19928..1ad03c5ead1 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -154,7 +154,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, barcode_product_screen: 'products', //if defined, this screen will be loaded when a product is scanned - barcode_product_error_popup: 'error', //if defined, this popup will be loaded when there's an error in the popup + barcode_product_error_popup: 'error-product', //if defined, this popup will be loaded when there's an error in the popup // what happens when a product is scanned : // it will add the product to the order and go to barcode_product_screen. Or show barcode_product_error_popup if @@ -411,6 +411,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa self.pos_widget.screen_selector.set_user_mode('cashier'); }, }); + this.$('.footer .button').off('click').click(function(){ + self.pos_widget.screen_selector.close_popup(); + }); }, close:function(){ this._super(); @@ -419,12 +422,12 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, }); - module.ErrorProductNotRecognizedPopupWidget = module.ErrorPopupWidget.extend({ - template:'ErrorProductNotRecognizedPopupWidget', + module.ProductErrorPopupWidget = module.ErrorPopupWidget.extend({ + template:'ProductErrorPopupWidget', }); - module.ErrorNoSessionPopupWidget = module.ErrorPopupWidget.extend({ - template:'ErrorNoSessionPopupWidget', + module.ErrorSessionPopupWidget = module.ErrorPopupWidget.extend({ + template:'ErrorSessionPopupWidget', }); module.ScaleInviteScreenWidget = module.ScreenWidget.extend({ @@ -539,6 +542,60 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, }); + // the JobQueue schedules a sequence of 'jobs'. each job is + // a function returning a deferred. the queue waits for each job to finish + // before launching the next. Each job can also be scheduled with a delay. + // the queue jobqueue is used to prevent parallel requests to the payment terminal. + + module.JobQueue = function(){ + var queue = []; + var running = false; + var run = function(){ + if(queue.length > 0){ + running = true; + var job = queue.shift(); + setTimeout(function(){ + var def = job.fun(); + if(def){ + def.then(run); + }else{ + run(); + } + },job.delay || 0); + }else{ + running = false; + } + }; + + // adds a job to the schedule. + this.schedule = function(fun, delay){ + queue.push({fun:fun, delay:delay}); + if(!running){ + run(); + } + } + + // remove all jobs from the schedule + this.clear = function(){ + queue = []; + }; + }; + + /* + module.BasicPaymentScreen = module.ScreenWidget.extend({ + queue: new JobQueue(), + start_payment_transaction: function(){ + }, + update_payment_transaction: function(){ + }, + cancel_payment_transaction: function(){ + }, + show: function(){ + this._super(); + }, + }); + */ + module.ClientPaymentScreenWidget = module.ScreenWidget.extend({ template:'ClientPaymentScreenWidget', @@ -548,50 +605,102 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa show: function(){ this._super(); var self = this; + + this.queue = new module.JobQueue(); + this.canceled = false; + this.paid = false; - this.pos.proxy.payment_request(this.pos.get('selectedOrder').getDueLeft(),'card','info'); //TODO TOTAL - - this.intervalID = setInterval(function(){ - var payment = self.pos.proxy.is_payment_accepted(); - if(payment === 'payment_accepted'){ - clearInterval(this.intervalID); - - var currentOrder = self.pos.get('selectedOrder'); - - //we get the first cashregister marked as self-checkout - var selfCheckoutRegisters = []; - for(var i = 0; i < self.pos.get('cashRegisters').models.length; i++){ - var cashregister = self.pos.get('cashRegisters').models[i]; - if(cashregister.self_checkout_payment_method){ - selfCheckoutRegisters.push(cashregister); + // initiates the connection to the payment terminal and starts the update requests + this.start = function(){ + var def = new $.Deferred(); + console.log("START"); + self.pos.proxy.payment_request(self.pos.get('selectedOrder').getDueLeft()) + .then(function(ack){ + if(ack === 'ok'){ + self.queue.schedule(self.update); + }else if(ack.indexOf('error') === 0){ + console.error('cannot make payment. TODO'); + }else{ + console.error('unknown payment request return value:',ack); } - } - - var cashregister = selfCheckoutRegisters[0] || self.pos.get('cashRegisters').models[0]; - currentOrder.addPaymentLine(cashregister); - self.pos.push_order(currentOrder.exportAsJSON()) - currentOrder.destroy(); - self.pos.proxy.transaction_end(); - self.pos_widget.screen_selector.set_current_screen(self.next_screen); - }else if(payment === 'payment_rejected'){ - clearInterval(self.intervalID); - //TODO show a tryagain thingie ? + console.log("START_END"); + def.resolve(); + }); + return def; + }; + + // gets updated status from the payment terminal and performs the appropriate consequences + this.update = function(){ + console.log("UPDATE"); + var def = new $.Deferred(); + if(self.canceled){ + console.log("UPDATE_END"); + return def.resolve(); } - },500); + self.pos.proxy.payment_status() + .then(function(status){ + if(status.status === 'paid'){ + + var currentOrder = self.pos.get('selectedOrder'); + + //we get the first cashregister marked as self-checkout + var selfCheckoutRegisters = []; + for(var i = 0; i < self.pos.get('cashRegisters').models.length; i++){ + var cashregister = self.pos.get('cashRegisters').models[i]; + if(cashregister.self_checkout_payment_method){ + selfCheckoutRegisters.push(cashregister); + } + } + + var cashregister = selfCheckoutRegisters[0] || self.pos.get('cashRegisters').models[0]; + currentOrder.addPaymentLine(cashregister); + self.pos.push_order(currentOrder.exportAsJSON()) + currentOrder.destroy(); + self.pos.proxy.transaction_end(); + self.pos_widget.screen_selector.set_current_screen(self.next_screen); + self.paid = true; + }else if(status.status.indexOf('error') === 0){ + console.error('error in payment request. TODO'); + }else if(status.status === 'waiting'){ + self.queue.schedule(self.update,200); + }else{ + console.error('unknown status value:',status.status); + } + console.log("UPDATE_END"); + def.resolve(); + }); + return def; + } + + // cancels a payment. + this.cancel = function(){ + console.log("CANCEL"); + if(!self.paid && !self.canceled){ + self.canceled = true; + self.pos.proxy.payment_cancel(); + self.pos_widget.screen_selector.set_current_screen(self.previous_screen); + self.queue.clear(); + } + console.log("CANCEL_END"); + return (new $.Deferred()).resolve(); + } + + this.queue.schedule(this.start); this.add_action_button({ label: 'back', icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ - clearInterval(this.intervalID); - self.pos.proxy.payment_canceled(); - self.pos_widget.screen_selector.set_current_screen(self.previous_screen); + self.queue.schedule(self.cancel); } }); }, close: function(){ + if(this.queue){ + this.queue.schedule(this.cancel); + } + //TODO CANCEL this._super(); - clearInterval(this.intervalID); }, }); diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index f4d16b527c8..47a527a010d 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -687,7 +687,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa 'print_receipt', 'print_pdf_invoice', 'weighting_read_kg', - 'is_payment_accepted', + 'payment_status', ], minimized: false, start: function(){ @@ -898,10 +898,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa this.error_popup = new module.ErrorPopupWidget(this, {}); this.error_popup.appendTo($('.point-of-sale')); - this.error_product_popup = new module.ErrorProductNotRecognizedPopupWidget(this, {}); + this.error_product_popup = new module.ProductErrorPopupWidget(this, {}); this.error_product_popup.appendTo($('.point-of-sale')); - this.error_session_popup = new module.ErrorNoSessionPopupWidget(this, {}); + this.error_session_popup = new module.ErrorSessionPopupWidget(this, {}); this.error_session_popup.appendTo($('.point-of-sale')); this.choose_receipt_popup = new module.ChooseReceiptPopupWidget(this, {}); diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 7af3c2c2255..53177b5ac4e 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -327,15 +327,20 @@
- + + - + From 62926be708d81935f2f47d92e4c312f2699133c5 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 20 Sep 2012 15:46:18 +0200 Subject: [PATCH 12/55] [WIP] oauth provider bzr revid: fme@openerp.com-20120920134618-ema9qyumuorvozig --- addons/auth_oauth_provider/__init__.py | 25 ++++++++++ addons/auth_oauth_provider/__openerp__.py | 42 ++++++++++++++++ .../controllers/__init__.py | 22 ++++++++ .../auth_oauth_provider/controllers/main.py | 38 ++++++++++++++ .../static/src/css/oauth_provider.css | 14 ++++++ .../static/src/css/oauth_provider.sass | 17 +++++++ .../static/src/js/oauth_provider.js | 50 +++++++++++++++++++ .../static/src/xml/oauth_provider.xml | 13 +++++ 8 files changed, 221 insertions(+) create mode 100644 addons/auth_oauth_provider/__init__.py create mode 100644 addons/auth_oauth_provider/__openerp__.py create mode 100644 addons/auth_oauth_provider/controllers/__init__.py create mode 100644 addons/auth_oauth_provider/controllers/main.py create mode 100644 addons/auth_oauth_provider/static/src/css/oauth_provider.css create mode 100644 addons/auth_oauth_provider/static/src/css/oauth_provider.sass create mode 100644 addons/auth_oauth_provider/static/src/js/oauth_provider.js create mode 100644 addons/auth_oauth_provider/static/src/xml/oauth_provider.xml diff --git a/addons/auth_oauth_provider/__init__.py b/addons/auth_oauth_provider/__init__.py new file mode 100644 index 00000000000..c19b731933c --- /dev/null +++ b/addons/auth_oauth_provider/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-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 . +# +############################################################################## + +import controllers + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/auth_oauth_provider/__openerp__.py b/addons/auth_oauth_provider/__openerp__.py new file mode 100644 index 00000000000..71a4971c9b8 --- /dev/null +++ b/addons/auth_oauth_provider/__openerp__.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-2012 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 . +# +############################################################################## + + +{ + 'name': 'OAuth Provider', + 'version': '1.0', + 'category': 'Tools', + 'description': """ +Allow an openerp server to provide OAuth service. +================================================= +""", + 'author': 'OpenERP s.a.', + 'maintainer': 'OpenERP s.a.', + 'website': 'http://www.openerp.com', + 'depends': ['base', 'web'], + #'data': ['res_users.xml'], + 'js': ['static/src/js/oauth_provider.js'], + 'css': ['static/src/css/oauth_provider.css'], + 'qweb': ['static/src/xml/oauth_provider.xml'], + 'installable': True, + 'auto_install': False, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/controllers/__init__.py b/addons/auth_oauth_provider/controllers/__init__.py new file mode 100644 index 00000000000..c5f359681b9 --- /dev/null +++ b/addons/auth_oauth_provider/controllers/__init__.py @@ -0,0 +1,22 @@ +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 OpenERP SA (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import main + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/controllers/main.py b/addons/auth_oauth_provider/controllers/main.py new file mode 100644 index 00000000000..50eed95b234 --- /dev/null +++ b/addons/auth_oauth_provider/controllers/main.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-2012 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 . +# +############################################################################## + +#import oauth.oauth as oauth +try: + import openerp.addons.web.common.http as openerpweb +except ImportError: + import web.common.http as openerpweb # noqa + + +class AuthOAuthProvider(openerpweb.Controller): + _cp_path = '/oauth2' + + @openerpweb.jsonrequest + def get_access_token(self, req, **kw): + return { + 'access_token': 'hefwjkhfejwk' + } + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/static/src/css/oauth_provider.css b/addons/auth_oauth_provider/static/src/css/oauth_provider.css new file mode 100644 index 00000000000..778179b63b4 --- /dev/null +++ b/addons/auth_oauth_provider/static/src/css/oauth_provider.css @@ -0,0 +1,14 @@ +@charset "utf-8"; +.openerp .oe_oauth_provider { + padding: 0 10px; +} +.openerp .oe_oauth_provider .oe_oauth_provider_error span.oe_i { + font-size: 60px; + color: #990000; + float: left; +} +.openerp .oe_oauth_provider .oe_oauth_provider_error ul { + list-style: none; + float: left; + font-weight: bold; +} diff --git a/addons/auth_oauth_provider/static/src/css/oauth_provider.sass b/addons/auth_oauth_provider/static/src/css/oauth_provider.sass new file mode 100644 index 00000000000..7921f4cc055 --- /dev/null +++ b/addons/auth_oauth_provider/static/src/css/oauth_provider.sass @@ -0,0 +1,17 @@ +@charset "utf-8" + + +.openerp .oe_oauth_provider + padding: 0 10px + .oe_oauth_provider_error + span.oe_i + font-size: 60px + color: #900 + float: left + ul + list-style: none + float: left + font-weight: bold + +// au BufWritePost,FileWritePost *.sass :!sass --style expanded --line-numbers > "%:p:r.css" +// vim:tabstop=4:shiftwidth=4:softtabstop=4:fdm=marker: diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js new file mode 100644 index 00000000000..9612559d038 --- /dev/null +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -0,0 +1,50 @@ +openerp.auth_oauth_provider = function(instance) { + +var QWeb = instance.web.qweb; +var _t = instance.web._t; + +instance.web.client_actions.add('oauth2_auth', 'instance.auth_oauth_provider.ProviderAction'); +instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ + template: "auth_oauth_provider", + start: function (parent) { + var self = this; + this._super.apply(this, arguments); + var params = $.deparam($.param.querystring()); + if (params.response_type !== 'token') { + this.error(_t("Unsupported 'response_type' parameter")); + } + if (!params.redirect_uri) { + this.error(_t("No 'redirect_uri' parameter given")); + } + // params.client_id TODO + // params.scope TODO + // params.approval_prompt TODO + if (!this._error) { + instance.session.rpc('/oauth2/get_access_token', {}).then(function(r) { + self.redirect(r.access_token); + }).fail(function() { + self.error(_t("An error occured while contacting the OpenERP server.")); + }); + } + }, + redirect: function(access_token) { + var params = $.deparam($.param.querystring()); + var a = document.createElement('a'); + a.href = params.redirect_uri; + var search = (a.search ? '&' : '?') + 'access_token=' + access_token; + if (params.state) { + search += "&state=" + params.state; + } + var redirect = a.protocol + '//' + a.host + a.pathname + search + a.hash; + //window.location = redirect; + console.log("redirect to", redirect); + }, + error: function(msg) { + this._error = true; + var $msg = $('
  • ').addClass('oe_oauth_provider_error_text').text(msg); + $msg.appendTo(this.$('.oe_oauth_provider_error').show().find('ul')); + return false; + }, +}); + +}; diff --git a/addons/auth_oauth_provider/static/src/xml/oauth_provider.xml b/addons/auth_oauth_provider/static/src/xml/oauth_provider.xml new file mode 100644 index 00000000000..ddf6ff08789 --- /dev/null +++ b/addons/auth_oauth_provider/static/src/xml/oauth_provider.xml @@ -0,0 +1,13 @@ + + From 100c0a60a5e35d8377fd5225a1b77b745d9a9bd3 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 20 Sep 2012 16:00:41 +0200 Subject: [PATCH 13/55] [ADD] Added res_user oauth token field bzr revid: fme@openerp.com-20120920140041-eied4nfw8pjs6ye8 --- addons/auth_oauth_provider/__init__.py | 1 + .../auth_oauth_provider/controllers/main.py | 5 +-- addons/auth_oauth_provider/res_users.py | 33 +++++++++++++++++++ .../static/src/js/oauth_provider.js | 2 +- 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 addons/auth_oauth_provider/res_users.py diff --git a/addons/auth_oauth_provider/__init__.py b/addons/auth_oauth_provider/__init__.py index c19b731933c..a6f4a72100b 100644 --- a/addons/auth_oauth_provider/__init__.py +++ b/addons/auth_oauth_provider/__init__.py @@ -20,6 +20,7 @@ ############################################################################## import controllers +import res_users # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/controllers/main.py b/addons/auth_oauth_provider/controllers/main.py index 50eed95b234..d0ca059aa93 100644 --- a/addons/auth_oauth_provider/controllers/main.py +++ b/addons/auth_oauth_provider/controllers/main.py @@ -30,9 +30,10 @@ class AuthOAuthProvider(openerpweb.Controller): _cp_path = '/oauth2' @openerpweb.jsonrequest - def get_access_token(self, req, **kw): + def get_token(self, req, **kw): + token = req.session.model('res.users').get_oauth_token() return { - 'access_token': 'hefwjkhfejwk' + 'access_token': token, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py new file mode 100644 index 00000000000..667ef3f838e --- /dev/null +++ b/addons/auth_oauth_provider/res_users.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-2012 OpenERP s.a. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import osv, fields + +class res_users(osv.osv): + _inherit = 'res.users' + + _columns = { + 'last_oauth_token': fields.char('Last OAuth Token', size=64, readonly=True, invisible=True), + } + + def get_oauth_token(self, cr, uid, context=None): + return "TOKENJEFILWJLK" + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index 9612559d038..f2bd4b21c00 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -20,7 +20,7 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ // params.scope TODO // params.approval_prompt TODO if (!this._error) { - instance.session.rpc('/oauth2/get_access_token', {}).then(function(r) { + instance.session.rpc('/oauth2/get_token', {}).then(function(r) { self.redirect(r.access_token); }).fail(function() { self.error(_t("An error occured while contacting the OpenERP server.")); From a6068f909e5dbdd8cb8207db64bbb9dff1c3d594 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 20 Sep 2012 17:15:38 +0200 Subject: [PATCH 14/55] [ADD] Create oauth token in res.users bzr revid: fme@openerp.com-20120920151538-stb6kamfpmwzf9xz --- addons/auth_oauth_provider/controllers/main.py | 4 ++-- addons/auth_oauth_provider/res_users.py | 11 ++++++++--- .../static/src/js/oauth_provider.js | 17 +++++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/addons/auth_oauth_provider/controllers/main.py b/addons/auth_oauth_provider/controllers/main.py index d0ca059aa93..79393a84a43 100644 --- a/addons/auth_oauth_provider/controllers/main.py +++ b/addons/auth_oauth_provider/controllers/main.py @@ -30,8 +30,8 @@ class AuthOAuthProvider(openerpweb.Controller): _cp_path = '/oauth2' @openerpweb.jsonrequest - def get_token(self, req, **kw): - token = req.session.model('res.users').get_oauth_token() + def get_token(self, req, client_id="", scope="", **kw): + token = req.session.model('res.users').get_oauth_token(client_id, scope) return { 'access_token': token, } diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py index 667ef3f838e..b1bf8270f0b 100644 --- a/addons/auth_oauth_provider/res_users.py +++ b/addons/auth_oauth_provider/res_users.py @@ -19,15 +19,20 @@ # ############################################################################## from openerp.osv import osv, fields +import random +import string class res_users(osv.osv): _inherit = 'res.users' _columns = { - 'last_oauth_token': fields.char('Last OAuth Token', size=64, readonly=True, invisible=True), + 'last_oauth_token': fields.char('Last OAuth Token', readonly=True, invisible=True), } - def get_oauth_token(self, cr, uid, context=None): - return "TOKENJEFILWJLK" + def get_oauth_token(self, cr, uid, client_id="", scope="", context=None): + chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + token = ''.join(random.choice(chars) for x in range(random.randrange(16, 24))) + self.write(cr, uid, [uid], { "last_oauth_token": token }, context=context) + return token # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index f2bd4b21c00..2551c82cd2a 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -16,25 +16,30 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ if (!params.redirect_uri) { this.error(_t("No 'redirect_uri' parameter given")); } - // params.client_id TODO - // params.scope TODO // params.approval_prompt TODO if (!this._error) { - instance.session.rpc('/oauth2/get_token', {}).then(function(r) { - self.redirect(r.access_token); + instance.session.rpc('/oauth2/get_token', { + client_id: params.client_id || '', + scope: params.scope || '', + }).then(function(result) { + self.redirect(result); }).fail(function() { self.error(_t("An error occured while contacting the OpenERP server.")); }); } }, - redirect: function(access_token) { + redirect: function(result) { var params = $.deparam($.param.querystring()); var a = document.createElement('a'); a.href = params.redirect_uri; - var search = (a.search ? '&' : '?') + 'access_token=' + access_token; + var search = (a.search ? '&' : '?') + 'access_token=' + result.access_token; if (params.state) { search += "&state=" + params.state; } + if (params.expires_in) { + search += "&expires_in=" + expires_in; + } + search += '&token_type=Bearer'; var redirect = a.protocol + '//' + a.host + a.pathname + search + a.hash; //window.location = redirect; console.log("redirect to", redirect); From 14f399df472031630852d02fb6177d49b21cbaa9 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 20 Sep 2012 17:45:57 +0200 Subject: [PATCH 15/55] [ADD] Added oauth tokeninfo bzr revid: fme@openerp.com-20120920154557-1ltsxnkoz6vzezan --- addons/auth_oauth_provider/controllers/main.py | 9 ++++++++- addons/auth_oauth_provider/res_users.py | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/addons/auth_oauth_provider/controllers/main.py b/addons/auth_oauth_provider/controllers/main.py index 79393a84a43..63bf3cad61c 100644 --- a/addons/auth_oauth_provider/controllers/main.py +++ b/addons/auth_oauth_provider/controllers/main.py @@ -25,15 +25,22 @@ try: except ImportError: import web.common.http as openerpweb # noqa +import simplejson + class AuthOAuthProvider(openerpweb.Controller): _cp_path = '/oauth2' @openerpweb.jsonrequest def get_token(self, req, client_id="", scope="", **kw): - token = req.session.model('res.users').get_oauth_token(client_id, scope) + token = req.session.model('res.users').auth_oauth_provider_get_token(client_id, scope) return { 'access_token': token, } + @openerpweb.httprequest + def tokeninfo(self, req, access_token="", **kw): + info = req.session.model('res.users').auth_oauth_provider_tokeninfo(access_token) + return simplejson.dumps(info) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py index b1bf8270f0b..dd2178a1dff 100644 --- a/addons/auth_oauth_provider/res_users.py +++ b/addons/auth_oauth_provider/res_users.py @@ -29,10 +29,23 @@ class res_users(osv.osv): 'last_oauth_token': fields.char('Last OAuth Token', readonly=True, invisible=True), } - def get_oauth_token(self, cr, uid, client_id="", scope="", context=None): + def auth_oauth_provider_get_token(self, cr, uid, client_id="", scope="", context=None): chars = string.ascii_uppercase + string.ascii_lowercase + string.digits token = ''.join(random.choice(chars) for x in range(random.randrange(16, 24))) self.write(cr, uid, [uid], { "last_oauth_token": token }, context=context) return token + def auth_oauth_provider_tokeninfo(self, cr, uid, access_token="", context=None): + if access_token == self.browse(cr, uid, [uid], context=context).access_token: + return { + "user_id": uid, + #"audience": "8819981768.apps.googleusercontent.com", + #"scope": "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email", + #"expires_in": 436 + } + else: + return { + "error": "invalid_token" + } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From d52896727b30848100776b9ca0db06e815f5ca37 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Sep 2012 10:17:02 +0200 Subject: [PATCH 16/55] [IMP] Use $.param for url search building bzr revid: fme@openerp.com-20120924081702-c3oxj1uf2i2ehgv8 --- .../static/src/js/oauth_provider.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index 2551c82cd2a..593c013d21a 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -32,15 +32,17 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ var params = $.deparam($.param.querystring()); var a = document.createElement('a'); a.href = params.redirect_uri; - var search = (a.search ? '&' : '?') + 'access_token=' + result.access_token; + var new_params = { + access_token: result.access_token, + token_type: 'Bearer', + }; if (params.state) { - search += "&state=" + params.state; + new_params.state = params.state; } - if (params.expires_in) { - search += "&expires_in=" + expires_in; + if (result.expires_in) { + new_params.expires_in = result.expires_in; } - search += '&token_type=Bearer'; - var redirect = a.protocol + '//' + a.host + a.pathname + search + a.hash; + var redirect = a.protocol + '//' + a.host + a.pathname + '?' + $.param(new_params) + a.hash; //window.location = redirect; console.log("redirect to", redirect); }, From 3ed1ce8255a4afb2247c7c282173d7a0f01fc53c Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Sep 2012 10:31:05 +0200 Subject: [PATCH 17/55] [IMP] Be honest bzr revid: fme@openerp.com-20120924083105-dvxj6gqunr6gewni --- addons/auth_oauth_provider/__openerp__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/auth_oauth_provider/__openerp__.py b/addons/auth_oauth_provider/__openerp__.py index 71a4971c9b8..d8b3d4e3c41 100644 --- a/addons/auth_oauth_provider/__openerp__.py +++ b/addons/auth_oauth_provider/__openerp__.py @@ -22,11 +22,11 @@ { 'name': 'OAuth Provider', - 'version': '1.0', + 'version': '0.1', 'category': 'Tools', 'description': """ -Allow an openerp server to provide OAuth service. -================================================= +Allow an openerp server to provide partial OAuth service. +========================================================= """, 'author': 'OpenERP s.a.', 'maintainer': 'OpenERP s.a.', From 6875258258a1478dd1356fc7176a025cf8f00a5b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Sep 2012 10:44:33 +0200 Subject: [PATCH 18/55] [IMP] Wip oauth bzr revid: fme@openerp.com-20120924084433-95rtadp5omhkc6x3 --- addons/auth_oauth_provider/res_users.py | 11 +++++++++-- .../static/src/js/oauth_provider.js | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py index dd2178a1dff..3831a6a97d0 100644 --- a/addons/auth_oauth_provider/res_users.py +++ b/addons/auth_oauth_provider/res_users.py @@ -26,19 +26,26 @@ class res_users(osv.osv): _inherit = 'res.users' _columns = { + # TODO: partial implementation supporting only one client_id for the moment. 'last_oauth_token': fields.char('Last OAuth Token', readonly=True, invisible=True), + 'last_oauth_token_scope': fields.char('Last OAuth Token Scope', readonly=True, invisible=True), } def auth_oauth_provider_get_token(self, cr, uid, client_id="", scope="", context=None): chars = string.ascii_uppercase + string.ascii_lowercase + string.digits token = ''.join(random.choice(chars) for x in range(random.randrange(16, 24))) - self.write(cr, uid, [uid], { "last_oauth_token": token }, context=context) + self.write(cr, uid, [uid], { + "last_oauth_token": token, + "last_oauth_token_scope": scope, + }, context=context) return token def auth_oauth_provider_tokeninfo(self, cr, uid, access_token="", context=None): - if access_token == self.browse(cr, uid, [uid], context=context).access_token: + user = self.browse(cr, uid, [uid], context=context) + if access_token == user.last_oauth_token: return { "user_id": uid, + "scope": user.last_oauth_token_scope, #"audience": "8819981768.apps.googleusercontent.com", #"scope": "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email", #"expires_in": 436 diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index 593c013d21a..eb2c1982d31 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -16,6 +16,10 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ if (!params.redirect_uri) { this.error(_t("No 'redirect_uri' parameter given")); } + // params.client_id + // TODO: check if client_id application is authorized to use the service, and get it's name + // that should be displayed in the approval confirmation dialog. + // params.approval_prompt TODO if (!this._error) { instance.session.rpc('/oauth2/get_token', { From a74b35ee3758545dabd811fe8ac9d0c68a3420ca Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Sep 2012 12:39:31 +0200 Subject: [PATCH 19/55] [ADD] Added oauth approval wip bzr revid: fme@openerp.com-20120924103931-d2zj6p8shpljf0v9 --- .../static/src/js/oauth_provider.js | 40 ++++++++++++------- .../static/src/xml/oauth_provider.xml | 11 +++++ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index eb2c1982d31..a5e05c60283 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -20,15 +20,22 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ // TODO: check if client_id application is authorized to use the service, and get it's name // that should be displayed in the approval confirmation dialog. - // params.approval_prompt TODO if (!this._error) { - instance.session.rpc('/oauth2/get_token', { - client_id: params.client_id || '', - scope: params.scope || '', - }).then(function(result) { - self.redirect(result); - }).fail(function() { - self.error(_t("An error occured while contacting the OpenERP server.")); + // params.approval_prompt TODO + // TODO: get client_id and scope + this.$('.oe_oauth_provider_approval').show().on('click', '.oe_oauth_provider_allow', function() { + instance.session.rpc('/oauth2/get_token', { + client_id: params.client_id || '', + scope: params.scope || '', + }).then(function(result) { + self.redirect(result); + }).fail(function() { + self.error(_t("An error occured while contacting the OpenERP server.")); + }); + }).on('click', '.oe_oauth_provider_deny', function() { + self.redirect({ + error: 'access_denied' + }); }); } }, @@ -36,16 +43,19 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ var params = $.deparam($.param.querystring()); var a = document.createElement('a'); a.href = params.redirect_uri; - var new_params = { - access_token: result.access_token, - token_type: 'Bearer', - }; + var new_params = {}; + if (!result.error) { + new_params.access_token = result.access_token; + new_params.token_type = 'Bearer'; + if (result.expires_in) { + new_params.expires_in = result.expires_in; + } + } else { + new_params.error = result.error; + } if (params.state) { new_params.state = params.state; } - if (result.expires_in) { - new_params.expires_in = result.expires_in; - } var redirect = a.protocol + '//' + a.host + a.pathname + '?' + $.param(new_params) + a.hash; //window.location = redirect; console.log("redirect to", redirect); diff --git a/addons/auth_oauth_provider/static/src/xml/oauth_provider.xml b/addons/auth_oauth_provider/static/src/xml/oauth_provider.xml index ddf6ff08789..85985e4e974 100644 --- a/addons/auth_oauth_provider/static/src/xml/oauth_provider.xml +++ b/addons/auth_oauth_provider/static/src/xml/oauth_provider.xml @@ -8,6 +8,17 @@ D
      + From 292252eb7dd18de14a3d4504e33c7b8df2936fbc Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Sep 2012 17:37:29 +0200 Subject: [PATCH 20/55] [ADD] Make things work .... or not ? bzr revid: fme@openerp.com-20120924153729-e7lsjvfxfpjzrpm7 --- .../auth_oauth_provider/controllers/main.py | 31 ++++++++++++++++--- addons/auth_oauth_provider/res_users.py | 12 +++++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/addons/auth_oauth_provider/controllers/main.py b/addons/auth_oauth_provider/controllers/main.py index 63bf3cad61c..7ca4ab75d56 100644 --- a/addons/auth_oauth_provider/controllers/main.py +++ b/addons/auth_oauth_provider/controllers/main.py @@ -23,14 +23,27 @@ try: import openerp.addons.web.common.http as openerpweb except ImportError: - import web.common.http as openerpweb # noqa + import web.common.http as openerpweb + +import openerp.modules.registry +from openerp import SUPERUSER_ID import simplejson - +import werkzeug +import urllib class AuthOAuthProvider(openerpweb.Controller): _cp_path = '/oauth2' + @openerpweb.httprequest + def auth(self, req, **kw): + # TODO: if logged and approval_prompt == auto then return get_token and redirect + search = req.params.copy() + if req.debug: + search['debug'] = 1 + redirect_url = '/?' + urllib.urlencode(search) + '#action=oauth2_auth' + return werkzeug.utils.redirect(redirect_url, 303) + @openerpweb.jsonrequest def get_token(self, req, client_id="", scope="", **kw): token = req.session.model('res.users').auth_oauth_provider_get_token(client_id, scope) @@ -39,8 +52,16 @@ class AuthOAuthProvider(openerpweb.Controller): } @openerpweb.httprequest - def tokeninfo(self, req, access_token="", **kw): - info = req.session.model('res.users').auth_oauth_provider_tokeninfo(access_token) - return simplejson.dumps(info) + def tokeninfo(self, req, dbname=None, access_token=None, **kw): + if not dbname or not access_token: + return simplejson.dumps({ "error": "No 'dbname' or 'access_token' url parameters specified." }) + try: + registry = openerp.modules.registry.RegistryManager.get(dbname) + with registry.cursor() as cr: + u = registry.get('res.users') + info = u.auth_oauth_provider_tokeninfo(cr, SUPERUSER_ID, access_token, kw) + return simplejson.dumps(info) + except Exception, e: + return simplejson.dumps({ "error": e.message }) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py index 3831a6a97d0..983672e0261 100644 --- a/addons/auth_oauth_provider/res_users.py +++ b/addons/auth_oauth_provider/res_users.py @@ -40,14 +40,20 @@ class res_users(osv.osv): }, context=context) return token - def auth_oauth_provider_tokeninfo(self, cr, uid, access_token="", context=None): - user = self.browse(cr, uid, [uid], context=context) + def auth_oauth_provider_tokeninfo(self, cr, uid, access_token, context=None): + user_id = self.search(cr, uid, [('last_oauth_token', '=', access_token)], context=context) + if len(user_id) != 1: + return { + "error": "invalid_token" + } + user = self.browse(cr, uid, user_id[0], context=context) if access_token == user.last_oauth_token: return { "user_id": uid, "scope": user.last_oauth_token_scope, + "email": user.partner_id.email or '', # TODO: should deliver only according to scopes + "scope": user.last_oauth_token_scope, #"audience": "8819981768.apps.googleusercontent.com", - #"scope": "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email", #"expires_in": 436 } else: From 1b5939817ff82d4356dd4da00ea7d7a9bd448a3b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Sep 2012 18:02:13 +0200 Subject: [PATCH 21/55] [FIX] Return correct userid in tokeninfo bzr revid: fme@openerp.com-20120924160213-kfjdi6s01mcic9jp --- addons/auth_oauth_provider/controllers/main.py | 1 - addons/auth_oauth_provider/res_users.py | 2 +- addons/auth_oauth_provider/static/src/js/oauth_provider.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/auth_oauth_provider/controllers/main.py b/addons/auth_oauth_provider/controllers/main.py index 7ca4ab75d56..944e3e44bf9 100644 --- a/addons/auth_oauth_provider/controllers/main.py +++ b/addons/auth_oauth_provider/controllers/main.py @@ -37,7 +37,6 @@ class AuthOAuthProvider(openerpweb.Controller): @openerpweb.httprequest def auth(self, req, **kw): - # TODO: if logged and approval_prompt == auto then return get_token and redirect search = req.params.copy() if req.debug: search['debug'] = 1 diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py index 983672e0261..38200597730 100644 --- a/addons/auth_oauth_provider/res_users.py +++ b/addons/auth_oauth_provider/res_users.py @@ -49,7 +49,7 @@ class res_users(osv.osv): user = self.browse(cr, uid, user_id[0], context=context) if access_token == user.last_oauth_token: return { - "user_id": uid, + "user_id": user.id, "scope": user.last_oauth_token_scope, "email": user.partner_id.email or '', # TODO: should deliver only according to scopes "scope": user.last_oauth_token_scope, diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index a5e05c60283..f08b098efed 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -21,7 +21,7 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ // that should be displayed in the approval confirmation dialog. if (!this._error) { - // params.approval_prompt TODO + // params.approval_prompt TODO --> add 'none' (default) // TODO: get client_id and scope this.$('.oe_oauth_provider_approval').show().on('click', '.oe_oauth_provider_allow', function() { instance.session.rpc('/oauth2/get_token', { From a129da845af5880ad3c7bca7bf53f1874bbccda6 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Sep 2012 18:15:18 +0200 Subject: [PATCH 22/55] [ACTIVATE] Yes ! Activate ! bzr revid: fme@openerp.com-20120924161518-n0096bt1j2n04cpa --- addons/auth_oauth_provider/static/src/js/oauth_provider.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index f08b098efed..b81b824cd88 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -57,8 +57,7 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ new_params.state = params.state; } var redirect = a.protocol + '//' + a.host + a.pathname + '?' + $.param(new_params) + a.hash; - //window.location = redirect; - console.log("redirect to", redirect); + window.location = redirect; }, error: function(msg) { this._error = true; From 6a99c09facf3c098dadba35c1728e14f1a92e7ef Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 25 Sep 2012 10:23:57 +0200 Subject: [PATCH 23/55] [IMP] Use uuid for tokens bzr revid: fme@openerp.com-20120925082357-g1yfq8udbwdda296 --- addons/auth_oauth_provider/res_users.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py index 38200597730..20d9e9c7ade 100644 --- a/addons/auth_oauth_provider/res_users.py +++ b/addons/auth_oauth_provider/res_users.py @@ -19,21 +19,19 @@ # ############################################################################## from openerp.osv import osv, fields -import random -import string +import uuid class res_users(osv.osv): _inherit = 'res.users' _columns = { # TODO: partial implementation supporting only one client_id for the moment. - 'last_oauth_token': fields.char('Last OAuth Token', readonly=True, invisible=True), + 'last_oauth_token': fields.char('Last OAuth Token', size=32, readonly=True, invisible=True), 'last_oauth_token_scope': fields.char('Last OAuth Token Scope', readonly=True, invisible=True), } def auth_oauth_provider_get_token(self, cr, uid, client_id="", scope="", context=None): - chars = string.ascii_uppercase + string.ascii_lowercase + string.digits - token = ''.join(random.choice(chars) for x in range(random.randrange(16, 24))) + token = str(uuid.uuid4()).replace('-', '') self.write(cr, uid, [uid], { "last_oauth_token": token, "last_oauth_token_scope": scope, From a19717019449a86973269ef7cefa492dd44ca97d Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 25 Sep 2012 11:51:19 +0200 Subject: [PATCH 24/55] [ADD] Added OpenERP Online oauth provider + openerp zocial css bzr revid: fme@openerp.com-20120925095119-erlvy2vjqxrkjvy6 --- addons/auth_oauth/__openerp__.py | 5 +++- addons/auth_oauth/auth_oauth_data.xml | 9 +++++++ .../auth_oauth/static/src/css/auth_oauth.css | 26 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 addons/auth_oauth/static/src/css/auth_oauth.css diff --git a/addons/auth_oauth/__openerp__.py b/addons/auth_oauth/__openerp__.py index d43815e8018..c8da9c65d4a 100644 --- a/addons/auth_oauth/__openerp__.py +++ b/addons/auth_oauth/__openerp__.py @@ -38,7 +38,10 @@ Allow users to login through Google OAuth2. 'security/ir.model.access.csv' ], 'js': ['static/src/js/auth_oauth.js'], - 'css': ['static/lib/zocial/css/zocial.css'], + 'css': [ + 'static/lib/zocial/css/zocial.css', + 'static/src/css/auth_oauth.css', + ], 'qweb': ['static/src/xml/auth_oauth.xml'], 'installable': True, 'auto_install': False, diff --git a/addons/auth_oauth/auth_oauth_data.xml b/addons/auth_oauth/auth_oauth_data.xml index 7bb95192e5d..86b0f6c593e 100644 --- a/addons/auth_oauth/auth_oauth_data.xml +++ b/addons/auth_oauth/auth_oauth_data.xml @@ -2,6 +2,15 @@ + + OpenERP + https://openerp.my.openerp.com/oauth2/auth + userinfo + https://openerp.my.openerp.com/oauth2/tokeninfo + + zocial openerp + Sign in with OpenERP Online + Facebook Graph https://www.facebook.com/dialog/oauth diff --git a/addons/auth_oauth/static/src/css/auth_oauth.css b/addons/auth_oauth/static/src/css/auth_oauth.css new file mode 100644 index 00000000000..ffec2a0a1e8 --- /dev/null +++ b/addons/auth_oauth/static/src/css/auth_oauth.css @@ -0,0 +1,26 @@ +.zocial.openerp:before { + content: "\E02E"; + font-style: italic; +} + +a.zocial.openerp { + float: right; + border: 1px solid #222222; + color: white; + margin: 0; + background-color: #b92020; + background-image: -webkit-gradient(linear, left top, left bottom, from(#b92020), to(#600606)); + background-image: -webkit-linear-gradient(top, #b92020, #600606); + background-image: -moz-linear-gradient(top, #b92020, #600606); + background-image: -ms-linear-gradient(top, #b92020, #600606); + background-image: -o-linear-gradient(top, #b92020, #600606); + background-image: linear-gradient(to bottom, #b92020, #600606); + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(155, 155, 155, 0.4) inset; + -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(155, 155, 155, 0.4) inset; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(155, 155, 155, 0.4) inset; + text-shadow: none; + font-weight: normal; +} From 404c2c2dbaa21d1520ac89430a7f565e1008d471 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 25 Sep 2012 12:32:11 +0200 Subject: [PATCH 25/55] [IMP] Minor css change bzr revid: fme@openerp.com-20120925103211-l1yfgp9s7ro3twuo --- addons/auth_oauth/static/src/css/auth_oauth.css | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/auth_oauth/static/src/css/auth_oauth.css b/addons/auth_oauth/static/src/css/auth_oauth.css index ffec2a0a1e8..ef0d648e950 100644 --- a/addons/auth_oauth/static/src/css/auth_oauth.css +++ b/addons/auth_oauth/static/src/css/auth_oauth.css @@ -1,6 +1,7 @@ .zocial.openerp:before { content: "\E02E"; font-style: italic; + text-shadow: 0 1px 1px black; } a.zocial.openerp { From 5a6c5044191486310f52e69bb39ec28f2f65b4e7 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 25 Sep 2012 14:01:29 +0200 Subject: [PATCH 26/55] [IMP] Pimp my gimp bzr revid: fme@openerp.com-20120925120129-0wx4451e1bi81dn6 --- addons/auth_oauth/auth_oauth_data.xml | 2 +- addons/auth_oauth/static/src/css/auth_oauth.css | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/auth_oauth/auth_oauth_data.xml b/addons/auth_oauth/auth_oauth_data.xml index 86b0f6c593e..feb4e5339ad 100644 --- a/addons/auth_oauth/auth_oauth_data.xml +++ b/addons/auth_oauth/auth_oauth_data.xml @@ -3,7 +3,7 @@ - OpenERP + OpenERP Online https://openerp.my.openerp.com/oauth2/auth userinfo https://openerp.my.openerp.com/oauth2/tokeninfo diff --git a/addons/auth_oauth/static/src/css/auth_oauth.css b/addons/auth_oauth/static/src/css/auth_oauth.css index ef0d648e950..8e267e17845 100644 --- a/addons/auth_oauth/static/src/css/auth_oauth.css +++ b/addons/auth_oauth/static/src/css/auth_oauth.css @@ -1,3 +1,7 @@ +.openerp .oe_application .zocial { + font: white; +} + .zocial.openerp:before { content: "\E02E"; font-style: italic; From 3120f9e0485a180ba08ed9e364d3698c00580f0b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 25 Sep 2012 14:51:25 +0200 Subject: [PATCH 27/55] [FIX] redirect should use hash instead of url params bzr revid: fme@openerp.com-20120925125125-58j0z3g3evbvi7bc --- addons/auth_oauth_provider/static/src/js/oauth_provider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth_provider/static/src/js/oauth_provider.js index b81b824cd88..84a89415ed3 100644 --- a/addons/auth_oauth_provider/static/src/js/oauth_provider.js +++ b/addons/auth_oauth_provider/static/src/js/oauth_provider.js @@ -56,7 +56,7 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ if (params.state) { new_params.state = params.state; } - var redirect = a.protocol + '//' + a.host + a.pathname + '?' + $.param(new_params) + a.hash; + var redirect = params.redirect_uri + (a.hash ? '&' : '#') + $.param(new_params); window.location = redirect; }, error: function(msg) { From 35f5ea03f8cf558e07dce6f9ca507a1271978220 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 26 Sep 2012 11:43:00 +0200 Subject: [PATCH 28/55] [FIX] oauth provider: do not return email key if user has no email bzr revid: fme@openerp.com-20120926094300-09qcpak6qg5eokeh --- addons/auth_oauth_provider/res_users.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth_provider/res_users.py index 20d9e9c7ade..833286b5642 100644 --- a/addons/auth_oauth_provider/res_users.py +++ b/addons/auth_oauth_provider/res_users.py @@ -46,14 +46,15 @@ class res_users(osv.osv): } user = self.browse(cr, uid, user_id[0], context=context) if access_token == user.last_oauth_token: - return { + r = { "user_id": user.id, "scope": user.last_oauth_token_scope, - "email": user.partner_id.email or '', # TODO: should deliver only according to scopes - "scope": user.last_oauth_token_scope, #"audience": "8819981768.apps.googleusercontent.com", #"expires_in": 436 } + if user.partner_id.email: # TODO: should deliver only according to scopes + r['email'] = user.partner_id.email + return r else: return { "error": "invalid_token" From 4536fe76cad54bffcd5d5532f462475b4cdae43f Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 26 Sep 2012 11:43:36 +0200 Subject: [PATCH 29/55] [FIX] oauth: make oauth works with providers not necessarily returning name and email (eg: facebook, OpenERP online) bzr revid: fme@openerp.com-20120926094336-xir22x45wpn98lqd --- addons/auth_oauth/res_users.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/addons/auth_oauth/res_users.py b/addons/auth_oauth/res_users.py index b4f62612746..fd26e89c2e3 100644 --- a/addons/auth_oauth/res_users.py +++ b/addons/auth_oauth/res_users.py @@ -1,6 +1,7 @@ import logging import urllib +import urlparse import urllib2 import simplejson @@ -20,8 +21,11 @@ class res_users(osv.Model): } def auth_oauth_rpc(self, cr, uid, endpoint, access_token, context=None): - params = urllib.urlencode({'access_token':access_token}) - url = endpoint + '?' + params + params = urllib.urlencode({ 'access_token': access_token }) + if urlparse.urlparse(endpoint)[4]: + url = endpoint + '&' + params + else: + url = endpoint + '?' + params f = urllib2.urlopen(url) response = f.read() return simplejson.loads(response) @@ -38,26 +42,32 @@ class res_users(osv.Model): validation = self.auth_oauth_rpc(cr, uid, p.validation_endpoint, access_token) if validation.get("error"): raise openerp.exceptions.AccessDenied - login = validation['email'] + if p.data_endpoint: + data = self.auth_oauth_rpc(cr, uid, p.data_endpoint, access_token) + validation.update(data) + # required oauth_uid = validation['user_id'] - name = self.auth_oauth_rpc(cr, uid, p.data_endpoint, access_token)['name'] - - credentials = (cr.dbname, login, access_token) + if not oauth_uid: + raise openerp.exceptions.AccessDenied + email = validation.get('email', 'provider_%d_user_%d' % (p.id, oauth_uid)) + # optional + name = validation.get('name', email) res = self.search(cr, uid, [("oauth_uid", "=", oauth_uid)]) if res: - self.write(cr, uid, res[0], {'oauth_access_token':access_token}) + self.write(cr, uid, res[0], { 'oauth_access_token': access_token }) else: # New user new_user = { 'name': name, - 'login': login, - 'user_email': login, - 'oauth_provider_id': 1, + 'login': email, + 'user_email': email, + 'oauth_provider_id': p.id, 'oauth_uid': oauth_uid, 'oauth_access_token': access_token, 'active': True, } self.auth_signup_create(cr, uid, new_user) + credentials = (cr.dbname, email, access_token) return credentials def check_credentials(self, cr, uid, password): From 5e3a747290f6e322e19de984e9d8328871e05d7d Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 26 Sep 2012 13:31:02 +0200 Subject: [PATCH 30/55] [REN] Renamed the module to auth_oauth2_provider bzr revid: fme@openerp.com-20120926113102-pdhpz9zh6zirrapw --- .../__init__.py | 2 +- .../__openerp__.py | 13 ++-- .../auth_oauth2_provider.py | 64 +++++++++++++++++ .../controllers/__init__.py | 0 .../controllers/main.py | 0 .../res_users.py | 0 .../static/src/css/auth_oauth2_provider.css} | 0 .../static/src/css/auth_oauth2_provider.sass} | 0 .../static/src/css/oauth_provider.css | 14 ++++ .../static/src/css/oauth_provider.sass | 17 +++++ .../static/src/js/auth_oauth2_provider.js} | 0 .../static/src/js/oauth_provider.js | 70 +++++++++++++++++++ .../static/src/xml/oauth_provider.xml | 0 13 files changed, 172 insertions(+), 8 deletions(-) rename addons/{auth_oauth_provider => auth_oauth2_provider}/__init__.py (97%) rename addons/{auth_oauth_provider => auth_oauth2_provider}/__openerp__.py (80%) create mode 100644 addons/auth_oauth2_provider/auth_oauth2_provider.py rename addons/{auth_oauth_provider => auth_oauth2_provider}/controllers/__init__.py (100%) rename addons/{auth_oauth_provider => auth_oauth2_provider}/controllers/main.py (100%) rename addons/{auth_oauth_provider => auth_oauth2_provider}/res_users.py (100%) rename addons/{auth_oauth_provider/static/src/css/oauth_provider.css => auth_oauth2_provider/static/src/css/auth_oauth2_provider.css} (100%) rename addons/{auth_oauth_provider/static/src/css/oauth_provider.sass => auth_oauth2_provider/static/src/css/auth_oauth2_provider.sass} (100%) create mode 100644 addons/auth_oauth2_provider/static/src/css/oauth_provider.css create mode 100644 addons/auth_oauth2_provider/static/src/css/oauth_provider.sass rename addons/{auth_oauth_provider/static/src/js/oauth_provider.js => auth_oauth2_provider/static/src/js/auth_oauth2_provider.js} (100%) create mode 100644 addons/auth_oauth2_provider/static/src/js/oauth_provider.js rename addons/{auth_oauth_provider => auth_oauth2_provider}/static/src/xml/oauth_provider.xml (100%) diff --git a/addons/auth_oauth_provider/__init__.py b/addons/auth_oauth2_provider/__init__.py similarity index 97% rename from addons/auth_oauth_provider/__init__.py rename to addons/auth_oauth2_provider/__init__.py index a6f4a72100b..4c5cc7b36e1 100644 --- a/addons/auth_oauth_provider/__init__.py +++ b/addons/auth_oauth2_provider/__init__.py @@ -20,7 +20,7 @@ ############################################################################## import controllers -import res_users +import auth_oauth2_provider # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/__openerp__.py b/addons/auth_oauth2_provider/__openerp__.py similarity index 80% rename from addons/auth_oauth_provider/__openerp__.py rename to addons/auth_oauth2_provider/__openerp__.py index d8b3d4e3c41..b792f3b6f10 100644 --- a/addons/auth_oauth_provider/__openerp__.py +++ b/addons/auth_oauth2_provider/__openerp__.py @@ -21,21 +21,20 @@ { - 'name': 'OAuth Provider', + 'name': 'OAuth2 Provider', 'version': '0.1', 'category': 'Tools', 'description': """ -Allow an openerp server to provide partial OAuth service. -========================================================= +Allow an openerp server to provide OAuth2 authentication service. +================================================================= """, 'author': 'OpenERP s.a.', 'maintainer': 'OpenERP s.a.', 'website': 'http://www.openerp.com', 'depends': ['base', 'web'], - #'data': ['res_users.xml'], - 'js': ['static/src/js/oauth_provider.js'], - 'css': ['static/src/css/oauth_provider.css'], - 'qweb': ['static/src/xml/oauth_provider.xml'], + 'js': ['static/src/js/auth_oauth2_provider.js'], + 'css': ['static/src/css/auth_oauth2_provider.css'], + 'qweb': ['static/src/xml/auth_oauth2_provider.xml'], 'installable': True, 'auto_install': False, } diff --git a/addons/auth_oauth2_provider/auth_oauth2_provider.py b/addons/auth_oauth2_provider/auth_oauth2_provider.py new file mode 100644 index 00000000000..1792d038b27 --- /dev/null +++ b/addons/auth_oauth2_provider/auth_oauth2_provider.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-2012 OpenERP s.a. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import osv, fields +import uuid + +class res_users(osv.osv): + """Oauth2 Provider Class""" + _inherit = 'res.users' + + _columns = { + # TODO: partial implementation supporting only one client_id for the moment. + 'last_oauth_token': fields.char('Last OAuth Token', size=32, readonly=True, invisible=True), + 'last_oauth_token_scope': fields.char('Last OAuth Token Scope', readonly=True, invisible=True), + } + + def auth_oauth_provider_get_token(self, cr, uid, client_id="", scope="", context=None): + token = str(uuid.uuid4()).replace('-', '') + self.write(cr, uid, [uid], { + "last_oauth_token": token, + "last_oauth_token_scope": scope, + }, context=context) + return token + + def auth_oauth_provider_tokeninfo(self, cr, uid, access_token, context=None): + user_id = self.search(cr, uid, [('last_oauth_token', '=', access_token)], context=context) + if len(user_id) != 1: + return { + "error": "invalid_token" + } + user = self.browse(cr, uid, user_id[0], context=context) + if access_token == user.last_oauth_token: + r = { + "user_id": user.id, + "scope": user.last_oauth_token_scope, + #"audience": "8819981768.apps.googleusercontent.com", + #"expires_in": 436 + } + if user.partner_id.email: # TODO: should deliver only according to scopes + r['email'] = user.partner_id.email + return r + else: + return { + "error": "invalid_token" + } + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth_provider/controllers/__init__.py b/addons/auth_oauth2_provider/controllers/__init__.py similarity index 100% rename from addons/auth_oauth_provider/controllers/__init__.py rename to addons/auth_oauth2_provider/controllers/__init__.py diff --git a/addons/auth_oauth_provider/controllers/main.py b/addons/auth_oauth2_provider/controllers/main.py similarity index 100% rename from addons/auth_oauth_provider/controllers/main.py rename to addons/auth_oauth2_provider/controllers/main.py diff --git a/addons/auth_oauth_provider/res_users.py b/addons/auth_oauth2_provider/res_users.py similarity index 100% rename from addons/auth_oauth_provider/res_users.py rename to addons/auth_oauth2_provider/res_users.py diff --git a/addons/auth_oauth_provider/static/src/css/oauth_provider.css b/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.css similarity index 100% rename from addons/auth_oauth_provider/static/src/css/oauth_provider.css rename to addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.css diff --git a/addons/auth_oauth_provider/static/src/css/oauth_provider.sass b/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.sass similarity index 100% rename from addons/auth_oauth_provider/static/src/css/oauth_provider.sass rename to addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.sass diff --git a/addons/auth_oauth2_provider/static/src/css/oauth_provider.css b/addons/auth_oauth2_provider/static/src/css/oauth_provider.css new file mode 100644 index 00000000000..778179b63b4 --- /dev/null +++ b/addons/auth_oauth2_provider/static/src/css/oauth_provider.css @@ -0,0 +1,14 @@ +@charset "utf-8"; +.openerp .oe_oauth_provider { + padding: 0 10px; +} +.openerp .oe_oauth_provider .oe_oauth_provider_error span.oe_i { + font-size: 60px; + color: #990000; + float: left; +} +.openerp .oe_oauth_provider .oe_oauth_provider_error ul { + list-style: none; + float: left; + font-weight: bold; +} diff --git a/addons/auth_oauth2_provider/static/src/css/oauth_provider.sass b/addons/auth_oauth2_provider/static/src/css/oauth_provider.sass new file mode 100644 index 00000000000..7921f4cc055 --- /dev/null +++ b/addons/auth_oauth2_provider/static/src/css/oauth_provider.sass @@ -0,0 +1,17 @@ +@charset "utf-8" + + +.openerp .oe_oauth_provider + padding: 0 10px + .oe_oauth_provider_error + span.oe_i + font-size: 60px + color: #900 + float: left + ul + list-style: none + float: left + font-weight: bold + +// au BufWritePost,FileWritePost *.sass :!sass --style expanded --line-numbers > "%:p:r.css" +// vim:tabstop=4:shiftwidth=4:softtabstop=4:fdm=marker: diff --git a/addons/auth_oauth_provider/static/src/js/oauth_provider.js b/addons/auth_oauth2_provider/static/src/js/auth_oauth2_provider.js similarity index 100% rename from addons/auth_oauth_provider/static/src/js/oauth_provider.js rename to addons/auth_oauth2_provider/static/src/js/auth_oauth2_provider.js diff --git a/addons/auth_oauth2_provider/static/src/js/oauth_provider.js b/addons/auth_oauth2_provider/static/src/js/oauth_provider.js new file mode 100644 index 00000000000..84a89415ed3 --- /dev/null +++ b/addons/auth_oauth2_provider/static/src/js/oauth_provider.js @@ -0,0 +1,70 @@ +openerp.auth_oauth_provider = function(instance) { + +var QWeb = instance.web.qweb; +var _t = instance.web._t; + +instance.web.client_actions.add('oauth2_auth', 'instance.auth_oauth_provider.ProviderAction'); +instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ + template: "auth_oauth_provider", + start: function (parent) { + var self = this; + this._super.apply(this, arguments); + var params = $.deparam($.param.querystring()); + if (params.response_type !== 'token') { + this.error(_t("Unsupported 'response_type' parameter")); + } + if (!params.redirect_uri) { + this.error(_t("No 'redirect_uri' parameter given")); + } + // params.client_id + // TODO: check if client_id application is authorized to use the service, and get it's name + // that should be displayed in the approval confirmation dialog. + + if (!this._error) { + // params.approval_prompt TODO --> add 'none' (default) + // TODO: get client_id and scope + this.$('.oe_oauth_provider_approval').show().on('click', '.oe_oauth_provider_allow', function() { + instance.session.rpc('/oauth2/get_token', { + client_id: params.client_id || '', + scope: params.scope || '', + }).then(function(result) { + self.redirect(result); + }).fail(function() { + self.error(_t("An error occured while contacting the OpenERP server.")); + }); + }).on('click', '.oe_oauth_provider_deny', function() { + self.redirect({ + error: 'access_denied' + }); + }); + } + }, + redirect: function(result) { + var params = $.deparam($.param.querystring()); + var a = document.createElement('a'); + a.href = params.redirect_uri; + var new_params = {}; + if (!result.error) { + new_params.access_token = result.access_token; + new_params.token_type = 'Bearer'; + if (result.expires_in) { + new_params.expires_in = result.expires_in; + } + } else { + new_params.error = result.error; + } + if (params.state) { + new_params.state = params.state; + } + var redirect = params.redirect_uri + (a.hash ? '&' : '#') + $.param(new_params); + window.location = redirect; + }, + error: function(msg) { + this._error = true; + var $msg = $('
    • ').addClass('oe_oauth_provider_error_text').text(msg); + $msg.appendTo(this.$('.oe_oauth_provider_error').show().find('ul')); + return false; + }, +}); + +}; diff --git a/addons/auth_oauth_provider/static/src/xml/oauth_provider.xml b/addons/auth_oauth2_provider/static/src/xml/oauth_provider.xml similarity index 100% rename from addons/auth_oauth_provider/static/src/xml/oauth_provider.xml rename to addons/auth_oauth2_provider/static/src/xml/oauth_provider.xml From 08cea541f8725fa52878860acd18cd44320875a6 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 26 Sep 2012 18:18:31 +0200 Subject: [PATCH 31/55] [ADD] Add auth.oauth2.token bzr revid: fme@openerp.com-20120926161831-q4uxxr3slqth9mzy --- .../auth_oauth2_provider.py | 87 +++++++++++-------- .../auth_oauth2_provider/controllers/main.py | 12 ++- .../static/src/css/auth_oauth2_provider.css | 6 +- .../static/src/css/auth_oauth2_provider.sass | 4 +- .../static/src/js/auth_oauth2_provider.js | 16 ++-- ..._provider.xml => auth_oauth2_provider.xml} | 12 +-- 6 files changed, 77 insertions(+), 60 deletions(-) rename addons/auth_oauth2_provider/static/src/xml/{oauth_provider.xml => auth_oauth2_provider.xml} (54%) diff --git a/addons/auth_oauth2_provider/auth_oauth2_provider.py b/addons/auth_oauth2_provider/auth_oauth2_provider.py index 1792d038b27..32977c4fabe 100644 --- a/addons/auth_oauth2_provider/auth_oauth2_provider.py +++ b/addons/auth_oauth2_provider/auth_oauth2_provider.py @@ -19,46 +19,65 @@ # ############################################################################## from openerp.osv import osv, fields +import datetime import uuid -class res_users(osv.osv): - """Oauth2 Provider Class""" - _inherit = 'res.users' +class auth_oauth2_token(osv.osv): + """Oauth2 Token Class""" + + _name = 'auth.oauth2.token' + _description = 'OAuth2 Token' _columns = { - # TODO: partial implementation supporting only one client_id for the moment. - 'last_oauth_token': fields.char('Last OAuth Token', size=32, readonly=True, invisible=True), - 'last_oauth_token_scope': fields.char('Last OAuth Token Scope', readonly=True, invisible=True), + 'token': fields.char('Token', size=32, readonly=True), + 'user_id': fields.many2one('res.users', 'User', required=True, select=True, readonly=True), + 'client': fields.char('Client', help="Client Application for which the token has been generated", readonly=True, select=True), # TODO: auth.oauth2.client object + 'scope': fields.char('Scope', help="Scope for which the token has ben delivered", readonly=True, select=True), + 'expires_at': fields.datetime('Token expiration date'), } - def auth_oauth_provider_get_token(self, cr, uid, client_id="", scope="", context=None): - token = str(uuid.uuid4()).replace('-', '') - self.write(cr, uid, [uid], { - "last_oauth_token": token, - "last_oauth_token_scope": scope, - }, context=context) - return token + TOKEN_EXPIRATION_TIMESPAN = 3600 # in seconds - def auth_oauth_provider_tokeninfo(self, cr, uid, access_token, context=None): - user_id = self.search(cr, uid, [('last_oauth_token', '=', access_token)], context=context) - if len(user_id) != 1: - return { - "error": "invalid_token" - } - user = self.browse(cr, uid, user_id[0], context=context) - if access_token == user.last_oauth_token: - r = { - "user_id": user.id, - "scope": user.last_oauth_token_scope, - #"audience": "8819981768.apps.googleusercontent.com", - #"expires_in": 436 - } - if user.partner_id.email: # TODO: should deliver only according to scopes - r['email'] = user.partner_id.email - return r - else: - return { - "error": "invalid_token" - } + _defaults = { + 'expires_at': lambda self, *a: datetime.datetime.utcnow() + datetime.timedelta(seconds=self.TOKEN_EXPIRATION_TIMESPAN), + } + + def get_token(self, cr, uid, client_id="", scope="", context=None): + token = str(uuid.uuid4()).replace('-', '') + self.create(cr, uid, { + 'token': token, + 'user_id': uid, + 'client': client_id, + 'scope': scope, + }, context=context) + return { + 'access_token': token, + 'expires_in': self.TOKEN_EXPIRATION_TIMESPAN, + } + + def tokeninfo(self, cr, uid, access_token, context=None): + token = self.search(cr, uid, [('token', '=', access_token)], context=context) + if not len(token): + return { "error": "invalid_token" } + token = self.browse(cr, uid, token[0], context=context) + expires_at = datetime.datetime.strptime(token.expires_at[:19], '%Y-%m-%d %H:%M:%S') + + # python 2.7's datetime.timedelta supports total_seconds() + # expires_in = int(round((expires_at - datetime.datetime.utcnow()).total_seconds())) + delta = expires_at - datetime.datetime.utcnow() + expires_in = (delta.microseconds + (delta.seconds + delta.days * 24 * 3600) * 10**6) / 10**6 + + if expires_in <= 0: + return { "error": "invalid_token" } + + r = { + "user_id": token.user_id.id, + "scope": token.scope, + "expires_in": expires_in, + "audience": token.client, + } + if token.user_id.email: # TODO: should deliver only according to scopes + r['email'] = token.user_id.email + return r # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth2_provider/controllers/main.py b/addons/auth_oauth2_provider/controllers/main.py index 944e3e44bf9..47e5d99df14 100644 --- a/addons/auth_oauth2_provider/controllers/main.py +++ b/addons/auth_oauth2_provider/controllers/main.py @@ -45,10 +45,8 @@ class AuthOAuthProvider(openerpweb.Controller): @openerpweb.jsonrequest def get_token(self, req, client_id="", scope="", **kw): - token = req.session.model('res.users').auth_oauth_provider_get_token(client_id, scope) - return { - 'access_token': token, - } + r = req.session.model('auth.oauth2.token').get_token(client_id, scope) + return r @openerpweb.httprequest def tokeninfo(self, req, dbname=None, access_token=None, **kw): @@ -57,10 +55,10 @@ class AuthOAuthProvider(openerpweb.Controller): try: registry = openerp.modules.registry.RegistryManager.get(dbname) with registry.cursor() as cr: - u = registry.get('res.users') - info = u.auth_oauth_provider_tokeninfo(cr, SUPERUSER_ID, access_token, kw) + u = registry.get('auth.oauth2.token') + info = u.tokeninfo(cr, SUPERUSER_ID, access_token, kw) return simplejson.dumps(info) except Exception, e: - return simplejson.dumps({ "error": e.message }) + return simplejson.dumps({ "error": str(e) }) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.css b/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.css index 778179b63b4..71e3fbe14ce 100644 --- a/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.css +++ b/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.css @@ -1,13 +1,13 @@ @charset "utf-8"; -.openerp .oe_oauth_provider { +.openerp .oe_oauth2_provider { padding: 0 10px; } -.openerp .oe_oauth_provider .oe_oauth_provider_error span.oe_i { +.openerp .oe_oauth2_provider .oe_oauth2_provider_error span.oe_i { font-size: 60px; color: #990000; float: left; } -.openerp .oe_oauth_provider .oe_oauth_provider_error ul { +.openerp .oe_oauth2_provider .oe_oauth2_provider_error ul { list-style: none; float: left; font-weight: bold; diff --git a/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.sass b/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.sass index 7921f4cc055..91dceb077db 100644 --- a/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.sass +++ b/addons/auth_oauth2_provider/static/src/css/auth_oauth2_provider.sass @@ -1,9 +1,9 @@ @charset "utf-8" -.openerp .oe_oauth_provider +.openerp .oe_oauth2_provider padding: 0 10px - .oe_oauth_provider_error + .oe_oauth2_provider_error span.oe_i font-size: 60px color: #900 diff --git a/addons/auth_oauth2_provider/static/src/js/auth_oauth2_provider.js b/addons/auth_oauth2_provider/static/src/js/auth_oauth2_provider.js index 84a89415ed3..0d807e0f4bc 100644 --- a/addons/auth_oauth2_provider/static/src/js/auth_oauth2_provider.js +++ b/addons/auth_oauth2_provider/static/src/js/auth_oauth2_provider.js @@ -1,11 +1,11 @@ -openerp.auth_oauth_provider = function(instance) { +openerp.auth_oauth2_provider = function(instance) { var QWeb = instance.web.qweb; var _t = instance.web._t; -instance.web.client_actions.add('oauth2_auth', 'instance.auth_oauth_provider.ProviderAction'); -instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ - template: "auth_oauth_provider", +instance.web.client_actions.add('oauth2_auth', 'instance.auth_oauth2_provider.ProviderAction'); +instance.auth_oauth2_provider.ProviderAction = instance.web.Widget.extend({ + template: "auth_oauth2_provider", start: function (parent) { var self = this; this._super.apply(this, arguments); @@ -23,7 +23,7 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ if (!this._error) { // params.approval_prompt TODO --> add 'none' (default) // TODO: get client_id and scope - this.$('.oe_oauth_provider_approval').show().on('click', '.oe_oauth_provider_allow', function() { + this.$('.oe_oauth2_provider_approval').show().on('click', '.oe_oauth2_provider_allow', function() { instance.session.rpc('/oauth2/get_token', { client_id: params.client_id || '', scope: params.scope || '', @@ -32,7 +32,7 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ }).fail(function() { self.error(_t("An error occured while contacting the OpenERP server.")); }); - }).on('click', '.oe_oauth_provider_deny', function() { + }).on('click', '.oe_oauth2_provider_deny', function() { self.redirect({ error: 'access_denied' }); @@ -61,8 +61,8 @@ instance.auth_oauth_provider.ProviderAction = instance.web.Widget.extend({ }, error: function(msg) { this._error = true; - var $msg = $('
    • ').addClass('oe_oauth_provider_error_text').text(msg); - $msg.appendTo(this.$('.oe_oauth_provider_error').show().find('ul')); + var $msg = $('
    • ').addClass('oe_oauth2_provider_error_text').text(msg); + $msg.appendTo(this.$('.oe_oauth2_provider_error').show().find('ul')); return false; }, }); diff --git a/addons/auth_oauth2_provider/static/src/xml/oauth_provider.xml b/addons/auth_oauth2_provider/static/src/xml/auth_oauth2_provider.xml similarity index 54% rename from addons/auth_oauth2_provider/static/src/xml/oauth_provider.xml rename to addons/auth_oauth2_provider/static/src/xml/auth_oauth2_provider.xml index 85985e4e974..d0723c70c33 100644 --- a/addons/auth_oauth2_provider/static/src/xml/oauth_provider.xml +++ b/addons/auth_oauth2_provider/static/src/xml/auth_oauth2_provider.xml @@ -1,14 +1,14 @@