From a2c3aad8c1628423df8ae66df943026338bf2889 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 5 Mar 2012 18:14:23 +0100 Subject: [PATCH 001/245] [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 002/245] [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 003/245] [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 004/245] [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 005/245] [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 006/245] [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 007/245] [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 008/245] [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 009/245] [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 010/245] [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 003ac3c0535949190c7d264e87d5c101b47c63b5 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 30 Jul 2012 12:24:35 +0530 Subject: [PATCH 011/245] [ADD] Add mail.message.subtype model in mail bzr revid: fka@tinyerp.com-20120730065435-u586t9y9gtfmx5tl --- addons/mail/__init__.py | 1 + addons/mail/__openerp__.py | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/mail/__init__.py b/addons/mail/__init__.py index 805c27386f3..bac92a833ff 100644 --- a/addons/mail/__init__.py +++ b/addons/mail/__init__.py @@ -19,6 +19,7 @@ # ############################################################################## +import mail_message_subtype import mail_message import mail_thread import mail_group diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py index ee22b0c153f..b8b359b8922 100644 --- a/addons/mail/__openerp__.py +++ b/addons/mail/__openerp__.py @@ -62,6 +62,7 @@ The main features of the module are: 'depends': ['base', 'base_tools'], 'data': [ 'wizard/mail_compose_message_view.xml', + 'mail_message_subtype.xml', 'mail_message_view.xml', 'mail_subscription_view.xml', 'mail_thread_view.xml', From cb473c4ffccfbf680d5bcbb6b64753315beeeac4 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 30 Jul 2012 12:33:29 +0530 Subject: [PATCH 012/245] [ADD] mail_message_subtype files added in mail bzr revid: fka@tinyerp.com-20120730070329-0iyb0r1908a8y86r --- addons/mail/mail_message_subtype.py | 41 ++++++++++++++++++++ addons/mail/mail_message_subtype.xml | 56 ++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 addons/mail/mail_message_subtype.py create mode 100644 addons/mail/mail_message_subtype.xml diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py new file mode 100644 index 00000000000..0a167a0f1d9 --- /dev/null +++ b/addons/mail/mail_message_subtype.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2009-today OpenERP SA () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see +# +############################################################################## + +from osv import osv +from osv import fields + +class mail_message_subtype(osv.osv): + + _name = 'mail.message.subtype' + _description = 'mail_message_subtype' + _columns = { + 'name': fields.char(' Message Subtype ', size = 128, + required = True, select = 1, + help = 'Subtype Of Message'), + 'model_ids': fields.many2many('ir.model', + 'mail_message_subtyp_message_rel', + 'message_subtype_id', 'model_id', 'Model', + help = "link some subtypes to several models, for projet/task"), + 'default': fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), + } + _defaults = { + 'default': True, + } diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml new file mode 100644 index 00000000000..8de3224470f --- /dev/null +++ b/addons/mail/mail_message_subtype.xml @@ -0,0 +1,56 @@ + + + + + + + + mail.message.subtype.tree + mail.message.subtype + tree + 10 + + + + + + + + + + + mail.message.subtype.form + mail.message.subtype + form + +
+ + + + + + + + + + + + +
+
+
+ + + Subtypes + mail.message.subtype + form + tree,form + + + + +
+
From b5c3a5327fcceb6d6c8843cd148e2f72d728ca08 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 30 Jul 2012 14:38:04 +0530 Subject: [PATCH 013/245] [ADD] Add many2many subtype_id field in mail.subscription bzr revid: fka@tinyerp.com-20120730090804-x3lpju3fq11hg703 --- addons/mail/mail_subscription.py | 4 ++++ addons/mail/mail_subscription_view.xml | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/addons/mail/mail_subscription.py b/addons/mail/mail_subscription.py index fc82af879a9..a3baa024ef0 100644 --- a/addons/mail/mail_subscription.py +++ b/addons/mail/mail_subscription.py @@ -42,6 +42,10 @@ class mail_subscription(osv.osv): help='Id of the followed resource'), 'user_id': fields.many2one('res.users', string='Related User', ondelete='cascade', required=True, select=1), + 'subtype_ids': fields.many2many('mail.message.subtype', + 'mail_message_subtyp_rel', + 'subscription_id', 'subtype_id', 'Subtype', + help = "linking some subscription to several subtype for projet/task"), } class mail_notification(osv.osv): diff --git a/addons/mail/mail_subscription_view.xml b/addons/mail/mail_subscription_view.xml index c3d79d48308..b88b8c25258 100644 --- a/addons/mail/mail_subscription_view.xml +++ b/addons/mail/mail_subscription_view.xml @@ -20,6 +20,27 @@ + + mail.subscription.form + mail.subscription + form + +
+ + + + + + + + + + + + +
+
+
From c494b78f7776f64bde8d4cdefa82f7cdda867548 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 30 Jul 2012 15:05:50 +0530 Subject: [PATCH 014/245] [ADD] Add many2one subtype_id field in mail.message bzr revid: fka@tinyerp.com-20120730093550-h9xnithn5h3eq5nk --- addons/mail/mail_message.py | 1 + addons/mail/mail_message_view.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index b96b6e3791e..14de51b39ab 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -230,6 +230,7 @@ class mail_message(osv.Model): select=True, ondelete='set null', help="Parent message, used for displaying as threads with hierarchy"), 'child_ids': fields.one2many('mail.message', 'parent_id', 'Child Messages'), + 'subtype_id': fields.many2one('mail.message.subtype', 'Subtype', select = True), } _defaults = { diff --git a/addons/mail/mail_message_view.xml b/addons/mail/mail_message_view.xml index 986bb4bef38..374b97624b1 100644 --- a/addons/mail/mail_message_view.xml +++ b/addons/mail/mail_message_view.xml @@ -152,6 +152,7 @@ + From 24264e759d42ab47f0b4b7f11a1341a3108c08b8 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 6 Aug 2012 16:10:15 +0530 Subject: [PATCH 015/245] [IMP] make changes into thread file bzr revid: rma@tinyerp.com-20120806104015-et9znlwd5lrqggfn --- addons/mail/mail_message.py | 3 ++- addons/mail/mail_thread.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 14de51b39ab..8b88647b108 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -275,6 +275,7 @@ class mail_message(osv.Model): def create(self, cr, uid, values, context=None): self.check(cr, uid, [], mode='create', context=context, values=values) return super(mail_message, self).create(cr, uid, values, context) + def read(self, cr, uid, ids, fields_to_read=None, context=None, load='_classic_read'): self.check(cr, uid, ids, 'read', context=context) @@ -392,7 +393,7 @@ class mail_message(osv.Model): def cancel(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'state':'cancel'}, context=context) - + def process_email_queue(self, cr, uid, ids=None, context=None): """Send immediately queued messages, committing after each message is sent - this is not transactional and should diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 1655ab98afb..0afddc747d6 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -176,7 +176,7 @@ class mail_thread(osv.Model): email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) return msg_id - + #TODO :in message creation: in push method: push only if user is subscriber (current case) and if user is sucscribed to the subtype (to add) def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None): subscription_obj = self.pool.get('mail.subscription') # get body @@ -327,7 +327,7 @@ class mail_thread(osv.Model): if partner_ids is None: partner_ids = [] mail_partner_ids = [(6, 0, partner_ids)] - + data = { 'subject': subject, 'body_text': body_text or (hasattr(thread, 'description') and thread.description or ''), @@ -363,7 +363,6 @@ class mail_thread(osv.Model): new_msg_ids.append(self.message_create(cr, uid, thread.id, data, context=context)) return new_msg_ids - def message_append_dict(self, cr, uid, ids, msg_dict, context=None): """Creates a new mail.message attached to the given threads (``ids``), with the contents of ``msg_dict``, by calling ``message_append`` @@ -874,6 +873,10 @@ class mail_thread(osv.Model): :param user_ids: a list of user_ids; if not set, subscribe uid instead """ + # TODO:Update Massage Subscribe and add paramenter subtype_ids + # if subtype_ids is False: add default ones (res_model = self._name, default = True) + # in method: if user_id already subscriber, update its subscription with subtype_ids + subscription_obj = self.pool.get('mail.subscription') to_subscribe_uids = [uid] if user_ids is None else user_ids create_ids = [] @@ -883,7 +886,8 @@ class mail_thread(osv.Model): if user_id in already_subscribed_user_ids: continue create_ids.append(subscription_obj.create(cr, uid, {'res_model': self._name, 'res_id': id, 'user_id': user_id}, context=context)) return create_ids - + #TODO : Add method : add message_subscribe_udpate_subtypes(..., user_id, subtype_ids): + def message_unsubscribe(self, cr, uid, ids, user_ids = None, context=None): """ Unsubscribe the user (or user_ids) from the current document. @@ -900,7 +904,8 @@ class mail_thread(osv.Model): if not to_delete_sub_ids: return False return subscription_obj.unlink(cr, uid, to_delete_sub_ids, context=context) - + #TODO : Add Method : add message_subscribeption_remove_subtype(..., user_id, subtype_id): + #TODO : Add method : add message_subscription_remove_subtype_name(.., user_id, subtype_name) #------------------------------------------------------ # Notification API #------------------------------------------------------ From d00b0a9d0e9f81f89fb5a222add0b55884fa917f Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 8 Aug 2012 17:58:12 +0530 Subject: [PATCH 016/245] [IMP] improve mail_thread bzr revid: fka@tinyerp.com-20120808122812-v0hw80phlnb9es75 --- addons/mail/mail_thread.py | 315 ++++++++++++++++++++----------------- 1 file changed, 171 insertions(+), 144 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 0afddc747d6..3e5bfabe350 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -62,33 +62,33 @@ class mail_thread(osv.Model): _name = 'mail.thread' _description = 'Email Thread' - def _get_message_ids(self, cr, uid, ids, name, args, context=None): + def _get_message_ids(self, cr, uid, ids, name, args, context = None): res = {} for id in ids: - message_ids = self.message_search(cr, uid, [id], context=context) - subscriber_ids = self.message_get_subscribers(cr, uid, [id], context=context) + message_ids = self.message_search(cr, uid, [id], context = context) + subscriber_ids = self.message_get_subscribers(cr, uid, [id], context = context) res[id] = { 'message_ids': message_ids, 'message_summary': "9 %d + %d" % (len(message_ids), len(subscriber_ids)), } return res - def _search_message_ids(self, cr, uid, obj, name, args, context=None): + def _search_message_ids(self, cr, uid, obj, name, args, context = None): msg_obj = self.pool.get('mail.message') - msg_ids = msg_obj.search(cr, uid, ['&', ('res_id', 'in', args[0][2]), ('model', '=', self._name)], context=context) + msg_ids = msg_obj.search(cr, uid, ['&', ('res_id', 'in', args[0][2]), ('model', '=', self._name)], context = context) return [('id', 'in', msg_ids)] _columns = { - 'message_ids': fields.function(_get_message_ids, method=True, - fnct_search=_search_message_ids, - type='one2many', obj='mail.message', _fields_id = 'res_id', - string='Temp messages', multi="_get_message_ids", - help="Functional field holding messages related to the current document."), + 'message_ids': fields.function(_get_message_ids, method = True, + fnct_search = _search_message_ids, + type = 'one2many', obj = 'mail.message', _fields_id = 'res_id', + string = 'Temp messages', multi = "_get_message_ids", + help = "Functional field holding messages related to the current document."), 'message_state': fields.boolean('Read', - help="When checked, new messages require your attention."), - 'message_summary': fields.function(_get_message_ids, method=True, - type='text', string='Summary', multi="_get_message_ids", - help="Holds the Chatter summary (number of messages, ...). "\ + help = "When checked, new messages require your attention."), + 'message_summary': fields.function(_get_message_ids, method = True, + type = 'text', string = 'Summary', multi = "_get_message_ids", + help = "Holds the Chatter summary (number of messages, ...). "\ "This summary is directly in html format in order to "\ "be inserted in kanban views."), } @@ -101,23 +101,23 @@ class mail_thread(osv.Model): # Automatic subscription when creating/reading #------------------------------------------------------ - def create(self, cr, uid, vals, context=None): + def create(self, cr, uid, vals, context = None): """Automatically subscribe the creator """ - thread_id = super(mail_thread, self).create(cr, uid, vals, context=context) + thread_id = super(mail_thread, self).create(cr, uid, vals, context = context) if thread_id: - self.message_subscribe(cr, uid, [thread_id], [uid], context=context) + self.message_subscribe(cr, uid, [thread_id], [uid], context = context) return thread_id - def write(self, cr, uid, ids, vals, context=None): + def write(self, cr, uid, ids, vals, context = None): """Automatically subscribe the writer""" if isinstance(ids, (int, long)): ids = [ids] - write_res = super(mail_thread, self).write(cr, uid, ids, vals, context=context); + write_res = super(mail_thread, self).write(cr, uid, ids, vals, context = context); if write_res: - self.message_subscribe(cr, uid, ids, [uid], context=context) + self.message_subscribe(cr, uid, ids, [uid], context = context) return write_res; - def unlink(self, cr, uid, ids, context=None): + def unlink(self, cr, uid, ids, context = None): """Override unlink, to automatically delete - subscriptions - messages @@ -128,19 +128,19 @@ class mail_thread(osv.Model): subscr_obj = self.pool.get('mail.subscription') msg_obj = self.pool.get('mail.message') # delete subscriptions - subscr_to_del_ids = subscr_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - subscr_obj.unlink(cr, uid, subscr_to_del_ids, context=context) + subscr_to_del_ids = subscr_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context = context) + subscr_obj.unlink(cr, uid, subscr_to_del_ids, context = context) # delete messages and notifications - msg_to_del_ids = msg_obj.search(cr, uid, [('model', '=', self._name), ('res_id', 'in', ids)], context=context) - msg_obj.unlink(cr, uid, msg_to_del_ids, context=context) + msg_to_del_ids = msg_obj.search(cr, uid, [('model', '=', self._name), ('res_id', 'in', ids)], context = context) + msg_obj.unlink(cr, uid, msg_to_del_ids, context = context) - return super(mail_thread, self).unlink(cr, uid, ids, context=context) + return super(mail_thread, self).unlink(cr, uid, ids, context = context) #------------------------------------------------------ # mail.message wrappers and tools #------------------------------------------------------ - def message_create(self, cr, uid, thread_id, vals, context=None): + def message_create(self, cr, uid, thread_id, vals, context = None): """ OpenChatter: wrapper of mail.message create method - creates the mail.message - automatically subscribe the message writer @@ -155,57 +155,58 @@ class mail_thread(osv.Model): # automatically subscribe the writer of the message if vals['user_id']: - self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context=context) + self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context = context) # create message - msg_id = message_obj.create(cr, uid, vals, context=context) + msg_id = message_obj.create(cr, uid, vals, context = context) # Set as unread if writer is not the document responsible - self.message_create_set_unread(cr, uid, [thread_id], context=context) + self.message_create_set_unread(cr, uid, [thread_id], context = context) # special: if install mode, do not push demo data if context.get('install_mode', False): return msg_id # get users that will get a notification pushed - user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context) + user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context = context) for id in user_to_push_ids: - notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context) + notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context = context) # create the email to send - email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) + email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context = context) return msg_id + #TODO :in message creation: in push method: push only if user is subscriber (current case) and if user is sucscribed to the subtype (to add) - def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None): + def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context = None): subscription_obj = self.pool.get('mail.subscription') # get body body = new_msg_vals.get('body_html', '') if new_msg_vals.get('content_subtype') == 'html' else new_msg_vals.get('body_text', '') # get subscribers - notif_user_ids = self.message_get_subscribers(cr, uid, thread_ids, context=context) + notif_user_ids = self.message_get_subscribers(cr, uid, thread_ids, context = context) # add users requested via parsing message (@login) - notif_user_ids += self.message_parse_users(cr, uid, body, context=context) + notif_user_ids += self.message_parse_users(cr, uid, body, context = context) # add users requested to perform an action (need_action mechanism) if hasattr(self, 'get_needaction_user_ids'): - user_ids_dict = self.get_needaction_user_ids(cr, uid, thread_ids, context=context) + user_ids_dict = self.get_needaction_user_ids(cr, uid, thread_ids, context = context) for id, user_ids in user_ids_dict.iteritems(): notif_user_ids += user_ids # add users notified of the parent messages (because: if parent message contains @login, login must receive the replies) if new_msg_vals.get('parent_id'): notif_obj = self.pool.get('mail.notification') - parent_notif_ids = notif_obj.search(cr, uid, [('message_id', '=', new_msg_vals.get('parent_id'))], context=context) - parent_notifs = notif_obj.read(cr, uid, parent_notif_ids, context=context) + parent_notif_ids = notif_obj.search(cr, uid, [('message_id', '=', new_msg_vals.get('parent_id'))], context = context) + parent_notifs = notif_obj.read(cr, uid, parent_notif_ids, context = context) notif_user_ids += [parent_notif['user_id'][0] for parent_notif in parent_notifs] # remove duplicate entries notif_user_ids = list(set(notif_user_ids)) return notif_user_ids - def message_parse_users(self, cr, uid, string, context=None): + def message_parse_users(self, cr, uid, string, context = None): """Parse message content - if find @login -(^|\s)@((\w|@|\.)*)-: returns the related ids this supports login that are emails (such as @raoul@grobedon.net) @@ -213,14 +214,14 @@ class mail_thread(osv.Model): regex = re.compile('(^|\s)@((\w|@|\.)*)') login_lst = [item[1] for item in regex.findall(string)] if not login_lst: return [] - user_ids = self.pool.get('res.users').search(cr, uid, [('login', 'in', login_lst)], context=context) + user_ids = self.pool.get('res.users').search(cr, uid, [('login', 'in', login_lst)], context = context) return user_ids #------------------------------------------------------ # Generic message api #------------------------------------------------------ - def message_capable_models(self, cr, uid, context=None): + def message_capable_models(self, cr, uid, context = None): ret_dict = {} for model_name in self.pool.obj_list(): model = self.pool.get(model_name) @@ -228,13 +229,13 @@ class mail_thread(osv.Model): ret_dict[model_name] = model._description return ret_dict - def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None, - type='email', email_date=None, parent_id=False, - content_subtype='plain', state=None, - partner_ids=None, email_from=False, email_to=False, - email_cc=None, email_bcc=None, reply_to=None, - headers=None, message_id=False, references=None, - attachments=None, original=None, context=None): + def message_append(self, cr, uid, threads, subject, body_text = None, body_html = None, + type = 'email', subtype_id = False, email_date = None, parent_id = False, + content_subtype = 'plain', state = None, + partner_ids = None, email_from = False, email_to = False, + email_cc = None, email_bcc = None, reply_to = None, + headers = None, message_id = False, references = None, + attachments = None, original = None, context = None): """ Creates a new mail.message through message_create. The new message is attached to the current mail.thread, containing all the details passed as parameters. All attachments will be attached to the @@ -298,7 +299,7 @@ class mail_thread(osv.Model): if all(isinstance(thread_id, (int, long)) for thread_id in threads): model = context.get('thread_model') or self._name model_pool = self.pool.get(model) - threads = model_pool.browse(cr, uid, threads, context=context) + threads = model_pool.browse(cr, uid, threads, context = context) ir_attachment = self.pool.get('ir.attachment') mail_message = self.pool.get('mail.message') @@ -318,7 +319,7 @@ class mail_thread(osv.Model): 'res_model': thread._name, 'res_id': thread.id, } - to_attach.append(ir_attachment.create(cr, uid, data_attach, context=context)) + to_attach.append(ir_attachment.create(cr, uid, data_attach, context = context)) # find related partner: partner_id column in thread object, or self is res.partner model partner_id = ('partner_id' in thread._columns.keys()) and (thread.partner_id and thread.partner_id.id or False) or False if not partner_id and thread._name == 'res.partner': @@ -361,9 +362,10 @@ class mail_thread(osv.Model): 'reply_to': reply_to, 'original': original, }) - new_msg_ids.append(self.message_create(cr, uid, thread.id, data, context=context)) + new_msg_ids.append(self.message_create(cr, uid, thread.id, data, context = context)) return new_msg_ids - def message_append_dict(self, cr, uid, ids, msg_dict, context=None): + + def message_append_dict(self, cr, uid, ids, msg_dict, context = None): """Creates a new mail.message attached to the given threads (``ids``), with the contents of ``msg_dict``, by calling ``message_append`` with the mail details. All attachments in msg_dict will be @@ -382,9 +384,10 @@ class mail_thread(osv.Model): return self.message_append(cr, uid, ids, subject = msg_dict.get('subject'), body_text = msg_dict.get('body_text'), - body_html= msg_dict.get('body_html'), + body_html = msg_dict.get('body_html'), parent_id = msg_dict.get('parent_id', False), type = msg_dict.get('type', 'email'), + subtype_id = msg_dict.get('subtype_id', False), content_subtype = msg_dict.get('content_subtype'), state = msg_dict.get('state'), partner_ids = msg_dict.get('partner_ids'), @@ -406,7 +409,7 @@ class mail_thread(osv.Model): # Message loading #------------------------------------------------------ - def _message_search_ancestor_ids(self, cr, uid, ids, child_ids, ancestor_ids, context=None): + def _message_search_ancestor_ids(self, cr, uid, ids, child_ids, ancestor_ids, context = None): """ Given message child_ids ids, find their ancestors until ancestor_ids using their parent_id relationship. @@ -425,13 +428,13 @@ class mail_thread(osv.Model): ] message_obj = self.pool.get('mail.message') - messages_temp = message_obj.read(cr, uid, child_ids, ['id', 'parent_id'], context=context) + messages_temp = message_obj.read(cr, uid, child_ids, ['id', 'parent_id'], context = context) parent_ids = _get_parent_ids(messages_temp, ancestor_ids, child_ids) child_ids += parent_ids cur_iter = 0; max_iter = 100; # avoid infinite loop while (parent_ids and (cur_iter < max_iter)): cur_iter += 1 - messages_temp = message_obj.read(cr, uid, parent_ids, ['id', 'parent_id'], context=context) + messages_temp = message_obj.read(cr, uid, parent_ids, ['id', 'parent_id'], context = context) parent_ids = _get_parent_ids(messages_temp, ancestor_ids, child_ids) child_ids += parent_ids if (cur_iter > max_iter): @@ -440,7 +443,7 @@ class mail_thread(osv.Model): "message graph, leading to a curious error. Have fun.") return child_ids - def message_search_get_domain(self, cr, uid, ids, context=None): + def message_search_get_domain(self, cr, uid, ids, context = None): """ OpenChatter feature: get the domain to search the messages related to a document. mail.thread defines the default behavior as being messages with model = self._name, id in ids. @@ -449,8 +452,8 @@ class mail_thread(osv.Model): """ return ['&', ('res_id', 'in', ids), ('model', '=', self._name)] - def message_search(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None, - limit=100, offset=0, domain=None, count=False, context=None): + def message_search(self, cr, uid, ids, fetch_ancestors = False, ancestor_ids = None, + limit = 100, offset = 0, domain = None, count = False, context = None): """ OpenChatter feature: return thread messages ids according to the search domain given by ``message_search_get_domain``. @@ -477,17 +480,17 @@ class mail_thread(osv.Model): default domain. :param limit, offset, count, context: as usual """ - search_domain = self.message_search_get_domain(cr, uid, ids, context=context) + search_domain = self.message_search_get_domain(cr, uid, ids, context = context) if domain: search_domain += domain message_obj = self.pool.get('mail.message') - message_res = message_obj.search(cr, uid, search_domain, limit=limit, offset=offset, count=count, context=context) + message_res = message_obj.search(cr, uid, search_domain, limit = limit, offset = offset, count = count, context = context) if not count and fetch_ancestors: - message_res += self._message_search_ancestor_ids(cr, uid, ids, message_res, ancestor_ids, context=context) + message_res += self._message_search_ancestor_ids(cr, uid, ids, message_res, ancestor_ids, context = context) return message_res - def message_read(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None, - limit=100, offset=0, domain=None, context=None): + def message_read(self, cr, uid, ids, fetch_ancestors = False, ancestor_ids = None, + limit = 100, offset = 0, domain = None, context = None): """ OpenChatter feature: read the messages related to some threads. This method is used mainly the Chatter widget, to directly have read result instead of searching then reading. @@ -495,8 +498,8 @@ class mail_thread(osv.Model): Please see message_search for more information about the parameters. """ message_ids = self.message_search(cr, uid, ids, fetch_ancestors, ancestor_ids, - limit, offset, domain, context=context) - messages = self.pool.get('mail.message').read(cr, uid, message_ids, context=context) + limit, offset, domain, context = context) + messages = self.pool.get('mail.message').read(cr, uid, message_ids, context = context) """ Retrieve all attachments names """ map_id_to_name = dict((attachment_id, '') for message in messages for attachment_id in message['attachment_ids']) @@ -506,7 +509,7 @@ class mail_thread(osv.Model): map_id_to_name[attach_id] = '' # use empty string as a placeholder ids = map_id_to_name.keys() - names = self.pool.get('ir.attachment').name_get(cr, uid, ids, context=context) + names = self.pool.get('ir.attachment').name_get(cr, uid, ids, context = context) # convert the list of tuples into a dictionnary for name in names: @@ -520,13 +523,13 @@ class mail_thread(osv.Model): msg["attachments"].append({'id': attach_id, 'name': map_id_to_name[attach_id]}) # Set the threads as read - self.message_check_and_set_read(cr, uid, ids, context=context) + self.message_check_and_set_read(cr, uid, ids, context = context) # Sort and return the messages - messages = sorted(messages, key=lambda d: (-d['id'])) + messages = sorted(messages, key = lambda d: (-d['id'])) return messages - def message_get_pushed_messages(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None, - limit=100, offset=0, msg_search_domain=[], context=None): + def message_get_pushed_messages(self, cr, uid, ids, fetch_ancestors = False, ancestor_ids = None, + limit = 100, offset = 0, msg_search_domain = [], context = None): """ OpenChatter: wall: get the pushed notifications and used them to fetch messages to display on the wall. @@ -550,13 +553,13 @@ class mail_thread(osv.Model): # compose final domain domain = [('user_id', '=', uid)] + msg_search_domain # get notifications - notification_ids = notification_obj.search(cr, uid, domain, limit=limit, offset=offset, context=context) - notifications = notification_obj.browse(cr, uid, notification_ids, context=context) + notification_ids = notification_obj.search(cr, uid, domain, limit = limit, offset = offset, context = context) + notifications = notification_obj.browse(cr, uid, notification_ids, context = context) msg_ids = [notification.message_id.id for notification in notifications] # get messages - msg_ids = msg_obj.search(cr, uid, [('id', 'in', msg_ids)], context=context) - if (fetch_ancestors): msg_ids = self._message_search_ancestor_ids(cr, uid, ids, msg_ids, ancestor_ids, context=context) - msgs = msg_obj.read(cr, uid, msg_ids, context=context) + msg_ids = msg_obj.search(cr, uid, [('id', 'in', msg_ids)], context = context) + if (fetch_ancestors): msg_ids = self._message_search_ancestor_ids(cr, uid, ids, msg_ids, ancestor_ids, context = context) + msgs = msg_obj.read(cr, uid, msg_ids, context = context) return msgs #------------------------------------------------------ @@ -564,9 +567,9 @@ class mail_thread(osv.Model): #------------------------------------------------------ # message_process will call either message_new or message_update. - def message_process(self, cr, uid, model, message, custom_values=None, - save_original=False, strip_attachments=False, - context=None): + def message_process(self, cr, uid, model, message, custom_values = None, + save_original = False, strip_attachments = False, + context = None): """Process an incoming RFC2822 email message related to the given thread model, relying on ``mail.message.parse()`` for the parsing operation, and then calling ``message_new`` @@ -606,7 +609,7 @@ class mail_thread(osv.Model): if isinstance(message, unicode): message = message.encode('utf-8') msg_txt = email.message_from_string(message) - msg = mail_message.parse_message(msg_txt, save_original=save_original, context=context) + msg = mail_message.parse_message(msg_txt, save_original = save_original, context = context) # update state msg['state'] = 'received' @@ -619,7 +622,7 @@ class mail_thread(osv.Model): if hasattr(model_pool, 'message_new'): return model_pool.message_new(cr, uid, msg, custom_values, - context=context) + context = context) res_id = False if msg.get('references') or msg.get('in-reply-to'): references = msg.get('references') or msg.get('in-reply-to') @@ -640,19 +643,19 @@ class mail_thread(osv.Model): res_id = res_id if model_pool.exists(cr, uid, res_id): if hasattr(model_pool, 'message_update'): - model_pool.message_update(cr, uid, [res_id], msg, {}, context=context) + model_pool.message_update(cr, uid, [res_id], msg, {}, context = context) else: # referenced thread was not found, we'll have to create a new one res_id = False if not res_id: res_id = create_record(msg) # To forward the email to other followers - self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) + self.message_forward(cr, uid, model, [res_id], msg_txt, context = context) # Set as Unread - model_pool.message_mark_as_unread(cr, uid, [res_id], context=context) + model_pool.message_mark_as_unread(cr, uid, [res_id], context = context) return res_id - def message_new(self, cr, uid, msg_dict, custom_values=None, context=None): + def message_new(self, cr, uid, msg_dict, custom_values = None, context = None): """Called by ``message_process`` when a new message is received for a given thread model, if the message did not belong to an existing thread. @@ -681,17 +684,17 @@ class mail_thread(osv.Model): context = {} model = context.get('thread_model') or self._name model_pool = self.pool.get(model) - fields = model_pool.fields_get(cr, uid, context=context) - data = model_pool.default_get(cr, uid, fields, context=context) + fields = model_pool.fields_get(cr, uid, context = context) + data = model_pool.default_get(cr, uid, fields, context = context) if 'name' in fields and not data.get('name'): data['name'] = msg_dict.get('from', '') if custom_values and isinstance(custom_values, dict): data.update(custom_values) - res_id = model_pool.create(cr, uid, data, context=context) - self.message_append_dict(cr, uid, [res_id], msg_dict, context=context) + res_id = model_pool.create(cr, uid, data, context = context) + self.message_append_dict(cr, uid, [res_id], msg_dict, context = context) return res_id - def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None): + def message_update(self, cr, uid, ids, msg_dict, update_vals = 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 @@ -711,10 +714,10 @@ class mail_thread(osv.Model): update (instead of the current model). """ if update_vals: - self.write(cr, uid, ids, update_vals, context=context) - return self.message_append_dict(cr, uid, ids, msg_dict, context=context) + self.write(cr, uid, ids, update_vals, context = context) + return self.message_append_dict(cr, uid, ids, msg_dict, context = context) - def message_thread_followers(self, cr, uid, ids, context=None): + def message_thread_followers(self, cr, uid, ids, context = None): """ Returns a list of email addresses of the people following this thread, including the sender of each mail, and the people who were in CC of the messages, if any. @@ -722,7 +725,7 @@ class mail_thread(osv.Model): res = {} if isinstance(ids, (str, int, long)): ids = [long(ids)] - for thread in self.browse(cr, uid, ids, context=context): + for thread in self.browse(cr, uid, ids, context = context): l = set() for message in thread.message_ids: l.add((message.user_id and message.user_id.user_email) or '') @@ -731,7 +734,7 @@ class mail_thread(osv.Model): res[thread.id] = filter(None, l) return res - def message_forward(self, cr, uid, model, thread_ids, msg, email_error=False, context=None): + def message_forward(self, cr, uid, model, thread_ids, msg, email_error = False, context = None): """Sends an email to all people following the given threads. The emails are forwarded immediately, not queued for sending, and not archived. @@ -746,7 +749,7 @@ class mail_thread(osv.Model): model_pool = self.pool.get(model) smtp_server_obj = self.pool.get('ir.mail_server') mail_message = self.pool.get('mail.message') - for res in model_pool.browse(cr, uid, thread_ids, context=context): + for res in model_pool.browse(cr, uid, thread_ids, context = context): if hasattr(model_pool, 'message_thread_followers'): followers = model_pool.message_thread_followers(cr, uid, [res.id])[res.id] else: @@ -765,7 +768,7 @@ class mail_thread(osv.Model): smtp_from, = to_email(msg['from']) msg['from'] = smtp_from - msg['to'] = ", ".join(forward_to) + msg['to'] = ", ".join(forward_to) msg['message-id'] = tools.generate_tracking_message_id(res.id) if not smtp_server_obj.send_email(cr, uid, msg) and email_error: subj = msg['subject'] @@ -775,7 +778,7 @@ class mail_thread(osv.Model): smtp_server_obj.send_email(cr, uid, msg) return True - def message_partner_by_email(self, cr, uid, email, context=None): + def message_partner_by_email(self, cr, uid, email, context = None): """Attempts to return the id of a partner address matching the given ``email``, and the corresponding partner id. Can be used by classes using the ``mail.thread`` mixin @@ -811,16 +814,16 @@ class mail_thread(osv.Model): # Note specific #------------------------------------------------------ - def log(self, cr, uid, id, message, secondary=False, context=None): + def log(self, cr, uid, id, message, secondary = False, context = None): _logger.warning("log() is deprecated. As this module inherit from \ mail.thread, the message will be managed by this \ module instead of by the res.log mechanism. Please \ use the mail.thread OpenChatter API instead of the \ now deprecated res.log.") - self.message_append_note(cr, uid, [id], 'res.log', message, context=context) + self.message_append_note(cr, uid, [id], 'res.log', message, context = context) - def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False, - type='notification', content_subtype='html', context=None): + def message_append_note(self, cr, uid, ids, subject = None, body = None, parent_id = False, + type = 'notification', subtype_id = False, content_subtype = 'html', context = None): if content_subtype == 'html': body_html = body body_text = body @@ -828,14 +831,14 @@ class mail_thread(osv.Model): body_html = body body_text = body return self.message_append(cr, uid, ids, subject, body_html, body_text, - type, parent_id=parent_id, - content_subtype=content_subtype, context=context) + type, subtype_id = subtype_id, parent_id = parent_id, + content_subtype = content_subtype, context = context) #------------------------------------------------------ # Subscription mechanism #------------------------------------------------------ - def message_get_subscribers(self, cr, uid, ids, context=None): + def message_get_subscribers(self, cr, uid, ids, context = None): """ Returns the current document followers. Basically this method checks in mail.subscription for entries with matching res_model, res_id. @@ -844,18 +847,18 @@ class mail_thread(osv.Model): ids returned by this method. """ subscr_obj = self.pool.get('mail.subscription') - subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - return [sub['user_id'][0] for sub in subscr_obj.read(cr, uid, subscr_ids, ['user_id'], context=context)] + subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', ids)], context = context) + return [sub['user_id'][0] for sub in subscr_obj.read(cr, uid, subscr_ids, ['user_id'], context = context)] - def message_read_subscribers(self, cr, uid, ids, fields=['id', 'name', 'avatar'], context=None): + def message_read_subscribers(self, cr, uid, ids, fields = ['id', 'name', 'avatar'], context = None): """ Returns the current document followers as a read result. Used mainly for Chatter having only one method to call to have details about users. """ - user_ids = self.message_get_subscribers(cr, uid, ids, context=context) - return self.pool.get('res.users').read(cr, uid, user_ids, fields=fields, context=context) + user_ids = self.message_get_subscribers(cr, uid, ids, context = context) + return self.pool.get('res.users').read(cr, uid, user_ids, fields = fields, context = context) - def message_is_subscriber(self, cr, uid, ids, user_id = None, context=None): + def message_is_subscriber(self, cr, uid, ids, user_id = None, context = None): """ Check if uid or user_id (if set) is a subscriber to the current document. @@ -863,16 +866,17 @@ class mail_thread(osv.Model): check is done on uid """ sub_user_id = uid if user_id is None else user_id - if sub_user_id in self.message_get_subscribers(cr, uid, ids, context=context): + if sub_user_id in self.message_get_subscribers(cr, uid, ids, context = context): return True return False - def message_subscribe(self, cr, uid, ids, user_ids = None, context=None): + def message_subscribe(self, cr, uid, ids, user_ids = None, subtype_ids = None, context = None): """ Subscribe the user (or user_ids) to the current document. :param user_ids: a list of user_ids; if not set, subscribe uid instead """ + # TODO:Update Massage Subscribe and add paramenter subtype_ids # if subtype_ids is False: add default ones (res_model = self._name, default = True) # in method: if user_id already subscriber, update its subscription with subtype_ids @@ -881,14 +885,20 @@ class mail_thread(osv.Model): to_subscribe_uids = [uid] if user_ids is None else user_ids create_ids = [] for id in ids: - already_subscribed_user_ids = self.message_get_subscribers(cr, uid, [id], context=context) + already_subscribed_user_ids = self.message_get_subscribers(cr, uid, [id], context = context) for user_id in to_subscribe_uids: - if user_id in already_subscribed_user_ids: continue - create_ids.append(subscription_obj.create(cr, uid, {'res_model': self._name, 'res_id': id, 'user_id': user_id}, context=context)) + res = {'res_model': self._name, 'res_id': id, 'user_id': user_id} + res['subtype_ids'] = [0, 0, {'res_model': self._name, 'default': True}] + if user_id in already_subscribed_user_ids: + if subtype_ids: + res['subtype_ids'] = [(6, 0, subtype_ids)] + else: continue + create_ids.append(subscription_obj.create(cr, uid, res, context = context)) return create_ids + #TODO : Add method : add message_subscribe_udpate_subtypes(..., user_id, subtype_ids): - def message_unsubscribe(self, cr, uid, ids, user_ids = None, context=None): + def message_unsubscribe(self, cr, uid, ids, user_ids = None, context = None): """ Unsubscribe the user (or user_ids) from the current document. :param user_ids: a list of user_ids; if not set, subscribe @@ -900,17 +910,19 @@ class mail_thread(osv.Model): to_unsubscribe_uids = [uid] if user_ids is None else user_ids subscription_obj = self.pool.get('mail.subscription') to_delete_sub_ids = subscription_obj.search(cr, uid, - ['&', '&', ('res_model', '=', self._name), ('res_id', 'in', ids), ('user_id', 'in', to_unsubscribe_uids)], context=context) + ['&', '&', ('res_model', '=', self._name), ('res_id', 'in', ids), ('user_id', 'in', to_unsubscribe_uids)], context = context) if not to_delete_sub_ids: return False - return subscription_obj.unlink(cr, uid, to_delete_sub_ids, context=context) + + return subscription_obj.unlink(cr, uid, to_delete_sub_ids, context = context) #TODO : Add Method : add message_subscribeption_remove_subtype(..., user_id, subtype_id): #TODO : Add method : add message_subscription_remove_subtype_name(.., user_id, subtype_name) + #------------------------------------------------------ # Notification API #------------------------------------------------------ - def message_create_notify_by_email(self, cr, uid, new_msg_values, user_to_notify_ids, context=None): + def message_create_notify_by_email(self, cr, uid, new_msg_values, user_to_notify_ids, context = None): """ When creating a new message and pushing notifications, emails must be send if users have chosen to receive notifications by email via the notification_email_pref field. @@ -937,11 +949,11 @@ class mail_thread(osv.Model): user_to_notify_ids.remove(new_msg_values.get('user_id')) # get user_ids directly asked - user_to_push_from_parse_ids = self.message_parse_users(cr, uid, body, context=context) + user_to_push_from_parse_ids = self.message_parse_users(cr, uid, body, context = context) # try to find an email_to email_to = '' - for user in res_users_obj.browse(cr, uid, user_to_notify_ids, context=context): + for user in res_users_obj.browse(cr, uid, user_to_notify_ids, context = context): if not user.notification_email_pref == 'all' and \ not (user.notification_email_pref == 'to_me' and user.id in user_to_push_from_parse_ids): continue @@ -955,17 +967,17 @@ class mail_thread(osv.Model): return # try to find an email_from - current_user = res_users_obj.browse(cr, uid, [uid], context=context)[0] + current_user = res_users_obj.browse(cr, uid, [uid], context = context)[0] email_from = new_msg_values.get('email_from') if not email_from: email_from = current_user.user_email # get email content, create it (with mail_message.create) email_values = self.message_create_notify_get_email_dict(cr, uid, new_msg_values, email_from, email_to, context) - email_id = message_obj.create(cr, uid, email_values, context=context) + email_id = message_obj.create(cr, uid, email_values, context = context) return email_id - def message_create_notify_get_email_dict(self, cr, uid, new_msg_values, email_from, email_to, context=None): + def message_create_notify_get_email_dict(self, cr, uid, new_msg_values, email_from, email_to, context = None): values = dict(new_msg_values) body_html = new_msg_values.get('body_html', '') @@ -989,47 +1001,62 @@ class mail_thread(osv.Model): }) return values - def message_remove_pushed_notifications(self, cr, uid, ids, msg_ids, remove_childs=True, context=None): + def message_remove_pushed_notifications(self, cr, uid, ids, msg_ids, remove_childs = True, context = None): notif_obj = self.pool.get('mail.notification') msg_obj = self.pool.get('mail.message') if remove_childs: - notif_msg_ids = msg_obj.search(cr, uid, [('id', 'child_of', msg_ids)], context=context) + notif_msg_ids = msg_obj.search(cr, uid, [('id', 'child_of', msg_ids)], context = context) else: notif_msg_ids = msg_ids - to_del_notif_ids = notif_obj.search(cr, uid, ['&', ('user_id', '=', uid), ('message_id', 'in', notif_msg_ids)], context=context) - return notif_obj.unlink(cr, uid, to_del_notif_ids, context=context) + to_del_notif_ids = notif_obj.search(cr, uid, ['&', ('user_id', '=', uid), ('message_id', 'in', notif_msg_ids)], context = context) + return notif_obj.unlink(cr, uid, to_del_notif_ids, context = context) #------------------------------------------------------ # Thread_state #------------------------------------------------------ - def message_create_set_unread(self, cr, uid, ids, context=None): + def message_create_set_unread(self, cr, uid, ids, context = None): """ When creating a new message, set as unread if uid is not the object responsible. """ - for obj in self.browse(cr, uid, ids, context=context): + for obj in self.browse(cr, uid, ids, context = context): if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id != uid): - self.message_mark_as_unread(cr, uid, [obj.id], context=context) + self.message_mark_as_unread(cr, uid, [obj.id], context = context) - def message_check_and_set_unread(self, cr, uid, ids, context=None): + def message_check_and_set_unread(self, cr, uid, ids, context = None): """ Set unread if uid is the object responsible or if the object has no responsible. """ - for obj in self.browse(cr, uid, ids, context=context): + for obj in self.browse(cr, uid, ids, context = context): if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id == uid): - self.message_mark_as_unread(cr, uid, [obj.id], context=context) + self.message_mark_as_unread(cr, uid, [obj.id], context = context) - def message_mark_as_unread(self, cr, uid, ids, context=None): + def message_mark_as_unread(self, cr, uid, ids, context = None): """ Set as unread. """ - return self.write(cr, uid, ids, {'message_state': False}, context=context) + return self.write(cr, uid, ids, {'message_state': False}, context = context) - def message_check_and_set_read(self, cr, uid, ids, context=None): + def message_check_and_set_read(self, cr, uid, ids, context = None): """ Set read if uid is the object responsible. """ - for obj in self.browse(cr, uid, ids, context=context): + for obj in self.browse(cr, uid, ids, context = context): if not obj.message_state and hasattr(obj, 'user_id') and obj.user_id and obj.user_id.id == uid: - self.message_mark_as_read(cr, uid, [obj.id], context=context) + self.message_mark_as_read(cr, uid, [obj.id], context = context) - def message_mark_as_read(self, cr, uid, ids, context=None): + def message_mark_as_read(self, cr, uid, ids, context = None): """ Set as read. """ - return self.write(cr, uid, ids, {'message_state': True}, context=context) - + return self.write(cr, uid, ids, {'message_state': True}, context = context) + def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids): + subscription_obj = self.pool.get('mail.subscription') + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [6, 0 , subtype_ids]}, context = context) #overright or add new one + + def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id): + subscription_obj = self.pool.get('mail.subscription') + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [3, subtype_id]}, context = context) # remove linl or record ? + + def message_subscription_remove_subtype_name(self, cr, uid, ids, user_id, subtype_name): + subtype_obj = self.pool.get('mail.message.subtype') + subtype_ids = subtype_obj.search(cr, uid, [('name', '=', subtype_name), ('model_ids', '=', self._name)]) + if not subtype_ids: + return False + self.message_subscription_remove_subtype(cr, uid, ids, user_id, subtype_ids) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From b942c562240d999c2f20ea154547ac46dde179a8 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 9 Aug 2012 14:52:56 +0530 Subject: [PATCH 017/245] [ADD] Add demo data in crm lead bzr revid: fka@tinyerp.com-20120809092256-r27t6y9nvndwnole --- addons/crm/crm_lead.py | 17 ++++++++++------- addons/crm/crm_lead_demo.xml | 32 ++++++++++++++++++++++++++++++++ addons/mail/mail_thread.py | 2 +- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index d5ec1309baa..675f41c94f4 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -275,6 +275,9 @@ class crm_lead(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) + obj = self.browse(cr, uid, obj_id, context) + if obj.user_id: + self.message_subscribe(cr, uid, ids, obj.user_id.id, context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id @@ -849,13 +852,13 @@ class crm_lead(base_stage, osv.osv): # OpenChatter methods and notifications # ---------------------------------------- - def message_get_subscribers(self, cr, uid, ids, context=None): - """ Override to add the salesman. """ - user_ids = super(crm_lead, self).message_get_subscribers(cr, uid, ids, context=context) - for obj in self.browse(cr, uid, ids, context=context): - if obj.user_id and not obj.user_id.id in user_ids: - user_ids.append(obj.user_id.id) - return user_ids + #def message_get_subscribers(self, cr, uid, ids, context=None): + #""" Override to add the salesman. """ + #user_ids = super(crm_lead, self).message_get_subscribers(cr, uid, ids, context=context) + #for obj in self.browse(cr, uid, ids, context=context): + #if obj.user_id and not obj.user_id.id in user_ids: + #user_ids.append(obj.user_id.id) + #return user_ids def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ diff --git a/addons/crm/crm_lead_demo.xml b/addons/crm/crm_lead_demo.xml index 7ed3bc2a86b..b064a9adfb1 100644 --- a/addons/crm/crm_lead_demo.xml +++ b/addons/crm/crm_lead_demo.xml @@ -540,5 +540,37 @@ ref('crm_case_ericdubois4'), ref('crm_case_abcfuelcounits0')], {}" /> + + new + + + + + won + + + + lost + + + + stage change + + + + + other + + + + + email + + + + comment + + + diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3e5bfabe350..21d123ec024 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1051,7 +1051,7 @@ class mail_thread(osv.Model): def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id): subscription_obj = self.pool.get('mail.subscription') subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) - return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [3, subtype_id]}, context = context) # remove linl or record ? + return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [3, subtype_id]}, context = context) # remove link def message_subscription_remove_subtype_name(self, cr, uid, ids, user_id, subtype_name): subtype_obj = self.pool.get('mail.message.subtype') From dae19bc174b3962088bf4b9fd0701f80ab8f8e5e Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 9 Aug 2012 16:48:06 +0530 Subject: [PATCH 018/245] [IMP] improve crm_lead bzr revid: fka@tinyerp.com-20120809111806-k79sserip4oyzo1r --- addons/crm/crm_lead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 675f41c94f4..a3fccffb011 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -277,7 +277,7 @@ class crm_lead(base_stage, osv.osv): obj_id = super(crm_lead, self).create(cr, uid, vals, context) obj = self.browse(cr, uid, obj_id, context) if obj.user_id: - self.message_subscribe(cr, uid, ids, obj.user_id.id, context = context) + self.message_subscribe(cr, uid, [obj_id], [obj.user_id.id], context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id From 2b331ed5e35640a23e8417bbf24d20b9746e3c13 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Mon, 13 Aug 2012 16:37:46 +0530 Subject: [PATCH 019/245] [IMP]all followers of the task project are automatically followers of the task bzr revid: sgo@tinyerp.com-20120813110746-wqivckynrcqnf7y6 --- addons/project/project.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/project/project.py b/addons/project/project.py index 6f3b23f4746..879e9500874 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1209,6 +1209,9 @@ class task(base_stage, osv.osv): user_ids.append(obj.user_id.id) if obj.manager_id and not obj.manager_id.id in user_ids: user_ids.append(obj.manager_id.id) + if obj.project_id.followers: + for follower in obj.project_id.followers: + user_ids.append(follower.id) return user_ids def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): From 0e916d159242e46d3f4b2c914c0d8dc49e88ee03 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 13 Aug 2012 18:40:40 +0530 Subject: [PATCH 020/245] [IMP] improve mail_thread bzr revid: fka@tinyerp.com-20120813131040-32v2tcz3eltkx4fn --- addons/crm/crm_lead.py | 28 +++++++++++++++++++++------- addons/mail/mail_thread.py | 3 ++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index da845cc8e5f..b02369cce9f 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -865,7 +865,9 @@ class crm_lead(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_stage_change') + res_id = res[1] + return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id=res_id,context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -875,33 +877,45 @@ class crm_lead(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_append_note(cr, uid, [id], body=message, context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_new') + res_id = res[1] + self.message_append_note(cr, uid, [id], body=message, subtype_id=res_id, context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_lost') + res_id = res[1] + return self.message_append_note(cr, uid, ids, body=message,subtype_id=res_id, context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_won') + res_id = res[1] + return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] if action == 'log': prefix = 'Logged' else: prefix = 'Scheduled' message = _("%s a call for the %s.") % (prefix, phonecall.date) - return self.message_append_note(cr, uid, ids, body=message, context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') + res_id = res[1] + return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context) def _lead_set_partner_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("%s partner is now set to %s." % (self.case_get_note_msg_prefix(cr, uid, lead, context=context), lead.partner_id.name)) - lead.message_append_note(body=message) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') + res_id = res[1] + lead.message_append_note(body=message, subtype_id=res_id) return True def convert_opportunity_send_note(self, cr, uid, lead, context=None): message = _("Lead has been converted to an opportunity.") - lead.message_append_note(body=message) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') + res_id = res[1] + lead.message_append_note(body=message, subtype_id=res_id) return True crm_lead() diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 79b734379d0..14e9138be55 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -335,6 +335,7 @@ class mail_thread(osv.Model): 'parent_id': parent_id, 'date': email_date or fields.datetime.now(), 'type': type, + 'subtype_id' : subtype_id, 'content_subtype': content_subtype, 'state': state, 'message_id': message_id, @@ -866,7 +867,7 @@ class mail_thread(osv.Model): now deprecated res.log.") self.message_append_note(cr, uid, [id], 'res.log', message, context=context) - def message_append_note(self, cr, uid, ids, subject=None, subtype_id=None, body=None, parent_id=False, + def message_append_note(self, cr, uid, ids, subject=None, subtype_id=False, body=None, parent_id=False, type='notification', content_subtype='html', context=None): if content_subtype == 'html': body_html = body From 9fac5651d55d44e4b6eb8d16fe0b802bc1df349d Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 14 Aug 2012 12:21:49 +0530 Subject: [PATCH 021/245] [IMP] improve as per suggetion bzr revid: fka@tinyerp.com-20120814065149-h1xf3we6t37bsyk3 --- addons/crm/crm_data.xml | 2 +- addons/crm/crm_lead.py | 28 +++++++--------------------- addons/mail/data/mail_group_data.xml | 2 +- addons/mail/mail_thread.py | 13 ++++++------- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/addons/crm/crm_data.xml b/addons/crm/crm_data.xml index 5e5f408673a..dfe2e4653c3 100644 --- a/addons/crm/crm_data.xml +++ b/addons/crm/crm_data.xml @@ -63,7 +63,7 @@ - + Module CRM has been installed From the top menu Sales, you can: trace leads and opportunities, get accurate forecast on your sales pipeline, plan meetings and phonecalls, get realtime statistics and efficiently organize the communication with your prospects. diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b02369cce9f..976eb333ddd 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -865,9 +865,7 @@ class crm_lead(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_stage_change') - res_id = res[1] - return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id=res_id,context=context) + return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id="stage change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -877,45 +875,33 @@ class crm_lead(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_new') - res_id = res[1] - self.message_append_note(cr, uid, [id], body=message, subtype_id=res_id, context=context) + self.message_append_note(cr, uid, [id], body=message, subtype_id="new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_lost') - res_id = res[1] - return self.message_append_note(cr, uid, ids, body=message,subtype_id=res_id, context=context) + return self.message_append_note(cr, uid, ids, body=message,subtype_id="lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_won') - res_id = res[1] - return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype_id="won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] if action == 'log': prefix = 'Logged' else: prefix = 'Scheduled' message = _("%s a call for the %s.") % (prefix, phonecall.date) - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') - res_id = res[1] - return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context) + return self.message_append_note(cr, uid, ids, body=message, context=context) def _lead_set_partner_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("%s partner is now set to %s." % (self.case_get_note_msg_prefix(cr, uid, lead, context=context), lead.partner_id.name)) - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') - res_id = res[1] - lead.message_append_note(body=message, subtype_id=res_id) + lead.message_append_note(body=message) return True def convert_opportunity_send_note(self, cr, uid, lead, context=None): message = _("Lead has been converted to an opportunity.") - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') - res_id = res[1] - lead.message_append_note(body=message, subtype_id=res_id) + lead.message_append_note(body=message) return True crm_lead() diff --git a/addons/mail/data/mail_group_data.xml b/addons/mail/data/mail_group_data.xml index 09a6ca29a2d..3a2ad01fab8 100644 --- a/addons/mail/data/mail_group_data.xml +++ b/addons/mail/data/mail_group_data.xml @@ -16,7 +16,7 @@ - + Welcome to OpenERP! Your homepage is a summary of messages you received and key information about documents you follow. diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 14e9138be55..8d1259ea4ff 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -228,8 +228,8 @@ class mail_thread(osv.Model): ret_dict[model_name] = model._description return ret_dict - def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None, - type = 'email', subtype_id = False, email_date = None, parent_id = False, + def message_append(self, cr, uid, threads, subject,subtype_id = "other", body_text=None, body_html=None, + type = 'email', email_date = None, parent_id = False, content_subtype='plain', state=None, partner_ids=None, email_from=False, email_to=False, email_cc=None, email_bcc=None, reply_to=None, @@ -335,7 +335,6 @@ class mail_thread(osv.Model): 'parent_id': parent_id, 'date': email_date or fields.datetime.now(), 'type': type, - 'subtype_id' : subtype_id, 'content_subtype': content_subtype, 'state': state, 'message_id': message_id, @@ -383,11 +382,11 @@ class mail_thread(osv.Model): """ return self.message_append(cr, uid, ids, subject = msg_dict.get('subject'), + subtype_id = msg_dict.get('subtype_id','other'), body_text = msg_dict.get('body_text'), body_html= msg_dict.get('body_html'), parent_id = msg_dict.get('parent_id', False), type = msg_dict.get('type', 'email'), - subtype_id = msg_dict.get('subtype_id', False), content_subtype = msg_dict.get('content_subtype'), state = msg_dict.get('state'), partner_ids = msg_dict.get('partner_ids'), @@ -867,7 +866,7 @@ class mail_thread(osv.Model): now deprecated res.log.") self.message_append_note(cr, uid, [id], 'res.log', message, context=context) - def message_append_note(self, cr, uid, ids, subject=None, subtype_id=False, body=None, parent_id=False, + def message_append_note(self, cr, uid, ids, subject=None, subtype_id='other', body=None, parent_id=False, type='notification', content_subtype='html', context=None): if content_subtype == 'html': body_html = body @@ -875,8 +874,8 @@ class mail_thread(osv.Model): else: body_html = body body_text = body - return self.message_append(cr, uid, ids, subject, body_html, body_text, - type, subtype_id = subtype_id, parent_id = parent_id, + return self.message_append(cr, uid, ids, subject,subtype_id, body_html, body_text, + type, parent_id = parent_id, content_subtype=content_subtype, context=context) #------------------------------------------------------ From 86768264f4e0027d62ac300410a8ef691e95d862 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 14 Aug 2012 12:49:19 +0530 Subject: [PATCH 022/245] [IMP] Add constraints in message subtype model bzr revid: fka@tinyerp.com-20120814071919-pk9wkepp7v1geswa --- addons/mail/mail_message_subtype.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index 0a167a0f1d9..0c4f5e7baa6 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -39,3 +39,6 @@ class mail_message_subtype(osv.osv): _defaults = { 'default': True, } + _sql_constraints = [ + ('name_uniq', 'unique (name)', 'The name of the message subtype must be unique !') + ] From b4b9ce7178494a5b414995d6236b255cc396caa2 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Tue, 14 Aug 2012 15:42:12 +0530 Subject: [PATCH 023/245] [IMP]improve code bzr revid: sgo@tinyerp.com-20120814101212-rjmlbtpmhdviick7 --- addons/project/project.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 879e9500874..f7309716429 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1209,9 +1209,10 @@ class task(base_stage, osv.osv): user_ids.append(obj.user_id.id) if obj.manager_id and not obj.manager_id.id in user_ids: user_ids.append(obj.manager_id.id) - if obj.project_id.followers: - for follower in obj.project_id.followers: - user_ids.append(follower.id) + if obj.project_id: + subscriber_ids = self.pool.get('project.project').message_get_subscribers(cr, uid, [obj.project_id.id], context=context) + for user_id in subscriber_ids: + user_ids.append(user_id) return user_ids def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): From 0ae13ed393ed42b1d6d3ef600556d526e7840a9d Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 14 Aug 2012 17:42:50 +0530 Subject: [PATCH 024/245] [IMP] improve message_create() in mail_thread bzr revid: fka@tinyerp.com-20120814121250-32fb4key3nt9lcaq --- addons/crm/crm_lead.py | 8 +++--- addons/mail/mail_thread.py | 55 ++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 976eb333ddd..0ec901698df 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -865,7 +865,7 @@ class crm_lead(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id="stage change",context=context) + return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -875,16 +875,16 @@ class crm_lead(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_append_note(cr, uid, [id], body=message, subtype_id="new", context=context) + self.message_append_note(cr, uid, [id], body=message, subtype="new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_append_note(cr, uid, ids, body=message,subtype_id="lost", context=context) + return self.message_append_note(cr, uid, ids, body=message,subtype="lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_append_note(cr, uid, ids, body=message, subtype_id="won", context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 8d1259ea4ff..4ffdac80116 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -153,29 +153,37 @@ class mail_thread(osv.Model): notification_obj = self.pool.get('mail.notification') body = vals.get('body_html', '') if vals.get('content_subtype') == 'html' else vals.get('body_text', '') + subtype_obj=self.pool.get('mail.message.subtype') + subtype_id=subtype_obj.search(cr, uid, [('name', '=', vals.get('subtype')), ('model_ids', '=', self._name)]) + vals['subtype_id'] = subtype_id[0] + user_subscribe=self.message_is_subscriber(cr, uid, [thread_id], vals['user_id'], context) # automatically subscribe the writer of the message if vals['user_id']: self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context=context) - # create message - msg_id = message_obj.create(cr, uid, vals, context=context) - - # Set as unread if writer is not the document responsible - self.message_create_set_unread(cr, uid, [thread_id], context=context) - - # special: if install mode, do not push demo data - if context.get('install_mode', False): - return msg_id - - # get users that will get a notification pushed - user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context) - for id in user_to_push_ids: - notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context) - - # create the email to send - email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) - - return msg_id + for subtype_obj in subtype_obj.browse(cr,uid,subtype_id,context): + if subtype_obj.default and user_subscribe: + # create message + msg_id = message_obj.create(cr, uid, vals, context=context) + + # Set as unread if writer is not the document responsible + self.message_create_set_unread(cr, uid, [thread_id], context=context) + + # special: if install mode, do not push demo data + if context.get('install_mode', False): + return msg_id + + # get users that will get a notification pushed + user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context) + for id in user_to_push_ids: + notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context) + + # create the email to send + email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) + + return msg_id + else: + return False def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None): subscription_obj = self.pool.get('mail.subscription') @@ -228,7 +236,7 @@ class mail_thread(osv.Model): ret_dict[model_name] = model._description return ret_dict - def message_append(self, cr, uid, threads, subject,subtype_id = "other", body_text=None, body_html=None, + def message_append(self, cr, uid, threads, subject,subtype = "other", body_text=None, body_html=None, type = 'email', email_date = None, parent_id = False, content_subtype='plain', state=None, partner_ids=None, email_from=False, email_to=False, @@ -330,6 +338,7 @@ class mail_thread(osv.Model): data = { 'subject': subject, + 'subtype': subtype, 'body_text': body_text or (hasattr(thread, 'description') and thread.description or ''), 'body_html': body_html or '', 'parent_id': parent_id, @@ -382,7 +391,7 @@ class mail_thread(osv.Model): """ return self.message_append(cr, uid, ids, subject = msg_dict.get('subject'), - subtype_id = msg_dict.get('subtype_id','other'), + subtype = msg_dict.get('subtype','other'), body_text = msg_dict.get('body_text'), body_html= msg_dict.get('body_html'), parent_id = msg_dict.get('parent_id', False), @@ -866,7 +875,7 @@ class mail_thread(osv.Model): now deprecated res.log.") self.message_append_note(cr, uid, [id], 'res.log', message, context=context) - def message_append_note(self, cr, uid, ids, subject=None, subtype_id='other', body=None, parent_id=False, + def message_append_note(self, cr, uid, ids, subject=None, subtype='other', body=None, parent_id=False, type='notification', content_subtype='html', context=None): if content_subtype == 'html': body_html = body @@ -874,7 +883,7 @@ class mail_thread(osv.Model): else: body_html = body body_text = body - return self.message_append(cr, uid, ids, subject,subtype_id, body_html, body_text, + return self.message_append(cr, uid, ids, subject,subtype, body_html, body_text, type, parent_id = parent_id, content_subtype=content_subtype, context=context) From 40768f8fd838635737dc7a376a7282a49620d43e Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 14 Aug 2012 19:13:14 +0530 Subject: [PATCH 025/245] [IMP] improve mail_thread bzr revid: fka@tinyerp.com-20120814134314-lyen3a13a76db9sv --- addons/mail/mail_thread.py | 74 +++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 04cb5bc6bc6..5b2efb98fcc 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -140,7 +140,7 @@ class mail_thread(osv.Model): # mail.message wrappers and tools #------------------------------------------------------ - def message_create(self, cr, uid, thread_id, vals, context=None): + def message_create(self, cr, uid, thread_id, vals, context = None): """ OpenChatter: wrapper of mail.message create method - creates the mail.message - automatically subscribe the message writer @@ -151,40 +151,40 @@ class mail_thread(osv.Model): message_obj = self.pool.get('mail.message') notification_obj = self.pool.get('mail.notification') + subscription_obj = self.pool.get('mail.subscription') body = vals.get('body_html', '') if vals.get('content_subtype') == 'html' else vals.get('body_text', '') - subtype_obj=self.pool.get('mail.message.subtype') - subtype_id=subtype_obj.search(cr, uid, [('name', '=', vals.get('subtype')), ('model_ids', '=', self._name)]) - if subtype_id: - vals['subtype_id'] = subtype_id[0] - user_subscribe=self.message_is_subscriber(cr, uid, [thread_id], vals['user_id'], context) # automatically subscribe the writer of the message if vals['user_id']: - self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context=context) + self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context = context) - for subtype_obj in subtype_obj.browse(cr,uid,subtype_id,context): - if subtype_obj.default and user_subscribe: - # create message - msg_id = message_obj.create(cr, uid, vals, context=context) - - # Set as unread if writer is not the document responsible - self.message_create_set_unread(cr, uid, [thread_id], context=context) - - # special: if install mode, do not push demo data - if context.get('install_mode', False): - return msg_id - - # get users that will get a notification pushed - user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context) - for id in user_to_push_ids: - notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context) - - # create the email to send - email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) - - return msg_id - else: - return False + # create message + msg_id = message_obj.create(cr, uid, vals, context = context) + + # Set as unread if writer is not the document responsible + self.message_create_set_unread(cr, uid, [thread_id], context = context) + + # special: if install mode, do not push demo data + if context.get('install_mode', False): + return msg_id + + # get users that will get a notification pushed + user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context = context) + subtype_id = vals.get('subtype', False) + subtype_ids = self.pool.get('mail.message.subtype').name_search(cr, uid, subtype_id) + subtype_id = len(subtype_ids) and subtype_ids[0][0] or False + for user_id in user_to_push_ids: + if subtype_id: + #TOCHECK: domain to find subscrition details of subtype + subscription_ids = subscription_obj.search(cr, uid, [('res_model','=',vals['model']),('res_id','=',vals['res_id']),('subtype_ids','in',subtype_id),('user_id','=',user_id)]) + if not subscription_ids: + continue + notification_obj.create(cr, uid, {'user_id': user_id, 'message_id': msg_id}, context = context) + + # create the email to send + email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context = context) + + return msg_id def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None): subscription_obj = self.pool.get('mail.subscription') @@ -237,13 +237,13 @@ class mail_thread(osv.Model): ret_dict[model_name] = model._description return ret_dict - def message_append(self, cr, uid, threads, subject,subtype = "other", body_text=None, body_html=None, + def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None, type = 'email', email_date = None, parent_id = False, content_subtype='plain', state=None, partner_ids=None, email_from=False, email_to=False, email_cc=None, email_bcc=None, reply_to=None, headers=None, message_id=False, references=None, - attachments=None, original=None, context=None): + attachments=None, original=None, subtype = "other", context=None): """ Creates a new mail.message through message_create. The new message is attached to the current mail.thread, containing all the details passed as parameters. All attachments will be attached to the @@ -392,7 +392,6 @@ class mail_thread(osv.Model): """ return self.message_append(cr, uid, ids, subject = msg_dict.get('subject'), - subtype = msg_dict.get('subtype','other'), body_text = msg_dict.get('body_text'), body_html= msg_dict.get('body_html'), parent_id = msg_dict.get('parent_id', False), @@ -412,6 +411,7 @@ class mail_thread(osv.Model): attachments = msg_dict.get('attachments'), headers = msg_dict.get('headers'), original = msg_dict.get('original'), + subtype = msg_dict.get('subtype','other'), context = context) #------------------------------------------------------ @@ -876,17 +876,17 @@ class mail_thread(osv.Model): now deprecated res.log.") self.message_append_note(cr, uid, [id], 'res.log', message, context=context) - def message_append_note(self, cr, uid, ids, subject=None, subtype='other', body=None, parent_id=False, - type='notification', content_subtype='html', context=None): + def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False, + type='notification', content_subtype='html', subtype='other', context=None): if content_subtype == 'html': body_html = body body_text = body else: body_html = body body_text = body - return self.message_append(cr, uid, ids, subject,subtype, body_html, body_text, + return self.message_append(cr, uid, ids, subject, body_text, body_html, type, parent_id = parent_id, - content_subtype=content_subtype, context=context) + content_subtype=content_subtype, subtype=subtype, context=context) #------------------------------------------------------ # Subscription mechanism From 95082105eba58087a461ed3af51e4302c3d7af78 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 16 Aug 2012 13:00:21 +0530 Subject: [PATCH 026/245] [IMP]improve code as per new changes bzr revid: sgo@tinyerp.com-20120816073021-p7wwjuoeegapjxjn --- addons/project/project.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/project/project.py b/addons/project/project.py index 1a8f8c8bfe5..c4b0472f5a1 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1122,6 +1122,10 @@ class task(base_stage, osv.osv): task_id = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [task_id], context=context) self.create_send_note(cr, uid, [task_id], context=context) + task_obj = self.browse(cr, uid, task_id, context=context) + if task_obj.project_id: + project_follower_ids = [follow.id for follow in task_obj.project_id.message_follower_ids] + self.message_subscribe(cr, uid, [task_id], project_follower_ids, context=context) return task_id # Overridden to reset the kanban_state to normal whenever From 1f60976cbc94ce1ad1500be21a7b98fdafbed0a7 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 16 Aug 2012 14:16:21 +0530 Subject: [PATCH 027/245] [IMP]minor changes in name bzr revid: sgo@tinyerp.com-20120816084621-s0v4o24o6hlqfrs0 --- addons/project/project.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index c4b0472f5a1..2815ec0f3ca 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1122,9 +1122,9 @@ class task(base_stage, osv.osv): task_id = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [task_id], context=context) self.create_send_note(cr, uid, [task_id], context=context) - task_obj = self.browse(cr, uid, task_id, context=context) - if task_obj.project_id: - project_follower_ids = [follow.id for follow in task_obj.project_id.message_follower_ids] + task_record = self.browse(cr, uid, task_id, context=context) + if task_record.project_id: + project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids] self.message_subscribe(cr, uid, [task_id], project_follower_ids, context=context) return task_id From 64470badab104a2b934af0f7c64223e4f2baa439 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 16 Aug 2012 15:08:17 +0530 Subject: [PATCH 028/245] [IMP]:project:improved code bzr revid: apa@tinyerp.com-20120816093817-gxsvt8bdmjvb2bu8 --- addons/project/project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 2815ec0f3ca..55dfd305189 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1120,12 +1120,12 @@ class task(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): task_id = super(task, self).create(cr, uid, vals, context=context) - self._store_history(cr, uid, [task_id], context=context) - self.create_send_note(cr, uid, [task_id], context=context) task_record = self.browse(cr, uid, task_id, context=context) if task_record.project_id: project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids] self.message_subscribe(cr, uid, [task_id], project_follower_ids, context=context) + self._store_history(cr, uid, [task_id], context=context) + self.create_send_note(cr, uid, [task_id], context=context) return task_id # Overridden to reset the kanban_state to normal whenever From a929752e463204cd1b9c3c214edc25d6d6897d09 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 16 Aug 2012 16:33:06 +0530 Subject: [PATCH 029/245] [IMP]remove selectin subtype field & change name of obj bzr revid: fka@tinyerp.com-20120816110306-q0mrqa2tp8128nmv --- addons/crm/crm_lead.py | 6 +++--- addons/mail/mail_message.py | 2 +- addons/mail/mail_thread.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 2e6a3b5514d..0ecc7d9bee2 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -278,9 +278,9 @@ class crm_lead(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) - obj = self.browse(cr, uid, obj_id, context) - if obj.user_id: - self.message_subscribe(cr, uid, [obj_id], [obj.user_id.id], context = context) + record = self.browse(cr, uid, obj_id, context) + if record.user_id: + self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 3d0ea943d3a..a50d091f7ff 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -234,7 +234,7 @@ class mail_message(osv.Model): select=True, ondelete='set null', help="Parent message, used for displaying as threads with hierarchy"), 'child_ids': fields.one2many('mail.message', 'parent_id', 'Child Messages'), - 'subtype_id': fields.many2one('mail.message.subtype', 'Subtype', select = True), + 'subtype_id': fields.many2one('mail.message.subtype', 'Subtype'), } _defaults = { diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 840cfbaaa37..ddace0cf9b9 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -273,7 +273,7 @@ class mail_thread(osv.Model): followers_obj = self.pool.get('mail.followers') subtype_obj = self.pool.get('mail.message.subtype') subtype_name = vals.get('subtype') - sutype = False + subtype = False body = vals.get('body_html', '') if vals.get('content_subtype') == 'html' else vals.get('body_text', '') if subtype_name: subtypes = subtype_obj.name_search(cr, uid, subtype_name) From 1b2f6c7551ffeda6c17c7d9492aae08d85efe6e3 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 20 Aug 2012 10:42:22 +0530 Subject: [PATCH 030/245] [IMP]add message_subtype.yml bzr revid: rma@tinyerp.com-20120820051222-9dk4p47uz53j5nzo --- addons/crm/__openerp__.py | 3 +- .../crm/test/process/crm_message_subtype.yml | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 addons/crm/test/process/crm_message_subtype.yml diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index 643908c1098..f0f181c47da 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -129,7 +129,8 @@ Creates a dashboard for CRM that includes: 'test/process/segmentation.yml', 'test/ui/crm_demo.yml', 'test/ui/duplicate_lead.yml', - 'test/ui/delete_lead.yml' + 'test/ui/delete_lead.yml', + 'test/process/crm_message_subtype.yml', ], 'installable': True, 'application': True, diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml new file mode 100644 index 00000000000..a83c729ecd4 --- /dev/null +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -0,0 +1,54 @@ +- + I have add the sub_type name other with default false +- + !record {model: mail.message.subtype, id: mail_subtype_lead_won }: + name: won + model_ids: + - crm.model_crm_lead + default: False +- + I have add the sub_type name email with default true +- + !record {model: mail.message.subtype, id: mail_subtype_lead_email }: + name: email + model_ids: + - crm.model_crm_lead + default: True +- + I have add the sub_type name comment with default true +- + !record {model: mail.message.subtype, id: mail_subtype_lead_comment }: + name: comment + model_ids: + - crm.model_crm_lead + default: True + +- + I have search and write its subtype in followers +- + !python {model: mail.followers}: | + ids = self.search(cr, uid, [('res_model', '=', 'crm.lead'),('res_id', '=', ref('crm_case_1'))]) + self.write(cr, uid, ids, {'subtype_ids': [(6,0,[ref('mail_subtype_lead_won')])]}) +- + I have change the lead into mark won +- + !python {model: crm.lead}: | + self.convert_opportunity(cr, uid ,[ref("crm_case_1")], ref("base.res_partner_4")) + self.case_mark_won(cr, uid,[ref("crm_case_1")] ) +- + I have check the lead into mark won +- + !assert {model: crm.lead, id: crm_case_1 ,string: 'The record is not in won state'}: + - state == 'done' +- + I have check to if subtype is won then display notification. +- + !python {model: mail.message}: | + ids = self.search(cr, uid, [('model', '=','crm.lead'),('res_id', '=', ref('crm_case_1'))]) + browse = self.browse(cr,uid,ids) + + assert ids, 'lead is in won' + + + + From aef5236ba71e9150b56c6b74f4518d7362e6010b Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 20 Aug 2012 12:48:10 +0530 Subject: [PATCH 031/245] [FIX]make changes into crm_message_subtype.yml file bzr revid: rma@tinyerp.com-20120820071810-fn1wdg36syq1epd5 --- .../crm/test/process/crm_message_subtype.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index a83c729ecd4..705d3cc2fc4 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -22,9 +22,8 @@ model_ids: - crm.model_crm_lead default: True - - - I have search and write its subtype in followers + I have add the subtypes as won in feeds - !python {model: mail.followers}: | ids = self.search(cr, uid, [('res_model', '=', 'crm.lead'),('res_id', '=', ref('crm_case_1'))]) @@ -41,14 +40,9 @@ !assert {model: crm.lead, id: crm_case_1 ,string: 'The record is not in won state'}: - state == 'done' - - I have check to if subtype is won then display notification. + I have check the subtype as won in feeds - - !python {model: mail.message}: | - ids = self.search(cr, uid, [('model', '=','crm.lead'),('res_id', '=', ref('crm_case_1'))]) - browse = self.browse(cr,uid,ids) - - assert ids, 'lead is in won' - - - - + !python {model: mail.followers}: | + followers_ids =self.search(cr, uid, [('res_model', '=','crm.lead'),('res_id', '=', ref('crm_case_1')),('subtype_ids', 'in',[ref('mail_subtype_lead_won')])]) + if len(followers_ids): + assert followers_ids, 'lead is in won' From 82b2b3a626befc97c14591c80b4952c5eed99f6d Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 22 Aug 2012 11:57:22 +0530 Subject: [PATCH 032/245] [IMP]add name and checkbox on click of follow and make it work as add in subtype_ids in followers bzr revid: sgo@tinyerp.com-20120822062722-ru93dme523lnuko7 --- addons/mail/mail_thread.py | 6 ++-- addons/mail/static/src/js/mail_followers.js | 35 +++++++++++++++++-- addons/mail/static/src/xml/mail_followers.xml | 5 +++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index ddace0cf9b9..d552dc108a4 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1192,10 +1192,10 @@ class mail_thread(osv.Model): """ Set as read. """ return self.write(cr, uid, ids, {'message_state': True}, context=context) - def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids): + def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): subscription_obj = self.pool.get('mail.followers') - subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) - return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [6, 0 , subtype_ids]}, context = context) #overright or add new one + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids),('user_id','=',user_id)]) + return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id): subscription_obj = self.pool.get('mail.followers') diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 0e920f73041..4e49919e7d2 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -31,6 +31,7 @@ openerp_mail_followers = function(session, mail) { this.params.display_control = this.node.attrs.display_control || false; this.params.display_actions = this.node.attrs.display_actions || false; this.ds_model = new session.web.DataSetSearch(this, this.view.model); + this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype') this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); }, @@ -42,8 +43,21 @@ openerp_mail_followers = function(session, mail) { this._check_visibility(); this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { - this.$element.find('button.oe_mail_button_followers').hide(); } - this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); }) + this.$element.find('button.oe_mail_button_followers').hide(); + } + this.$element.find('ul.oe_mail_recthread_subtype').click(function () { + var sublist = new Array(); + _($(this).find('.oe_msg_subtype_check')).each(function (record){ + if($(record).is(':checked')) { + sublist.push(parseInt($(record).attr('id'))) + } + }); + self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,sublist]) + }) + this.$element.find('button.oe_mail_button_follow').click(function () { + self.add_subtype(); + self.do_follow(); + }) .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) @@ -103,10 +117,25 @@ openerp_mail_followers = function(session, mail) { this.$element.find('button.oe_mail_button_follow').show(); this.$element.find('button.oe_mail_button_unfollow').hide(); } }, - + + subtype_value: function(value_) { + return this.sub_model.call('read', [value_ || this.get_value(),['name', 'default']]).then(this.proxy('read_subtype')); + }, + + read_subtype: function(records) { + this.reinit() + var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty(); + _(records).each(function (record) { + $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); + }); + }, + do_follow: function () { return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); }, + add_subtype: function () { + return this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]).pipe(this.proxy('subtype_value')); + }, do_unfollow: function () { return this.ds_model.call('message_unsubscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 53c899b9569..9979aa9d6fa 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -16,6 +16,7 @@

    +
      @@ -27,5 +28,9 @@ +
    • + + +
    • From ecdab52f06551bca82a53544c52194970779a4e1 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 22 Aug 2012 14:53:17 +0530 Subject: [PATCH 033/245] [IMP]if subtype selected its write in follower and improve code bzr revid: sgo@tinyerp.com-20120822092317-4nlhfton4ltk1lcq --- addons/mail/static/src/js/mail_followers.js | 29 ++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 4e49919e7d2..2940ae54288 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -33,6 +33,7 @@ openerp_mail_followers = function(session, mail) { this.ds_model = new session.web.DataSetSearch(this, this.view.model); this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype') this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); + this.follow_model = new session.web.DataSetSearch(this,'mail.followers') }, start: function() { @@ -41,6 +42,8 @@ openerp_mail_followers = function(session, mail) { // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); + self.add_subtype(); + this.$element.find('ul.oe_mail_recthread_subtype').hide() this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { this.$element.find('button.oe_mail_button_followers').hide(); @@ -55,12 +58,13 @@ openerp_mail_followers = function(session, mail) { self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,sublist]) }) this.$element.find('button.oe_mail_button_follow').click(function () { - self.add_subtype(); self.do_follow(); + self.$element.find('ul.oe_mail_recthread_subtype').show() }) .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) + this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); + self.$element.find('ul.oe_mail_recthread_subtype').hide() }) .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.reinit(); @@ -81,6 +85,7 @@ openerp_mail_followers = function(session, mail) { this.$element.find('button.oe_mail_button_followers').html('Hide followers') this.$element.find('button.oe_mail_button_follow').hide(); this.$element.find('button.oe_mail_button_unfollow').hide(); + this.$element.find('ul.oe_mail_recthread_subtype').hide() }, set_value: function(value_) { @@ -112,10 +117,12 @@ openerp_mail_followers = function(session, mail) { }); if (this.is_subscriber) { this.$element.find('button.oe_mail_button_follow').hide(); - this.$element.find('button.oe_mail_button_unfollow').show(); } + this.$element.find('button.oe_mail_button_unfollow').show(); + this.$element.find('ul.oe_mail_recthread_subtype').show()} else { this.$element.find('button.oe_mail_button_follow').show(); - this.$element.find('button.oe_mail_button_unfollow').hide(); } + this.$element.find('button.oe_mail_button_unfollow').hide(); + this.$element.find('ul.oe_mail_recthread_subtype').hide() } }, subtype_value: function(value_) { @@ -123,9 +130,19 @@ openerp_mail_followers = function(session, mail) { }, read_subtype: function(records) { - this.reinit() + var self = this var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty(); - _(records).each(function (record) { + var follow_ids = this.follow_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) + follow_ids.then(function (record){ + var msg_subtype = self.follow_model.call('read', [record,['subtype_ids']]); + if(msg_subtype){ + msg_subtype.then(function (subtype){ + _(subtype[0].subtype_ids).each(function (subtype_id){ + self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true + }); + })} + }); + _(records).each(function (record) { $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); }); }, From 117e0dffa03fc8ca55254310fc02455fc0930276 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 23 Aug 2012 10:30:29 +0530 Subject: [PATCH 034/245] [IMP]improve code bzr revid: sgo@tinyerp.com-20120823050029-wz5ce5f8xsrsbqyq --- addons/mail/static/src/js/mail_followers.js | 48 ++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 2940ae54288..a468a0b25d9 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -42,21 +42,20 @@ openerp_mail_followers = function(session, mail) { // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); - self.add_subtype(); + self.search_subtype(); this.$element.find('ul.oe_mail_recthread_subtype').hide() + this.$element.find('ul.oe_mail_recthread_subtype').click(function () { + var subtypelist = new Array(); + _($(this).find('.oe_msg_subtype_check')).each(function (record){ + if($(record).is(':checked')) { + subtypelist.push(parseInt($(record).attr('id')))} + }); + self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,subtypelist]) + }) this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { this.$element.find('button.oe_mail_button_followers').hide(); } - this.$element.find('ul.oe_mail_recthread_subtype').click(function () { - var sublist = new Array(); - _($(this).find('.oe_msg_subtype_check')).each(function (record){ - if($(record).is(':checked')) { - sublist.push(parseInt($(record).attr('id'))) - } - }); - self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,sublist]) - }) this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.$element.find('ul.oe_mail_recthread_subtype').show() @@ -72,6 +71,7 @@ openerp_mail_followers = function(session, mail) { _check_visibility: function() { this.$element.toggle(this.view.get("actual_mode") !== "create"); + if(this.view.get("actual_mode") == "create"){this.search_subtype();} }, destroy: function () { @@ -132,25 +132,25 @@ openerp_mail_followers = function(session, mail) { read_subtype: function(records) { var self = this var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty(); - var follow_ids = this.follow_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) - follow_ids.then(function (record){ - var msg_subtype = self.follow_model.call('read', [record,['subtype_ids']]); - if(msg_subtype){ - msg_subtype.then(function (subtype){ - _(subtype[0].subtype_ids).each(function (subtype_id){ - self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true - }); - })} - }); - _(records).each(function (record) { + var follow_ids = this.follow_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) + follow_ids.then(function (record){ + var follow_read = self.follow_model.call('read', [record,['subtype_ids']]); + follow_read.then(function (follow_record){ + if(follow_record.length != 0){ + _(follow_record[0].subtype_ids).each(function (subtype_id){ + self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true + });} + }) + }); + _(records).each(function (record) { $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); - }); - }, + }); + }, do_follow: function () { return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); }, - add_subtype: function () { + search_subtype: function () { return this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]).pipe(this.proxy('subtype_value')); }, From 753e55c089e5faf1ff51e6790f82f1fffc83d5e6 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 23 Aug 2012 11:32:16 +0530 Subject: [PATCH 035/245] [IMP]improve code and naming convention bzr revid: sgo@tinyerp.com-20120823060216-sp10hvix2uw3wrg0 --- addons/mail/static/src/js/mail_followers.js | 42 +++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index a468a0b25d9..3ba080e19f0 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -33,7 +33,7 @@ openerp_mail_followers = function(session, mail) { this.ds_model = new session.web.DataSetSearch(this, this.view.model); this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype') this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); - this.follow_model = new session.web.DataSetSearch(this,'mail.followers') + this.follower_model = new session.web.DataSetSearch(this,'mail.followers') }, start: function() { @@ -42,7 +42,7 @@ openerp_mail_followers = function(session, mail) { // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); - self.search_subtype(); + this.fetch_subtype(); this.$element.find('ul.oe_mail_recthread_subtype').hide() this.$element.find('ul.oe_mail_recthread_subtype').click(function () { var subtypelist = new Array(); @@ -71,7 +71,7 @@ openerp_mail_followers = function(session, mail) { _check_visibility: function() { this.$element.toggle(this.view.get("actual_mode") !== "create"); - if(this.view.get("actual_mode") == "create"){this.search_subtype();} + if(this.view.get("actual_mode") == "create"){this.fetch_subtype();} }, destroy: function () { @@ -125,33 +125,37 @@ openerp_mail_followers = function(session, mail) { this.$element.find('ul.oe_mail_recthread_subtype').hide() } }, - subtype_value: function(value_) { - return this.sub_model.call('read', [value_ || this.get_value(),['name', 'default']]).then(this.proxy('read_subtype')); - }, - - read_subtype: function(records) { + // Display the subtypes of each records. + display_subtype: function(records) { var self = this var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty(); - var follow_ids = this.follow_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) - follow_ids.then(function (record){ - var follow_read = self.follow_model.call('read', [record,['subtype_ids']]); - follow_read.then(function (follow_record){ - if(follow_record.length != 0){ - _(follow_record[0].subtype_ids).each(function (subtype_id){ - self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true - });} + var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) + follower_ids.then(function (record){ + var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); + follower_read.then(function (follower_record){ + if(follower_record.length != 0){ + _(follower_record[0].subtype_ids).each(function (subtype_id){ + self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true + }); + } }) }); _(records).each(function (record) { $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); }); - }, + }, do_follow: function () { return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); }, - search_subtype: function () { - return this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]).pipe(this.proxy('subtype_value')); + + //fetch subtype from subtype model + fetch_subtype: function () { + var self = this + var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); + subtype_object.then(function (subtype_ids){ + self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); + }); }, do_unfollow: function () { From 27e0487ee742ca0692557ccc38508c18904c531b Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 23 Aug 2012 14:36:16 +0530 Subject: [PATCH 036/245] [IMP] improve code in mail.xml bzr revid: fka@tinyerp.com-20120823090616-e2ro792wqyywxtt9 --- addons/mail/static/src/js/mail_followers.js | 2 +- addons/mail/static/src/xml/mail_followers.xml | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 3ba080e19f0..76280e38ae3 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -141,7 +141,7 @@ openerp_mail_followers = function(session, mail) { }) }); _(records).each(function (record) { - $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); + $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list); }); }, diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 9979aa9d6fa..c0cc747a817 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -28,9 +28,17 @@ -
    • - - +
    • + + + + + +
      + + + +
    • From 107eade158b0950e01277e09fbed0a5c0459f84e Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 23 Aug 2012 15:51:38 +0530 Subject: [PATCH 037/245] [IMP] make 1st latter of name of subtype bzr revid: fka@tinyerp.com-20120823102138-0cjhjiw5ob6z2i7e --- addons/mail/static/src/js/mail_followers.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 76280e38ae3..42e331863be 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -141,6 +141,9 @@ openerp_mail_followers = function(session, mail) { }) }); _(records).each(function (record) { + record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) { + return letter.toUpperCase(); + }); $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list); }); }, From 0d8bfaaf87e7013190f0587e411ab0e3a467db6c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 23 Aug 2012 16:17:05 +0530 Subject: [PATCH 038/245] [IMP]add comment whr needed bzr revid: sgo@tinyerp.com-20120823104705-ji03v95oe2ycz2k2 --- addons/mail/static/src/js/mail_followers.js | 9 ++++----- addons/mail/static/src/xml/mail_followers.xml | 9 +++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 42e331863be..29761ff66ce 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -43,7 +43,6 @@ openerp_mail_followers = function(session, mail) { this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); - this.$element.find('ul.oe_mail_recthread_subtype').hide() this.$element.find('ul.oe_mail_recthread_subtype').click(function () { var subtypelist = new Array(); _($(this).find('.oe_msg_subtype_check')).each(function (record){ @@ -55,15 +54,15 @@ openerp_mail_followers = function(session, mail) { this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { this.$element.find('button.oe_mail_button_followers').hide(); + this.$element.find('ul.oe_mail_recthread_subtype').hide() } this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); - self.$element.find('ul.oe_mail_recthread_subtype').show() + self.fetch_subtype(); }) .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); - self.$element.find('ul.oe_mail_recthread_subtype').hide() }) + this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.reinit(); @@ -118,7 +117,7 @@ openerp_mail_followers = function(session, mail) { if (this.is_subscriber) { this.$element.find('button.oe_mail_button_follow').hide(); this.$element.find('button.oe_mail_button_unfollow').show(); - this.$element.find('ul.oe_mail_recthread_subtype').show()} + this.$element.find('ul.oe_mail_recthread_subtype').show(); } else { this.$element.find('button.oe_mail_button_follow').show(); this.$element.find('button.oe_mail_button_unfollow').hide(); diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index c0cc747a817..d590407494f 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -3,7 +3,7 @@
      @@ -27,7 +27,12 @@
    • -
    • + \ + +
    • From cc56b498a14992e4fe78ec11962da1161466d726 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 24 Aug 2012 14:16:28 +0530 Subject: [PATCH 039/245] [IMP]if record is unread it also show only those record which checked in subtype bzr revid: sgo@tinyerp.com-20120824084628-r9bvejcya6mt6l33 --- addons/mail/mail_thread.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index c7f77208149..04a71a91a5b 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -319,9 +319,11 @@ class mail_thread(osv.Model): subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', thread_ids)], context=context) notif_user_ids = [] # check with subtype + is_subtype = False for subscription in subscr_obj.browse(cr, uid, subscr_ids, context=context): if subtype_id: if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: + is_subtype = True notif_user_ids.append(subscription.user_id.id) else: notif_user_ids.append(subscription.user_id.id) @@ -330,7 +332,8 @@ class mail_thread(osv.Model): if hasattr(self, 'get_needaction_user_ids') and self._columns.get('user_id'): user_ids_dict = self.get_needaction_user_ids(cr, uid, thread_ids, context=context) for id, user_ids in user_ids_dict.iteritems(): - notif_user_ids += user_ids + if is_subtype: + notif_user_ids += user_ids # add users notified of the parent messages (because: if parent message contains @login, login must receive the replies) if new_msg_vals.get('parent_id'): From 27010a32ec33107d658f932ed2b5b8a0d36ae9d5 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 24 Aug 2012 18:02:03 +0530 Subject: [PATCH 040/245] [IMP]add access rights bzr revid: sgo@tinyerp.com-20120824123203-4kmu02cyehbqd48v --- addons/mail/security/ir.model.access.csv | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/mail/security/ir.model.access.csv b/addons/mail/security/ir.model.access.csv index 1979e2fec05..1e88e4e5a12 100644 --- a/addons/mail/security/ir.model.access.csv +++ b/addons/mail/security/ir.model.access.csv @@ -1,9 +1,10 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_mail_message_all,mail.message.all,model_mail_message,,1,0,0,0 -access_mail_message_group_user,mail.message.group.user,model_mail_message,base.group_user,1,1,1,1 -access_mail_thread,mail.thread,model_mail_thread,base.group_user,1,1,1,0 -access_mail_followers_all,mail.followers.all,model_mail_followers,,1,1,1,1 -access_mail_notification_all,mail.notification.all,model_mail_notification,,1,1,1,1 -access_mail_group,mail.group,model_mail_group,base.group_user,1,1,1,1 -access_mail_alias_user,mail.alias,model_mail_alias,base.group_user,1,1,1,0 -access_mail_alias_system,mail.alias,model_mail_alias,base.group_system,1,1,1,1 +id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink +access_mail_message_all mail.message.all model_mail_message 1 0 0 0 +access_mail_message_group_user mail.message.group.user model_mail_message base.group_user 1 1 1 1 +access_mail_thread mail.thread model_mail_thread base.group_user 1 1 1 0 +access_mail_followers_all mail.followers.all model_mail_followers 1 1 1 1 +access_mail_notification_all mail.notification.all model_mail_notification 1 1 1 1 +access_mail_group mail.group model_mail_group base.group_user 1 1 1 1 +access_mail_alias_user mail.alias model_mail_alias base.group_user 1 1 1 0 +access_mail_alias_system mail.alias model_mail_alias base.group_system 1 1 1 1 +access_mail_message_subtype mail.message.subtype mode_mail_message_subtype 1 1 1 1 From af5583bb93822f4a5c8d2c48ddfb5a9cfd208fd8 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Mon, 27 Aug 2012 10:59:20 +0530 Subject: [PATCH 041/245] [IMP]:improved view bzr revid: apa@tinyerp.com-20120827052920-e7dwg2vqj0swnwqk --- addons/mail/static/src/xml/mail_followers.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index d590407494f..1a93d860b53 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -11,12 +11,12 @@ +

          -
            @@ -33,7 +33,7 @@ record_thread.subtype template Template used to display subtype of record --> -
          • +
          • @@ -44,6 +44,6 @@
            -
          • +
            From 1338046cf0f7d37f724a09899695b7e02a5b873c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Mon, 27 Aug 2012 10:59:33 +0530 Subject: [PATCH 042/245] [IMP]added access to mail_message_subtype bzr revid: sgo@tinyerp.com-20120827052933-6ajhaete5vuzqhiv --- addons/mail/security/ir.model.access.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mail/security/ir.model.access.csv b/addons/mail/security/ir.model.access.csv index 1979e2fec05..61106fbf234 100644 --- a/addons/mail/security/ir.model.access.csv +++ b/addons/mail/security/ir.model.access.csv @@ -7,3 +7,4 @@ access_mail_notification_all,mail.notification.all,model_mail_notification,,1,1, access_mail_group,mail.group,model_mail_group,base.group_user,1,1,1,1 access_mail_alias_user,mail.alias,model_mail_alias,base.group_user,1,1,1,0 access_mail_alias_system,mail.alias,model_mail_alias,base.group_system,1,1,1,1 +access_mail_message_subtype,mail.message.subtype,model_mail_message_subtype,,1,1,1,1 \ No newline at end of file From 5a8bdae6d684cc4e4c9140ff971aaa5c552e7925 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Mon, 27 Aug 2012 11:25:39 +0530 Subject: [PATCH 043/245] [IMP]:improved view bzr revid: apa@tinyerp.com-20120827055539-kqybbq2sqhx9tax9 --- addons/mail/static/src/js/mail_followers.js | 12 ++++++------ addons/mail/static/src/xml/mail_followers.xml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index c6a83817af9..f81919de1c7 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -43,7 +43,7 @@ openerp_mail_followers = function(session, mail) { this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); - this.$el.find('ul.oe_mail_recthread_subtype').click(function () { + this.$el.find('div.oe_mail_recthread_subtype').click(function () { var subtypelist = new Array(); _($(this).find('.oe_msg_subtype_check')).each(function (record){ if($(record).is(':checked')) { @@ -55,7 +55,7 @@ openerp_mail_followers = function(session, mail) { if (! this.params.display_control) { this.$el.find('button.oe_mail_button_followers').hide(); - this.$el.find('ul.oe_mail_recthread_subtype').hide() + this.$el.find('div.oe_mail_recthread_subtype').hide() } this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); @@ -85,7 +85,7 @@ openerp_mail_followers = function(session, mail) { this.$el.find('button.oe_mail_button_followers').html('Hide followers') this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').hide(); - this.$el.find('ul.oe_mail_recthread_subtype').hide() + this.$el.find('div.oe_mail_recthread_subtype').hide() }, set_value: function(value_) { @@ -118,17 +118,17 @@ openerp_mail_followers = function(session, mail) { if (this.is_subscriber) { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').show(); - this.$el.find('ul.oe_mail_recthread_subtype').show(); } + this.$el.find('div.oe_mail_recthread_subtype').show(); } else { this.$el.find('button.oe_mail_button_follow').show(); this.$el.find('button.oe_mail_button_unfollow').hide(); - this.$el.find('ul.oe_mail_recthread_subtype').hide() } + this.$el.find('div.oe_mail_recthread_subtype').hide() } }, // Display the subtypes of each records. display_subtype: function(records) { var self = this - var subtype_list = this.$el.find('ul.oe_mail_recthread_subtype').empty(); + var subtype_list = this.$el.find('div.oe_mail_recthread_subtype').empty(); var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) follower_ids.then(function (record){ var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 1a93d860b53..2f7f5e6cde8 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -11,7 +11,7 @@
            -
              +

              From 0f8274ffa30acf585dbd7359c0e9872727a8663d Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 28 Aug 2012 12:49:06 +0530 Subject: [PATCH 044/245] [IMP] Display Default value of subtype bzr revid: fka@tinyerp.com-20120828071906-cdoh84qlie1si73t --- addons/mail/static/src/js/mail_followers.js | 18 +++++++++++------- addons/mail/static/src/xml/mail_followers.xml | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index f81919de1c7..cfbff3744aa 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -44,12 +44,7 @@ openerp_mail_followers = function(session, mail) { this._check_visibility(); this.fetch_subtype(); this.$el.find('div.oe_mail_recthread_subtype').click(function () { - var subtypelist = new Array(); - _($(this).find('.oe_msg_subtype_check')).each(function (record){ - if($(record).is(':checked')) { - subtypelist.push(parseInt($(record).attr('id')))} - }); - self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,subtypelist]) + self.update_subtype(); }) this.$el.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); @@ -108,6 +103,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; + if(this.view.get("actual_mode") == "edit"){this.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { @@ -124,7 +120,15 @@ openerp_mail_followers = function(session, mail) { this.$el.find('button.oe_mail_button_unfollow').hide(); this.$el.find('div.oe_mail_recthread_subtype').hide() } }, - + update_subtype: function (){ + var self = this; + var cheklist = new Array(); + _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ + if($(record).is(':checked')) { + cheklist.push(parseInt($(record).attr('id')))} + }); + self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,cheklist]) + }, // Display the subtypes of each records. display_subtype: function(records) { var self = this diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 2f7f5e6cde8..d307aff7b19 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -40,7 +40,8 @@ - + + From 65d83c36204529e60fcdc6a16bb583d4090a9ce8 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Tue, 28 Aug 2012 14:26:35 +0530 Subject: [PATCH 045/245] [IMP]:improved code. set default while reload and create bzr revid: apa@tinyerp.com-20120828085635-tw54dpuno965k2bn --- addons/mail/static/src/js/mail_followers.js | 42 ++++++++++----------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index cfbff3744aa..5750d005973 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -43,15 +43,13 @@ openerp_mail_followers = function(session, mail) { this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); - this.$el.find('div.oe_mail_recthread_subtype').click(function () { - self.update_subtype(); - }) + this.$el.find('div.oe_mail_recthread_subtype').click(function () {self.update_subtype();}) this.$el.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { this.$el.find('button.oe_mail_button_followers').hide(); this.$el.find('div.oe_mail_recthread_subtype').hide() - } + } this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.fetch_subtype(); @@ -66,7 +64,7 @@ openerp_mail_followers = function(session, mail) { _check_visibility: function() { this.$el.toggle(this.view.get("actual_mode") !== "create"); - if(this.view.get("actual_mode") == "create"){this.fetch_subtype();} + if (this.view.get("actual_mode") === "create"){this.fetch_subtype();} }, destroy: function () { @@ -103,7 +101,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; - if(this.view.get("actual_mode") == "edit"){this.update_subtype();} + if (this.view.get("actual_mode") !== "create"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { @@ -125,7 +123,7 @@ openerp_mail_followers = function(session, mail) { var cheklist = new Array(); _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ if($(record).is(':checked')) { - cheklist.push(parseInt($(record).attr('id')))} + cheklist.push(parseInt($(record).attr('id')))} }); self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,cheklist]) }, @@ -135,19 +133,17 @@ openerp_mail_followers = function(session, mail) { var subtype_list = this.$el.find('div.oe_mail_recthread_subtype').empty(); var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) follower_ids.then(function (record){ - var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); - follower_read.then(function (follower_record){ - if(follower_record.length != 0){ - _(follower_record[0].subtype_ids).each(function (subtype_id){ - self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true - }); - } - }) + var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); + follower_read.then(function (follower_record){ + if(follower_record.length != 0){ + _(follower_record[0].subtype_ids).each(function (subtype_id){ + self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true + }); + } + }) }); _(records).each(function (record) { - record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) { - return letter.toUpperCase(); - }); + record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) {return letter.toUpperCase();}); $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list); }); }, @@ -158,11 +154,11 @@ openerp_mail_followers = function(session, mail) { //fetch subtype from subtype model fetch_subtype: function () { - var self = this - var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); - subtype_object.then(function (subtype_ids){ - self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); - }); + var self = this + var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); + subtype_object.then(function (subtype_ids){ + self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); + }); }, do_unfollow: function () { From 362e7e310262f1a160bf3c8aadfbf11a526848fb Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Tue, 28 Aug 2012 14:57:23 +0530 Subject: [PATCH 046/245] [IMP]:improved code. set default while reload and create bzr revid: apa@tinyerp.com-20120828092723-oogxsd60t348defy --- addons/mail/static/src/js/mail_followers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 5750d005973..4606996c374 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -101,7 +101,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; - if (this.view.get("actual_mode") !== "create"){self.update_subtype();} + if (this.view.get("actual_mode") === "edit"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { From 99e021203f1e13360bf953c3502aaa38c2980215 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Tue, 28 Aug 2012 15:01:25 +0530 Subject: [PATCH 047/245] [IMP]:improve code bzr revid: apa@tinyerp.com-20120828093125-mbyw902f77cm9n1w --- addons/mail/static/src/js/mail_followers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 4606996c374..bc219712b3d 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -101,7 +101,6 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; - if (this.view.get("actual_mode") === "edit"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { @@ -130,6 +129,7 @@ openerp_mail_followers = function(session, mail) { // Display the subtypes of each records. display_subtype: function(records) { var self = this + if (self.view.get("actual_mode") === "edit"){self.update_subtype();} var subtype_list = this.$el.find('div.oe_mail_recthread_subtype').empty(); var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) follower_ids.then(function (record){ From 205c8453ea9ec353e26497309a749333dd29600f Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Tue, 28 Aug 2012 15:35:06 +0530 Subject: [PATCH 048/245] [IMP]:reverted default to display subcribe method bzr revid: apa@tinyerp.com-20120828100506-7o73f6sh6gcbeq7p --- addons/mail/static/src/js/mail_followers.js | 2 +- addons/mail/static/src/xml/mail_followers.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index bc219712b3d..4a328fbbc55 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -101,6 +101,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; + if (self.view.get("actual_mode") === "edit"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { @@ -129,7 +130,6 @@ openerp_mail_followers = function(session, mail) { // Display the subtypes of each records. display_subtype: function(records) { var self = this - if (self.view.get("actual_mode") === "edit"){self.update_subtype();} var subtype_list = this.$el.find('div.oe_mail_recthread_subtype').empty(); var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) follower_ids.then(function (record){ diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index d307aff7b19..b0e19e57579 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -40,7 +40,7 @@ - + From 7c3569385fa5cd5e32899a3b044a71605aeb07d5 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 12:12:43 +0530 Subject: [PATCH 049/245] [IMP]:default work with demo data and remove readonly from subtype bzr revid: apa@tinyerp.com-20120829064243-w0y3k6c3uxcqruzm --- addons/crm/crm_lead.py | 4 +++- addons/mail/mail_thread.py | 2 +- addons/mail/static/src/js/mail_followers.js | 1 - addons/mail/static/src/xml/mail_followers.xml | 3 +-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index c4423520847..75c1863c4d8 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -278,9 +278,11 @@ class crm_lead(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) + subtype_obj = self.pool.get('mail.message.subtype'); + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', 'crm.lead')]) record = self.browse(cr, uid, obj_id, context) if record.user_id: - self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], context = context) + self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], subtype_ids,context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 04a71a91a5b..0e1e90f39df 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1051,7 +1051,7 @@ class mail_thread(osv.Model): write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context) follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] if subtype_ids: - self.pool.get('mail.followers').write(cr, uid, follower_ids, {'subtype_ids': [(6, 0, subtype_ids)]}, context=context) + self.message_subscribe_udpate_subtypes(cr, uid, ids, user_ids, subtype_ids, context=context) return follower_ids def message_subscribe_get_command(self, cr, uid, follower_ids, context=None): diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 4a328fbbc55..7e150051f7f 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -101,7 +101,6 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; - if (self.view.get("actual_mode") === "edit"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index b0e19e57579..3bdd18bb0a0 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -40,8 +40,7 @@ - - + From 8e0151002ac6692afc833f523872b97b7433784d Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 12:25:14 +0530 Subject: [PATCH 050/245] [IMP]:improved code bzr revid: apa@tinyerp.com-20120829065514-mzr02sccg2fhrfog --- addons/crm/crm_lead.py | 4 +--- addons/mail/mail_thread.py | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 75c1863c4d8..c4423520847 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -278,11 +278,9 @@ class crm_lead(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) - subtype_obj = self.pool.get('mail.message.subtype'); - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', 'crm.lead')]) record = self.browse(cr, uid, obj_id, context) if record.user_id: - self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], subtype_ids,context = context) + self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 0e1e90f39df..b68c32ad860 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1050,6 +1050,10 @@ class mail_thread(osv.Model): to_subscribe_uids = [uid] if user_ids is None else user_ids write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context) follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] + + if not subtype_ids: + subtype_obj = self.pool.get('mail.message.subtype') + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, user_ids, subtype_ids, context=context) return follower_ids From 1325a350d5f21f3a2ee789d6bb1ee73d0dbb6210 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 12:46:57 +0530 Subject: [PATCH 051/245] [IMP]:improved code to display subtype while create new lead bzr revid: apa@tinyerp.com-20120829071657-rb5kmx9kdbgiyydj --- addons/mail/mail_thread.py | 3 ++- addons/mail/static/src/js/mail_followers.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b68c32ad860..8c117065055 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1050,10 +1050,11 @@ class mail_thread(osv.Model): to_subscribe_uids = [uid] if user_ids is None else user_ids write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context) follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] - + print "self._name",self._name if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) + print "subtype_ids",subtype_ids if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, user_ids, subtype_ids, context=context) return follower_ids diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 7e150051f7f..d9c55a2d6ab 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -64,7 +64,7 @@ openerp_mail_followers = function(session, mail) { _check_visibility: function() { this.$el.toggle(this.view.get("actual_mode") !== "create"); - if (this.view.get("actual_mode") === "create"){this.fetch_subtype();} + if (this.view.get("actual_mode") !== "create"){this.fetch_subtype();} }, destroy: function () { @@ -101,6 +101,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; + //if (self.view.get("actual_mode") === "edit"){self.fetch_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { From 8a84afef994b08834f97e325ecbdf591dbbccb47 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 12:56:33 +0530 Subject: [PATCH 052/245] [IMP]:removed print and pass uid bzr revid: apa@tinyerp.com-20120829072633-c13fg277j6be8182 --- addons/mail/mail_thread.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 8c117065055..78b6dfac92c 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1050,13 +1050,11 @@ class mail_thread(osv.Model): to_subscribe_uids = [uid] if user_ids is None else user_ids write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context) follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] - print "self._name",self._name if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) - print "subtype_ids",subtype_ids if subtype_ids: - self.message_subscribe_udpate_subtypes(cr, uid, ids, user_ids, subtype_ids, context=context) + self.message_subscribe_udpate_subtypes(cr, uid, ids, to_subscribe_uids, subtype_ids, context=context) return follower_ids def message_subscribe_get_command(self, cr, uid, follower_ids, context=None): @@ -1202,7 +1200,7 @@ class mail_thread(osv.Model): def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): subscription_obj = self.pool.get('mail.followers') - subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids),('user_id','=',user_id)]) + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids),('user_id','in',user_id)]) return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id): From abc4e850421a6bb19f32cba5768ad2b8828fa0d7 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 13:03:33 +0530 Subject: [PATCH 053/245] [IMP]:improved code bzr revid: apa@tinyerp.com-20120829073333-j6xts836d3bqepk8 --- addons/mail/static/src/js/mail_followers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index d9c55a2d6ab..3c91bbae89e 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -125,7 +125,7 @@ openerp_mail_followers = function(session, mail) { if($(record).is(':checked')) { cheklist.push(parseInt($(record).attr('id')))} }); - self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,cheklist]) + self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],[self.session.uid],cheklist]) }, // Display the subtypes of each records. display_subtype: function(records) { From aa9fa89423b341d1c95356065352bfc2d4a65d7d Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 29 Aug 2012 18:45:32 +0530 Subject: [PATCH 054/245] [IMP] improve demo data of crm and add demo data in project bzr revid: fka@tinyerp.com-20120829131532-vpvaaq0mbwdfktyk --- addons/crm/crm_lead_data.xml | 33 +++++++++++-------------- addons/mail/data/mail_data.xml | 11 +++++++++ addons/project/project.py | 16 ++++++------ addons/project/project_data.xml | 43 +++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 27 deletions(-) diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index ce9951defc6..6f6562657ce 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -155,37 +155,32 @@ - + new - + - + won - + - + lost - + - + stage change - + - - other - - + + - - email - + + - - comment - - + + diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index c8e8b1a488e..b241cb095de 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -12,5 +12,16 @@ + + + other + + + + email + + + comment + diff --git a/addons/project/project.py b/addons/project/project.py index 4a6311b7f56..4f23cbbdc49 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -536,23 +536,23 @@ def Project(): return project_id def create_send_note(self, cr, uid, ids, context=None): - return self.message_append_note(cr, uid, ids, body=_("Project has been created."), context=context) + return self.message_append_note(cr, uid, ids, body=_("Project has been created."), subtype="new", context=context) def set_open_send_note(self, cr, uid, ids, context=None): message = _("Project has been opened.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="open", context=context) def set_pending_send_note(self, cr, uid, ids, context=None): message = _("Project is now pending.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="pending", context=context) def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Project has been cancelled.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="cancel", context=context) def set_close_send_note(self, cr, uid, ids, context=None): message = _("Project has been closed.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="close", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly @@ -1210,14 +1210,14 @@ class task(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) def create_send_note(self, cr, uid, ids, context=None): - return self.message_append_note(cr, uid, ids, body=_("Task has been created."), context=context) + return self.message_append_note(cr, uid, ids, body=_("Task has been created."), subtype="new", context=context) def case_draft_send_note(self, cr, uid, ids, context=None): msg = _('Task has been set as draft.') - return self.message_append_note(cr, uid, ids, body=msg, context=context) + return self.message_append_note(cr, uid, ids, body=msg, subtype="draft", context=context) def do_delegation_send_note(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index c2d37f7943d..77eb203e66b 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -83,6 +83,49 @@ + + + + new + + + + + open + + + + pending + + + + + close + + + + cancel + + + + + stage change + + + + + draft + + + + + + + + + + + From 0135c779a8b3389331d64e03115fc1d4c2cae91a Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 30 Aug 2012 11:59:48 +0530 Subject: [PATCH 055/245] [IMP] Improve code in project demo bzr revid: fka@tinyerp.com-20120830062948-llta7r2pc2ezbjij --- addons/project/project.py | 2 +- addons/project/project_data.xml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 4f23cbbdc49..66fb81d6fbd 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1217,7 +1217,7 @@ class task(base_stage, osv.osv): def case_draft_send_note(self, cr, uid, ids, context=None): msg = _('Task has been set as draft.') - return self.message_append_note(cr, uid, ids, body=msg, subtype="draft", context=context) + return self.message_append_note(cr, uid, ids, body=msg, context=context) def do_delegation_send_note(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 77eb203e66b..f6f2af7953c 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -113,10 +113,6 @@ - - draft - - From 9e067bc26eb63c6a8658a4ab412c636ee3bfdcdc Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 30 Aug 2012 14:54:43 +0530 Subject: [PATCH 056/245] [IMP] Add demo data of subtype in sale bzr revid: fka@tinyerp.com-20120830092443-4ptms30neaz4xjnv --- addons/sale/sale.py | 10 +++++----- addons/sale/sale_data.xml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index c525ba04df1..fdffdf465c9 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1031,7 +1031,7 @@ class sale_order(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -1039,7 +1039,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancel", context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): @@ -1051,15 +1051,15 @@ class sale_order(osv.osv): self.message_append_note(cr, uid, [order.id], body=_("Delivery Order %s scheduled for %s.") % (picking.name, picking_date_str), context=context) def delivery_end_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Order delivered."), context=context) + self.message_append_note(cr, uid, ids, body=_("Order delivered."), subtype="delivered", context=context) def invoice_paid_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Invoice paid."), context=context) + self.message_append_note(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) + self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) def action_cancel_draft_send_note(self, cr, uid, ids, context=None): return self.message_append_note(cr, uid, ids, body='Sale order has been set in draft.', context=context) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index bbee9ca7455..974b3dd4490 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -49,5 +49,38 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. + + + new + + + + + cancel + + + + + paid + + + + pending + + + + + delivered + + + + + + + + + + + From 1e6099d7136739d3ba415968e5cc6461c6179961 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 30 Aug 2012 17:00:37 +0530 Subject: [PATCH 057/245] [IMP] Add data of subtype in purchase & purchase_requisition bzr revid: fka@tinyerp.com-20120830113037-7t4raly1gf4a3uoh --- addons/purchase/purchase.py | 10 +++--- addons/purchase/purchase_data.xml | 32 +++++++++++++++++++ .../purchase_requisition.py | 8 ++--- .../purchase_requisition_data.xml | 19 +++++++++++ 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 756016d39e2..1dfcc8a3f46 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -744,7 +744,7 @@ class purchase_order(osv.osv): return res + ['validator'] def create_send_note(self, cr, uid, ids, context=None): - return self.message_append_note(cr, uid, ids, body=_("Request for quotation created."), context=context) + return self.message_append_note(cr, uid, ids, body=_("Request for quotation created."), subtype="new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -762,20 +762,20 @@ class purchase_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) + self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) def shipment_done_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("""Shipment received."""), context=context) + self.message_append_note(cr, uid, ids, body=_("""Shipment received."""), subtype="received", context=context) def invoice_done_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Invoice paid."), context=context) + self.message_append_note(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) def draft_send_note(self, cr, uid, ids, context=None): return self.message_append_note(cr, uid, ids, body=_("Purchase Order has been set to draft."), context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancel", context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index 75074d4cedf..41ff7dd59ac 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -48,5 +48,37 @@ You can also manage purchase requisitions, see the Purchase Settings. model="ir.values" name="set"/> + + new + + + + + paid + + + + pending + + + + + received + + + + cancel + + + + + + + + + + + + diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index cf0294730a7..084701ff52e 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -94,13 +94,13 @@ class purchase_requisition(osv.osv): self.message_append_note(cr, uid, ids, body=_("Draft Requisition has been sent to suppliers."), context=context) def reset_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), context=context) + self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype="new", context=context) def done_to_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been done."), context=context) + self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="close", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), context=context) + self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype="cancel", context=context) def _planned_date(self, requisition, delay=0.0): company = requisition.company_id @@ -184,7 +184,7 @@ class purchase_requisition(osv.osv): return res def create_send_note(self, cr, uid, ids, context=None): - return self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been created."), context=context) + return self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype="new", context=context) def create(self, cr, uid, vals, context=None): requisition = super(purchase_requisition, self).create(cr, uid, vals, context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 98591535f91..211f51374dd 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -6,5 +6,24 @@ id="purchase_default_set" model="ir.values" name="set"/> + + close + + + + + + + + + + + + + + + + + \ No newline at end of file From 1dd00e9116a1b37469a97064ce74f0e75c904aff Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Thu, 30 Aug 2012 18:19:47 +0530 Subject: [PATCH 058/245] [IMP]Add data of the subtype in accouting modules bzr revid: rma@tinyerp.com-20120830124947-xxkah5za90oa5tuy --- addons/account/account_invoice.py | 6 ++--- addons/account/data/account_data.xml | 26 ++++++++++++++++--- addons/account_voucher/account_voucher.py | 6 ++--- .../account_voucher/account_voucher_data.xml | 23 ++++++++++++++++ addons/analytic/analytic.py | 2 +- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 7bc9ceaaf61..57606ba46fb 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1297,15 +1297,15 @@ class account_invoice(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), context=context) + self.message_append_note(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype="new", context=context) def confirm_paid_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype="paid", context=context) def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancel", context=context) account_invoice() diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index e8899d0348a..589683055d8 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -563,8 +563,28 @@ Invoice account.invoice - - - + + new + + + + + paid + + + + cancel + + + + + + + + + + + + diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 223705af85e..ee57368e509 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1293,17 +1293,17 @@ class account_voucher(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s created." % self._document_type[obj.type or False] - self.message_append_note(cr, uid, [obj.id], body=message, context=context) + self.message_append_note(cr, uid, [obj.id], body=message, subtype="new", context=context) def post_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s '%s' is posted." % (self._document_type[obj.type or False], obj.move_id.name) - self.message_append_note(cr, uid, [obj.id], body=message, context=context) + self.message_append_note(cr, uid, [obj.id], body=message, subtype="post", context=context) def reconcile_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s reconciled." % self._document_type[obj.type or False] - self.message_append_note(cr, uid, [obj.id], body=message, context=context) + self.message_append_note(cr, uid, [obj.id], body=message, subtype="reconcile", context=context) account_voucher() diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index 8be2851a434..76e4d7b1849 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -12,5 +12,28 @@ You can track customer payments easily and automate the reminders. You get an ov If you want to use advanced accounting features, you should install the "Accounting and Finance" module. + + + + + + post + + + + + reconcile + + + + + + + + + + + + diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 7eeb9266e47..60d2731fe9d 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -297,7 +297,7 @@ class account_analytic_account(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) account_analytic_account() From 88adf5a68e404a2ed95f18189e8b5e277aa203ff Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 31 Aug 2012 10:26:36 +0530 Subject: [PATCH 059/245] [IMP]improve code as per changes in mail message bzr revid: sgo@tinyerp.com-20120831045636-5p1oa9lkhglyd6on --- addons/mail/mail_message.py | 16 ++++++++++------ addons/mail/mail_thread.py | 1 - 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index af6a5cdbb2a..147f4f2d02c 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -330,19 +330,23 @@ class mail_message(osv.Model): """ Add the related record followers to the destination partner_ids. Call mail_notification.notify to manage the email sending """ + followers_obj = self.pool.get('mail.followers') message = self.browse(cr, uid, newid, context=context) + followers_ids = followers_obj.search(cr, uid, ['&', ('res_model', '=', message.model), ('res_id', 'in', [message.res_id])], context=context) + # check with subtype + is_subtype = False + + for subscription in followers_obj.browse(cr, uid, followers_ids, context=context): + if subtype_id: + if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: + is_subtype = True partners_to_notify = [] # add all partner_ids of the message - is_subtype = False if message.partner_ids: for partner in message.partner_ids: if partner.id not in partners_to_notify: - if subtype_id: - if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: - is_subtype = False + if(is_subtype): partners_to_notify.append(partner.id) - else: - partners_to_notify.append(partner.id) # add all followers and set them as partner_ids if message.model and message.res_id: modobj = self.pool.get(message.model) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 28286783f39..a100a8f1b84 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -652,7 +652,6 @@ class mail_thread(osv.Model): :param partner_ids: a list of partner_ids to subscribe :param return: new value of followers, for Chatter """ - print "message_subscribe",subtype_ids self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') From 82f0465b30d5be8089867789372b8721f62b9864 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 10:33:58 +0530 Subject: [PATCH 060/245] [IMP] Add data of subtype in stock bzr revid: fka@tinyerp.com-20120831050358-fg7r75e0og1myke6 --- addons/stock/stock.py | 10 +++++----- addons/stock/stock_data.xml | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 006af587c1f..5e8b5dfaf5d 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1379,13 +1379,13 @@ class stock_picking(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype="new", context=context) def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None): - return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name), context=context) + return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name), subtype="moved", context=context) def back_order_send_note(self, cr, uid, ids, back_name, context=None): - return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), context=context) + return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype="new", context=context) def ship_done_send_note(self, cr, uid, ids, context=None): type_dict = { @@ -1394,11 +1394,11 @@ class stock_picking(osv.osv): 'internal': 'moved', } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype="close", context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancel", context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index 282929ea6fb..f8fd499e311 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -164,5 +164,32 @@ + + + + + + + moved + + + + close + + + + + + + + + + + + + + From d25ac32d1bb102a918044bee433751a161de44e9 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 11:16:14 +0530 Subject: [PATCH 061/245] [IMP] improve code: add stock.move object bzr revid: fka@tinyerp.com-20120831054614-41w4jus1rjki1tg6 --- addons/stock/stock_data.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index f8fd499e311..72c9be96b16 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -183,13 +183,13 @@ - + - + - + From 6e8660a776fdf582535776eb5b199cd256822961 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 12:05:24 +0530 Subject: [PATCH 062/245] [IMP] Add data of subtype in idea bzr revid: fka@tinyerp.com-20120831063524-bnvxkie4tgsjxjsq --- addons/idea/idea.py | 8 ++++---- addons/idea/idea_data.xml | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/addons/idea/idea.py b/addons/idea/idea.py index e2e5ec50ddf..a20ddf51414 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -67,21 +67,21 @@ class idea_idea(osv.osv): def idea_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea canceled.'), context=context) + self.message_post(cr, uid, ids, body=_('Idea canceled.'), subtype="cancel", context=context) return True def idea_open(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'open'}) - self.message_post(cr, uid, ids, body=_('Idea accepted.'), context=context) + self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype="open", context=context) return True def idea_close(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea done.'), context=context) + self.message_post(cr, uid, ids, body=_('Idea done.'), subtype="close", context=context) self.write(cr, uid, ids, { 'state': 'close' }) return True def idea_draft(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), context=context) + self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype="new", context=context) self.write(cr, uid, ids, { 'state': 'draft' }) return True idea_idea() diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index d63eb907ef8..a4cd4970511 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -15,6 +15,35 @@ + + + + new + + + + + open + + + + cancel + + + + + close + + + + + + + + + + + From d993e47c007e7e1ee363d6f81e5e6999741b3dff Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 31 Aug 2012 14:12:35 +0530 Subject: [PATCH 063/245] [IMP]if subtype not selected should not b show in wall bzr revid: sgo@tinyerp.com-20120831084235-0pbgui7w4d62c4ip --- addons/mail/mail_message.py | 29 ++++++++----------- addons/mail/static/src/xml/mail_followers.xml | 2 +- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 563e6d2ef6f..c0ae16dc503 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -323,37 +323,32 @@ class mail_message(osv.Model): values['message_id'] = tools.generate_tracking_message_id('%(model)s-%(res_id)s'% values) newid = super(mail_message, self).create(cr, uid, values, context) self.check(cr, uid, [newid], mode='create', context=context) - self.notify(cr, uid, newid, values.get('subtype_id',False), context=context) + self.notify(cr, uid, newid, context=context) return newid - def notify(self, cr, uid, newid,subtype_id=None, context=None): + def notify(self, cr, uid, newid, context=None): """ Add the related record followers to the destination partner_ids. Call mail_notification.notify to manage the email sending """ - followers_obj = self.pool.get('mail.followers') + followers_obj = self.pool.get("mail.followers") message = self.browse(cr, uid, newid, context=context) - followers_ids = followers_obj.search(cr, uid, ['&', ('res_model', '=', message.model), ('res_id', 'in', [message.res_id])], context=context) - # check with subtype - is_subtype = False - - for subscription in followers_obj.browse(cr, uid, followers_ids, context=context): - if subtype_id: - if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: - is_subtype = True partners_to_notify = set([]) # add all partner_ids of the message if message.partner_ids: - if(is_subtype): - partners_to_notify |= set(partner.id for partner in message.partner_ids) + partners_to_notify |= set(partner.id for partner in message.partner_ids) # add all followers and set add them in partner_ids if message.model and message.res_id: record = self.pool.get(message.model).browse(cr, uid, message.res_id, context=context) extra_notified = set(partner.id for partner in record.message_follower_ids) missing_notified = extra_notified - partners_to_notify - if missing_notified: - message.write({'partner_ids': [(4, p_id) for p_id in missing_notified]}) - if(is_subtype): - partners_to_notify |= extra_notified + missing_follow_ids = [] + if message.subtype_id: + for p_id in missing_notified: + follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)]) + if follow_ids and len(follow_ids): + missing_follow_ids.append(p_id) + message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) + partners_to_notify |= extra_notified self.pool.get('mail.notification').notify(cr, uid, list(partners_to_notify), newid, context=context) def read(self, cr, uid, ids, fields_to_read=None, context=None, load='_classic_read'): diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 6960e2a3b5f..66173dd47ee 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -10,11 +10,11 @@
              +

                -
                    From 5eed2be266d4dd2d12280ba06b467f3fd54387be Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 31 Aug 2012 14:40:43 +0530 Subject: [PATCH 064/245] [IMP]minor changes bzr revid: sgo@tinyerp.com-20120831091043-4rix3ozakssbxrgn --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index abe5c296218..972227e120f 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -577,7 +577,7 @@ class mail_thread(osv.Model): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, - msg_type='notification', parent_id=False, attachments=None, context=None, **kwargs): + msg_type='notification', parent_id=False, attachments=None, subtype='other', context=None, **kwargs): """ Post a new message in an existing message thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. From ca22d79a2107d943f1484728cdda7b6d37f43826 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 14:42:06 +0530 Subject: [PATCH 065/245] [IMP] Add data of subtype in procurement bzr revid: fka@tinyerp.com-20120831091206-196wzqlatj7lryi0 --- addons/procurement/procurement.py | 12 ++++----- addons/procurement/procurement_data.xml | 34 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index db50ebd94fd..4c60316ffb6 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -496,22 +496,22 @@ class procurement_order(osv.osv): return obj_id def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been created."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been created."), subtype="new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), subtype="confirmed", context=context) def running_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), subtype="running", context=context) def ready_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype="ready", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancel", context=context) def done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been done."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="close", context=context) procurement_order() diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index 6a83d525c68..bbcaa33d2a1 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -28,5 +28,39 @@ 1 1 + + + + + + + confirmed + + + + ready + + + + running + + + + + + + + + + + + + + + + + \ No newline at end of file From 17ef40f428cbe12358e5bd54efa3c66ecf8e1b0c Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Fri, 31 Aug 2012 15:30:12 +0530 Subject: [PATCH 066/245] [IMP]add the data into event for subtype bzr revid: rma@tinyerp.com-20120831100012-mlzik593orznp9aj --- addons/event/__openerp__.py | 1 + addons/event/event.py | 20 ++++++++++---------- addons/event/event_data.xml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/addons/event/__openerp__.py b/addons/event/__openerp__.py index 1e548f68991..428ebb4cb06 100644 --- a/addons/event/__openerp__.py +++ b/addons/event/__openerp__.py @@ -46,6 +46,7 @@ Note that: 'data': [ 'security/event_security.xml', 'security/ir.model.access.csv', + 'event_data.xml', 'wizard/event_confirm_view.xml', 'event_view.xml', 'report/report_event_registration_view.xml', diff --git a/addons/event/event.py b/addons/event/event.py index 763aa423378..c3284695ab9 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -264,27 +264,27 @@ class event_event(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Event has been created.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="new", context=context) return True def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancel", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): message = _("Event has been set to draft.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="new", context=context) return True def button_done_send_note(self, cr, uid, ids, context=None): message = _("Event has been done.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="close", context=context) return True def button_confirm_send_note(self, cr, uid, ids, context=None): message = _("Event has been confirmed.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="confirm", context=context) return True event_event() @@ -331,7 +331,7 @@ class event_registration(osv.osv): def confirm_registration(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_('State set to open'), context=context) - return self.write(cr, uid, ids, {'state': 'open'}, context=context) + return self.write(cr, uid, ids, {'state': 'open'}, subtype="open", context=context) def create(self, cr, uid, vals, context=None): obj_id = super(event_registration, self).create(cr, uid, vals, context) @@ -360,13 +360,13 @@ class event_registration(osv.osv): if today >= registration.event_id.date_begin: values = {'state': 'done', 'date_closed': today} self.write(cr, uid, ids, values) - self.message_post(cr, uid, ids, body=_('State set to Done'), context=context) + self.message_post(cr, uid, ids, body=_('State set to Done'), subtype="close", context=context) else: raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") ) return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancel", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): @@ -436,12 +436,12 @@ class event_registration(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Registration has been created.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="new", context=context) return True def do_draft_send_note(self, cr, uid, ids, context=None): message = _("Registration has been set as draft.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="new", context=context) return True event_registration() diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 83af2f35cfb..0498d3e490b 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -12,6 +12,38 @@ automatic 100 + + new + + + + + close + + + + cancel + + + + + confirm + + + + + open + + + + + + + + + + + @@ -20,5 +52,6 @@ From the top menu Events, you can organize events, manage registrations, automate communication around your event and sell events through your quotations. Module Events Organisation has been installed + From 90e55a5337694a15131bfac9a3d705ee25723052 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 31 Aug 2012 15:33:18 +0530 Subject: [PATCH 067/245] [IMP]remove unused method and improve code bzr revid: sgo@tinyerp.com-20120831100318-t2e2wv81trwfpc7u --- addons/mail/mail_thread.py | 6 +++--- addons/mail/static/src/js/mail_followers.js | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 972227e120f..2d31a9ad3ba 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -711,8 +711,8 @@ class mail_thread(osv.Model): return True def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): - subscription_obj = self.pool.get('mail.followers') - subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) - return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one + followers_obj = self.pool.get('mail.followers') + followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 1601f3aaf46..fc9223b3657 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -40,11 +40,7 @@ openerp_mail_followers = function(session, mail) { this._check_visibility(); this.fetch_subtype(); this.$el.find('ul.oe_mail_recthread_subtype').click(function () {self.update_subtype();}) - this.$el.find('button.oe_mail_button_follow').click(function () { - self.do_follow(); - self.fetch_subtype(); - }) - this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); }) + this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.fetch_subtype();}) .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.$el.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) From a6a3d4eda6427fc1470e1bfd8408ba90581ad9e9 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:10:32 +0530 Subject: [PATCH 068/245] [IMP] set indentation in purchase_requisition.xml bzr revid: fka@tinyerp.com-20120831104032-yfuugotohlgfvz75 --- .../purchase_requisition_data.xml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 211f51374dd..11ac73a6dd2 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -6,17 +6,18 @@ id="purchase_default_set" model="ir.values" name="set"/> - + + close - - - - - - - + + + + + + + From 31064b1855a60bf211c4a6f0abcb304865ee692e Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Fri, 31 Aug 2012 16:11:43 +0530 Subject: [PATCH 069/245] fix data bzr revid: apa@tinyerp.com-20120831104143-1ymb932kpng3bu3z --- addons/sale/sale_data.xml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index a9c0e18a415..fceb806b3a2 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -41,14 +41,13 @@ - - mail.group - - notification - Sales Management application installed! - This application lets you create and send quotations and process your sales orders; from delivery to invoicing. -If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. + + + The Sales Management application has been installed. + This modules allows you to create and send easily quotations and process your sales orders; from the delivery to the invoicing. + +If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. From 139ee97562ec45549e35ac747bd6c2ae53360c58 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Fri, 31 Aug 2012 16:15:40 +0530 Subject: [PATCH 070/245] typo bzr revid: apa@tinyerp.com-20120831104540-oixjx4jpknk5hlcc --- addons/sale/sale_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index fceb806b3a2..a23ab401dbd 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -56,7 +56,7 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), yo - cancel + cancelled From 1100d6b1cceb2cf74edf3b68f19d1a74b1c35c0c Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Fri, 31 Aug 2012 16:21:17 +0530 Subject: [PATCH 071/245] typo bzr revid: apa@tinyerp.com-20120831105117-mjm99cs7ko8pmkfq --- addons/sale/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 9628c4fdc91..a407be80c99 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1035,7 +1035,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancel", context=context) + self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): From d621d8fae3ca98ccd0cfffd56413459421069655 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:24:22 +0530 Subject: [PATCH 072/245] [IMP] improve code bzr revid: fka@tinyerp.com-20120831105422-m2unzh8mezt4oan4 --- addons/stock/stock.py | 2 +- addons/stock/stock_data.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 5e8b5dfaf5d..3011fc6c6c2 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1398,7 +1398,7 @@ class stock_picking(osv.osv): def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancel", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index a24502ab361..976c89ad06f 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -181,7 +181,7 @@ watch your stock valuation, and track production lots upstream and downstream (b close - + From 6c04925c0f3521a5a99586f688727f2be5f6340b Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:28:55 +0530 Subject: [PATCH 073/245] [IMP] improve code bzr revid: fka@tinyerp.com-20120831105855-crs13rnqi2uztgha --- addons/purchase/purchase.py | 2 +- addons/purchase/purchase_data.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 81b851eb2a2..16b827c1323 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -766,7 +766,7 @@ class purchase_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancel", context=context) + self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index 1cc3b3b014b..a84564b2360 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -67,8 +67,8 @@ You can also manage purchase requisitions, see also the Purchase Settings.received - - cancel + + cancelled From d32908a359dcba66b032ee4dcfca7dd2142b94d6 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Fri, 31 Aug 2012 16:30:00 +0530 Subject: [PATCH 074/245] [IMP]make changes for the calcelled state into event bzr revid: rma@tinyerp.com-20120831110000-cd022yy58aken0iw --- addons/event/event.py | 4 ++-- addons/event/event_data.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index c3284695ab9..feb0aed9d46 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -269,7 +269,7 @@ class event_event(osv.osv): def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancel", context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): @@ -366,7 +366,7 @@ class event_registration(osv.osv): return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancel", context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancelled", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 65713628de9..bc16fc08aee 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -21,8 +21,8 @@ close - - cancel + + cancelled From 6c56f95e869f21d5eaecb3c3eda1de831e1d5499 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:34:43 +0530 Subject: [PATCH 075/245] [IMP] improve code bzr revid: fka@tinyerp.com-20120831110443-55nxhelq1dfl073j --- addons/idea/idea.py | 2 +- addons/idea/idea_data.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/idea/idea.py b/addons/idea/idea.py index a20ddf51414..ff55e6afbc3 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -67,7 +67,7 @@ class idea_idea(osv.osv): def idea_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea canceled.'), subtype="cancel", context=context) + self.message_post(cr, uid, ids, body=_('Idea canceled.'), subtype="cancelled", context=context) return True def idea_open(self, cr, uid, ids, context={}): diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index a4cd4970511..17401f72f98 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -26,8 +26,8 @@ open - - cancel + + cancelled From 5ec28dcd8933cb8ef42d3349d7651e66b02d46f5 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:41:15 +0530 Subject: [PATCH 076/245] [IMP] improve code bzr revid: fka@tinyerp.com-20120831111115-fqoapz8uroxsdddm --- addons/procurement/procurement.py | 2 +- addons/procurement/procurement_data.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 4c60316ffb6..d59a894bc2b 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -508,7 +508,7 @@ class procurement_order(osv.osv): self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype="ready", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancel", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancelled", context=context) def done_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="close", context=context) diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index bbcaa33d2a1..8f4e945a7de 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -47,7 +47,7 @@ running - + From e5b99dca25aea687272e0e09d73d9ac034acd14c Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 18:11:23 +0530 Subject: [PATCH 077/245] [IMP] change close bzr revid: fka@tinyerp.com-20120831124123-3fq363k7b5bcnuix --- addons/procurement/procurement.py | 2 +- addons/procurement/procurement_data.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index d59a894bc2b..94d83675df1 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -511,7 +511,7 @@ class procurement_order(osv.osv): self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancelled", context=context) def done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="close", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="closed", context=context) procurement_order() diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index 8f4e945a7de..bd44f0caee5 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -50,7 +50,7 @@ - + From 596debf67e4792755c72b629cd481d7cdb653292 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Fri, 31 Aug 2012 18:17:22 +0530 Subject: [PATCH 078/245] [IMP]make changes into account data for subtype bzr revid: rma@tinyerp.com-20120831124722-2u9fcx10gnrcfsl5 --- addons/account/data/account_data.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 589683055d8..fe0c864e72f 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -518,7 +518,6 @@ - Account Reconcile account.reconcile @@ -554,8 +553,6 @@ - - @@ -563,7 +560,7 @@ Invoice account.invoice - + new From 84fd3b3a35767140a0fcbc0aebb5a4439fcd4e79 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 18:17:44 +0530 Subject: [PATCH 079/245] [IMP] change subtype close bzr revid: fka@tinyerp.com-20120831124744-uup75dwshj5nmf2n --- addons/purchase_requisition/purchase_requisition.py | 2 +- addons/purchase_requisition/purchase_requisition_data.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 67905f35922..5a5f669b1a1 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -97,7 +97,7 @@ class purchase_requisition(osv.osv): self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype="new", context=context) def done_to_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="close", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="closed", context=context) def cancel_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype="cancel", context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 11ac73a6dd2..11dd5f45170 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -7,8 +7,8 @@ model="ir.values" name="set"/> - - close + + closed From de9f0c9777800cb398afddc8466c6a5c9ea3056e Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 18:22:01 +0530 Subject: [PATCH 080/245] [IMP] change subtype close bzr revid: fka@tinyerp.com-20120831125201-gomz1f0hy8wid1rh --- addons/stock/stock.py | 2 +- addons/stock/stock_data.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 3011fc6c6c2..0bc455a149c 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1394,7 +1394,7 @@ class stock_picking(osv.osv): 'internal': 'moved', } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype="close", context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype="closed", context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index 976c89ad06f..a7e2ffdd562 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -177,8 +177,8 @@ watch your stock valuation, and track production lots upstream and downstream (b moved - - close + + closed From e44d125479d9208d3d2d9b0b64b655b530a07eae Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 18:47:12 +0530 Subject: [PATCH 081/245] [IMP] Add data of subtype in mrp, mrp_repair & mrp_operations bzr revid: fka@tinyerp.com-20120831131712-dz5b5isq797v5xfc --- addons/mrp/mrp.py | 10 ++-- addons/mrp/mrp_data.xml | 33 ++++++++++++++ addons/mrp_operations/mrp_operation_data.xml | 34 ++++++++++++++ addons/mrp_operations/mrp_operations.py | 10 ++-- addons/mrp_repair/__openerp__.py | 1 + addons/mrp_repair/mrp_repair.py | 14 +++--- addons/mrp_repair/mrp_repair_data.xml | 48 ++++++++++++++++++++ 7 files changed, 133 insertions(+), 17 deletions(-) create mode 100644 addons/mrp_repair/mrp_repair_data.xml diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index c667daadbec..a9f6290c58a 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1047,27 +1047,27 @@ class mrp_production(osv.osv): # --------------------------------------------------- def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), context=context) + self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype="new", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been canceled.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) return True def action_ready_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is ready to produce.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) return True def action_in_production_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is in production.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="production", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been done.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) return True def action_confirm_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mrp/mrp_data.xml b/addons/mrp/mrp_data.xml index 0bbf2d3b64c..6ee7cc82dd2 100644 --- a/addons/mrp/mrp_data.xml +++ b/addons/mrp/mrp_data.xml @@ -27,5 +27,38 @@ From the Manufacturing Settings, you can choose to compute production schedules 1 + + new + + + + + ready + + + + + production + + + + cancelled + + + + + closed + + + + + + + + + + + + diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index ff83fdc7e8b..e2d7f9f0a56 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -30,5 +30,39 @@ done + + + new + + + + + started + + + + + pending + + + + cancelled + + + + + closed + + + + + + + + + + + + diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index ee2547bc7df..a18eb4141ba 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="started", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="pending", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="cancelled", context=context) return True mrp_production_workcenter_line() diff --git a/addons/mrp_repair/__openerp__.py b/addons/mrp_repair/__openerp__.py index da4070d6210..13a6e81e141 100644 --- a/addons/mrp_repair/__openerp__.py +++ b/addons/mrp_repair/__openerp__.py @@ -43,6 +43,7 @@ The following topics should be covered by this module: 'data': [ 'security/ir.model.access.csv', 'security/mrp_repair_security.xml', + 'mrp_repair_data.xml', 'mrp_repair_sequence.xml', 'wizard/mrp_repair_cancel_view.xml', 'wizard/mrp_repair_make_invoice_view.xml', diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index c1ac8f809ce..44624044090 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -571,40 +571,40 @@ class mrp_repair(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been created." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype="new", context=context) return True def set_start_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been started." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype="started", context=context) return True def set_toinvoiced_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Draft Invoice of %s %s waiting for validation.") % (repair.invoice_id.amount_total, repair.invoice_id.currency_id.symbol) - self.message_post(cr, uid, [repair.id], body=message, context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype="pending", context=context) return True def set_confirm_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _( "Repair Order for %s has been accepted." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype="accepted", context=context) return True def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Repair has been cancelled.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) return True def set_ready_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is now ready to repair.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) return True def set_done_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is closed.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) return True mrp_repair() diff --git a/addons/mrp_repair/mrp_repair_data.xml b/addons/mrp_repair/mrp_repair_data.xml new file mode 100644 index 00000000000..337a4113382 --- /dev/null +++ b/addons/mrp_repair/mrp_repair_data.xml @@ -0,0 +1,48 @@ + + + + + + new + + + + + started + + + + + ready + + + + + pending + + + + accepted + + + + cancelled + + + + + closed + + + + + + + + + + + + + + From aa216774eab92cd4334a9bbbdbf50293b26d5565 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 3 Sep 2012 11:47:13 +0530 Subject: [PATCH 082/245] [IMP] make changes into account data for the subtype bzr revid: rma@tinyerp.com-20120903061713-xuhcfdqi4e7cp6qf --- addons/account/account_invoice.py | 2 +- addons/account/data/account_data.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index e8e935a9505..5f81cbfe857 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1306,7 +1306,7 @@ class account_invoice(osv.osv): def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancel", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) account_invoice() class account_invoice_line(osv.osv): diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index fe0c864e72f..bf3b3152552 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -569,12 +569,12 @@ paid - - cancel + + cancelled - + From 23007e8aebbd269abfbf3f62f27e8cbbcecafb33 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 3 Sep 2012 14:27:28 +0530 Subject: [PATCH 083/245] [IMP] Add picking_in & picking_out object in stock bzr revid: fka@tinyerp.com-20120903085728-vx5hbkug5527nolo --- addons/stock/stock_data.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index a7e2ffdd562..3539d5b5056 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -171,27 +171,27 @@ watch your stock valuation, and track production lots upstream and downstream (b Mail: mail.message.subtype --> - + moved - + closed - + - + - + - + - + From 49722c77c05375ad2f04c716cda3599f1c5bd5e8 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 3 Sep 2012 18:04:05 +0530 Subject: [PATCH 084/245] [IMP] add received & delivered subtype in stock bzr revid: fka@tinyerp.com-20120903123405-7rmte2src1xtdghp --- addons/stock/stock.py | 2 +- addons/stock/stock_data.xml | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0bc455a149c..ed20bbec2c5 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1394,7 +1394,7 @@ class stock_picking(osv.osv): 'internal': 'moved', } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype="closed", context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype=type_dict.get(obj.type), context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index 3539d5b5056..f83b0ada388 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -171,27 +171,29 @@ watch your stock valuation, and track production lots upstream and downstream (b Mail: mail.message.subtype --> - + - - moved - + + delivered + + - - closed - + + received + + - + - + - + - + From df3aa41ac443d22511dc4cf4732629e109c15ef1 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 12:47:54 +0530 Subject: [PATCH 085/245] [IMP] add subtype data in hr module bzr revid: rma@tinyerp.com-20120904071754-d99h6iey5nzrjf08 --- addons/hr_holidays/hr_holidays.py | 12 +++--- addons/hr_holidays/hr_holidays_data.xml | 38 +++++++++++++++++++ addons/hr_recruitment/hr_recruitment.py | 14 +++---- addons/hr_recruitment/hr_recruitment_data.xml | 36 +++++++++++++++++- .../hr_timesheet_invoice.py | 8 ++-- .../hr_timesheet_invoice_data.xml | 28 ++++++++++++++ 6 files changed, 118 insertions(+), 18 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 759170224bd..e0358efe0d9 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -364,32 +364,32 @@ class hr_holidays(osv.osv): def create_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, ids, - _("The request has been created and is waiting confirmation."), context=context) + _("The request has been created and is waiting confirmation."),subtype="new", context=context) return True def holidays_confirm_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been submitted and is waiting for validation by the manager."), context=context) + _("The request has been submitted and is waiting for validation by the manager."), subtype="submitted", context=context) def holidays_first_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], - _("The request has been approved. A second validation is necessary and is now pending."), context=context) + _("The request has been approved. A second validation is necessary and is now pending."), subtype="pending", context=context) def holidays_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): if obj.double_validation: self.message_post(cr, uid, [obj.id], - _("The request has been double validated. The validation process is now over."), context=context) + _("The request has been double validated. The validation process is now over."), subtype="double validated", context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), context=context) + _("The request has been approved. The validation process is now over."), subtype="closed", context=context) def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), context=context) + _("The request has been refused. The validation process is now over."), subtype="cancelled", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index 1e534093eb3..3b927b60419 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -49,5 +49,43 @@ Once validated, they are visible in the employee's calendar. HR officers can def True brown + + + new + + + + + submitted + + + + + pending + + + + + double validated + + + + closed + + + + cancelled + + + + + + + + + + + + diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 82f2c9c3a21..578ebde9162 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -457,14 +457,14 @@ class hr_applicant(base_stage, osv.Model): """ Override of the (void) default notification method. """ if not stage_id: return True stage_name = self.pool.get('hr.recruitment.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): return 'Applicant' def case_open_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been set in progress.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="in progress", context=context) def case_close_send_note(self, cr, uid, ids, context=None): if context is None: @@ -472,23 +472,23 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=msg, subtype="cancelled", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been created.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) class hr_job(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 84289da7bae..a567489751a 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -460,6 +460,40 @@ You can automatically receive job application though an email gateway, see the H - + + + + new + + + + + closed + + + + cancelled + + + + + stage change + + + + + in progress + + + + + + + + + + + + diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index a1562d53a61..4ed61119a5f 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -95,25 +95,25 @@ class account_analytic_account(osv.osv): def set_close(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'close'}, context=context) message = _("Contract has been closed.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) return True def set_cancel(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'cancelled'}, context=context) message = _("Contract has been cancelled.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) return True def set_open(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'open'}, context=context) message = _("Contract has been opened.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="open", context=context) return True def set_pending(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'pending'}, context=context) message = _("Contract has been set as pending.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="pending", context=context) return True account_analytic_account() diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml index 462888e0b39..5cc5024d591 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml @@ -16,5 +16,33 @@ 50% 50.0 + + + closed + + + + pending + + + + + open + + + + cancelled + + + + + + + + + + + + From 61118d78473a91cdc13ef753c5509fdf62d25e63 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 14:26:26 +0530 Subject: [PATCH 086/245] [IMP] add subtype data into project and project_issue module bzr revid: rma@tinyerp.com-20120904085626-klbtc8hrrksi4gy9 --- addons/project/project.py | 4 +-- addons/project/project_data.xml | 8 +++--- addons/project_issue/project_issue.py | 6 ++--- addons/project_issue/project_issue_data.xml | 27 ++++++++++++++++++++- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index ae70dcc1dd4..26e42a73539 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -525,11 +525,11 @@ def Project(): def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Project has been cancelled.") - return self.message_post(cr, uid, ids, body=message, subtype="cancel", context=context) + return self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) def set_close_send_note(self, cr, uid, ids, context=None): message = _("Project has been closed.") - return self.message_post(cr, uid, ids, body=message, subtype="close", context=context) + return self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 88afc08b961..c2e51fa8049 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -99,12 +99,12 @@ - - close + + closed - - cancel + + cancelled diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 9cc97ec470b..52bb2d2d687 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -500,7 +500,7 @@ class project_issue(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): """ Override of default prefix for notifications. """ @@ -508,11 +508,11 @@ class project_issue(base_stage, osv.osv): def convert_to_task_send_note(self, cr, uid, ids, context=None): message = _("Project issue converted to task.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="converted", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) def case_escalate_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index ddb0d575e63..2501bd821d2 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -30,7 +30,32 @@ v3.0 - + + + + new + + + + + stage change + + + + + converted + + + + + + + + + + + + mail.group From 93f5c6b6a9265e30c7b7addb7eceeef57dbb7fb6 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Tue, 4 Sep 2012 15:01:11 +0530 Subject: [PATCH 087/245] [IMP]add unit test for message subtype bzr revid: sgo@tinyerp.com-20120904093111-hj291blbbkg39cey --- addons/mail/mail_thread.py | 1 - addons/mail/tests/test_mail.py | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 2d31a9ad3ba..241e6674b17 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -656,7 +656,6 @@ class mail_thread(osv.Model): subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) - # TDE: temp, must check followers widget return [] # return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index fd4b116b364..c27b3c6f68e 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -83,6 +83,7 @@ class test_mail(common.TransactionCase): self.mail_message = self.registry('mail.message') self.mail_notification = self.registry('mail.notification') self.mail_followers = self.registry('mail.followers') + self.mail_message_subtype = self.registry('mail.message.subtype') self.res_users = self.registry('res.users') self.res_partner = self.registry('res.partner') @@ -534,3 +535,37 @@ class test_mail(common.TransactionCase): msg1.refresh() self.assertEqual(5, len(group_pigs.message_ids), 'group should contain 5 messages') self.assertEqual(2, len(msg1.child_ids), 'msg1 should have 2 children now') + + def test_60_message_subtype(self): + """ Tests designed for message_subtype. """ + cr, uid = self.cr, self.uid + self.res_users.write(cr, uid, [uid], {'signature': 'Admin', 'email': 'a@a'}) + user_admin = self.res_users.browse(cr, uid, uid) + group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) + + # 0 - Admin + p_a_id = user_admin.partner_id.id + # Subscribe #1, + self.mail_group_model_id = self.ir_model.search(cr, uid, [('model','=', 'mail.group')])[0] + subtype_ids = self.mail_message_subtype.search(cr, uid, []) + self.mail_message_subtype.write(cr,uid,subtype_ids,{'model_ids':[(4,self.mail_group_model_id )]}) + group_pigs.message_subscribe_users([uid]) + + # Mail data + _subject = 'Pigs' + _mail_subject = '%s posted on %s' % (user_admin.name, group_pigs.name) + _body1 = 'Pigs rules' + _mail_body1 = 'Pigs rules\n
                    Admin
                    \n' + _mail_bodyalt1 = 'Pigs rules\nAdmin' + _body2 = 'Pigs rules' + _mail_body2 = 'Pigs rules\n
                    Admin
                    \n' + _mail_bodyalt2 = 'Pigs rules\nAdmin\n' + filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) + # Post comment with body and subject, comment preference + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, msg_type='comment',subtype='email') + notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) + self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") + # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message + msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, msg_type='email', subtype='other') + notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) + self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From e50afb97b4f2c5183fc5d60db5736ed822a2710f Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 15:10:52 +0530 Subject: [PATCH 088/245] [IMP] make changes into hr module for subtype data bzr revid: rma@tinyerp.com-20120904094052-5povh2fua010g3ej --- addons/hr_holidays/hr_holidays.py | 10 ++++----- addons/hr_holidays/hr_holidays_data.xml | 22 ++++--------------- addons/hr_recruitment/hr_recruitment.py | 4 ++-- addons/hr_recruitment/hr_recruitment_data.xml | 8 +++---- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index e0358efe0d9..4136abbb2f7 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -370,26 +370,26 @@ class hr_holidays(osv.osv): def holidays_confirm_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been submitted and is waiting for validation by the manager."), subtype="submitted", context=context) + _("The request has been submitted and is waiting for validation by the manager."), context=context) def holidays_first_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], - _("The request has been approved. A second validation is necessary and is now pending."), subtype="pending", context=context) + _("The request has been approved. A second validation is necessary and is now pending."), context=context) def holidays_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): if obj.double_validation: self.message_post(cr, uid, [obj.id], - _("The request has been double validated. The validation process is now over."), subtype="double validated", context=context) + _("The request has been double validated. The validation process is now over."), context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), subtype="closed", context=context) + _("The request has been approved. The validation process is now over."), subtype="approved", context=context) def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), subtype="cancelled", context=context) + _("The request has been refused. The validation process is now over."), subtype="refused", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index 3b927b60419..ad337b72c62 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -55,26 +55,12 @@ Once validated, they are visible in the employee's calendar. HR officers can def
                    - - submitted - - - - - pending - - - - - double validated + + approved - - closed - - - - cancelled + + refused diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 578ebde9162..99d522703d3 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -475,12 +475,12 @@ class hr_applicant(base_stage, osv.Model): self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, subtype="cancelled", context=context) + return self.message_post(cr, uid, ids, body=msg, subtype="refused", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index a567489751a..818b5f5adef 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -467,12 +467,12 @@ You can automatically receive job application though an email gateway, see the H - - closed + + hired - - cancelled + + refused From 10313331e8f10c148bb9acc602d34822d4bbbae2 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 15:26:49 +0530 Subject: [PATCH 089/245] [IMP] make chnages into subtype data in hr bzr revid: rma@tinyerp.com-20120904095649-ye94bntdm8ia5jrd --- addons/hr_recruitment/hr_recruitment.py | 2 +- addons/hr_recruitment/hr_recruitment_data.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 99d522703d3..2ff594aa820 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -472,7 +472,7 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) else: message = _("Applicant has been hired.") self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 818b5f5adef..30ff9118584 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -471,7 +471,7 @@ You can automatically receive job application though an email gateway, see the H hired - + refused From d90d78171bb257cc4c65ca935d3f43814e31de67 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 18:34:23 +0530 Subject: [PATCH 090/245] [IMP] make changes into the subtype data for project module bzr revid: rma@tinyerp.com-20120904130423-928mhaatxuxfbwi4 --- addons/base_status/base_stage.py | 6 +++--- addons/project_issue/project_issue.py | 2 +- addons/project_issue/project_issue_data.xml | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 26afe548217..fdbc41cd8ac 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -401,13 +401,13 @@ class base_stage(object): def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) + self.message_post(cr, uid, [id], body=msg, subtype="closed", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: - msg = _('%s has been canceled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) + msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) + self.message_post(cr, uid, [id], body=msg, subtype="cancelled", context=context) return True def case_pending_send_note(self, cr, uid, ids, context=None): diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 52bb2d2d687..833c7dbb460 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -508,7 +508,7 @@ class project_issue(base_stage, osv.osv): def convert_to_task_send_note(self, cr, uid, ids, context=None): message = _("Project issue converted to task.") - return self.message_post(cr, uid, ids, body=message, subtype="converted", context=context) + return self.message_post(cr, uid, ids, body=message, context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index 2501bd821d2..6ee704c6b39 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -42,11 +42,15 @@ - - converted + + cancelled + + closed + + From ef747c7143eb0ce04d505dc1c24eae0d8b83f688 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 5 Sep 2012 11:00:31 +0530 Subject: [PATCH 091/245] [IMP]improve test case bzr revid: sgo@tinyerp.com-20120905053031-dqtcfyr1na9j7zpk --- addons/mail/tests/test_mail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index bc8a0e5c085..45583d46fa3 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -566,10 +566,10 @@ class test_mail(common.TransactionCase): _mail_bodyalt2 = 'Pigs rules\nAdmin\n' filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, msg_type='comment',subtype='email') + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype='email') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message - msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, msg_type='email', subtype='other') + msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From 3476daf79fad6a05feefd76379c262bfd9d4a4a7 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 5 Sep 2012 15:01:35 +0530 Subject: [PATCH 092/245] [IMP]Add mail_subtype.rst file in mail bzr revid: fka@tinyerp.com-20120905093135-ydsqq62gnkcifqyv --- addons/mail/doc/index.rst.inc | 1 + addons/mail/doc/mail_subtype.rst | 70 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 addons/mail/doc/mail_subtype.rst diff --git a/addons/mail/doc/index.rst.inc b/addons/mail/doc/index.rst.inc index c4b87cc18f9..4b01d3ec7bd 100644 --- a/addons/mail/doc/index.rst.inc +++ b/addons/mail/doc/index.rst.inc @@ -11,3 +11,4 @@ Mail Module documentation topics mail_needaction_howto mail_partner mail_state + mail_subtype diff --git a/addons/mail/doc/mail_subtype.rst b/addons/mail/doc/mail_subtype.rst new file mode 100644 index 00000000000..e63b67936cd --- /dev/null +++ b/addons/mail/doc/mail_subtype.rst @@ -0,0 +1,70 @@ +.. _mail_message_subtype: + +OpenChatter Pi (3.1415): Message Subtype +======================================== + + To overcome the problems of crowdy walls in system notification, We have added features of **Message Subtype** in mail. + +mail.message.subtype +++++++++++++++++++++ +``mail.message.subtype`` has following fields: + + - ``Name``: fields.char(' Message Subtype ', size = 128,required = True,help = 'Subtype Of Message'), + - ``model_ids``: fields.many2many('ir.model','mail_message_subtyp_message_rel','message_subtype_id', 'model_id', 'Model',help = "link some subtypes to several models, for projet/task"), + - ``default``: fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), + +mail.followers +++++++++++++++ + +In ``mail.followers`` we have added additional many2many field subtype ids : + + - ``subtype_ids``: fields.many2many('mail.message.subtype','mail_message_subtyp_rel','subscription_id', 'subtype_id', 'Subtype',help = "linking some subscription to several subtype for projet/task") + +mail.message +++++++++++++ + +In mail_message we have added additional field subtype_id which Indicates the Type of Message + + - ``subtype_id``: fields.many2one('mail.message.subtype', 'Subtype') + +mail.thread ++++++++++++ + + - In **message_post** method add the *subtype_id* field as parameter and set as default subtype 'Other'. + + def message_post(self, cr, uid, thread_id, body='', subject=False, msg_type='notification', parent_id=False, attachments=None, subtype='other', context=None, ``**kwargs``): + + - In **message_subscribe** method add the *subtype_ids* field as parameter.In this method if subtype_ids is None, it fatch the default true subtypes in mail.message.subtypes otherwise pass selected subtypes. + For update subtypes call **message_subscribe_udpate_subtypes** method + + def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids = None, context=None): + + - Add **message_subscribe_udpate_subtypes** method to update the subtype_ids in followers. + + def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): + followers_obj = self.pool.get('mail.followers') + followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) + +For Each Addons: +++++++++++++++++ + + - Add data of subtypes for each addons module. + - Add subtype field as parameter in **message_post** Method for each addons module. + +How It Works: ++++++++++++++ + + - In addons module when we Follow a Perticular document It display under the followers button. + - In sybtypes there are 3 default subtypes for each addons + 1) Email + 2) Comment + 3) Other + - In document display a default subtypes(which are true) related a perticular model_ids wise. + + Example:- + If I have open crm.lead, It display only subtypes of crm.lead + + - When we select subtype it update subtype_ids(which are checked) in mail.follower where match res_model & res_id of the current documents. + - when message created update subtype_id of that message in mail.message. + - In Feeds display only those notifications of documents which subtypes are selected From d3edae5084b9c4a0a60fa0992c7e517ceb0b3bc7 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 12:25:03 +0530 Subject: [PATCH 093/245] [IMP]:improved yml bzr revid: apa@tinyerp.com-20120906065503-h8rziczo7ri31z3o --- addons/crm/test/process/crm_message_subtype.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 705d3cc2fc4..ee78553c913 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -9,7 +9,7 @@ - I have add the sub_type name email with default true - - !record {model: mail.message.subtype, id: mail_subtype_lead_email }: + !record {model: mail.message.subtype, id: mail.mail_subtype_email }: name: email model_ids: - crm.model_crm_lead @@ -17,7 +17,7 @@ - I have add the sub_type name comment with default true - - !record {model: mail.message.subtype, id: mail_subtype_lead_comment }: + !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: name: comment model_ids: - crm.model_crm_lead From c028143bcf6e33592ff4c344ff990285ad48a178 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 12:33:34 +0530 Subject: [PATCH 094/245] [IMP]:improved yml bzr revid: apa@tinyerp.com-20120906070334-bf4fvtr3kz055qfh --- addons/crm/crm_lead_data.xml | 2 +- addons/crm/test/process/crm_message_subtype.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 6f6562657ce..168aa62f714 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -160,7 +160,7 @@ - + won diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index ee78553c913..6c0038a7fb8 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -1,7 +1,7 @@ - I have add the sub_type name other with default false - - !record {model: mail.message.subtype, id: mail_subtype_lead_won }: + !record {model: mail.message.subtype, id: mail.mail_subtype_won }: name: won model_ids: - crm.model_crm_lead From 87bb5e31bff85fd3d5abe685d5271970c53c403b Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 12:35:09 +0530 Subject: [PATCH 095/245] [IMP]:improved yml bzr revid: apa@tinyerp.com-20120906070509-u7ueba94sr10dqcg --- addons/crm/test/process/crm_message_subtype.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 6c0038a7fb8..3dd042c1279 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -27,7 +27,7 @@ - !python {model: mail.followers}: | ids = self.search(cr, uid, [('res_model', '=', 'crm.lead'),('res_id', '=', ref('crm_case_1'))]) - self.write(cr, uid, ids, {'subtype_ids': [(6,0,[ref('mail_subtype_lead_won')])]}) + self.write(cr, uid, ids, {'subtype_ids': [(6,0,[ref('mail.mail_subtype_won')])]}) - I have change the lead into mark won - @@ -43,6 +43,6 @@ I have check the subtype as won in feeds - !python {model: mail.followers}: | - followers_ids =self.search(cr, uid, [('res_model', '=','crm.lead'),('res_id', '=', ref('crm_case_1')),('subtype_ids', 'in',[ref('mail_subtype_lead_won')])]) + followers_ids =self.search(cr, uid, [('res_model', '=','crm.lead'),('res_id', '=', ref('crm_case_1')),('subtype_ids', 'in',[ref('mail.mail_subtype_won')])]) if len(followers_ids): assert followers_ids, 'lead is in won' From 70c1c3df658c38e477108c40c8344bd0d967cd1e Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 12:38:01 +0530 Subject: [PATCH 096/245] [IMP]:hide subtype when unfollowing bzr revid: apa@tinyerp.com-20120906070801-9fulnfblrrdxhetx --- addons/mail/static/src/js/mail_followers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 5d7b2ec5116..90318664474 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -95,7 +95,7 @@ openerp_mail_followers = function(session, mail) { else { this.$el.find('button.oe_mail_button_follow').show(); this.$el.find('button.oe_mail_button_unfollow').hide(); - // this.$el.find('ul.oe_mail_recthread_subtype').hide() + this.$el.find('ul.oe_mail_recthread_subtype').hide() } }, update_subtype: function (){ From 330abd29996e4b439c0d7cd59b9ace89fc7119f8 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 15:07:54 +0530 Subject: [PATCH 097/245] [IMP]:improved indentation bzr revid: apa@tinyerp.com-20120906093754-gvly9tnpbc6mzhxs --- addons/mrp_repair/mrp_repair_data.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/mrp_repair/mrp_repair_data.xml b/addons/mrp_repair/mrp_repair_data.xml index 337a4113382..b45b7ec3105 100644 --- a/addons/mrp_repair/mrp_repair_data.xml +++ b/addons/mrp_repair/mrp_repair_data.xml @@ -1,7 +1,6 @@ - - + new @@ -44,5 +43,5 @@ - + From 4707ee56a9e6f2d5b4af389a1adba8fd83f0dac4 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 6 Sep 2012 15:11:23 +0530 Subject: [PATCH 098/245] [IMP]add context to the method bzr revid: sgo@tinyerp.com-20120906094123-ua4zxhot0z3wgd7g --- addons/mail/mail_message.py | 2 +- addons/mail/mail_thread.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 3ef731b766b..be1fbe78176 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -335,7 +335,7 @@ class mail_message(osv.Model): missing_follow_ids = [] if message.subtype_id: for p_id in missing_notified: - follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)]) + follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)], context=context) if follow_ids and len(follow_ids): missing_follow_ids.append(p_id) message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 7fc6c79bd9a..4d627712742 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -600,9 +600,9 @@ class mail_thread(osv.AbstractModel): values = kwargs subtype_obj = self.pool.get('mail.message.subtype') if subtype: - subtypes = subtype_obj.name_search(cr, uid, subtype) + subtypes = subtype_obj.name_search(cr, uid, subtype,context=context) if len(subtypes): - subtype_browse = subtype_obj.browse(cr, uid, subtypes[0][0]) + subtype_browse = subtype_obj.browse(cr, uid, subtypes[0][0],context=context) if self._name in [model.model for model in subtype_browse.model_ids]: values['subtype_id']=subtype_browse.id values.update({ @@ -636,7 +636,7 @@ class mail_thread(osv.AbstractModel): self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)],context=context) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) if context and context.get('read_back'): @@ -690,7 +690,7 @@ class mail_thread(osv.AbstractModel): def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): followers_obj = self.pool.get('mail.followers') - followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From f36dd4c891710bb3ddb6e097f80ef0b9b6c26134 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 16:29:14 +0530 Subject: [PATCH 099/245] [IMP]:improved test case bzr revid: apa@tinyerp.com-20120906105914-iwoi15ghgtibt2lr --- addons/mail/data/mail_data.xml | 5 ++++- addons/mail/mail_thread.py | 2 +- addons/mail/tests/test_mail.py | 4 +--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index b241cb095de..80aff038dac 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -15,13 +15,16 @@ other - + + email + comment + diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 4d627712742..42581654ace 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -562,7 +562,7 @@ class mail_thread(osv.AbstractModel): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, - type='notification', parent_id=False, attachments=None, subtype='other', context=None, **kwargs): + type='notification', parent_id=False, attachments=None, subtype='comment', context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index a8c1d6b7cf1..8cf0e25ecbb 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -616,9 +616,7 @@ class test_mail(common.TransactionCase): # 0 - Admin p_a_id = user_admin.partner_id.id # Subscribe #1, - self.mail_group_model_id = self.ir_model.search(cr, uid, [('model','=', 'mail.group')])[0] - subtype_ids = self.mail_message_subtype.search(cr, uid, []) - self.mail_message_subtype.write(cr,uid,subtype_ids,{'model_ids':[(4,self.mail_group_model_id )]}) + group_pigs.message_subscribe_users([uid]) # Mail data From 6977a136498ccd320f5dbcc0caa9e476db5ada86 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 7 Sep 2012 17:12:16 +0530 Subject: [PATCH 100/245] [IMP]resolve error bzr revid: sgo@tinyerp.com-20120907114216-5qbzq1y80ut9d6mx --- addons/mail/mail_message_subtype.xml | 9 +++++++++ addons/mail/static/src/js/mail_followers.js | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml index 8de3224470f..0bfdc2cad95 100644 --- a/addons/mail/mail_message_subtype.xml +++ b/addons/mail/mail_message_subtype.xml @@ -47,6 +47,15 @@ mail.message.subtype form tree,form + +

                    + Click to create a message subtype. +

                    + OpenERP's message subtype allows to ease and fasten the + subtype which helps to decrease over crowdy wall comments which displays + only those. +

                    +
                    Date: Fri, 7 Sep 2012 17:42:58 +0530 Subject: [PATCH 101/245] [IMP]improve code bzr revid: sgo@tinyerp.com-20120907121258-r48mymwh9yvxlrqi --- addons/mail/static/src/js/mail_followers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 53f2117fa04..c2d4f31c159 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -117,8 +117,9 @@ openerp_mail_followers = function(session, mail) { follower_read.then(function (follower_record){ if(follower_record.length != 0){ _(follower_record[0].subtype_ids).each(function (subtype_id){ - if(self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0]){ - self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true} + var subtype_check = self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']') + if(subtype_check.length > 0){ + subtype_check[0].checked=true} }); } }) From 741bbaa9f457577b25d8f6007b6aae34aedf2840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 7 Sep 2012 18:09:20 +0200 Subject: [PATCH 102/245] [WIP] mail_message.message_read(): WIP about having correct expandables. Will be updated next week. bzr revid: tde@openerp.com-20120907160920-4ijs93y9ogp39xma --- addons/mail/mail_message.py | 59 ++++++++++++++++++++++++---------- addons/mail/res_partner.py | 1 - addons/mail/tests/test_mail.py | 13 ++++---- 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 18a88bb0b61..90ccc8a2f24 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -167,7 +167,24 @@ class mail_message(osv.Model): 'child_ids': [], } - def message_read_tree_flatten(self, cr, uid, messages, current_level, level, context=None): + def message_read_tree_get_expandable(self, cr, uid, parent_message, last_message, domain=[], current_level=0, level=0, context=None): + """ . """ + base_domain = [('id', '<', last_message['id'])] + if parent_message and current_level < level: + base_domain += [('parent_id', '=', parent_message['id'])] + elif parent_message: + base_domain += [('id', 'child_od', parent_message['id'])] + if domain: + base_domain += domain + extension = { 'type': 'expandable', + 'domain': base_domain, + 'thread_level': current_level, + 'context': context, + 'id': -1, + } + return extension + + def message_read_tree_flatten(self, cr, uid, parent_message, messages, current_level, level, domain=[], context=None): """ Given a tree with several roots of following structure : [ {'id': 1, 'child_ids': [ {'id': 11, 'child_ids': [...] },], @@ -186,28 +203,36 @@ class mail_message(osv.Model): child_ids = msg_dict.pop('child_ids', []) msg_dict['child_ids'] = [] return [msg_dict] + child_ids - # return sorted([msg_dict] + child_ids, key=itemgetter('id'), reverse=True) context = context or {} # Depth-first flattening for message in messages: if message.get('type') == 'expandable': continue - message['child_ids'] = self.message_read_tree_flatten(cr, uid, message['child_ids'], current_level + 1, level, context=context) + message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], current_level + 1, level, domain, context=context) # Flatten if above maximum depth if current_level < level: return_list = messages else: - return_list = [] - for message in messages: - for flat_message in _flatten(message): - return_list.append(flat_message) - return sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) + return_list = [flat_message for message in messages for flat_message in _flatten(message)] + # Add expandable + return_list = sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) + if current_level <= level: + expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) + print 'expandable', expandable + return return_list - def message_read(self, cr, uid, ids=False, domain=[], thread_level=0, limit=None, context=None): - """ If IDs are provided, fetch these records. Otherwise use the domain - to fetch the matching records. - After having fetched the records provided by IDs, it will fetch the - parents to have well-formed threads. + def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, limit=None, tree_parent_id=False): + """ Read messages from mail.message, and get back a structured tree + of messages to be displayed as discussion threads. If IDs is set, + fetch these records. Otherwise use the domain to fetch messages. + After having fetch messages, their parents will be added to obtain + well formed threads. + + :param domain: optional domain for searching ids + :param level: level of threads to display, 0 being flat + :param limit: number of messages to fetch + :param tree_parent_id: if parent_id reached, stop searching for + further parents :return list: list of trees of messages """ limit = limit or self._message_read_limit @@ -221,8 +246,8 @@ class mail_message(osv.Model): for msg in messages: if len(result) < (limit - 1): record = self._message_dict_get(cr, uid, msg, context=context) - if thread_level and msg.parent_id: - while msg.parent_id: + if level and msg.parent_id: + while msg.parent_id != tree_parent_id: if msg.parent_id.id in tree: record_parent = tree[msg.parent_id.id] else: @@ -241,14 +266,14 @@ class mail_message(osv.Model): 'type': 'expandable', 'domain': [('id', '<=', msg.id)] + domain, 'context': context, - 'thread_level': thread_level, # should be improve accodting to level of records + 'thread_level': level, # should be improve accodting to level of records 'id': -1, }) break # Flatten the result if thread_level > 0: - result = self.message_read_tree_flatten(cr, uid, result, 0, thread_level, context=context) + result = self.message_read_tree_flatten(cr, uid, None, result, 0, thread_level, domain, context=context) return result #------------------------------------------------------ diff --git a/addons/mail/res_partner.py b/addons/mail/res_partner.py index 2988cee3d9c..4a6f98fa31d 100644 --- a/addons/mail/res_partner.py +++ b/addons/mail/res_partner.py @@ -41,5 +41,4 @@ class res_partner_mail(osv.Model): 'notification_email_send': lambda *args: 'comment' } - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index f45745f31dc..1f65c38f755 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -459,13 +459,13 @@ class test_mail(common.TransactionCase): cr, uid = self.cr, self.uid group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) def _compare_structures(struct1, struct2, n=0): - # print '%scompare structure' % ('\t' * n) + print '%scompare structure' % ('\t' * n) self.assertEqual(len(struct1), len(struct2), 'message_read structure number of childs incorrect') for x in range(len(struct1)): - # print '%s' % ('\t' * n), struct1[x]['id'], struct2[x]['id'], struct1[x].get('subject') or '' + print '%s' % ('\t' * n), struct1[x]['id'], struct2[x]['id'], struct1[x].get('subject') or '' self.assertEqual(struct1[x]['id'], struct2[x]['id'], 'message_read failure %s' % struct1[x].get('subject')) _compare_structures(struct1[x]['child_ids'], struct2[x]['child_ids'], n + 1) - # print '%send compare' % ('\t' * n) + print '%send compare' % ('\t' * n) # ---------------------------------------- # CASE1: Flattening test @@ -490,7 +490,8 @@ class test_mail(common.TransactionCase): ]}, ] # Test: completely flat - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, copy.deepcopy(tree), 0, 0) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 0, [('type', 'in', 'borderlands')]) + _compare_structures(new_tree, new_tree) self.assertEqual(len(new_tree), 10, 'message_read_tree_flatten wrong in flat') # Test: 1 thread level tree_test = [{'id': 2, 'child_ids': [ @@ -502,10 +503,10 @@ class test_mail(common.TransactionCase): {'id': 4, 'child_ids': []}, {'id': 3, 'child_ids': []}, ]}, ] - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, copy.deepcopy(tree), 0, 1) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 1, [('type', 'in', 'borderlands')]) _compare_structures(new_tree, tree_test) # Test: 2 thread levels - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, copy.deepcopy(tree), 0, 2) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 2, [('type', 'in', 'borderlands')]) _compare_structures(new_tree, tree) # ---------------------------------------- From 5cf330f39a23157caa50d475add761ff93109f99 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Mon, 10 Sep 2012 11:19:03 +0530 Subject: [PATCH 103/245] [IMP]add help on subtype name bzr revid: sgo@tinyerp.com-20120910054903-22sveyi971arsl39 --- addons/mail/mail_message_subtype.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index ab41c83ed61..2330e34e1d3 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -27,8 +27,8 @@ class mail_message_subtype(osv.osv): _name = 'mail.message.subtype' _description = 'mail_message_subtype' _columns = { - 'name': fields.char(' Message Subtype ', size = 128, - required = True, help = 'Subtype Of Message'), + 'name': fields.char('Message Subtype ', size = 128, + required = True, help = 'Message subtype, gives a more precise type on the message, especially for system notifications. For example, it can be a notification related to a new record (New), or to a stage change in a process (Stage change). Message subtypes allow to precisely tune the notifications the user want to receive on its wall.'), 'model_ids': fields.many2many('ir.model', 'mail_message_subtyp_message_rel', 'message_subtype_id', 'model_id', 'Model', From dfa14420d212911bb5f87af19231a848c59cab07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 14:01:17 +0200 Subject: [PATCH 104/245] [WIP] mail_message: continued work on message_read and expandables. bzr revid: tde@openerp.com-20120911120117-xeeercvglfwq3c9e --- addons/mail/mail_message.py | 69 +++++++++++++++---------------- addons/mail/static/src/js/mail.js | 2 +- addons/mail/tests/test_mail.py | 37 +++++++++-------- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 90ccc8a2f24..230199569f4 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -147,6 +147,7 @@ class mail_message(osv.Model): def _message_dict_get(self, cr, uid, msg, context=None): """ Return a dict representation of the message browse record. """ + child_nbr = len(msg.child_ids) attachment_ids = [{'id': attach[0], 'name': attach[1]} for attach in self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context)] author_id = self.pool.get('res.partner').name_get(cr, uid, [msg.author_id.id], context=context)[0] author_user_id = self.pool.get('res.users').name_get(cr, uid, [msg.author_id.user_ids[0].id], context=context)[0] @@ -165,6 +166,7 @@ class mail_message(osv.Model): 'author_user_id': author_user_id, 'partner_ids': partner_ids, 'child_ids': [], + 'child_nbr': child_nbr, } def message_read_tree_get_expandable(self, cr, uid, parent_message, last_message, domain=[], current_level=0, level=0, context=None): @@ -173,7 +175,7 @@ class mail_message(osv.Model): if parent_message and current_level < level: base_domain += [('parent_id', '=', parent_message['id'])] elif parent_message: - base_domain += [('id', 'child_od', parent_message['id'])] + base_domain += [('id', 'child_of', parent_message['id'])] if domain: base_domain += domain extension = { 'type': 'expandable', @@ -184,7 +186,7 @@ class mail_message(osv.Model): } return extension - def message_read_tree_flatten(self, cr, uid, parent_message, messages, current_level, level, domain=[], context=None): + def message_read_tree_flatten(self, cr, uid, parent_message, messages, domain=[], level=0, current_level=0, context=None, limit=None): """ Given a tree with several roots of following structure : [ {'id': 1, 'child_ids': [ {'id': 11, 'child_ids': [...] },], @@ -204,11 +206,14 @@ class mail_message(osv.Model): msg_dict['child_ids'] = [] return [msg_dict] + child_ids context = context or {} + limit = limit or self._message_read_limit # Depth-first flattening for message in messages: if message.get('type') == 'expandable': continue - message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], current_level + 1, level, domain, context=context) + message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], domain, level, current_level + 1, context=context) + for child in message['child_ids']: + message['child_nbr'] += child['child_nbr'] # Flatten if above maximum depth if current_level < level: return_list = messages @@ -216,12 +221,17 @@ class mail_message(osv.Model): return_list = [flat_message for message in messages for flat_message in _flatten(message)] # Add expandable return_list = sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) - if current_level <= level: + if current_level == 0: + expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) + if len(return_list) >= limit: + print 'we need an expandable here' + print 'expandable', expandable + elif current_level <= level: expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) print 'expandable', expandable return return_list - def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, limit=None, tree_parent_id=False): + def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, limit=None, parent_id=False): """ Read messages from mail.message, and get back a structured tree of messages to be displayed as discussion threads. If IDs is set, fetch these records. Otherwise use the domain to fetch messages. @@ -231,7 +241,7 @@ class mail_message(osv.Model): :param domain: optional domain for searching ids :param level: level of threads to display, 0 being flat :param limit: number of messages to fetch - :param tree_parent_id: if parent_id reached, stop searching for + :param parent_id: if parent_id reached, stop searching for further parents :return list: list of trees of messages """ @@ -241,39 +251,28 @@ class mail_message(osv.Model): ids = self.search(cr, uid, domain, context=context, limit=limit) messages = self.browse(cr, uid, ids, context=context) + # key: ID, value: record + tree = {} result = [] - tree = {} # key: ID, value: record for msg in messages: - if len(result) < (limit - 1): - record = self._message_dict_get(cr, uid, msg, context=context) - if level and msg.parent_id: - while msg.parent_id != tree_parent_id: - if msg.parent_id.id in tree: - record_parent = tree[msg.parent_id.id] - else: - record_parent = self._message_dict_get(cr, uid, msg.parent_id, context=context) - if msg.parent_id.parent_id: - tree[msg.parent_id.id] = record_parent - if record['id'] not in [x['id'] for x in record_parent['child_ids']]: - record_parent['child_ids'].append(record) - record = record_parent - msg = msg.parent_id - if msg.id not in tree: - result.append(record) - tree[msg.id] = record - else: - result.append({ - 'type': 'expandable', - 'domain': [('id', '<=', msg.id)] + domain, - 'context': context, - 'thread_level': level, # should be improve accodting to level of records - 'id': -1, - }) - break + record = self._message_dict_get(cr, uid, msg, context=context) + while msg.parent_id and msg.parent_id.id != parent_id: + if msg.parent_id.id in tree: + record_parent = tree[msg.parent_id.id] + else: + record_parent = self._message_dict_get(cr, uid, msg.parent_id, context=context) + if msg.parent_id.parent_id: + tree[msg.parent_id.id] = record_parent + if record['id'] not in [x['id'] for x in record_parent['child_ids']]: + record_parent['child_ids'].append(record) + record = record_parent + msg = msg.parent_id + if msg.id not in tree: + result.append(record) + tree[msg.id] = record # Flatten the result - if thread_level > 0: - result = self.message_read_tree_flatten(cr, uid, None, result, 0, thread_level, domain, context=context) + result = self.message_read_tree_flatten(cr, uid, None, result, domain, level, context=context) return result #------------------------------------------------------ diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index c02b81d0c4f..651a2642cc4 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -455,7 +455,7 @@ openerp.mail = function(session) { return this.message_display(this.options.message_data); } return this.ds_message.call('message_read', - [(initial_mode && this.options.message_ids) || false, fetch_domain, this.options.thread_level, undefined, fetch_context] + [(initial_mode && this.options.message_ids) || false, fetch_domain, this.options.thread_level, fetch_context] ).then(this.proxy('message_display')); }, diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 1f65c38f755..053e5697207 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -29,7 +29,7 @@ Received: by mail1.openerp.com (Postfix, from userid 10002) From: Sylvie Lelitre Subject: {subject} MIME-Version: 1.0 -Content-Type: multipart/alternative; +Content-Type: multipart/alternative; boundary="----=_Part_4200734_24778174.1344608186754" Date: Fri, 10 Aug 2012 14:16:26 +0000 Message-ID: <1198923581.41972151344608186760.JavaMail@agrolait.com> @@ -52,9 +52,9 @@ Content-Transfer-Encoding: quoted-printable =20 =20 - +

                    Please call me as soon as possible this afternoon!

                    - +

                    --
                    Sylvie

                    @@ -153,7 +153,7 @@ class test_mail(common.TransactionCase): test_msg_id = '' mail_text = MAIL_TEMPLATE_PLAINTEXT.format(to='groups@example.com', subject='frogs', extra='', msg_id=test_msg_id) self.mail_thread.message_process(cr, uid, None, mail_text) - new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id','=',test_msg_id)])[0]) + new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id', '=', test_msg_id)])[0]) self.assertEqual(new_mail.body, '\n

                    \nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n
                    \n', 'plaintext mail incorrectly parsed') @@ -458,11 +458,12 @@ class test_mail(common.TransactionCase): # It will be updated as soon as we have fixed specs ! cr, uid = self.cr, self.uid group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) + def _compare_structures(struct1, struct2, n=0): print '%scompare structure' % ('\t' * n) self.assertEqual(len(struct1), len(struct2), 'message_read structure number of childs incorrect') for x in range(len(struct1)): - print '%s' % ('\t' * n), struct1[x]['id'], struct2[x]['id'], struct1[x].get('subject') or '' + print '%s' % ('\t' * n), struct1[x]['id'], struct1[x]['child_nbr'], struct2[x]['id'], struct2[x]['child_nbr'], struct1[x].get('subject') or '' self.assertEqual(struct1[x]['id'], struct2[x]['id'], 'message_read failure %s' % struct1[x].get('subject')) _compare_structures(struct1[x]['child_ids'], struct2[x]['child_ids'], n + 1) print '%send compare' % ('\t' * n) @@ -473,24 +474,24 @@ class test_mail(common.TransactionCase): # Create dummy message structure import copy - tree = [{'id': 2, 'child_ids': [ - {'id': 6, 'child_ids': [ - {'id': 8, 'child_ids': []}, + tree = [{'id': 2, 'child_nbr': 1, 'child_ids': [ + {'id': 6, 'child_nbr': 1, 'child_ids': [ + {'id': 8, 'child_nbr': 0, 'child_ids': []}, ]}, ]}, - {'id': 1, 'child_ids':[ - {'id': 7, 'child_ids': [ - {'id': 9, 'child_ids': []}, + {'id': 1, 'child_nbr': 3, 'child_ids':[ + {'id': 7, 'child_nbr': 1, 'child_ids': [ + {'id': 9, 'child_nbr': 0, 'child_ids': []}, ]}, - {'id': 4, 'child_ids': [ - {'id': 10, 'child_ids': []}, - {'id': 5, 'child_ids': []}, + {'id': 4, 'child_nbr': 2, 'child_ids': [ + {'id': 10, 'child_nbr': 0, 'child_ids': []}, + {'id': 5, 'child_nbr': 0, 'child_ids': []}, ]}, - {'id': 3, 'child_ids': []}, + {'id': 3, 'child_nbr': 0, 'child_ids': []}, ]}, ] # Test: completely flat - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 0, [('type', 'in', 'borderlands')]) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 0) _compare_structures(new_tree, new_tree) self.assertEqual(len(new_tree), 10, 'message_read_tree_flatten wrong in flat') # Test: 1 thread level @@ -503,10 +504,10 @@ class test_mail(common.TransactionCase): {'id': 4, 'child_ids': []}, {'id': 3, 'child_ids': []}, ]}, ] - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 1, [('type', 'in', 'borderlands')]) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 1) _compare_structures(new_tree, tree_test) # Test: 2 thread levels - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 2, [('type', 'in', 'borderlands')]) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 2) _compare_structures(new_tree, tree) # ---------------------------------------- From ce39ffe9271261cdc52b76e3bc981d177f7a6693 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 12 Sep 2012 16:52:45 +0530 Subject: [PATCH 105/245] [IMP]changed as per new spec update and make it work for crm changes done in crm bzr revid: sgo@tinyerp.com-20120912112245-3cp03024fiqb47qs --- addons/crm/crm_lead.py | 18 ++-- addons/crm/crm_lead_data.xml | 28 +++--- addons/mail/data/mail_data.xml | 10 --- addons/mail/mail_message.py | 45 +++------- addons/mail/mail_message_subtype.py | 8 +- addons/mail/mail_message_subtype.xml | 5 +- addons/mail/mail_thread.py | 41 ++++++--- addons/mail/static/src/js/mail_followers.js | 64 +++++-------- addons/mail/tests/test_mail.py | 99 ++++++--------------- 9 files changed, 106 insertions(+), 212 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b7cc0f840d9..6b04be2244d 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -27,15 +27,13 @@ import time import tools from tools.translate import _ -from base.res.res_partner import format_address - CRM_LEAD_PENDING_STATES = ( crm.AVAILABLE_STATES[2][0], # Cancelled crm.AVAILABLE_STATES[3][0], # Done crm.AVAILABLE_STATES[4][0], # Pending ) -class crm_lead(base_stage, format_address, osv.osv): +class crm_lead(base_stage, osv.osv): """ CRM Lead Case """ _name = "crm.lead" _description = "Lead/Opportunity" @@ -107,12 +105,6 @@ class crm_lead(base_stage, format_address, osv.osv): return result, fold - def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - res = super(crm_lead,self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) - if view_type == 'form': - res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context) - return res - _group_by_full = { 'stage_id': _read_group_stage_ids } @@ -842,7 +834,7 @@ class crm_lead(base_stage, format_address, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change",context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), mail_subtype_new="crm_subtype_stage_change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -852,16 +844,16 @@ class crm_lead(base_stage, format_address, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [id], body=message, subtype_xml_id="crm_subtype_new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_post(cr, uid, ids, body=message,subtype="lost", context=context) + return self.message_post(cr, uid, ids, body=message,subtype_xml_id="crm_subtype_lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_post(cr, uid, ids, body=message, subtype="won", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="crm_subtype_won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 9b3f5d7ec75..252e843cf30 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -155,32 +155,24 @@
                    - + new - + crm.lead - + won - + crm.lead - + lost - - - - stage change - + crm.lead - - - - - - - - + + stage change + crm.lead + diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index 80aff038dac..8e2af38f2ea 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -13,18 +13,8 @@ - - other - - - - - email - - comment - diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 686f3e3d381..9e228083b1b 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -20,13 +20,11 @@ ############################################################################## import logging -import openerp import tools from email.header import decode_header from operator import itemgetter from osv import osv, fields -from tools.translate import _ _logger = logging.getLogger(__name__) @@ -37,7 +35,6 @@ def decode(text): text = decode_header(text.replace('\r', '')) return ''.join([tools.ustr(x[0], x[1]) for x in text]) - class mail_message(osv.Model): """ Messages model: system notification (replacing res.log notifications), comments (OpenChatter discussion) and incoming emails. """ @@ -60,10 +57,7 @@ class mail_message(osv.Model): for message in self.browse(cr, uid, ids, context=context): if not message.model or not message.res_id: continue - try: - result[message.id] = self._shorten_name(self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1]) - except openerp.exceptions.AccessDenied, e: - pass + result[message.id] = self._shorten_name(self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1]) return result def _get_unread(self, cr, uid, ids, name, arg, context=None): @@ -154,7 +148,7 @@ class mail_message(osv.Model): def _message_dict_get(self, cr, uid, msg, context=None): """ Return a dict representation of the message browse record. """ - attachment_ids = [{'id': attach[0], 'name': attach[1]} for attach in self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context)] + attachment_ids = self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context) author_id = self.pool.get('res.partner').name_get(cr, uid, [msg.author_id.id], context=context)[0] author_user_id = self.pool.get('res.users').name_get(cr, uid, [msg.author_id.user_ids[0].id], context=context)[0] partner_ids = self.pool.get('res.partner').name_get(cr, uid, [x.id for x in msg.partner_ids], context=context) @@ -313,15 +307,15 @@ class mail_message(osv.Model): def unlink(self, cr, uid, ids, context=None): # cascade-delete attachments that are directly attached to the message (should only happen - # for mail.messages that act as parent for a standalone mail.mail record). + # for mail.messages that act as parent for a standalone mail.mail record. attachments_to_delete = [] - for message in self.browse(cr, uid, ids, context=context): - for attach in message.attachment_ids: - if attach.res_model == self._name and attach.res_id == message.id: + for mail in self.browse(cr, uid, ids, context=context): + for attach in mail.attachment_ids: + if attach.res_model == 'mail.message' and attach.res_id == mail.id: attachments_to_delete.append(attach.id) if attachments_to_delete: self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context) - return super(mail_message, self).unlink(cr, uid, ids, context=context) + return super(mail_message,self).unlink(cr, uid, ids, context=context) def notify(self, cr, uid, newid, context=None): """ Add the related record followers to the destination partner_ids. @@ -344,6 +338,9 @@ class mail_message(osv.Model): follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)], context=context) if follow_ids and len(follow_ids): missing_follow_ids.append(p_id) + subtype_record = self.pool.get('mail.message.subtype').browse(cr, uid, message.subtype_id.id,context=context) + if not subtype_record.res_model: + missing_follow_ids.append(p_id) message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) partners_to_notify |= extra_notified self.pool.get('mail.notification').notify(cr, uid, list(partners_to_notify), newid, context=context) @@ -354,25 +351,3 @@ class mail_message(osv.Model): default = {} default.update(message_id=False, headers=False) return super(mail_message, self).copy(cr, uid, id, default=default, context=context) - - #------------------------------------------------------ - # Tools - #------------------------------------------------------ - - def check_partners_email(self, cr, uid, partner_ids, context=None): - """ Verify that selected partner_ids have an email_address defined. - Otherwise throw a warning. """ - partner_wo_email_lst = [] - for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids, context=context): - if not partner.email: - partner_wo_email_lst.append(partner) - if not partner_wo_email_lst: - return {} - warning_msg = _('The following partners chosen as recipients for the email have no email address linked :') - for partner in partner_wo_email_lst: - warning_msg += '\n- %s' % (partner.name) - return {'warning': { - 'title': _('Partners email addresses not found'), - 'message': warning_msg, - } - } diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index 2330e34e1d3..6eb349fc71e 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -29,15 +29,9 @@ class mail_message_subtype(osv.osv): _columns = { 'name': fields.char('Message Subtype ', size = 128, required = True, help = 'Message subtype, gives a more precise type on the message, especially for system notifications. For example, it can be a notification related to a new record (New), or to a stage change in a process (Stage change). Message subtypes allow to precisely tune the notifications the user want to receive on its wall.'), - 'model_ids': fields.many2many('ir.model', - 'mail_message_subtyp_message_rel', - 'message_subtype_id', 'model_id', 'Model', - help = "link some subtypes to several models, for projet/task"), + 'res_model': fields.char('Model',size = 128, help = "link subtype to model"), 'default': fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), } _defaults = { 'default': True, } - _sql_constraints = [ - ('name_uniq', 'unique (name)', 'The name of the message subtype must be unique !') - ] diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml index 0bfdc2cad95..7d0eed2f4da 100644 --- a/addons/mail/mail_message_subtype.xml +++ b/addons/mail/mail_message_subtype.xml @@ -14,7 +14,7 @@ - + @@ -30,13 +30,12 @@ + - - diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 87c2e22d46b..23c038ce692 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -562,7 +562,7 @@ class mail_thread(osv.AbstractModel): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, - type='notification', parent_id=False, attachments=None, subtype='comment', context=None, **kwargs): + type='notification', parent_id=False, attachments=None, subtype_xml_id='mail_subtype_comment', context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. @@ -599,12 +599,13 @@ class mail_thread(osv.AbstractModel): values = kwargs subtype_obj = self.pool.get('mail.message.subtype') - if subtype: - subtypes = subtype_obj.name_search(cr, uid, subtype,context=context) - if len(subtypes): - subtype_browse = subtype_obj.browse(cr, uid, subtypes[0][0],context=context) - if self._name in [model.model for model in subtype_browse.model_ids]: - values['subtype_id']=subtype_browse.id + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) + if subtype_xml_id: + subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) + if self._name == subtype_browse.res_model: + values['subtype_id']=subtype_browse.id + else: + values['subtype_id']=subtype_browse.id values.update({ 'model': context.get('thread_model', self._name) if thread_id else False, 'res_id': thread_id or False, @@ -628,14 +629,20 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): - """ Add partners to the records followers. """ + def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids = None, context=None): + """ Add partners to the records followers. + :param partner_ids: a list of partner_ids to subscribe + :param return: new value of followers if read_back key in context + """ + self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)],context=context) + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('res_model', '=', self._name)],context=context) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) - return self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) + if context and context.get('read_back'): + return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] + return [] def message_unsubscribe_users(self, cr, uid, ids, user_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not @@ -645,8 +652,14 @@ class mail_thread(osv.AbstractModel): return self.message_unsubscribe(cr, uid, ids, partner_ids, context=context) def message_unsubscribe(self, cr, uid, ids, partner_ids, context=None): - """ Remove partners from the records followers. """ - return self.write(cr, uid, ids, {'message_follower_ids': [(3, pid) for pid in partner_ids]}, context=context) + """ Remove partners from the records followers. + :param partner_ids: a list of partner_ids to unsubscribe + :param return: new value of followers if read_back key in context + """ + self.write(cr, uid, ids, {'message_follower_ids': [(3, pid) for pid in partner_ids]}, context=context) + if context and context.get('read_back'): + return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] + return [] #------------------------------------------------------ # Thread state @@ -679,6 +692,6 @@ class mail_thread(osv.AbstractModel): def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): followers_obj = self.pool.get('mail.followers') followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one + return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 2126d60edf0..b1d62b76a62 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -33,12 +33,20 @@ openerp_mail_followers = function(session, mail) { }, start: function() { - // use actual_mode property on view to know if the view is in create mode anymore + var self = this; + // NB: all the widget should be modified to check the actual_mode property on view, not use + // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); + this.$el.find('ul.oe_mail_recthread_subtype').click(function () {self.update_subtype();}) + this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.fetch_subtype();}) + .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) + .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); + this.$el.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) + .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) + .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.reinit(); - this.bind_events(); }, _check_visibility: function() { @@ -46,40 +54,14 @@ openerp_mail_followers = function(session, mail) { if (this.view.get("actual_mode") !== "create"){this.fetch_subtype();} }, + destroy: function () { + this._super.apply(this, arguments); + }, + reinit: function() { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').hide(); - }, - - bind_events: function() { - var self = this; - this.$('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) - .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) - .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.fetch_subtype(); }); - this.$el.on('click','ul.oe_mail_recthread_subtype', function () {self.update_subtype();}) - this.$el.on('click', 'button.oe_mail_button_invite', function(event) { - action = { - type: 'ir.actions.act_window', - res_model: 'mail.wizard.invite', - view_mode: 'form', - view_type: 'form', - views: [[false, 'form']], - target: 'new', - context: { - 'default_res_model': self.view.dataset.model, - 'default_res_id': self.view.datarecord.id - }, - } - self.do_action(action, function() { self.read_value(); }); - }); - }, - - read_value: function() { - var self = this; - return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { - return results[0].message_follower_ids; - }).pipe(this.proxy('set_value')); + // this.$el.find('ul.oe_mail_recthread_subtype').hide() }, set_value: function(value_) { @@ -89,11 +71,11 @@ openerp_mail_followers = function(session, mail) { this.$el.find('div.oe_mail_recthread_aside').hide(); return; } - return this.fetch_followers(value_ || this.get_value()); + return this.fetch_followers(value_); }, fetch_followers: function (value_) { - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers')); + return this.ds_follow.call('read', [value_ || this.get_value(), ['name', 'user_ids']]).then(this.proxy('display_followers')); }, /** Display the followers, evaluate is_follower directly */ @@ -103,7 +85,7 @@ openerp_mail_followers = function(session, mail) { var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); _(records).each(function (record) { - record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); + record.avatar_url = mail.ChatterUtils.get_image(self.session.prefix, self.session.session_id, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); if (this.message_is_follower) { @@ -149,22 +131,22 @@ openerp_mail_followers = function(session, mail) { }, do_follow: function () { - var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); + var context = new session.web.CompoundContext(this.build_context(), {'read_back': true}); + return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('set_value')); }, //fetch subtype from subtype model fetch_subtype: function () { var self = this - var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); + var subtype_object = this.sub_model.call('search', [[['res_model','=',this.view.model]]]); subtype_object.then(function (subtype_ids){ self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); }); }, do_unfollow: function () { - var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); + var context = new session.web.CompoundContext(this.build_context(), {'read_back': true}); + return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('set_value')); }, }); }; diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 5da3456abe9..0ed1d2b38c0 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -19,8 +19,6 @@ # ############################################################################## -import tools - from openerp.tests import common from openerp.tools.html_sanitize import html_sanitize @@ -31,7 +29,7 @@ Received: by mail1.openerp.com (Postfix, from userid 10002) From: Sylvie Lelitre Subject: {subject} MIME-Version: 1.0 -Content-Type: multipart/alternative; +Content-Type: multipart/alternative; boundary="----=_Part_4200734_24778174.1344608186754" Date: Fri, 10 Aug 2012 14:16:26 +0000 Message-ID: <1198923581.41972151344608186760.JavaMail@agrolait.com> @@ -54,9 +52,9 @@ Content-Transfer-Encoding: quoted-printable =20 =20 - +

                    Please call me as soon as possible this afternoon!

                    - +

                    --
                    Sylvie

                    @@ -84,42 +82,15 @@ Sylvie """ -class TestMailMockups(common.TransactionCase): +class test_mail(common.TransactionCase): def _mock_smtp_gateway(self, *args, **kwargs): return True - def _init_mock_build_email(self): - self._build_email_args_list = [] - self._build_email_kwargs_list = [] - def _mock_build_email(self, *args, **kwargs): - self._build_email_args_list.append(args) - self._build_email_kwargs_list.append(kwargs) - return self._build_email(*args, **kwargs) - - def setUp(self): - super(TestMailMockups, self).setUp() - # Install mock SMTP gateway - self._init_mock_build_email() - self._build_email = self.registry('ir.mail_server').build_email - self.registry('ir.mail_server').build_email = self._mock_build_email - self._send_email = self.registry('ir.mail_server').send_email - self.registry('ir.mail_server').send_email = self._mock_smtp_gateway - - def tearDown(self): - # Remove mocks - self.registry('ir.mail_server').build_email = self._build_email - self.registry('ir.mail_server').send_email = self._send_email - super(TestMailMockups, self).tearDown() - - -class test_mail(TestMailMockups): - - def _mock_send_get_mail_body(self, *args, **kwargs): - # def _send_get_mail_body(self, cr, uid, mail, partner=None, context=None) - body = tools.append_content_to_html(args[2].body_html, kwargs.get('partner').name if kwargs.get('partner') else 'No specific partner') - return body + self._build_email_args = args + self._build_email_kwargs = kwargs + return self.build_email_real(*args, **kwargs) def setUp(self): super(test_mail, self).setUp() @@ -135,9 +106,10 @@ class test_mail(TestMailMockups): self.res_users = self.registry('res.users') self.res_partner = self.registry('res.partner') - # Mock send_get_mail_body to test its functionality without other addons override - self._send_get_mail_body = self.registry('mail.mail').send_get_mail_body - self.registry('mail.mail').send_get_mail_body = self._mock_send_get_mail_body + # Install mock SMTP gateway + self.build_email_real = self.registry('ir.mail_server').build_email + self.registry('ir.mail_server').build_email = self._mock_build_email + self.registry('ir.mail_server').send_email = self._mock_smtp_gateway # groups@.. will cause the creation of new mail groups self.mail_group_model_id = self.ir_model.search(self.cr, self.uid, [('model', '=', 'mail.group')])[0] @@ -147,11 +119,6 @@ class test_mail(TestMailMockups): self.group_pigs_id = self.mail_group.create(self.cr, self.uid, {'name': 'Pigs', 'description': 'Fans of Pigs, unite !'}) - def tearDown(self): - # Remove mocks - self.registry('mail.mail').send_get_mail_body = self._send_get_mail_body - super(test_mail, self).tearDown() - def test_00_message_process(self): cr, uid = self.cr, self.uid # Incoming mail creates a new mail_group "frogs" @@ -187,7 +154,7 @@ class test_mail(TestMailMockups): test_msg_id = '' mail_text = MAIL_TEMPLATE_PLAINTEXT.format(to='groups@example.com', subject='frogs', extra='', msg_id=test_msg_id) self.mail_thread.message_process(cr, uid, None, mail_text) - new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id', '=', test_msg_id)])[0]) + new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id','=',test_msg_id)])[0]) self.assertEqual(new_mail.body, '\n

                    \nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n
                    \n', 'plaintext mail incorrectly parsed') @@ -308,20 +275,18 @@ class test_mail(TestMailMockups): _attachments = [('First', 'My first attachment'), ('Second', 'My second attachment')] # CASE1: post comment, body and subject specified - self._init_mock_build_email() msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body1, subject=_subject, type='comment') message = self.mail_message.browse(cr, uid, msg_id) - sent_emails = self._build_email_kwargs_list + sent_email = self._build_email_kwargs # Test: notifications have been deleted self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg_id)]), 'mail.mail notifications should have been auto-deleted!') # Test: mail_message: subject is _subject, body is _body1 (no formatting done) self.assertEqual(message.subject, _subject, 'mail.message subject incorrect') self.assertEqual(message.body, _body1, 'mail.message body incorrect') - # Test: sent_email: email send by server: correct subject, body, body_alternative - for sent_email in sent_emails: - self.assertEqual(sent_email['subject'], _subject, 'sent_email subject incorrect') - self.assertEqual(sent_email['body'], _mail_body1 + '\n
                    Bert Tartopoils
                    \n', 'sent_email body incorrect') - self.assertEqual(sent_email['body_alternative'], _mail_bodyalt1 + '\nBert Tartopoils', 'sent_email body_alternative is incorrect') + # Test: sent_email: email send by server: correct subject, body; body_alternative + self.assertEqual(sent_email['subject'], _subject, 'sent_email subject incorrect') + self.assertEqual(sent_email['body'], _mail_body1, 'sent_email body incorrect') + self.assertEqual(sent_email['body_alternative'], _mail_bodyalt1, 'sent_email body_alternative is incorrect') # Test: mail_message: partner_ids = group followers message_pids = set([partner.id for partner in message.partner_ids]) test_pids = set([p_a_id, p_b_id, p_c_id]) @@ -331,16 +296,14 @@ class test_mail(TestMailMockups): notif_pids = set([notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)]) self.assertEqual(notif_pids, test_pids, 'mail.message notification partners incorrect') # Test: sent_email: email_to should contain b@b, not c@c (pref email), not a@a (writer) - for sent_email in sent_emails: - self.assertEqual(sent_email['email_to'], ['b@b'], 'sent_email email_to is incorrect') + self.assertEqual(sent_email['email_to'], ['b@b'], 'sent_email email_to is incorrect') # CASE2: post an email with attachments, parent_id, partner_ids # TESTS: automatic subject, signature in body_html, attachments propagation - self._init_mock_build_email() msg_id2 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body2, type='email', partner_ids=[(6, 0, [p_d_id])], parent_id=msg_id, attachments=_attachments) message = self.mail_message.browse(cr, uid, msg_id2) - sent_emails = self._build_email_kwargs_list + sent_email = self._build_email_kwargs self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg_id2)]), 'mail.mail notifications should have been auto-deleted!') # Test: mail_message: subject is False, body is _body2 (no formatting done), parent_id is msg_id @@ -348,11 +311,9 @@ class test_mail(TestMailMockups): self.assertEqual(message.body, html_sanitize(_body2), 'mail.message body incorrect') self.assertEqual(message.parent_id.id, msg_id, 'mail.message parent_id incorrect') # Test: sent_email: email send by server: correct subject, body, body_alternative - self.assertEqual(len(sent_emails), 2, 'sent_email number of sent emails incorrect') - for sent_email in sent_emails: - self.assertEqual(sent_email['subject'], _mail_subject, 'sent_email subject incorrect') - self.assertIn(_mail_body2, sent_email['body'], 'sent_email body incorrect') - self.assertIn(_mail_bodyalt2, sent_email['body_alternative'], 'sent_email body_alternative incorrect') + self.assertEqual(sent_email['subject'], _mail_subject, 'sent_email subject incorrect') + self.assertEqual(sent_email['body'], _mail_body2, 'sent_email body incorrect') + self.assertEqual(sent_email['body_alternative'], _mail_bodyalt2, 'sent_email body_alternative incorrect') # Test: mail_message: partner_ids = group followers message_pids = set([partner.id for partner in message.partner_ids]) test_pids = set([p_a_id, p_b_id, p_c_id, p_d_id]) @@ -362,8 +323,7 @@ class test_mail(TestMailMockups): notif_pids = set([notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)]) self.assertEqual(notif_pids, test_pids, 'mail.message notification partners incorrect') # Test: sent_email: email_to should contain b@b, c@c, not a@a (writer) - for sent_email in sent_emails: - self.assertTrue(set(sent_email['email_to']).issubset(set(['b@b', 'c@c'])), 'sent_email email_to incorrect') + self.assertEqual(set(sent_email['email_to']), set(['b@b', 'c@c']), 'sent_email email_to incorrect') # Test: attachments for attach in message.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect') @@ -450,14 +410,12 @@ class test_mail(TestMailMockups): self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message incorrect content_subtype') # 2. Post the comment, get created message - parent_id = message.id mail_compose.send_mail(cr, uid, [compose_id]) group_pigs.refresh() message = group_pigs.message_ids[0] - # Test: mail.message: subject as Re:.., body in html, parent_id + # Test: mail.message: subject as Re:.., body in html self.assertEqual(message.subject, _msg_reply, 'mail.message incorrect subject') self.assertIn('Administrator wrote:
                    Pigs rules
                    ', message.body, 'mail.message body is incorrect') - self.assertEqual(message.parent_id and message.parent_id.id, parent_id, 'mail.message parent_id incorrect') # Test: mail.message: attachments for attach in message.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect') @@ -501,7 +459,6 @@ class test_mail(TestMailMockups): # It will be updated as soon as we have fixed specs ! cr, uid = self.cr, self.uid group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - def _compare_structures(struct1, struct2, n=0): # print '%scompare structure' % ('\t' * n) self.assertEqual(len(struct1), len(struct2), 'message_read structure number of childs incorrect') @@ -673,10 +630,10 @@ class test_mail(TestMailMockups): _mail_bodyalt2 = 'Pigs rules\nAdmin\n' filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype='email') + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message - msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') - notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) - self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") +# msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') +# notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) +# self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From 6f0b8abe3159831e67434c5938bc867a98b462dd Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 11:05:40 +0530 Subject: [PATCH 106/245] [IMP]account,project,project_issue: changed as per new spec bzr revid: sgo@tinyerp.com-20120913053540-atfsrw8bkf16qo3t --- addons/account/account_invoice.py | 33 ++++++------- addons/account/data/account_data.xml | 26 +++++----- addons/account_voucher/account_voucher.py | 8 ++-- .../account_voucher/account_voucher_data.xml | 21 +++------ addons/analytic/analytic.py | 18 ++++++- addons/base_status/base_stage.py | 14 +++++- addons/project/project.py | 21 ++++----- addons/project/project_data.xml | 47 ++++++++++--------- addons/project_issue/project_issue.py | 4 +- addons/project_issue/project_issue_data.xml | 25 ++++------ 10 files changed, 109 insertions(+), 108 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 9dcbd877c67..8a7251b3856 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -395,23 +395,18 @@ class account_invoice(osv.osv): template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - ctx = dict(context) - ctx.update({ - 'default_model': 'account.invoice', - 'default_res_id': ids[0], - 'default_use_template': True, - 'default_template_id': template_id, - }) + ctx = dict(context, active_model='account.invoice', active_id=ids[0]) + ctx.update({'mail.compose.template_id': template_id}) return { - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'mail.compose.message', - 'views': [(res_id, 'form')], - 'view_id': res_id, - 'type': 'ir.actions.act_window', - 'target': 'new', - 'context': ctx, - 'nodestroy': True, + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'views': [(res_id, 'form')], + 'view_id': res_id, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': ctx, + 'nodestroy': True, } def confirm_paid(self, cr, uid, ids, context=None): @@ -1306,15 +1301,15 @@ class account_invoice(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype="new", context=context) + self.message_post(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype_xml_id="analytic_subtype_new", context=context) def confirm_paid_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype="paid", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_paid", context=context) def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_cancelled", context=context) account_invoice() class account_invoice_line(osv.osv): diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index bf3b3152552..22849a9b886 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,28 +560,24 @@ Invoice account.invoice
                    - + new - + account.analytic.account - + + new + account.invoice + + + paid - + account.invoice - + cancelled - + account.invoice - - - - - - - - - diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index ae670b3d0b7..d2976882981 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1045,8 +1045,6 @@ class account_voucher(osv.osv): # if the amount encoded in voucher is equal to the amount unreconciled, we need to compute the # currency rate difference if line.amount == line.amount_unreconciled: - if not line.move_line_id.amount_residual: - raise osv.except_osv(_('Wrong bank statement line'),_("You have to delete the bank statement line which the payment was reconciled to manually. Please check the payment of the partner %s by the amount of %s.")%(line.voucher_id.partner_id.name, line.voucher_id.amount)) currency_rate_difference = line.move_line_id.amount_residual - amount else: currency_rate_difference = 0.0 @@ -1295,17 +1293,17 @@ class account_voucher(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s created." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_new", context=context) def post_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s '%s' is posted." % (self._document_type[obj.type or False], obj.move_id.name) - self.message_post(cr, uid, [obj.id], body=message, subtype="post", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_post", context=context) def reconcile_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s reconciled." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype="reconcile", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_reconcile", context=context) account_voucher() diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index a99a8735842..dd46a83777e 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -13,27 +13,18 @@ If you want to use advanced accounting features, you should install the "Account Module eInvoicing & Payments has been installed.
                    - - + + account.voucher - + post - + account.voucher - + reconcile - + account.voucher - - - - - - - - - diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index a44fcb01653..776df713b4e 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -96,6 +96,22 @@ class account_analytic_account(osv.osv): res[row['id']][field] = row[field] return self._compute_level_tree(cr, uid, ids, child_ids, res, fields, context) + def name_get(self, cr, uid, ids, context=None): + if isinstance(ids, (int, long)): + ids=[ids] + if not ids: + return [] + res = [] + for account in self.browse(cr, uid, ids, context=context): + data = [] + acc = account + while acc: + data.insert(0, acc.name) + acc = acc.parent_id + data = ' / '.join(data) + res.append((account.id, data)) + return res + def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict): res = self.name_get(cr, uid, ids) return dict(res) @@ -281,7 +297,7 @@ class account_analytic_account(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype_xml_id="analytic_subtype_new", context=context) account_analytic_account() diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 9bb2764d8bd..f72168cde46 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -362,17 +362,27 @@ class base_stage(object): msg = _('%s has been opened.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) self.message_post(cr, uid, [id], body=msg, context=context) return True + + def find_xml_id(self,cr,uid,ids,name,context=None): + subtype_obj = self.pool.get('mail.message.subtype') + irmodel_obj = self.pool.get('ir.model.data') + subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) + ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','=',subtype_id)]) + ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) + return ir_model_browse.name def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, subtype="closed", context=context) + xml_id = self.find_xml_id(cr, uid, ids, name="closed", context) + self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, subtype="cancelled", context=context) + xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context) + self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_pending_send_note(self, cr, uid, ids, context=None): diff --git a/addons/project/project.py b/addons/project/project.py index e1dea8e70c5..412e14fd8fd 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -41,9 +41,8 @@ class project_task_type(osv.osv): 'case_default': fields.boolean('Common to All Projects', help="If you check this field, this stage will be proposed by default on each new project. It will not assign this stage to existing projects."), 'project_ids': fields.many2many('project.project', 'project_task_type_rel', 'type_id', 'project_id', 'Projects'), - 'state': fields.selection(_TASK_STATE, 'Related Status', required=True, - help="The status of your document is automatically changed regarding the selected stage. " \ - "For example, if a stage is related to the status 'Close', when your document reaches this stage, it is automatically closed."), + 'state': fields.selection(_TASK_STATE, 'State', required=True, + help="The related state for the stage. The state of your document will automatically change regarding the selected stage. Example, a stage is related to the state 'Close', when your document reach this stage, it will be automatically closed."), 'fold': fields.boolean('Hide in views if empty', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."), } @@ -514,23 +513,23 @@ def Project(): return project_id def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype_xml_id="project_subtype_new", context=context) def set_open_send_note(self, cr, uid, ids, context=None): message = _("Project has been opened.") - return self.message_post(cr, uid, ids, body=message, subtype="open", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_open", context=context) def set_pending_send_note(self, cr, uid, ids, context=None): message = _("Project is now pending.") - return self.message_post(cr, uid, ids, body=message, subtype="pending", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_pending", context=context) def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Project has been cancelled.") - return self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_cancelled", context=context) def set_close_send_note(self, cr, uid, ids, context=None): message = _("Project has been closed.") - return self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_closed", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly @@ -728,7 +727,7 @@ class task(base_stage, osv.osv): When the case is over, the state is set to \'Done\'.\ If the case needs to be reviewed then the state is \ set to \'Pending\'.'), - 'categ_ids': fields.many2many('project.category', string='Tags'), + 'categ_ids': fields.many2many('project.category', string='Categories'), 'kanban_state': fields.selection([('normal', 'Normal'),('blocked', 'Blocked'),('done', 'Ready To Pull')], 'Kanban State', help="A task's kanban state indicates special situations affecting it:\n" " * Normal is the default situation\n" @@ -1231,10 +1230,10 @@ class task(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="task_subtype_stage_change", context=context) def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype_xml_id="task_subtype_new", context=context) def case_draft_send_note(self, cr, uid, ids, context=None): msg = _('Task has been set as draft.') diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 34608d3abeb..0544b6d4e78 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -85,43 +85,48 @@ - + new - + project.project - + + new + project.task + + + open - + project.project - + pending - + project.project - + closed - + project.project - + + closed + project.task + + cancelled - + project.project - + + cancelled + project.task + + + stage change - + project.task - - - - - - - - - diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index d3f47ba9b3e..83eddb83d5e 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -503,7 +503,7 @@ class project_issue(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="issue_subtype_stage_change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): """ Override of default prefix for notifications. """ @@ -515,7 +515,7 @@ class project_issue(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="issue_subtype_new", context=context) def case_escalate_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index 6ee704c6b39..f6c225a4d00 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -32,33 +32,24 @@ - + new - + project.issue - + stage change - + project.issue - + cancelled - + project.issue - + closed - - - - - - - - - - + project.issue From 8ca3f76711df87f17e2514dec84f63b82fee2ab7 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 11:59:28 +0530 Subject: [PATCH 107/245] [IMP]code improvement and other minor changes bzr revid: sgo@tinyerp.com-20120913062928-hvqnp116y49yrl4d --- addons/account/data/account_data.xml | 6 +----- addons/analytic/__openerp__.py | 3 ++- addons/analytic/analytic_data.xml | 10 ++++++++++ addons/base_status/base_stage.py | 11 +++++++---- addons/crm/crm_lead_data.xml | 5 +++++ 5 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 addons/analytic/analytic_data.xml diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 22849a9b886..7689ca2c253 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,11 +560,7 @@ Invoice account.invoice - - new - account.analytic.account - - + new account.invoice diff --git a/addons/analytic/__openerp__.py b/addons/analytic/__openerp__.py index 10762a1d2be..d90b2fd62ac 100644 --- a/addons/analytic/__openerp__.py +++ b/addons/analytic/__openerp__.py @@ -38,7 +38,8 @@ that have no counterpart in the general financial accounts. 'security/analytic_security.xml', 'security/ir.model.access.csv', 'analytic_sequence.xml', - 'analytic_view.xml' + 'analytic_view.xml', + 'analytic_data.xml' ], 'demo': [], 'installable': True, diff --git a/addons/analytic/analytic_data.xml b/addons/analytic/analytic_data.xml new file mode 100644 index 00000000000..cfd3b5e9b78 --- /dev/null +++ b/addons/analytic/analytic_data.xml @@ -0,0 +1,10 @@ + + + + + new + account.analytic.account + + + + \ No newline at end of file diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index f72168cde46..4b1cc3c6946 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -367,21 +367,24 @@ class base_stage(object): subtype_obj = self.pool.get('mail.message.subtype') irmodel_obj = self.pool.get('ir.model.data') subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) - ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','=',subtype_id)]) + ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_id)]) + xml_id = False ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) - return ir_model_browse.name + if ir_model_browse: + xml_id = ir_model_browse[0].name + return xml_id def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="closed", context) + xml_id = self.find_xml_id(cr, uid, ids, name="closed", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context) + xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 252e843cf30..633782ed233 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -174,5 +174,10 @@ crm.lead + + cancelled + crm.lead + + From 296ae6e24baa8918331d57c7c8e21b21a82cb4bc Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:11:01 +0530 Subject: [PATCH 108/245] [IMP]event:changed in event module as per new spec bzr revid: sgo@tinyerp.com-20120913064101-85pfg3kbbqnoufzx --- addons/event/event.py | 20 +++++++++---------- addons/event/event_data.xml | 39 ++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index 8c755456d9c..82c0390ee03 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -287,27 +287,27 @@ class event_event(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Event has been created.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) return True def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_cancelled", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): message = _("Event has been set to draft.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) return True def button_done_send_note(self, cr, uid, ids, context=None): message = _("Event has been done.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_closed", context=context) return True def button_confirm_send_note(self, cr, uid, ids, context=None): message = _("Event has been confirmed.") - self.message_post(cr, uid, ids, body=message, subtype="confirmed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_confirmed", context=context) return True event_event() @@ -353,7 +353,7 @@ class event_registration(osv.osv): return self.write(cr, uid, ids, {'state': 'draft'}, context=context) def confirm_registration(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_('State set to open'), context=context) + self.message_post(cr, uid, ids, body=_('State set to open'),subtype_xml_id="registration_subtype_confirmed", context=context) return self.write(cr, uid, ids, {'state': 'open'},context=context) def create(self, cr, uid, vals, context=None): @@ -383,13 +383,13 @@ class event_registration(osv.osv): if today >= registration.event_id.date_begin: values = {'state': 'done', 'date_closed': today} self.write(cr, uid, ids, values) - self.message_post(cr, uid, ids, body=_('State set to Done'), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_('State set to Done'), subtype_xml_id="registration_subtype_closed", context=context) else: raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") ) return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype_xml_id="registration_subtype_cancelled", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): @@ -459,12 +459,12 @@ class event_registration(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Registration has been created.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) return True def do_draft_send_note(self, cr, uid, ids, context=None): message = _("Registration has been set as draft.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) return True event_registration() diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 608dcdb4e8f..814fd0b179c 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -12,34 +12,51 @@ automatic 100 - + + new + event.event - + closed + event.event - + cancelled + event.event - + confirmed + event.event - - - - - + + + + new + event.registration + - - + + closed + event.registration + + cancelled + event.event + + + + confirmed + event.registration + + From 66e8595b01b0c1d38190b1222d0955b710b6c1db Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:28:54 +0530 Subject: [PATCH 109/245] [IMP]changed in all hr module for subtype bzr revid: sgo@tinyerp.com-20120913065854-7y5jkls3q2jebduv --- addons/hr_holidays/hr_holidays.py | 6 ++-- addons/hr_holidays/hr_holidays_data.xml | 21 ++++---------- addons/hr_recruitment/hr_recruitment.py | 14 ++++----- addons/hr_recruitment/hr_recruitment_data.xml | 29 +++++++------------ .../hr_timesheet_invoice.py | 8 ++--- .../hr_timesheet_invoice_data.xml | 25 +++++----------- 6 files changed, 38 insertions(+), 65 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 4136abbb2f7..4e85313e2e4 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -364,7 +364,7 @@ class hr_holidays(osv.osv): def create_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, ids, - _("The request has been created and is waiting confirmation."),subtype="new", context=context) + _("The request has been created and is waiting confirmation."),subtype_xml_id="hr_holidays_subtype_new", context=context) return True def holidays_confirm_notificate(self, cr, uid, ids, context=None): @@ -384,12 +384,12 @@ class hr_holidays(osv.osv): _("The request has been double validated. The validation process is now over."), context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), subtype="approved", context=context) + _("The request has been approved. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_approved", context=context) def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), subtype="refused", context=context) + _("The request has been refused. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_refused", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index ad337b72c62..8ddfb79a527 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -50,28 +50,19 @@ Once validated, they are visible in the employee's calendar. HR officers can def brown - + new - + hr.holidays - + approved - + hr.holidays - + refused - + hr.holidays - - - - - - - - - diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 25be4f3c3f1..6d38c4e4e08 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -461,14 +461,14 @@ class hr_applicant(base_stage, osv.Model): """ Override of the (void) default notification method. """ if not stage_id: return True stage_name = self.pool.get('hr.recruitment.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="hr_recruitment_subtype_stage_change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): return 'Applicant' def case_open_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been set in progress.") - return self.message_post(cr, uid, ids, body=message, subtype="in progress", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_in_progress", context=context) def case_close_send_note(self, cr, uid, ids, context=None): if context is None: @@ -476,23 +476,23 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, subtype="refused", context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id="hr_recruitment_subtype_refused", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been created.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) class hr_job(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 30ff9118584..dedeb20a3dc 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -462,38 +462,29 @@ You can automatically receive job application though an email gateway, see the H - + new - + hr.applicant - + hired - + hr.applicant - + refused - + hr.applicant - + stage change - + hr.applicant - + in progress - + hr.applicant - - - - - - - - - diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 4ed61119a5f..e3f54609e95 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -95,25 +95,25 @@ class account_analytic_account(osv.osv): def set_close(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'close'}, context=context) message = _("Contract has been closed.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_closed", context=context) return True def set_cancel(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'cancelled'}, context=context) message = _("Contract has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_invoice_subtype_cancelled", context=context) return True def set_open(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'open'}, context=context) message = _("Contract has been opened.") - self.message_post(cr, uid, ids, body=message, subtype="open", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_open", context=context) return True def set_pending(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'pending'}, context=context) message = _("Contract has been set as pending.") - self.message_post(cr, uid, ids, body=message, subtype="pending", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_pending", context=context) return True account_analytic_account() diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml index 5cc5024d591..29a3233f509 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml @@ -17,32 +17,23 @@ 50.0 - + closed - + account.analytic.account - + pending - + account.analytic.account - + open - + account.analytic.account - + cancelled - + account.analytic.account - - - - - - - - - From 97026e96d30c103a6873f66da0e50b4f47ece37f Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:33:33 +0530 Subject: [PATCH 110/245] [IMP]changed in idea for subtype bzr revid: sgo@tinyerp.com-20120913070333-8mvke4g0h13r6e6d --- addons/idea/idea.py | 8 ++++---- addons/idea/idea_data.xml | 25 ++++++++----------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/addons/idea/idea.py b/addons/idea/idea.py index e33c9b99014..f8346ec2bba 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -67,21 +67,21 @@ class idea_idea(osv.osv): def idea_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea cancelled.'), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_('Idea cancelled.'), subtype_xml_id="idea_subtype_cancelled", context=context) return True def idea_open(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'open'}) - self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype="open", context=context) + self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype_xml_id="idea_subtype_open", context=context) return True def idea_close(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea closed.'), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_('Idea closed.'), subtype_xml_id="idea_subtype_closed", context=context) self.write(cr, uid, ids, { 'state': 'close' }) return True def idea_draft(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype_xml_id="idea_subtype_new", context=context) self.write(cr, uid, ids, { 'state': 'draft' }) return True idea_idea() diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index 36ccf2e992e..b4f3f70d2dd 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -17,32 +17,23 @@ - + new - + idea.idea - + open - + idea.idea - + cancelled - + idea.idea - + closed - - - - - - - - - - + idea.idea From fa5f1e174e8e0c525edc6e5a43a3d0681a11d77c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:44:30 +0530 Subject: [PATCH 111/245] [IMP]changed in mrp and mrp_operations for subtype bzr revid: sgo@tinyerp.com-20120913071430-o7bml82s6tgnwn4h --- addons/mrp/mrp.py | 10 +++---- addons/mrp/mrp_data.xml | 29 +++++++------------- addons/mrp_operations/mrp_operation_data.xml | 29 +++++++------------- addons/mrp_operations/mrp_operations.py | 10 +++---- 4 files changed, 30 insertions(+), 48 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 40d8d1b7e5f..bc0baae71e8 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1044,27 +1044,27 @@ class mrp_production(osv.osv): # --------------------------------------------------- def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype_xml_id="mrp_subtype_new", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been canceled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_cancelled", context=context) return True def action_ready_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is ready to produce.") - self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_ready", context=context) return True def action_in_production_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is in production.") - self.message_post(cr, uid, ids, body=message, subtype="production", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_production", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been done.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_closed", context=context) return True def action_confirm_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mrp/mrp_data.xml b/addons/mrp/mrp_data.xml index 6ee7cc82dd2..3740f03bdc8 100644 --- a/addons/mrp/mrp_data.xml +++ b/addons/mrp/mrp_data.xml @@ -27,38 +27,29 @@ From the Manufacturing Settings, you can choose to compute production schedules 1 - + new - + mrp.production - + ready - + mrp.production - + production - + mrp.production - + cancelled - + mrp.production - + closed - + mrp.production - - - - - - - - - diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index e2d7f9f0a56..812ce3da536 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -31,38 +31,29 @@ - + new - + mrp.production.workcenter.line - + started - + mrp.production.workcenter.line - + pending - + mrp.production.workcenter.line - + cancelled - + mrp.production.workcenter.line - + closed - + mrp.production.workcenter.line - - - - - - - - - diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index a18eb4141ba..6ed636850f1 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="started", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="started", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="closed", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="pending", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="pending", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="cancelled", context=context) return True mrp_production_workcenter_line() From 2e7de7cf6fad0212d3d2a8953fba64d8b5aa77a2 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:50:05 +0530 Subject: [PATCH 112/245] [IMP]changed in mrp_repair for subtype bzr revid: sgo@tinyerp.com-20120913072005-cmlf91arfwpxnv6o --- addons/mrp_repair/mrp_repair.py | 14 +++++----- addons/mrp_repair/mrp_repair_data.xml | 37 ++++++++++----------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 44624044090..202f9efd391 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -571,40 +571,40 @@ class mrp_repair(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been created." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_new", context=context) return True def set_start_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been started." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="started", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_started", context=context) return True def set_toinvoiced_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Draft Invoice of %s %s waiting for validation.") % (repair.invoice_id.amount_total, repair.invoice_id.currency_id.symbol) - self.message_post(cr, uid, [repair.id], body=message, subtype="pending", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_pending", context=context) return True def set_confirm_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _( "Repair Order for %s has been accepted." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="accepted", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_accepted", context=context) return True def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Repair has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_cancelled", context=context) return True def set_ready_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is now ready to repair.") - self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_ready", context=context) return True def set_done_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is closed.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_closed", context=context) return True mrp_repair() diff --git a/addons/mrp_repair/mrp_repair_data.xml b/addons/mrp_repair/mrp_repair_data.xml index b45b7ec3105..6414e07f713 100644 --- a/addons/mrp_repair/mrp_repair_data.xml +++ b/addons/mrp_repair/mrp_repair_data.xml @@ -1,47 +1,38 @@ - + new - + mrp.repair - + started - + mrp.repair - + ready - + mrp.repair - + pending - + mrp.repair - + accepted - + mrp.repair - + cancelled - + mrp.repair - + closed - + mrp.repair - - - - - - - - - From 2e3f2e2458d71cdf693c6ec97e3d9cc28d4a6e75 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:59:49 +0530 Subject: [PATCH 113/245] [IMP]changed in procurement for subtype bzr revid: sgo@tinyerp.com-20120913072949-pny1yj3ke2gj2rr3 --- addons/procurement/procurement.py | 12 ++++----- addons/procurement/procurement_data.xml | 35 ++++++++++--------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 1cb695663df..dcb47f1af88 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -496,22 +496,22 @@ class procurement_order(osv.osv): return obj_id def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been created."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been created."), subtype_xml_id="procurement_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), subtype="confirmed", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), subtype_xml_id="procurement_subtype_confirmed", context=context) def running_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), subtype="running", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), subtype_xml_id="procurement_subtype_running", context=context) def ready_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype="ready", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype_xml_id="procurement_subtype_ready", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype_xml_id="procurement_subtype_cancelled", context=context) def done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype_xml_id="procurement_subtype_closed", context=context) procurement_order() diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index 1f60977c4dd..950c487ae53 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -32,36 +32,29 @@ - - + + new + procurement.order - + confirmed - + procurement.order - + ready - + procurement.order - + running - + procurement.order - - + + cancelled + procurement.order - + closed - - - - - - - - - - + procurement.order \ No newline at end of file From ad6e9d96e4d6f0f33f48415e13ffebcaf7992b77 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:27:27 +0530 Subject: [PATCH 114/245] [IMP]changed in sale module for subtype update specification bzr revid: sgo@tinyerp.com-20120913085727-7swp0404g99fkf7l --- addons/stock/stock.py | 18 +++++++++++++----- addons/stock/stock_data.xml | 29 +++++++++++++---------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index d577e69e237..50e85fa5191 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1379,13 +1379,13 @@ class stock_picking(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype_xml_id="stock_in_subtype_new", context=context) def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None): - return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name), subtype="moved", context=context) + return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name),context=context) def back_order_send_note(self, cr, uid, ids, back_name, context=None): - return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype_xml_id="stock_in_subtype_new", context=context) def ship_done_send_note(self, cr, uid, ids, context=None): type_dict = { @@ -1393,12 +1393,20 @@ class stock_picking(osv.osv): 'in': 'received', 'internal': 'moved', } + xml_id_dict = { + 'out':'stock_out_subtype_delivered', + 'in' : 'stock_in_subtype_received' + } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype=type_dict.get(obj.type), context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype_xml_id=xml_id_dict.get(obj.type), context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): + xml_id_dict = { + 'out':'stock_out_subtype_cancelled', + 'in' : 'stock_in_subtype_cancelled' + } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id=xml_id_dict.get(obj.type), context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index f83b0ada388..a59642fa912 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -170,30 +170,27 @@ watch your stock valuation, and track production lots upstream and downstream (b - - + + new + stock.picking.in - + delivered - + stock.picking.out - + received - + stock.picking.in - - + + cancelled + stock.picking.in - - - - - - - - + + cancelled + stock.picking.out From 986e5817d18b149c3d31cc8c123b878a3e6b62b9 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:32:12 +0530 Subject: [PATCH 115/245] [IMP]changed in sale module for subtype update specification bzr revid: sgo@tinyerp.com-20120913090212-8c9jgb38x1d6517j --- addons/sale/sale.py | 10 +++++----- addons/sale/sale_data.xml | 29 ++++++++++------------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 0af625ed7d9..0f01909ac7f 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1032,7 +1032,7 @@ class sale_order(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -1040,7 +1040,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_cancelled", context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): @@ -1052,15 +1052,15 @@ class sale_order(osv.osv): self.message_post(cr, uid, [order.id], body=_("Delivery Order %s scheduled for %s.") % (picking.name, picking_date_str), context=context) def delivery_end_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Order delivered."), subtype="delivered", context=context) + self.message_post(cr, uid, ids, body=_("Order delivered."), subtype_xml_id="sale_subtype_delivered", context=context) def invoice_paid_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) + self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="sale_subtype_paid", context=context) def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="sale_subtype_pending", context=context) def action_cancel_draft_send_note(self, cr, uid, ids, context=None): return self.message_post(cr, uid, ids, body=_('Sale order set to draft.'), context=context) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index 2f4b81b27f4..4eca7f60c8f 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -50,37 +50,28 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. - + new - + sale.order - + cancelled - + sale.order - + paid - + sale.order - + pending - + sale.order - + delivered - - - - - - - - - - + sale.order From c67edb99bb891c468fedb6b4a373fe9da1843ebc Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:38:34 +0530 Subject: [PATCH 116/245] [IMP]changed in purchase module for subtype update specification bzr revid: sgo@tinyerp.com-20120913090834-5lf57kikymrzsg8z --- addons/purchase/purchase.py | 12 ++++++------ addons/purchase/purchase_data.xml | 29 ++++++++++------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index c950c852261..b0f10d3f71f 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -740,7 +740,7 @@ class purchase_order(osv.osv): return [('state', '=', 'draft')] def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype_xml_id="purchase_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -758,20 +758,20 @@ class purchase_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="purchase_subtype_pending", context=context) def shipment_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype="received", context=context) + self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype_xml_id="purchase_subtype_received", context=context) def invoice_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) + self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="purchase_subtype_paid", context=context) def draft_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), subtype_xml_id="purchase_subtype_new", context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="purchase_subtype_cancelled", context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index a84564b2360..aa62e84e19d 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -49,37 +49,28 @@ You can also manage purchase requisitions, see also the Purchase Settings. - + new - + purchase.order - + paid - + purchase.order - + pending - + purchase.order - + received - + purchase.order - + cancelled - + purchase.order - - - - - - - - - From 9524b34e314511191fc2c2265a44e5c9594f645c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:42:08 +0530 Subject: [PATCH 117/245] [IMP]changed in purchase_requisition module for subtype update specification bzr revid: sgo@tinyerp.com-20120913091208-si6e042trpzdyq6m --- .../purchase_requisition.py | 8 +++---- .../purchase_requisition_data.xml | 23 +++++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index a3df366381d..5d8d2bb2f87 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -94,13 +94,13 @@ class purchase_requisition(osv.osv): self.message_post(cr, uid, ids, body=_("Draft Requisition has been sent to suppliers."), context=context) def reset_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype_xml_id="requisition_subtype_new", context=context) def done_to_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype_xml_id="requisition_subtype_closed", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype_xml_id="requisition_subtype_cancelled", context=context) def _planned_date(self, requisition, delay=0.0): company = requisition.company_id @@ -184,7 +184,7 @@ class purchase_requisition(osv.osv): return res def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype_xml_id="requisition_subtype_new", context=context) def create(self, cr, uid, vals, context=None): requisition = super(purchase_requisition, self).create(cr, uid, vals, context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 2b22c2057a1..534bf2fe2a7 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -7,24 +7,17 @@ model="ir.values" name="set"/> - + closed - + purchase.requisition - - + + new + purchase.requisition - - - - - - - - - - - + + cancelled + purchase.requisition \ No newline at end of file From 18ceddcf2ee7086fe2e2d512e415064986febf9c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:45:02 +0530 Subject: [PATCH 118/245] [IMP]minor changes bzr revid: sgo@tinyerp.com-20120913091502-dvlpgoa3dr72km04 --- addons/event/event_data.xml | 4 ---- addons/mail/tests/test_mail.py | 4 ---- 2 files changed, 8 deletions(-) diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 814fd0b179c..bc7f71ef664 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -16,24 +16,20 @@ new event.event - closed event.event - cancelled event.event - confirmed event.event - diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index e3718d23855..9b0586d5d5c 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -636,7 +636,3 @@ class test_mail(common.TransactionCase): msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") - # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message -# msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') -# notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) -# self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From e6eafcaf22aa4c84ca751f1e6cd2f06a0833c987 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:47:57 +0530 Subject: [PATCH 119/245] [IMP]minor changes in account bzr revid: sgo@tinyerp.com-20120913091757-6izlnq34z3v9jd7n --- addons/account_voucher/account_voucher_data.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index dd46a83777e..a59993aae6b 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -14,6 +14,7 @@ If you want to use advanced accounting features, you should install the "Account + new account.voucher From 53a67e065236f549cd07b35406cc59181417ee55 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:12:09 +0530 Subject: [PATCH 120/245] [IMP]change in mrp bzr revid: sgo@tinyerp.com-20120913094209-4r0laz8gtmcz1tsq --- addons/mrp_operations/mrp_operations.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 6ed636850f1..53eaceed066 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="new", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="started", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_started", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="closed", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="pending", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_pending", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="cancelled", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_cancelled", context=context) return True mrp_production_workcenter_line() From 458899673b2d06572ea68b1874b56767d7966a76 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:33:07 +0530 Subject: [PATCH 121/245] [IMP]change in mrp operations openerp.py bzr revid: sgo@tinyerp.com-20120913100307-4f49x1my6ajzzfiz --- addons/mrp_operations/__openerp__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mrp_operations/__openerp__.py b/addons/mrp_operations/__openerp__.py index a5bda80f924..ba2e2d88637 100644 --- a/addons/mrp_operations/__openerp__.py +++ b/addons/mrp_operations/__openerp__.py @@ -58,6 +58,7 @@ So, that we can compare the theoretic delay and real delay. 'depends': ['mrp'], 'data': [ 'security/ir.model.access.csv', + 'mrp_operation_data.xml', 'mrp_operations_workflow.xml', 'mrp_operations_view.xml', 'mrp_operations_report.xml', @@ -65,7 +66,7 @@ So, that we can compare the theoretic delay and real delay. 'process/mrp_operation_process.xml', 'mrp_operations_workflow_instance.xml' ], - 'demo': ['mrp_operation_data.xml', + 'demo': [ 'mrp_operations_demo.yml' ], 'test': [ From 17987c7e2c71a695a5d3fcff324c29067ba6b7ab Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:54:56 +0530 Subject: [PATCH 122/245] [IMP]crm yml improve for subtype bzr revid: sgo@tinyerp.com-20120913102456-c74asnmmh6kx5270 --- addons/crm/test/process/crm_message_subtype.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 3dd042c1279..46c6aae7bf4 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -3,24 +3,21 @@ - !record {model: mail.message.subtype, id: mail.mail_subtype_won }: name: won - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: False - I have add the sub_type name email with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_email }: name: email - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: True - I have add the sub_type name comment with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: name: comment - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: True - I have add the subtypes as won in feeds From d5687b3ed0538d095cc8209c1de78de1a10448b6 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 16:15:18 +0530 Subject: [PATCH 123/245] [IMP]crm yml improve bzr revid: sgo@tinyerp.com-20120913104518-6cse5m221l8n5yc4 --- addons/crm/test/process/crm_message_subtype.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 46c6aae7bf4..a1ad9a9c39a 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -3,22 +3,14 @@ - !record {model: mail.message.subtype, id: mail.mail_subtype_won }: name: won - res_model:crm.lead + res_model: crm.lead default: False -- - I have add the sub_type name email with default true -- - !record {model: mail.message.subtype, id: mail.mail_subtype_email }: - name: email - res_model:crm.lead - default: True - I have add the sub_type name comment with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: name: comment - res_model:crm.lead - default: True + res_model: crm.lead - I have add the subtypes as won in feeds - From f554db5c6bc94b3e9fdf5aa67a0030cbb4026df2 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 17:10:44 +0530 Subject: [PATCH 124/245] [IMP]add subtype for crm_claim bzr revid: sgo@tinyerp.com-20120913114044-0spnm47pty5g04wu --- addons/crm_claim/crm_claim.py | 6 +++--- addons/crm_claim/crm_claim_data.xml | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index 535f6d20367..ce2427b9752 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -238,16 +238,16 @@ class crm_claim(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been created.') - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_new', context=context) def case_refuse_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been refused.') - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_refused', context=context) def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.claim.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id='claim_subtype_stage_change', context=context) class res_partner(osv.osv): diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index 33bd280c364..a72c285f506 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -75,6 +75,32 @@ + + + + new + crm.claim + + + + refused + crm.claim + + + + stage change + crm.claim + + + cancelled + crm.claim + + + + closed + crm.claim + + From 2fbc7e9d046dcebea15b6a43289297e705984212 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 17:21:38 +0530 Subject: [PATCH 125/245] [IMP]improve subtype in crm_claim bzr revid: sgo@tinyerp.com-20120913115138-4rrsmwmlfh4f25s1 --- addons/crm_claim/crm_claim_data.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index a72c285f506..e68bc3ad6cb 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -99,7 +99,6 @@ closed crm.claim - From 8821601a87dc1a35253314673252f40a10e93493 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 11:27:30 +0530 Subject: [PATCH 126/245] [IMP]minor changes bzr revid: sgo@tinyerp.com-20120914055730-c0x2tshrr8j6aa5v --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 87c2e22d46b..71f22138c90 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -628,7 +628,7 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): + def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids=None, context=None): """ Add partners to the records followers. """ if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') From a11e752ea2a1533c7db3e037689a8e132ade8bbd Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 11:35:46 +0530 Subject: [PATCH 127/245] [IMP]improve code bzr revid: sgo@tinyerp.com-20120914060546-e0uj8dru6c9pym9y --- addons/base_status/base_stage.py | 14 +++++++------- addons/mail/mail_thread.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 4b1cc3c6946..2695567e0a1 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -365,13 +365,13 @@ class base_stage(object): def find_xml_id(self,cr,uid,ids,name,context=None): subtype_obj = self.pool.get('mail.message.subtype') - irmodel_obj = self.pool.get('ir.model.data') - subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) - ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_id)]) - xml_id = False - ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) - if ir_model_browse: - xml_id = ir_model_browse[0].name + ir_model_data_obj = self.pool.get('ir.model.data') + subtype_ids = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) + ir_data_ids = ir_model_data_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_ids)]) + xml_id = 'mail_subtype_comment' + ir_model_data_record = ir_model_data_obj.browse(cr,uid,ir_data_ids) + if ir_model_data_record: + xml_id = ir_model_data_record[0].name return xml_id def case_close_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3f034b8875a..137ba3eccda 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -604,7 +604,7 @@ class mail_thread(osv.AbstractModel): subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) if self._name == subtype_browse.res_model: values['subtype_id']=subtype_browse.id - else: + if not subtype_browse.res_model: values['subtype_id']=subtype_browse.id values.update({ 'model': context.get('thread_model', self._name) if thread_id else False, @@ -629,7 +629,7 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): + def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') From 6537579a9c927264100e3dc5cb843b930566c6ab Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 15:02:36 +0530 Subject: [PATCH 128/245] [IMP]improve lead code bzr revid: sgo@tinyerp.com-20120914093236-knk88eqvnbd4slct --- addons/crm/crm_lead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 924326c7c02..81ca828dc76 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -842,7 +842,7 @@ class crm_lead(base_stage, format_address, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), mail_subtype_new="crm_subtype_stage_change",context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="crm_subtype_stage_change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): 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 129/245] [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 9ec025be0ed4a896b37b0323fe427e39f6abb13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 13:00:35 +0200 Subject: [PATCH 130/245] [CLEAN] mail message subtype: cleaned model and views. bzr revid: tde@openerp.com-20120919110035-724052iqfkkafm73 --- addons/mail/data/mail_data.xml | 2 +- addons/mail/mail_message_subtype.py | 20 +++++++++++------ addons/mail/mail_message_subtype.xml | 32 ++++++---------------------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index 8e2af38f2ea..c8eb8829d64 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -12,7 +12,7 @@ - + comment diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index 6eb349fc71e..71e8147cfc9 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2009-today OpenERP SA () +# Copyright (C) 2012-today OpenERP SA () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,15 +22,23 @@ from osv import osv from osv import fields + class mail_message_subtype(osv.osv): - + """ Class holding subtype definition for messages. Subtypes allow to tune + the follower subscription, allowing only some subtypes to be pushed + on the Wall. """ _name = 'mail.message.subtype' _description = 'mail_message_subtype' _columns = { - 'name': fields.char('Message Subtype ', size = 128, - required = True, help = 'Message subtype, gives a more precise type on the message, especially for system notifications. For example, it can be a notification related to a new record (New), or to a stage change in a process (Stage change). Message subtypes allow to precisely tune the notifications the user want to receive on its wall.'), - 'res_model': fields.char('Model',size = 128, help = "link subtype to model"), - 'default': fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), + 'name': fields.char('Message Subtype ', required=True, + help='Message subtype, gives a more precise type on the message, '\ + 'especially for system notifications. For example, it can be '\ + 'a notification related to a new record (New), or to a stage '\ + 'change in a process (Stage change). Message subtypes allow to '\ + 'precisely tune the notifications the user want to receive on its wall.'), + 'res_model': fields.char('Model', help="link subtype to model"), + 'default': fields.boolean('Default', + help="When subscribing to the document, this subtype will be checked by default."), } _defaults = { 'default': True, diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml index 7d0eed2f4da..c6490d5e61a 100644 --- a/addons/mail/mail_message_subtype.xml +++ b/addons/mail/mail_message_subtype.xml @@ -2,19 +2,14 @@ - - mail.message.subtype.tree mail.message.subtype - tree 10 - + @@ -23,42 +18,27 @@ mail.message.subtype.form mail.message.subtype - form
                    - - - - - - - + + +
                    - + Subtypes mail.message.subtype form tree,form - -

                    - Click to create a message subtype. -

                    - OpenERP's message subtype allows to ease and fasten the - subtype which helps to decrease over crowdy wall comments which displays - only those. -

                    -
                    - +
                    From 64672b176447c662408e853f5980a0f8f6c6f675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 13:43:53 +0200 Subject: [PATCH 131/245] [CLEAN] mail: comment xml_id is now mt_comment. Propagated change. Slighty cleaned code in base_status. bzr revid: tde@openerp.com-20120919114353-8s9lo6tp78tnwj56 --- addons/base_status/base_stage.py | 27 +++++++++---------- .../crm/test/process/crm_message_subtype.yml | 2 +- addons/mail/data/mail_data.xml | 2 +- addons/mail/mail_thread.py | 4 +-- addons/mail/tests/test_mail.py | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 2695567e0a1..859e577bf31 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -349,6 +349,15 @@ class base_stage(object): """ return '' + def find_subtype_xml_id(self, cr, uid, ids, name, context=None): + ir_model_data_obj = self.pool.get('ir.model.data') + subtype_ids = self.pool.get('mail.message.subtype').search(cr, uid, [('res_model', '=', self._name), ('name', '=', name)], context=context) + ir_data_ids = ir_model_data_obj.search(cr, uid, [('model', '=', 'mail.message.subtype'), ('res_id', 'in', subtype_ids)], context=context) + ir_model_data_record = ir_model_data_obj.browse(cr, uid, ir_data_ids, context=context) + if ir_model_data_record: + return ir_model_data_record[0].name + return None + def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Send a notification when the stage changes. This method has to be overriden, because each document will have its particular @@ -360,31 +369,21 @@ class base_stage(object): def case_open_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been opened.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) + xml_id = self.find_subtype_xml_id(cr, uid, ids, name="open", context=context) + self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True - - def find_xml_id(self,cr,uid,ids,name,context=None): - subtype_obj = self.pool.get('mail.message.subtype') - ir_model_data_obj = self.pool.get('ir.model.data') - subtype_ids = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) - ir_data_ids = ir_model_data_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_ids)]) - xml_id = 'mail_subtype_comment' - ir_model_data_record = ir_model_data_obj.browse(cr,uid,ir_data_ids) - if ir_model_data_record: - xml_id = ir_model_data_record[0].name - return xml_id def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="closed", context=context) + xml_id = self.find_subtype_xml_id(cr, uid, ids, name="closed", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context=context) + xml_id = self.find_subtype_xml_id(cr, uid, ids, name="cancel", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index a1ad9a9c39a..bec5f730fa7 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -8,7 +8,7 @@ - I have add the sub_type name comment with default true - - !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: + !record {model: mail.message.subtype, id: mail.mt_comment }: name: comment res_model: crm.lead - diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index c8eb8829d64..5fe1ee45b1d 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -13,7 +13,7 @@
                    - + comment diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 9ce3a8c8f95..400f3ccaa2d 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -562,8 +562,8 @@ class mail_thread(osv.AbstractModel): "now deprecated res.log.") self.message_post(cr, uid, [id], message, context=context) - def message_post(self, cr, uid, thread_id, body='', subject=False, - type='notification', parent_id=False, attachments=None, subtype_xml_id='mail_subtype_comment', context=None, **kwargs): + def message_post(self, cr, uid, thread_id, body='', subject=False, type='notification', + subtype_xml_id=None, parent_id=False, attachments=None, context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 2dfb7a75136..1ecdc4b6e5f 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -702,7 +702,7 @@ class test_mail(TestMailMockups): _mail_bodyalt2 = 'Pigs rules\nAdmin\n' filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment') + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mt_comment') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") From f59a9a83bbd7d75fb885717abe13a475e18fa8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 13:46:12 +0200 Subject: [PATCH 132/245] [CLEAN] sale: cleaned subtypes. bzr revid: tde@openerp.com-20120919114612-6vrcnzl2up2cdqzk --- addons/sale/sale.py | 8 ++++---- addons/sale/sale_data.xml | 18 ++++-------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index cc6e5f71f30..ba85a62ca1d 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1028,7 +1028,7 @@ class sale_order(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype_xml_id="mt_sale_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -1036,7 +1036,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): @@ -1048,7 +1048,7 @@ class sale_order(osv.osv): self.message_post(cr, uid, [order.id], body=_("Delivery Order %s scheduled for %s.") % (picking.name, picking_date_str), context=context) def delivery_end_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Order delivered."), subtype_xml_id="sale_subtype_delivered", context=context) + self.message_post(cr, uid, ids, body=_("Order delivered."), subtype_xml_id="mt_sale_delivered", context=context) def invoice_paid_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="sale_subtype_paid", context=context) @@ -1056,7 +1056,7 @@ class sale_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="sale_subtype_pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) def action_cancel_draft_send_note(self, cr, uid, ids, context=None): return self.message_post(cr, uid, ids, body=_('Sale order set to draft.'), context=context) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index 4337c4bd1e8..3be79035fc6 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -44,26 +44,16 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. - - new + + create sale.order - - cancelled - sale.order - - - + paid sale.order - - pending - sale.order - - - + delivered sale.order From 4fa322cfe5334473676b03e8ac6e9ed06eb552b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 13:51:56 +0200 Subject: [PATCH 133/245] [CLEAN] stock: cleaned subtypes. bzr revid: tde@openerp.com-20120919115156-mi80hp8jprnag506 --- addons/stock/stock.py | 16 ++++++---------- addons/stock/stock_data.xml | 22 +++++----------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 77849e12627..f96c3582a6d 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1379,13 +1379,13 @@ class stock_picking(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype_xml_id="stock_in_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype_xml_id="mt_stock_new", context=context) def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None): - return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name),context=context) + return self.message_post(cr, uid, ids, body=_("%s %s %s has been moved to scrap.") % (quantity, uom, name), context=context) def back_order_send_note(self, cr, uid, ids, back_name, context=None): - return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype_xml_id="stock_in_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype_xml_id="mt_stock_new", context=context) def ship_done_send_note(self, cr, uid, ids, context=None): type_dict = { @@ -1394,19 +1394,15 @@ class stock_picking(osv.osv): 'internal': 'moved', } xml_id_dict = { - 'out':'stock_out_subtype_delivered', - 'in' : 'stock_in_subtype_received' + 'out': 'mt_stock_delivered', + 'in': 'mt_stock_received' } for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype_xml_id=xml_id_dict.get(obj.type), context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): - xml_id_dict = { - 'out':'stock_out_subtype_cancelled', - 'in' : 'stock_in_subtype_cancelled' - } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id=xml_id_dict.get(obj.type), context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index a59642fa912..1ab30af2abc 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -167,30 +167,18 @@ watch your stock valuation, and track production lots upstream and downstream (b - - - new + + + created stock.picking.in - + delivered stock.picking.out - - + received stock.picking.in - - - - cancelled - stock.picking.in - - - cancelled - stock.picking.out From 5e9f78ebfd3b5a996b78fc598417bc68fe33ec9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:00:00 +0200 Subject: [PATCH 134/245] [CLEAN] project_issue: cleaned subtypes. bzr revid: tde@openerp.com-20120919120000-62v9f5e24fh3grzd --- addons/project_issue/project_issue.py | 4 +-- addons/project_issue/project_issue_data.xml | 38 +++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 83eddb83d5e..0677fbfbd75 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -503,7 +503,7 @@ class project_issue(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="issue_subtype_stage_change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="mt_issue_new", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): """ Override of default prefix for notifications. """ @@ -515,7 +515,7 @@ class project_issue(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="issue_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_issue_new", context=context) def case_escalate_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index f6c225a4d00..edd44e52dd2 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -30,27 +30,7 @@ v3.0 - - - - new - project.issue - - - - stage change - project.issue - - - - cancelled - project.issue - - - - closed - project.issue - + mail.group @@ -62,5 +42,21 @@ You can record issues, assign them to a responsible person, and keep track of th Access all issues from the top Project menu, and access the issues of a specific project via the projects gallery view.
                    + + + created + project.issue + + + + stage change + project.issue + + + + closed + project.issue + + From bd998703847e01fdceb565484bbfaf690586d7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:03:33 +0200 Subject: [PATCH 135/245] [CLEAN] purchase: cleaned subtypes. bzr revid: tde@openerp.com-20120919120333-sc1vyw0jzfjltin7 --- addons/purchase/purchase.py | 12 ++++++------ addons/purchase/purchase_data.xml | 18 ++++-------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 8bcd6d39ef9..9fe05da33fc 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -741,7 +741,7 @@ class purchase_order(osv.osv): return [('state', '=', 'draft')] def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype_xml_id="purchase_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype_xml_id="mt_purchase_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -759,20 +759,20 @@ class purchase_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="purchase_subtype_pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) def shipment_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype_xml_id="purchase_subtype_received", context=context) + self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype_xml_id="mt_purchase_received", context=context) def invoice_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="purchase_subtype_paid", context=context) + self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="mt_purchase_paid", context=context) def draft_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), subtype_xml_id="purchase_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), subtype_xml_id="mt_purchase_new", context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="purchase_subtype_cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index aa62e84e19d..25981e2e01a 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -49,28 +49,18 @@ You can also manage purchase requisitions, see also the Purchase Settings. - - new + + created purchase.order - + paid purchase.order - - pending - purchase.order - - - + received purchase.order - - cancelled - purchase.order - - From dbcb9b2b1e5048c61819769bacaccf858425fd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:06:02 +0200 Subject: [PATCH 136/245] [CLEAN] purchase_requisition: cleaned subtypes. bzr revid: tde@openerp.com-20120919120602-1klpv75xzs5ngw3n --- .../purchase_requisition/purchase_requisition.py | 14 +++++++------- .../purchase_requisition_data.xml | 13 +++++-------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 98fbdd1c5b1..7ce03d7a623 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -92,15 +92,15 @@ class purchase_requisition(osv.osv): def in_progress_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Draft Requisition has been sent to suppliers."), context=context) - + def reset_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype_xml_id="requisition_subtype_new", context=context) - + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype_xml_id="mt_requisition_new", context=context) + def done_to_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype_xml_id="requisition_subtype_closed", context=context) - + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype_xml_id="mt_requisition_closed", context=context) + def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype_xml_id="requisition_subtype_cancelled", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), context=context) def _planned_date(self, requisition, delay=0.0): company = requisition.company_id @@ -183,7 +183,7 @@ class purchase_requisition(osv.osv): return res def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype_xml_id="requisition_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype_xml_id="mt_requisition_new", context=context) def create(self, cr, uid, vals, context=None): requisition = super(purchase_requisition, self).create(cr, uid, vals, context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 534bf2fe2a7..7ca50f6a80c 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -6,17 +6,14 @@ id="purchase_default_set" model="ir.values" name="set"/> - - - closed - purchase.requisition - - + + + new purchase.requisition - - cancelled + + closed purchase.requisition From cd1c44568e65c21d1e6740a44a0796bc31662dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:13:30 +0200 Subject: [PATCH 137/245] [CLEAN] crm, crm_claim: cleaned subtypes. bzr revid: tde@openerp.com-20120919121330-rc4mv900fhynqu6v --- addons/crm/crm_lead.py | 8 +++--- addons/crm/crm_lead_data.xml | 15 ++++------- addons/crm_claim/crm_claim.py | 6 ++--- addons/crm_claim/crm_claim_data.xml | 42 +++++++++++++---------------- 4 files changed, 30 insertions(+), 41 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 81ca828dc76..a7337b7178f 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -842,7 +842,7 @@ class crm_lead(base_stage, format_address, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="crm_subtype_stage_change",context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="mt_crm_stage",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -852,16 +852,16 @@ class crm_lead(base_stage, format_address, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=message, subtype_xml_id="crm_subtype_new", context=context) + self.message_post(cr, uid, [id], body=message, subtype_xml_id="mt_crm_new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_post(cr, uid, ids, body=message,subtype_xml_id="crm_subtype_lost", context=context) + return self.message_post(cr, uid, ids, body=message,subtype_xml_id="mt_crm_lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="crm_subtype_won", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_crm_won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 633782ed233..e347a7a03af 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -155,29 +155,24 @@ - - new + + created crm.lead - + won crm.lead - + lost crm.lead - + stage change crm.lead - - cancelled - crm.lead - - diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index ce2427b9752..fc80e320c08 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -238,16 +238,16 @@ class crm_claim(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been created.') - return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_new', context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='mt_claim_new', context=context) def case_refuse_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been refused.') - return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_refused', context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='mt_claim_refused', context=context) def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.claim.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id='claim_subtype_stage_change', context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id='mt_claim_stage', context=context) class res_partner(osv.osv): diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index e68bc3ad6cb..5e79220aea8 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -76,30 +76,24 @@ - - - new - crm.claim - - - - refused - crm.claim - - - - stage change - crm.claim - - - cancelled - crm.claim - - - - closed - crm.claim - + + + created + crm.claim + + + refused + crm.claim + + + + stage change + crm.claim + + + closed + crm.claim + From 27f2ceecac030305c7566bf26c92cc99b54b14fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:31:17 +0200 Subject: [PATCH 138/245] [CLEAN] event: cleaned subtypes. bzr revid: tde@openerp.com-20120919123117-ohey5we13wusgi0g --- addons/event/event.py | 20 ++++++++++---------- addons/event/event_data.xml | 34 +++++++++++----------------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index feebd3a3f93..1bd52f2389b 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -293,17 +293,17 @@ class event_event(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Event has been created.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_event_new", context=context) return True def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_event_cancel", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): message = _("Event has been set to draft.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_event_new", context=context) return True def button_done_send_note(self, cr, uid, ids, context=None): @@ -313,7 +313,7 @@ class event_event(osv.osv): def button_confirm_send_note(self, cr, uid, ids, context=None): message = _("Event has been confirmed.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_confirmed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_event_confirm", context=context) return True event_event() @@ -359,7 +359,7 @@ class event_registration(osv.osv): return self.write(cr, uid, ids, {'state': 'draft'}, context=context) def confirm_registration(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_('State set to open'),subtype_xml_id="registration_subtype_confirmed", context=context) + self.message_post(cr, uid, ids, body=_('State set to open'),subtype_xml_id="mt_registration_confirm", context=context) return self.write(cr, uid, ids, {'state': 'open'},context=context) def create(self, cr, uid, vals, context=None): @@ -389,13 +389,13 @@ class event_registration(osv.osv): if today >= registration.event_id.date_begin: values = {'state': 'done', 'date_closed': today} self.write(cr, uid, ids, values) - self.message_post(cr, uid, ids, body=_('State set to Done'), subtype_xml_id="registration_subtype_closed", context=context) + self.message_post(cr, uid, ids, body=_('State set to Done'), context=context) else: - raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") ) + raise osv.except_osv(_('Error!'), _("You must wait for the starting day of the event to do this action.")) return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype_xml_id="registration_subtype_cancelled", context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype_xml_id="mt_registration_cancel", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): @@ -465,12 +465,12 @@ class event_registration(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Registration has been created.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def do_draft_send_note(self, cr, uid, ids, context=None): message = _("Registration has been set as draft.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True event_registration() diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 251f78973c7..9fa16b77689 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -11,43 +11,31 @@ open - - - new + + + + created event.event - - closed - event.event - - - cancelled + + canceled event.event - + confirmed event.event - - - new - event.registration - - - - closed - event.registration - - - cancelled + + + canceled event.event - + confirmed event.registration From 4312649fb5b1759efdcb6daef6eeda301d800ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:33:18 +0200 Subject: [PATCH 139/245] [FIX] mail_thread: moved get_object_reference into if exist. bzr revid: tde@openerp.com-20120919123318-k2wax6npnm1tw1mm --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 400f3ccaa2d..a3cd727aeb6 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -600,8 +600,8 @@ class mail_thread(osv.AbstractModel): values = kwargs subtype_obj = self.pool.get('mail.message.subtype') - ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) if subtype_xml_id: + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) if self._name == subtype_browse.res_model: values['subtype_id']=subtype_browse.id From 378966f9f1c0dc9d1f7aca8dbc666eff4cda74d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:05:14 +0200 Subject: [PATCH 140/245] [FIX] event: fixed xml_id not existing. bzr revid: tde@openerp.com-20120919130514-oeto9qfiujd3v71e --- addons/event/event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/event/event.py b/addons/event/event.py index 1bd52f2389b..5797e12355c 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -308,7 +308,7 @@ class event_event(osv.osv): def button_done_send_note(self, cr, uid, ids, context=None): message = _("Event has been done.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_closed", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def button_confirm_send_note(self, cr, uid, ids, context=None): From b9820db8f0b7c81429dd0c3471cb4835ef11c195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:12:40 +0200 Subject: [PATCH 141/245] [CLEAN] hr_holidays, hr_recruitment, idea, mrp: cleaned subtypes. bzr revid: tde@openerp.com-20120919131240-7cc61fqg5eoom9zt --- addons/hr_holidays/hr_holidays.py | 28 +++++++++---------- addons/hr_holidays/hr_holidays_data.xml | 12 ++++---- addons/hr_recruitment/hr_recruitment.py | 14 +++++----- addons/hr_recruitment/hr_recruitment_data.xml | 18 +++--------- addons/idea/idea.py | 18 ++++++------ addons/idea/idea_data.xml | 19 ------------- addons/mrp/mrp.py | 10 +++---- addons/mrp/mrp_data.xml | 22 +++++---------- 8 files changed, 50 insertions(+), 91 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 4e85313e2e4..731efad4d8d 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -352,44 +352,42 @@ class hr_holidays(osv.osv): def needaction_domain_get(self, cr, uid, ids, context=None): # to be tested, otherwise convert into employee_id in ... emp_obj = self.pool.get('hr.employee') - empids = emp_obj.search(cr, uid, [('parent_id.user_id','=',uid)], context=context) - dom = [ - '&', ('state','=','confirm'),('employee_id', 'in', empids) - ] + empids = emp_obj.search(cr, uid, [('parent_id.user_id', '=', uid)], context=context) + dom = ['&', ('state', '=', 'confirm'), ('employee_id', 'in', empids)] # if this user is a hr.manager, he should do second validations if self.pool.get('res.users').has_group(cr, uid, 'base.group_hr_manager'): - dom = ['|'] + dom + [ ('state','=','validate1') ] + dom = ['|'] + dom + [('state', '=', 'validate1')] return dom def create_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, ids, - _("The request has been created and is waiting confirmation."),subtype_xml_id="hr_holidays_subtype_new", context=context) + self.message_post(cr, uid, ids, + _("The request has been created and is waiting confirmation."), context=context) return True - + def holidays_confirm_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been submitted and is waiting for validation by the manager."), context=context) - + _("The request has been submitted and is waiting for validation by the manager."), subtype_xml_id="mt_holidays_confirm", context=context) + def holidays_first_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], _("The request has been approved. A second validation is necessary and is now pending."), context=context) - + def holidays_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): if obj.double_validation: - self.message_post(cr, uid, [obj.id], + self.message_post(cr, uid, [obj.id], _("The request has been double validated. The validation process is now over."), context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_approved", context=context) - + _("The request has been approved. The validation process is now over."), subtype_xml_id="mt_holidays_closed", context=context) + def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_refused", context=context) + _("The request has been refused. The validation process is now over."), subtype_xml_id="mt_holidays_refused", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index 0eb411e90cb..50a3f3fde17 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -43,17 +43,17 @@ Once validated, they are visible in the employee's calendar. HR officers can def True brown - - - new + + + + confirmed hr.holidays - - + approved hr.holidays - + refused hr.holidays diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index ec2ea806fec..49a80ef26d6 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -461,14 +461,14 @@ class hr_applicant(base_stage, osv.Model): """ Override of the (void) default notification method. """ if not stage_id: return True stage_name = self.pool.get('hr.recruitment.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="hr_recruitment_subtype_stage_change", context=context) + return self.message_post(cr, uid, ids, body=_("Stage changed to %s.") % (stage_name), context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): return 'Applicant' def case_open_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been set in progress.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_in_progress", context=context) + return self.message_post(cr, uid, ids, body=message, context=context) def case_close_send_note(self, cr, uid, ids, context=None): if context is None: @@ -476,23 +476,23 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="mt_recruitment_hired", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="mt_recruitment_hired", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, subtype_xml_id="hr_recruitment_subtype_refused", context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id="mt_recruitment_refused", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_recruitment_new", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been created.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_recruitment_new", context=context) class hr_job(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index dedeb20a3dc..1fb79227770 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -461,30 +461,20 @@ You can automatically receive job application though an email gateway, see the H - - + + new hr.applicant - - + hired hr.applicant - + refused hr.applicant - - stage change - hr.applicant - - - - in progress - hr.applicant - diff --git a/addons/idea/idea.py b/addons/idea/idea.py index f8346ec2bba..14fbe5eda17 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -66,23 +66,21 @@ class idea_idea(osv.osv): _order = 'name asc' def idea_cancel(self, cr, uid, ids, context={}): - self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea cancelled.'), subtype_xml_id="idea_subtype_cancelled", context=context) + self.write(cr, uid, ids, {'state': 'cancel'}, context=context) + self.message_post(cr, uid, ids, body=_('Idea cancelled.'), context=context) return True def idea_open(self, cr, uid, ids, context={}): - self.write(cr, uid, ids, { 'state': 'open'}) - self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype_xml_id="idea_subtype_open", context=context) + self.write(cr, uid, ids, {'state': 'open'}, context=context) + self.message_post(cr, uid, ids, body=_('Idea accepted.'), context=context) return True def idea_close(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea closed.'), subtype_xml_id="idea_subtype_closed", context=context) - self.write(cr, uid, ids, { 'state': 'close' }) + self.write(cr, uid, ids, {'state': 'close'}, context=context) + self.message_post(cr, uid, ids, body=_('Idea closed.'), context=context) return True def idea_draft(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype_xml_id="idea_subtype_new", context=context) - self.write(cr, uid, ids, { 'state': 'draft' }) + self.write(cr, uid, ids, {'state': 'draft'}, context=context) + self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), context=context) return True -idea_idea() - diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index b4f3f70d2dd..421cb6a9eef 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -16,25 +16,6 @@ - - - new - idea.idea - - - - open - idea.idea - - - cancelled - idea.idea - - - - closed - idea.idea - diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index bc0baae71e8..b4dece5dfa4 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1044,27 +1044,27 @@ class mrp_production(osv.osv): # --------------------------------------------------- def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype_xml_id="mrp_subtype_new", context=context) + self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype_xml_id="mt_mrp_order_new", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been canceled.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_mrp_order_canceled", context=context) return True def action_ready_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is ready to produce.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_ready", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def action_in_production_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is in production.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_production", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been done.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_mrp_order_closed", context=context) return True def action_confirm_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mrp/mrp_data.xml b/addons/mrp/mrp_data.xml index 3740f03bdc8..79e202cd8e0 100644 --- a/addons/mrp/mrp_data.xml +++ b/addons/mrp/mrp_data.xml @@ -26,27 +26,19 @@ From the Manufacturing Settings, you can choose to compute production schedules 1 1 - - - new + + + + created mrp.production - - ready + + canceled mrp.production - - production - mrp.production - - - cancelled - mrp.production - - - + closed mrp.production From 10458eb098a79336183532e114a3a38360b92cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:35:40 +0200 Subject: [PATCH 142/245] [CLEAN] mrp_operation, analytic, account, account_voucher: cleaned subtypes. bzr revid: tde@openerp.com-20120919133540-e0d8huak2g3v915o --- addons/account/account_invoice.py | 11 +++++++---- addons/account/data/account_data.xml | 15 +++++---------- addons/account_voucher/account_voucher.py | 6 +++--- .../account_voucher/account_voucher_data.xml | 14 +++++++------- addons/analytic/analytic.py | 3 ++- addons/analytic/analytic_data.xml | 5 +++-- addons/mrp_operations/mrp_operation_data.xml | 19 +++++-------------- addons/mrp_operations/mrp_operations.py | 10 +++++----- 8 files changed, 37 insertions(+), 46 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index b8f3a9071a0..a145e5c06be 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1306,16 +1306,19 @@ class account_invoice(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype_xml_id="analytic_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s created.") % (self._get_document_type(obj.type)), + subtype_xml_id="mt_invoice_new", context=context) def confirm_paid_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_paid", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), + subtype_xml_id="mt_invoice_paid", context=context) def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_cancelled", context=context) -account_invoice() + self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), + context=context) + class account_invoice_line(osv.osv): diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 7689ca2c253..007ef33c8c2 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,20 +560,15 @@ Invoice account.invoice - - - new + + + + created account.invoice - - + paid account.invoice - - cancelled - account.invoice - - diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 05a75f5847d..632367b74bc 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1295,17 +1295,17 @@ class account_voucher(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s created." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="mt_voucher_new", context=context) def post_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s '%s' is posted." % (self._document_type[obj.type or False], obj.move_id.name) - self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_post", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="mt_voucher_post", context=context) def reconcile_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s reconciled." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_reconcile", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="mt_voucher_reconciled", context=context) account_voucher() diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index a59993aae6b..b69a694faff 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -12,18 +12,18 @@ You can track customer payments easily and automate the reminders. You get an ov If you want to use advanced accounting features, you should install the "Accounting and Finance" module. Module eInvoicing & Payments has been installed. - - - new + + + + created account.voucher - + post account.voucher - - - reconcile + + reconciled account.voucher diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 250ad98a603..0aa6b5406c0 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -281,7 +281,8 @@ class account_analytic_account(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype_xml_id="analytic_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), + subtype_xml_id="mt_account_new", context=context) account_analytic_account() diff --git a/addons/analytic/analytic_data.xml b/addons/analytic/analytic_data.xml index cfd3b5e9b78..1bee414e66a 100644 --- a/addons/analytic/analytic_data.xml +++ b/addons/analytic/analytic_data.xml @@ -1,10 +1,11 @@ - + + + new account.analytic.account - \ No newline at end of file diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index 812ce3da536..45d79860b0e 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -30,27 +30,18 @@ done - - + + new mrp.production.workcenter.line - - started + + canceled mrp.production.workcenter.line - - pending - mrp.production.workcenter.line - - - cancelled - mrp.production.workcenter.line - - - + closed mrp.production.workcenter.line diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 53eaceed066..efac450f7f2 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_new", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mt_workcenter_new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_started", context=context) + self.message_post(cr, uid, [workorder.id], body=message, context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_closed", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mt_workcenter_closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_pending", context=context) + self.message_post(cr, uid, [workorder.id], body=message, context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_cancelled", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mt_workcenter_canceled", context=context) return True mrp_production_workcenter_line() From e30e4064587a8ae8167801cb5f4d866270770997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:39:50 +0200 Subject: [PATCH 143/245] [CLEAN] hr_timesheet_invoice: cleaned subtypes, moved analytic account subtypes to the related module. bzr revid: tde@openerp.com-20120919133950-upc80g20b711t8c0 --- addons/analytic/analytic_data.xml | 10 +++++++++ .../hr_timesheet_invoice.py | 22 +++++++++---------- .../hr_timesheet_invoice_data.xml | 19 ---------------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/addons/analytic/analytic_data.xml b/addons/analytic/analytic_data.xml index 1bee414e66a..934827b0334 100644 --- a/addons/analytic/analytic_data.xml +++ b/addons/analytic/analytic_data.xml @@ -7,5 +7,15 @@ new account.analytic.account + + closed + account.analytic.account + + + canceled + account.analytic.account + + + \ No newline at end of file diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index e3f54609e95..5dd8053e2c1 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -84,8 +84,8 @@ class account_analytic_account(osv.osv): res['value']['to_invoice'] = ir_model_obj.get_object_reference(cr, uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor1')[1] return res - def on_change_partner_id(self, cr, uid, ids,partner_id, name, context=None): - res = super(account_analytic_account,self).on_change_partner_id(cr, uid, ids,partner_id, name, context=context) + def on_change_partner_id(self, cr, uid, ids, partner_id, name, context=None): + res = super(account_analytic_account, self).on_change_partner_id(cr, uid, ids, partner_id, name, context=context) part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False if pricelist: @@ -93,27 +93,27 @@ class account_analytic_account(osv.osv): return res def set_close(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, {'state':'close'}, context=context) + self.write(cr, uid, ids, {'state': 'close'}, context=context) message = _("Contract has been closed.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_account_closed", context=context) return True def set_cancel(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, {'state':'cancelled'}, context=context) - message = _("Contract has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_invoice_subtype_cancelled", context=context) + self.write(cr, uid, ids, {'state': 'cancelled'}, context=context) + message = _("Contract has been canceled.") + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_account_canceled", context=context) return True def set_open(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, {'state':'open'}, context=context) + self.write(cr, uid, ids, {'state': 'open'}, context=context) message = _("Contract has been opened.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_open", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def set_pending(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, {'state':'pending'}, context=context) + self.write(cr, uid, ids, {'state': 'pending'}, context=context) message = _("Contract has been set as pending.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_pending", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True account_analytic_account() diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml index 29a3233f509..462888e0b39 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml @@ -16,24 +16,5 @@ 50% 50.0 - - - closed - account.analytic.account - - - pending - account.analytic.account - - - - open - account.analytic.account - - - cancelled - account.analytic.account - - From d85ca655ad0f71bb877811c88009af2df0772408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:43:47 +0200 Subject: [PATCH 144/245] [REV] account_voucher: reverted change in notification of account_voucher, somebody took away the message and set back the old message_post way of doing it. bzr revid: tde@openerp.com-20120919134347-0tp2r52dfzddcuh5 --- addons/account_voucher/account_voucher_data.xml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index b69a694faff..938836cc5ce 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -1,17 +1,14 @@ + - - - - OpenERP's electronic invoicing allows to ease and fasten the creation of invoices and collection of customer payments. Invoices are created in a few clicks and your customers receive them by email. They can pay online and/or import them in their own system. - -You can track customer payments easily and automate the reminders. You get an overview of the discussion with your customers on each invoice to ensure a full traceability. - -If you want to use advanced accounting features, you should install the "Accounting and Finance" module. - Module eInvoicing & Payments has been installed. - + + mail.group + + notification + eInvoicing & Payments application installed! + OpenERP's electronic invoicing accelerates the creation of invoices and collection of customer payments. Invoices are created in a few clicks and your customers receive them by email. They can pay online and/or import them in their own system. You can track customer payments easily and automate follow-ups. You get an overview of the discussion with your customers on each invoice for easier traceability. For advanced accounting features, you should install the "Accounting and Finance" module. From e560a74cb550ed1290d165ca1f37657178632549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:54:23 +0200 Subject: [PATCH 145/245] [CLEAN] project: cleaned subtypes. bzr revid: tde@openerp.com-20120919135423-ldfd3fx4wtyss7ae --- addons/project/project.py | 22 ++++++-------- addons/project/project_data.xml | 54 ++++++++++++++------------------- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index f430cd4993a..58bc3714526 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -514,23 +514,19 @@ def Project(): return project_id def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype_xml_id="project_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype_xml_id="mt_project_new", context=context) def set_open_send_note(self, cr, uid, ids, context=None): - message = _("Project has been opened.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_open", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been opened."), context=context) def set_pending_send_note(self, cr, uid, ids, context=None): - message = _("Project is now pending.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_pending", context=context) + return self.message_post(cr, uid, ids, body=_("Project is now pending."), context=context) def set_cancel_send_note(self, cr, uid, ids, context=None): - message = _("Project has been cancelled.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_cancelled", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been canceled."), context=context) def set_close_send_note(self, cr, uid, ids, context=None): - message = _("Project has been closed.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_closed", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been closed."), subtype_xml_id="mt_project_closed", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly @@ -1231,14 +1227,14 @@ class task(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="task_subtype_stage_change", context=context) + return self.message_post(cr, uid, ids, body=_("Stage changed to %s.") % (stage_name), + subtype_xml_id="mt_task_change", context=context) def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype_xml_id="task_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype_xml_id="mt_task_new", context=context) def case_draft_send_note(self, cr, uid, ids, context=None): - msg = _('Task has been set as draft.') - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=_('Task has been set as draft.'), subtype_xml_id="mt_task_new", context=context) def do_delegation_send_note(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 0544b6d4e78..e7f486e834f 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -83,49 +83,41 @@ - - - - new + + + + created project.project - - new - project.task - - - - open - project.project - - - pending - project.project - - - + closed project.project - + + canceled + project.task + + + stage changed + project.task + + + + created + project.task + + closed project.task - - cancelled - project.project - - - - cancelled + + canceled project.task - - - stage change + + stage changed project.task - From 1b79a43833a3d6bee6dfdf8ae5e1340103131394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 09:56:22 +0200 Subject: [PATCH 146/245] [FIX] hr_rcruitment: fixed error in xml file. bzr revid: tde@openerp.com-20120920075622-mn10nv2vu7rkiddx --- addons/hr_recruitment/hr_recruitment_data.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 1fb79227770..a0a5ca4ab02 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -474,7 +474,6 @@ You can automatically receive job application though an email gateway, see the H refused hr.applicant - From 7df8619cbda6823d199be935980a88c88a6338c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 10:32:48 +0200 Subject: [PATCH 147/245] [FIX] account_voucher: fixed missin record tag in xml file. bzr revid: tde@openerp.com-20120920083248-ayvo8t141e6th3ej --- addons/account_voucher/account_voucher_data.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index 938836cc5ce..65336e9ddcb 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -9,6 +9,7 @@ notification eInvoicing & Payments application installed! OpenERP's electronic invoicing accelerates the creation of invoices and collection of customer payments. Invoices are created in a few clicks and your customers receive them by email. They can pay online and/or import them in their own system. You can track customer payments easily and automate follow-ups. You get an overview of the discussion with your customers on each invoice for easier traceability. For advanced accounting features, you should install the "Accounting and Finance" module. + From ed3518d858392cbdd7fd4780c9985fc27ac0c77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 12:17:04 +0200 Subject: [PATCH 148/245] [CLEAN] Cleaned subtype model, implementation and tests. Added a message_subtype_data field, holding data about subtypes. This will allow to avoid doing too much calls from the front-end. bzr revid: tde@openerp.com-20120920101704-cri6zq7sqi7y660b --- addons/mail/mail_followers.py | 6 +- addons/mail/mail_message.py | 27 +++--- addons/mail/mail_thread.py | 99 +++++++++++++++------- addons/mail/tests/test_mail.py | 89 ++++++++++--------- addons/mail/wizard/mail_compose_message.py | 2 +- 5 files changed, 135 insertions(+), 88 deletions(-) diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index 6b1f2d302bc..e77e4a3d4da 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -45,10 +45,8 @@ class mail_followers(osv.Model): help='Id of the followed resource'), 'partner_id': fields.many2one('res.partner', string='Related Partner', ondelete='cascade', required=True, select=1), - 'subtype_ids': fields.many2many('mail.message.subtype', - 'mail_message_subtyp_rel', - 'subscription_id', 'subtype_id', 'Subtype', - help = "linking some subscription to several subtype for projet/task"), + 'subtype_ids': fields.many2many('mail.message.subtype', string='Subtype', + help="Message subtypes followed, meaning subtypes that will be pushed onto the user's Wall."), } diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 65ee7f41d77..793345ffb32 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -354,27 +354,24 @@ class mail_message(osv.Model): """ Add the related record followers to the destination partner_ids. Call mail_notification.notify to manage the email sending """ - followers_obj = self.pool.get("mail.followers") message = self.browse(cr, uid, newid, context=context) partners_to_notify = set([]) - # add all partner_ids of the message + # message has no subtype_id: pure log message -> no partners, no one notified + if not message.subtype_id: + message.write({'partner_ids': [5]}) + return True + # all partner_ids of the mail.message have to be notified if message.partner_ids: partners_to_notify |= set(partner.id for partner in message.partner_ids) - # add all followers and set add them in partner_ids + # all followers of the mail.message document have to be added as partners and notified if message.model and message.res_id: - record = self.pool.get(message.model).browse(cr, uid, message.res_id, context=context) - extra_notified = set(partner.id for partner in record.message_follower_ids) + fol_obj = self.pool.get("mail.followers") + fol_ids = fol_obj.search(cr, uid, [('res_model', '=', message.model), ('res_id', '=', message.res_id), ('subtype_ids', 'in', message.subtype_id.id)], context=context) + fol_objs = fol_obj.browse(cr, uid, fol_ids, context=context) + extra_notified = set(fol.partner_id.id for fol in fol_objs) missing_notified = extra_notified - partners_to_notify - missing_follow_ids = [] - if message.subtype_id: - for p_id in missing_notified: - follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)], context=context) - if follow_ids and len(follow_ids): - missing_follow_ids.append(p_id) - subtype_record = self.pool.get('mail.message.subtype').browse(cr, uid, message.subtype_id.id,context=context) - if not subtype_record.res_model: - missing_follow_ids.append(p_id) - message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) + if missing_notified: + message.write({'partner_ids': [(4, p_id) for p_id in missing_notified]}) partners_to_notify |= extra_notified self.pool.get('mail.notification').notify(cr, uid, list(partners_to_notify), newid, context=context) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index a3cd727aeb6..39a8e011f3c 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -95,6 +95,7 @@ class many2many_reference(fields.many2many): else: return super(many2many_reference, self).set(cr, model, id, name, values, user, context) + class mail_thread(osv.AbstractModel): ''' mail_thread model is meant to be inherited by any model that needs to act as a discussion topic on which messages can be attached. Public @@ -117,8 +118,10 @@ class mail_thread(osv.AbstractModel): _description = 'Email Thread' def _get_message_data(self, cr, uid, ids, name, args, context=None): + """ Computes: + - message_unread: has uid unread message for the document + - message_summary: html snippet summarizing the Chatter for kanban views """ res = dict((id, dict(message_unread=False, message_summary='')) for id in ids) - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) notif_obj = self.pool.get('mail.notification') notif_ids = notif_obj.search(cr, uid, [ @@ -133,7 +136,35 @@ class mail_thread(osv.AbstractModel): for thread in self.browse(cr, uid, ids, context=context): cls = res[thread.id]['message_unread'] and ' class="oe_kanban_mail_new"' or '' res[thread.id]['message_summary'] = "9 %d + %d" % (cls, len(thread.message_comment_ids), len(thread.message_follower_ids)) - res[thread.id]['message_is_follower'] = user.partner_id.id in [follower.id for follower in thread.message_follower_ids] + return res + + def _get_subscription_data(self, cr, uid, ids, name, args, context=None): + """ Computes: + - message_is_follower: is uid in the document followers + - message_subtype_data: data about document subtypes: which are + available, which are followed if any """ + res = dict((id, dict(message_subtype_data='')) for id in ids) + user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0] + + # find current model subtypes, add them to a dictionary + subtype_obj = self.pool.get('mail.message.subtype') + subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context) + subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context)) + + # find the document followers, update the data + fol_obj = self.pool.get('mail.followers') + fol_ids = fol_obj.search(cr, uid, [ + ('partner_id', '=', user_pid), + ('res_id', 'in', ids), + ('res_model', '=', self._name), + ], context=context) + for fol in fol_obj.browse(cr, uid, fol_ids, context=context): + thread_subtype_dict = subtype_dict.copy() + res[fol.res_id]['message_is_follower'] = True + for subtype in fol.subtype_ids: + thread_subtype_dict[subtype.name]['followed'] = True + res[fol.res_id]['message_subtype_data'] = '%s' % thread_subtype_dict + return res def _search_unread(self, cr, uid, obj=None, name=None, domain=None, context=None): @@ -150,8 +181,13 @@ class mail_thread(osv.AbstractModel): return [('id', 'in', res.keys())] _columns = { - 'message_is_follower': fields.function(_get_message_data, - type='boolean', string='Is a Follower', multi='_get_message_data'), + 'message_is_follower': fields.function(_get_subscription_data, + type='boolean', string='Is a Follower', multi='_get_subscription_data,'), + 'message_subtype_data': fields.function(_get_subscription_data, + type='text', string='Subscription data', multi="_get_subscription_data", + help="Holds data about the subtypes. The content of this field "\ + "is a structure holding the current model subtypes, and the "\ + "current document followed subtypes."), 'message_follower_ids': many2many_reference('res.partner', 'mail_followers', 'res_id', 'partner_id', reference_column='res_model', string='Followers'), @@ -563,7 +599,7 @@ class mail_thread(osv.AbstractModel): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, type='notification', - subtype_xml_id=None, parent_id=False, attachments=None, context=None, **kwargs): + subtype=None, parent_id=False, attachments=None, context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. @@ -579,8 +615,8 @@ class mail_thread(osv.AbstractModel): """ context = context or {} attachments = attachments or [] - assert (not thread_id) or isinstance(thread_id, (int,long)) or \ - (isinstance(thread_id, (list, tuple)) and len(thread_id) == 1), "Invalid thread_id" + assert (not thread_id) or isinstance(thread_id, (int, long)) or \ + (isinstance(thread_id, (list, tuple)) and len(thread_id) == 1), "Invalid thread_id" if isinstance(thread_id, (list, tuple)): thread_id = thread_id and thread_id[0] @@ -598,15 +634,13 @@ class mail_thread(osv.AbstractModel): } attachment_ids.append((0, 0, data_attach)) + if subtype: + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype) + subtype_id = ref and ref[1] or False + else: + subtype_id = False + values = kwargs - subtype_obj = self.pool.get('mail.message.subtype') - if subtype_xml_id: - ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) - subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) - if self._name == subtype_browse.res_model: - values['subtype_id']=subtype_browse.id - if not subtype_browse.res_model: - values['subtype_id']=subtype_browse.id values.update({ 'model': context.get('thread_model', self._name) if thread_id else False, 'res_id': thread_id or False, @@ -615,34 +649,44 @@ class mail_thread(osv.AbstractModel): 'type': type, 'parent_id': parent_id, 'attachment_ids': attachment_ids, + 'subtype_id': subtype_id, }) - for x in ('from', 'to', 'cc'): values.pop(x, None) # Avoid warnings + # Avoid warnings about non-existing fields + for x in ('from', 'to', 'cc'): + values.pop(x, None) return self.pool.get('mail.message').create(cr, uid, values, context=context) #------------------------------------------------------ # Followers API #------------------------------------------------------ - def message_subscribe_users(self, cr, uid, ids, user_ids=None, context=None): + def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, subscribe uid instead. """ - if not user_ids: user_ids = [uid] + if not user_ids: + user_ids = [uid] partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] - return self.message_subscribe(cr, uid, ids, partner_ids, context=context) + return self.message_subscribe(cr, uid, ids, partner_ids, subtype_ids=subtype_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids=None, context=None): + def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ + self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) + if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('res_model', '=', self._name)],context=context) - if subtype_ids: - self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) - return self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', True), '|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context) + + fol_obj = self.pool.get('mail.followers') + fol_ids = fol_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids), ('partner_id', 'in', partner_ids)], context=context) + fol_obj.write(cr, uid, fol_ids, {'subtype_ids': [(6, 0, subtype_ids)]}, context=context) + + return True def message_unsubscribe_users(self, cr, uid, ids, user_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, unsubscribe uid instead. """ - if not user_ids: user_ids = [uid] + if not user_ids: + user_ids = [uid] partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_unsubscribe(cr, uid, ids, partner_ids, context=context) @@ -678,9 +722,4 @@ class mail_thread(osv.AbstractModel): ''', (ids, self._name, partner_id)) return True - def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): - followers_obj = self.pool.get('mail.followers') - followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 1ecdc4b6e5f..28dd3e6fe4f 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -253,30 +253,65 @@ class test_mail(TestMailMockups): follower_ids = set([follower.partner_id.id for follower in self.mail_followers.browse(cr, uid, fol_obj_ids)]) self.assertEqual(follower_ids, set([partner_bert_id, user_admin.partner_id.id]), 'Bert and Admin should be the followers of dummy mail.group data') - def test_11_message_followers(self): - """ Tests designed for the subscriber API. """ + def test_11_message_followers_and_subtypes(self): + """ Tests designed for the subscriber API as well as message subtypes """ cr, uid = self.cr, self.uid user_admin = self.res_users.browse(cr, uid, uid) group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - - # Create user Raoul + # Data: user Raoul user_raoul_id = self.res_users.create(cr, uid, {'name': 'Raoul Grosbedon', 'login': 'raoul'}) user_raoul = self.res_users.browse(cr, uid, user_raoul_id) + # Data: message subtypes + self.mail_message_subtype.create(cr, uid, {'name': 'mt_mg_def', 'default': True, 'res_model': 'mail.group'}) + self.mail_message_subtype.create(cr, uid, {'name': 'mt_other_def', 'default': True, 'res_model': 'crm.lead'}) + self.mail_message_subtype.create(cr, uid, {'name': 'mt_all_def', 'default': True, 'res_model': False}) + mt_mg_nodef = self.mail_message_subtype.create(cr, uid, {'name': 'mt_mg_nodef', 'default': False, 'res_model': 'mail.group'}) + mt_all_nodef = self.mail_message_subtype.create(cr, uid, {'name': 'mt_all_nodef', 'default': False, 'res_model': False}) + default_group_subtypes = self.mail_message_subtype.search(cr, uid, [('default', '=', True), '|', ('res_model', '=', 'mail.group'), ('res_model', '=', False)]) - # Subscribe Raoul three times (niak niak) through message_subscribe_users + # ---------------------------------------- + # CASE1: test subscriptions with subtypes + # ---------------------------------------- + + # Do: Subscribe Raoul three times (niak niak) through message_subscribe_users group_pigs.message_subscribe_users([user_raoul_id, user_raoul_id]) group_pigs.message_subscribe_users([user_raoul_id]) group_pigs.refresh() + # Test: 2 followers (Admin and Raoul) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(len(follower_ids), 2, 'There should be 2 Pigs fans') self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]), 'Admin and Raoul should be the only 2 Pigs fans') + # Test: Raoul follows default subtypes + fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_raoul.partner_id.id)]) + fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0] + fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids]) + self.assertEqual(set(fol_subtype_ids), set(default_group_subtypes), 'subscription subtypes are incorrect') - # Unsubscribe Raoul twice through message_unsubscribe_users + # Do: Unsubscribe Raoul twice through message_unsubscribe_users group_pigs.message_unsubscribe_users([user_raoul_id, user_raoul_id]) group_pigs.refresh() + # Test: 1 follower (Admin) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(follower_ids, [user_admin.partner_id.id], 'Admin must be the only Pigs fan') + # Do: subscribe Admin with subtype_ids + group_pigs.message_subscribe_users([uid], [mt_mg_nodef, mt_all_nodef]) + fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_admin.partner_id.id)]) + fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0] + fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids]) + self.assertEqual(set(fol_subtype_ids), set([mt_mg_nodef, mt_all_nodef]), 'subscription subtypes are incorrect') + + # ---------------------------------------- + # CASE2: test mail_thread fields + # ---------------------------------------- + + group_pigs.refresh() + subtype_data = eval(group_pigs.message_subtype_data) + self.assertEqual(set(subtype_data.keys()), set(['comment', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') + self.assertFalse(subtype_data['comment']['followed'], 'Admin should not follow comments in pigs') + self.assertTrue(subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') + self.assertTrue(subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') + def test_20_message_post(self): """ Tests designed for message_post. """ cr, uid = self.cr, self.uid @@ -307,9 +342,12 @@ class test_mail(TestMailMockups): _mail_bodyalt2 = 'Pigs rules\nAdmin' _attachments = [('First', 'My first attachment'), ('Second', 'My second attachment')] + # ---------------------------------------- # CASE1: post comment, body and subject specified + # ---------------------------------------- + self._init_mock_build_email() - msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body1, subject=_subject, type='comment') + msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body1, subject=_subject, type='comment', subtype='mt_comment') message = self.mail_message.browse(cr, uid, msg_id) sent_emails = self._build_email_kwargs_list # Test: notifications have been deleted @@ -334,10 +372,13 @@ class test_mail(TestMailMockups): for sent_email in sent_emails: self.assertEqual(sent_email['email_to'], ['b@b'], 'sent_email email_to is incorrect') + # ---------------------------------------- # CASE2: post an email with attachments, parent_id, partner_ids + # ---------------------------------------- + # TESTS: automatic subject, signature in body_html, attachments propagation self._init_mock_build_email() - msg_id2 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body2, type='email', + msg_id2 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body2, type='email', subtype='mt_comment', partner_ids=[(6, 0, [p_d_id])], parent_id=msg_id, attachments=_attachments) message = self.mail_message.browse(cr, uid, msg_id2) sent_emails = self._build_email_kwargs_list @@ -608,7 +649,7 @@ class test_mail(TestMailMockups): # Post 4 message on group_pigs for dummy in range(4): - group_pigs.message_post(body='My Body') + group_pigs.message_post(body='My Body', subtype='mt_comment') # Check there are 4 new needaction on mail.message notif_ids = self.mail_notification.search(cr, uid, [ @@ -652,6 +693,7 @@ class test_mail(TestMailMockups): def test_60_vote(self): """ Test designed for the vote/unvote feature. """ cr, uid = self.cr, self.uid + user_admin = self.res_users.browse(cr, uid, uid) group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) msg1 = group_pigs.message_post(body='My Body', subject='1') msg1 = self.mail_message.browse(cr, uid, msg1) @@ -677,32 +719,3 @@ class test_mail(TestMailMockups): msg1.refresh() # Test: msg1 has Bert as voter self.assertEqual(set(msg1.vote_user_ids), set([user_bert]), 'after unvoting for Admin, Bert is not the voter') - - def test_70_message_subtype(self): - """ Tests designed for message_subtype. """ - cr, uid = self.cr, self.uid - self.res_users.write(cr, uid, [uid], {'signature': 'Admin', 'email': 'a@a'}) - user_admin = self.res_users.browse(cr, uid, uid) - group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - - # 0 - Admin - p_a_id = user_admin.partner_id.id - # Subscribe #1, - - group_pigs.message_subscribe_users([uid]) - - # Mail data - _subject = 'Pigs' - _mail_subject = '%s posted on %s' % (user_admin.name, group_pigs.name) - _body1 = 'Pigs rules' - _mail_body1 = 'Pigs rules\n
                    Admin
                    \n' - _mail_bodyalt1 = 'Pigs rules\nAdmin' - _body2 = 'Pigs rules' - _mail_body2 = 'Pigs rules\n
                    Admin
                    \n' - _mail_bodyalt2 = 'Pigs rules\nAdmin\n' - filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) - # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mt_comment') - notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) - self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") - diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 760d16dbef2..32d361a3126 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -245,7 +245,7 @@ class mail_compose_message(osv.TransientModel): post_values['attachments'] += new_attachments post_values.update(email_dict) # post the message - active_model_pool.message_post(cr, uid, [res_id], type='comment', context=context, **post_values) + active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype='mt_comment', context=context, **post_values) # post process: update attachments, because id is not necessarily known when adding attachments in Chatter self.pool.get('ir.attachment').write(cr, uid, [attach.id for attach in wizard.attachment_ids], {'res_id': wizard.id}, context=context) From 04c18c2c943fb44090d3540a36e3fd78dbcf1ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 13:49:09 +0200 Subject: [PATCH 149/245] [CLEAN[ mail_followers widget: cleaned subtype management. bzr revid: tde@openerp.com-20120920114909-90s6f5dvol2y0vo7 --- addons/mail/static/src/js/mail_followers.js | 94 +++++++++---------- addons/mail/static/src/xml/mail_followers.xml | 21 ++--- 2 files changed, 54 insertions(+), 61 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index f4710580d81..c048550611b 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -36,14 +36,12 @@ openerp_mail_followers = function(session, mail) { // use actual_mode property on view to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); - this.fetch_subtype(); this.reinit(); this.bind_events(); }, _check_visibility: function() { this.$el.toggle(this.view.get("actual_mode") !== "create"); - if (this.view.get("actual_mode") !== "create"){this.fetch_subtype();} }, reinit: function() { @@ -56,8 +54,8 @@ openerp_mail_followers = function(session, mail) { this.$('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.fetch_subtype(); }); - this.$el.on('click','ul.oe_mail_recthread_subtype', function () {self.update_subtype();}) + this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); + this.$el.on('click', 'ul.oe_mail_recthread_subtypes', function () {self.do_update_subscription(); }) this.$el.on('click', 'button.oe_mail_button_invite', function(event) { action = { type: 'ir.actions.act_window', @@ -77,18 +75,30 @@ openerp_mail_followers = function(session, mail) { read_value: function() { var self = this; - return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { - return results[0].message_follower_ids; - }).pipe(this.proxy('set_value')); + return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids', 'message_is_follower', 'message_subtype_data']).pipe(function (results) { + self.set_value(results[0].message_follower_ids, results[0].message_is_follower, results[0].message_subtype_data); + }); }, - set_value: function(value_) { + set_value: function(value_, message_is_follower_value_, message_subtype_data_value_) { this.reinit(); if (! this.view.datarecord.id || session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) { this.$el.find('div.oe_mail_recthread_aside').hide(); return; } + if (message_subtype_data_value_ === undefined) { + this.message_subtype_data_value_ = this.view.fields.message_subtype_data && this.view.fields.message_subtype_data.get_value() || {}; + } + else { + this.message_subtype_data_value_ = message_subtype_data_value_; + } + if (message_is_follower_value_ === undefined) { + this.message_is_follower_value_ = this.view.fields.message_is_follower && this.view.fields.message_is_follower.get_value() || false; + } + else { + this.message_is_follower_value_ = message_is_follower_value_; + } return this.fetch_followers(value_ || this.get_value()); }, @@ -108,63 +118,47 @@ openerp_mail_followers = function(session, mail) { }); if (this.message_is_follower) { this.$el.find('button.oe_mail_button_follow').hide(); - this.$el.find('button.oe_mail_button_unfollow').show(); - this.$el.find('ul.oe_mail_recthread_subtype').show(); } + this.$el.find('button.oe_mail_button_unfollow').show(); + } else { this.$el.find('button.oe_mail_button_follow').show(); this.$el.find('button.oe_mail_button_unfollow').hide(); - this.$el.find('ul.oe_mail_recthread_subtype').hide() - } + } + return this.display_subtypes(this.message_subtype_data_value_); }, - update_subtype: function (){ - var self = this; - var cheklist = new Array(); - _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ - if($(record).is(':checked')) { - cheklist.push(parseInt($(record).attr('id')))} - }); - self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],[self.session.uid],cheklist]) - }, - // Display the subtypes of each records. - display_subtype: function(records) { + + /** Display subtypes: {'name': default, followed} */ + display_subtypes: function (records) { var self = this - var subtype_list = this.$el.find('ul.oe_mail_recthread_subtype').empty(); - var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id]]]) - follower_ids.then(function (record){ - var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); - follower_read.then(function (follower_record){ - if(follower_record.length != 0){ - _(follower_record[0].subtype_ids).each(function (subtype_id){ - var subtype_check = self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']') - if(subtype_check.length > 0){ - subtype_check[0].checked=true} - }); - } - }) - }); - _(records).each(function (record) { - record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) {return letter.toUpperCase();}); - $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list); + // this.$el.find('ul.oe_mail_recthread_subtype').show(); + var subtype_list = this.$el.find('ul.oe_mail_recthread_subtypes').empty(); + _(records).each(function (record, record_name) { + record.name = record_name; + record.followed = record.followed || undefined; + $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo(subtype_list); }); }, do_follow: function () { var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); - }, - - //fetch subtype from subtype model - fetch_subtype: function () { - var self = this - var subtype_object = this.sub_model.call('search', [[['res_model','=',this.view.model]]]); - subtype_object.then(function (subtype_ids){ - self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); - }); + return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(this.proxy('read_value')); }, do_unfollow: function () { var context = new session.web.CompoundContext(this.build_context(), {}); return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); }, + + do_update_subscription: function () { + var context = new session.web.CompoundContext(this.build_context(), {}); + var self = this; + var checklist = new Array(); + _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ + if($(record).is(':checked')) { + checklist.push(parseInt($(record).attr('id')))} + }); + return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value')); + }, + }); }; diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 9d7a0077437..b2922753acf 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -7,11 +7,14 @@ -->
                    - + +
                    +

                    Message types to follow

                    +
                      +
                      -

                        @@ -30,18 +33,14 @@ \ -
                      • +
                      • - - + +
                        - - - -
                      • From b1d05506ebe2eb1c262e5dbec05f7305603320f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 13:49:47 +0200 Subject: [PATCH 150/245] [FIX] mail_thread: fixed message_subscribe, not recognizing void list compared to none; misc fixes of subtype. bzr revid: tde@openerp.com-20120920114947-64643cmduzww5i5c --- addons/mail/mail_thread.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 39a8e011f3c..5ad76a44c4f 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -143,13 +143,15 @@ class mail_thread(osv.AbstractModel): - message_is_follower: is uid in the document followers - message_subtype_data: data about document subtypes: which are available, which are followed if any """ - res = dict((id, dict(message_subtype_data='')) for id in ids) + res = dict((id, dict(message_subtype_data='', message_is_follower=False)) for id in ids) user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0] # find current model subtypes, add them to a dictionary subtype_obj = self.pool.get('mail.message.subtype') subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context) - subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context)) + subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False, id=subtype.id)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context)) + for id in ids: + res[id]['message_subtype_data'] = subtype_dict.copy() # find the document followers, update the data fol_obj = self.pool.get('mail.followers') @@ -159,11 +161,11 @@ class mail_thread(osv.AbstractModel): ('res_model', '=', self._name), ], context=context) for fol in fol_obj.browse(cr, uid, fol_ids, context=context): - thread_subtype_dict = subtype_dict.copy() + thread_subtype_dict = res[fol.res_id]['message_subtype_data'] res[fol.res_id]['message_is_follower'] = True for subtype in fol.subtype_ids: thread_subtype_dict[subtype.name]['followed'] = True - res[fol.res_id]['message_subtype_data'] = '%s' % thread_subtype_dict + res[fol.res_id]['message_subtype_data'] = thread_subtype_dict return res @@ -663,6 +665,7 @@ class mail_thread(osv.AbstractModel): def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, subscribe uid instead. """ + print cr, uid, ids, user_ids, subtype_ids, context if not user_ids: user_ids = [uid] partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] @@ -671,15 +674,14 @@ class mail_thread(osv.AbstractModel): def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) - - if not subtype_ids: + # if subtypes are not specified (and not set to a void list), fetch default ones + if subtype_ids is None: subtype_obj = self.pool.get('mail.message.subtype') subtype_ids = subtype_obj.search(cr, uid, [('default', '=', True), '|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context) - + # update the subscriptions fol_obj = self.pool.get('mail.followers') fol_ids = fol_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids), ('partner_id', 'in', partner_ids)], context=context) fol_obj.write(cr, uid, fol_ids, {'subtype_ids': [(6, 0, subtype_ids)]}, context=context) - return True def message_unsubscribe_users(self, cr, uid, ids, user_ids=None, context=None): From 2a33b4cb266e1c087998e9b47bb60431cce5ece7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 13:57:46 +0200 Subject: [PATCH 151/245] [FIX] mail: fixed tests. bzr revid: tde@openerp.com-20120920115746-6ospayxyyi6y9c3z --- addons/mail/tests/test_mail.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 28dd3e6fe4f..11bc860fb0f 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -306,11 +306,10 @@ class test_mail(TestMailMockups): # ---------------------------------------- group_pigs.refresh() - subtype_data = eval(group_pigs.message_subtype_data) - self.assertEqual(set(subtype_data.keys()), set(['comment', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') - self.assertFalse(subtype_data['comment']['followed'], 'Admin should not follow comments in pigs') - self.assertTrue(subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') - self.assertTrue(subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') + self.assertEqual(set(group_pigs.message_subtype_data.keys()), set(['comment', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') + self.assertFalse(group_pigs.message_subtype_data['comment']['followed'], 'Admin should not follow comments in pigs') + self.assertTrue(group_pigs.message_subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') + self.assertTrue(group_pigs.message_subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') def test_20_message_post(self): """ Tests designed for message_post. """ From 1206b8f7a0c8d2de9cd7ae05eefbd1c84433896f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 13:59:00 +0200 Subject: [PATCH 152/245] [IMP] Addons: added message_is_follower and message_subtype_data invisible fields to all views using Chatter and Followers widgets. bzr revid: tde@openerp.com-20120920115900-vvpfhjvw135vhf91 --- addons/account/account_invoice_view.xml | 6 ++++ .../account_voucher/account_voucher_view.xml | 3 ++ .../voucher_payment_receipt_view.xml | 6 ++++ .../voucher_sales_purchase_view.xml | 6 ++++ addons/analytic/analytic_view.xml | 3 ++ addons/base_calendar/crm_meeting_view.xml | 3 ++ addons/crm/crm_lead_view.xml | 6 ++++ addons/crm/crm_phonecall_view.xml | 3 ++ addons/crm_claim/crm_claim_view.xml | 3 ++ addons/crm_helpdesk/crm_helpdesk_view.xml | 3 ++ addons/event/event_view.xml | 6 ++++ addons/hr_expense/hr_expense_view.xml | 3 ++ addons/hr_holidays/hr_holidays_view.xml | 6 ++++ addons/hr_recruitment/hr_recruitment_view.xml | 3 ++ addons/idea/idea_view.xml | 3 ++ addons/mail/mail_group_view.xml | 6 ++++ addons/mail/mail_thread.py | 1 - addons/mail/res_partner_view.xml | 3 ++ addons/mrp/mrp_view.xml | 6 ++++ addons/mrp_operations/mrp_operations_view.xml | 3 ++ addons/mrp_repair/mrp_repair_view.xml | 3 ++ addons/note/note_view.xml | 32 +++++++++++-------- addons/procurement/procurement_view.xml | 3 ++ addons/product/product_view.xml | 3 ++ addons/project/project_view.xml | 6 ++++ addons/project_issue/project_issue_view.xml | 3 ++ addons/purchase/purchase_view.xml | 3 ++ .../purchase_requisition_view.xml | 3 ++ addons/sale/sale_view.xml | 3 ++ addons/stock/stock_view.xml | 6 ++++ 30 files changed, 133 insertions(+), 14 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 1c4d83106ca..a24c86c58f4 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -279,6 +279,9 @@
                        + + +
                        @@ -438,6 +441,9 @@
                        + + +
                        diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index 07647d02fe3..daf1f7a361e 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -111,6 +111,9 @@
                        + + +
                        diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index c41ed6d5577..0e7e4dd3fe7 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -240,6 +240,9 @@
                        + + +
                        @@ -409,6 +412,9 @@
                        + + +
                        diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 5bcecfa268e..2ba0aa6e691 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -147,6 +147,9 @@
                        + + +
                        @@ -302,6 +305,9 @@
                        + + +
                        diff --git a/addons/analytic/analytic_view.xml b/addons/analytic/analytic_view.xml index 51f5428002f..1613a3a20b0 100644 --- a/addons/analytic/analytic_view.xml +++ b/addons/analytic/analytic_view.xml @@ -54,6 +54,9 @@
                        + + +
                        diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index b963de68130..88f62c5320a 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -230,6 +230,9 @@
                        + + +
                        diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index f018a355579..4bfa145188c 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -222,6 +222,9 @@
                        + + +
                        @@ -522,6 +525,9 @@
                        + + +
                        diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index 8c1e1c9ec76..160c3bfe388 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -151,6 +151,9 @@
                        + + +
                        diff --git a/addons/crm_claim/crm_claim_view.xml b/addons/crm_claim/crm_claim_view.xml index 820fb38e58a..db9a75eca5e 100644 --- a/addons/crm_claim/crm_claim_view.xml +++ b/addons/crm_claim/crm_claim_view.xml @@ -182,6 +182,9 @@
                        + + +
                        diff --git a/addons/crm_helpdesk/crm_helpdesk_view.xml b/addons/crm_helpdesk/crm_helpdesk_view.xml index 5399c9880ca..aec2b8c1e4c 100644 --- a/addons/crm_helpdesk/crm_helpdesk_view.xml +++ b/addons/crm_helpdesk/crm_helpdesk_view.xml @@ -100,6 +100,9 @@
                        + + +
                        diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index fd396053d5d..b2502c23b06 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -198,6 +198,9 @@
                        + + +
                        @@ -480,6 +483,9 @@
                        + + +
                        diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index 5389f88b885..e577d196695 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -140,6 +140,9 @@
                        + + +
                        diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index 5a2e0603b88..8ac67fa1723 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -122,6 +122,9 @@
                        + + +
                        @@ -159,6 +162,9 @@
                        + + +
                        diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 08e5f31a2d2..e81da63b73c 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -184,6 +184,9 @@
                        + + +
                        diff --git a/addons/idea/idea_view.xml b/addons/idea/idea_view.xml index eab3d03ceea..3861e86bff8 100644 --- a/addons/idea/idea_view.xml +++ b/addons/idea/idea_view.xml @@ -78,6 +78,9 @@
                        + + +
                        diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml index 31beba80ecc..a805fb3b575 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -16,6 +16,9 @@ + + + @@ -83,6 +86,9 @@
                        + + +
                        diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 5ad76a44c4f..bf50b582323 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -665,7 +665,6 @@ class mail_thread(osv.AbstractModel): def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, subscribe uid instead. """ - print cr, uid, ids, user_ids, subtype_ids, context if not user_ids: user_ids = [uid] partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] diff --git a/addons/mail/res_partner_view.xml b/addons/mail/res_partner_view.xml index 2a8430926d5..9589b6409a7 100644 --- a/addons/mail/res_partner_view.xml +++ b/addons/mail/res_partner_view.xml @@ -11,6 +11,9 @@
                        + + +
                        diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index d05893cf778..a379ae9b4cb 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -410,6 +410,9 @@
                        + + +
                        @@ -788,6 +791,9 @@
                        + + +
                        diff --git a/addons/mrp_operations/mrp_operations_view.xml b/addons/mrp_operations/mrp_operations_view.xml index 834f3000472..f069f06fca7 100644 --- a/addons/mrp_operations/mrp_operations_view.xml +++ b/addons/mrp_operations/mrp_operations_view.xml @@ -108,6 +108,9 @@
                        + + +
                        diff --git a/addons/mrp_repair/mrp_repair_view.xml b/addons/mrp_repair/mrp_repair_view.xml index 55cbe49c75b..9158944f952 100644 --- a/addons/mrp_repair/mrp_repair_view.xml +++ b/addons/mrp_repair/mrp_repair_view.xml @@ -190,6 +190,9 @@
                        + + +
                        diff --git a/addons/note/note_view.xml b/addons/note/note_view.xml index 8d943dde44d..4ed2fade43f 100644 --- a/addons/note/note_view.xml +++ b/addons/note/note_view.xml @@ -50,6 +50,7 @@ + @@ -108,19 +109,24 @@ - note.note.form - note.note - -
                        -
                        - - -
                        - - - - - + note.note.form + note.note + +
                        +
                        + + +
                        + +
                        + + + + + +
                        + +
                        diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml index bf73b383216..b6138ca78d3 100644 --- a/addons/procurement/procurement_view.xml +++ b/addons/procurement/procurement_view.xml @@ -104,6 +104,9 @@
                        + + +
                        diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index d04e6f17fe8..05e3d0b2497 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -202,6 +202,9 @@
                        + + +
                        diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index ff8ac943a67..4d7bceb4599 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -154,6 +154,9 @@
                        + + +
                        @@ -482,6 +485,9 @@
                        + + +
                        diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index be7427fe8f4..6d1d0272ab0 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -160,6 +160,9 @@
                        + + +
                        diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 796fd1351a9..9a2bd02f9a2 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -265,6 +265,9 @@
                        + + +
                        diff --git a/addons/purchase_requisition/purchase_requisition_view.xml b/addons/purchase_requisition/purchase_requisition_view.xml index 1fafec92bc7..13ea40df765 100644 --- a/addons/purchase_requisition/purchase_requisition_view.xml +++ b/addons/purchase_requisition/purchase_requisition_view.xml @@ -103,6 +103,9 @@
                        + + +
                        diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 5c2320a7d5c..32d9b03cdff 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -352,6 +352,9 @@
                        + + +
                        diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 83fed186f42..1a8e7c0ff3f 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -918,6 +918,9 @@
                        + + +
                        @@ -1044,6 +1047,9 @@
                        + + +
                        From 6fa56dcba546286157a07771c8c5a35e6648cec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 14:20:24 +0200 Subject: [PATCH 153/245] [IMP] Followers widget: cleaned code, and now more clearly uses message_is_follower and message_subtype_data fields. bzr revid: tde@openerp.com-20120920122024-wf8ilufgrp1vhccd --- addons/mail/static/src/js/mail_followers.js | 41 ++++++++++--------- addons/mail/static/src/xml/mail_followers.xml | 4 +- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index c048550611b..58c53d5556a 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -55,7 +55,7 @@ openerp_mail_followers = function(session, mail) { .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); - this.$el.on('click', 'ul.oe_mail_recthread_subtypes', function () {self.do_update_subscription(); }) + this.$el.on('click', 'ul.oe_mail_subtypes', function () {self.do_update_subscription(); }) this.$el.on('click', 'button.oe_mail_button_invite', function(event) { action = { type: 'ir.actions.act_window', @@ -80,6 +80,18 @@ openerp_mail_followers = function(session, mail) { }); }, + get_or_set: function(field_name, value) { + if (this.view.fields[field_name]) { + if (value !== undefined) { + this.view.fields[field_name].set_value(value); + } + return this.view.fields[field_name].get_value(); + } + else { + return value; + } + }, + set_value: function(value_, message_is_follower_value_, message_subtype_data_value_) { this.reinit(); if (! this.view.datarecord.id || @@ -87,36 +99,25 @@ openerp_mail_followers = function(session, mail) { this.$el.find('div.oe_mail_recthread_aside').hide(); return; } - if (message_subtype_data_value_ === undefined) { - this.message_subtype_data_value_ = this.view.fields.message_subtype_data && this.view.fields.message_subtype_data.get_value() || {}; - } - else { - this.message_subtype_data_value_ = message_subtype_data_value_; - } - if (message_is_follower_value_ === undefined) { - this.message_is_follower_value_ = this.view.fields.message_is_follower && this.view.fields.message_is_follower.get_value() || false; - } - else { - this.message_is_follower_value_ = message_is_follower_value_; - } + this.message_is_follower_value_ = this.get_or_set('message_is_follower', message_is_follower_value_) || false; + this.message_subtype_data_value_ = this.get_or_set('message_subtype_data', message_subtype_data_value_) || {}; return this.fetch_followers(value_ || this.get_value()); }, fetch_followers: function (value_) { - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers')); + return this.ds_follow.call('read', [value_, ['name']]).pipe(this.proxy('display_followers')); }, /** Display the followers, evaluate is_follower directly */ display_followers: function (records) { var self = this; - this.message_is_follower = _.indexOf(_.flatten(_.pluck(records, 'user_ids')), this.session.uid) != -1; var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); _(records).each(function (record) { record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); - if (this.message_is_follower) { + if (this.message_is_follower_value_) { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').show(); } @@ -129,9 +130,11 @@ openerp_mail_followers = function(session, mail) { /** Display subtypes: {'name': default, followed} */ display_subtypes: function (records) { - var self = this - // this.$el.find('ul.oe_mail_recthread_subtype').show(); - var subtype_list = this.$el.find('ul.oe_mail_recthread_subtypes').empty(); + if (! this.message_is_follower_value_) { + this.$('div.oe_mail_recthread_subtypes').remove(); + return; + } + var subtype_list = this.$el.find('ul.oe_mail_subtypes').empty(); _(records).each(function (record, record_name) { record.name = record_name; record.followed = record.followed || undefined; diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index b2922753acf..05eb349ea5d 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -10,9 +10,9 @@ -
                        +

                        Message types to follow

                        -
                          +
                            From fda33df8a608fd5063ae45b7f9db73c9e1c65013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 14:39:59 +0200 Subject: [PATCH 154/245] [FIX] Followers widget: fixed bad refreshing when going through various form views. bzr revid: tde@openerp.com-20120920123959-3799cpr57f7ac3u1 --- addons/mail/static/src/js/mail_followers.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 58c53d5556a..1e650ca7125 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -130,11 +130,10 @@ openerp_mail_followers = function(session, mail) { /** Display subtypes: {'name': default, followed} */ display_subtypes: function (records) { + var subtype_list = this.$('ul.oe_mail_subtypes').empty(); if (! this.message_is_follower_value_) { - this.$('div.oe_mail_recthread_subtypes').remove(); return; } - var subtype_list = this.$el.find('ul.oe_mail_subtypes').empty(); _(records).each(function (record, record_name) { record.name = record_name; record.followed = record.followed || undefined; From 62926be708d81935f2f47d92e4c312f2699133c5 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 20 Sep 2012 15:46:18 +0200 Subject: [PATCH 155/245] [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 156/245] [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 3774f6d54572584b4860c712ad7e15b3d25fb1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 16:46:45 +0200 Subject: [PATCH 157/245] [IMP] [FIX] Chatter: fixed load more, message_read and expandables. Cleaned tests. bzr revid: tde@openerp.com-20120920144645-o92edguwjzws3t3e --- addons/mail/mail_message.py | 31 ++++++----- addons/mail/static/src/css/mail.css | 25 ++++----- addons/mail/static/src/js/mail.js | 86 ++++------------------------- addons/mail/static/src/xml/mail.xml | 19 ++++++- addons/mail/tests/test_mail.py | 22 ++++---- 5 files changed, 68 insertions(+), 115 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 362b027f6d1..dee44d9f8b8 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -208,7 +208,7 @@ class mail_message(osv.Model): if parent_message and current_level < level: base_domain += [('parent_id', '=', parent_message['id'])] elif parent_message: - base_domain += [('id', 'child_of', parent_message['id'])] + base_domain += [('id', 'child_of', parent_message['id']), ('id', '!=', parent_message['id'])] if domain: base_domain += domain extension = { 'type': 'expandable', @@ -219,7 +219,7 @@ class mail_message(osv.Model): } return extension - def message_read_tree_flatten(self, cr, uid, parent_message, messages, domain=[], level=0, current_level=0, context=None, limit=None): + def message_read_tree_flatten(self, cr, uid, parent_message, messages, domain=[], level=0, current_level=0, context=None, limit=None, add_expandable=True): """ Given a tree with several roots of following structure : [ {'id': 1, 'child_ids': [ {'id': 11, 'child_ids': [...] },], @@ -238,33 +238,36 @@ class mail_message(osv.Model): child_ids = msg_dict.pop('child_ids', []) msg_dict['child_ids'] = [] return [msg_dict] + child_ids + context = context or {} limit = limit or self._message_read_limit + # Depth-first flattening for message in messages: if message.get('type') == 'expandable': continue - message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], domain, level, current_level + 1, context=context) + message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], domain, level, current_level + 1, context=context, limit=limit) for child in message['child_ids']: + if child.get('type') == 'expandable': + continue message['child_nbr'] += child['child_nbr'] # Flatten if above maximum depth if current_level < level: return_list = messages else: return_list = [flat_message for message in messages for flat_message in _flatten(message)] + # Add expandable return_list = sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) - if current_level == 0: - expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) - if len(return_list) >= limit: - print 'we need an expandable here' - print 'expandable', expandable - elif current_level <= level: - expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) - print 'expandable', expandable + if return_list and current_level == 0 and add_expandable: + expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, domain, current_level, level, context=context) + return_list.append(expandable) + elif return_list and current_level <= level and add_expandable: + expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, domain, current_level, level, context=context) + return_list.append(expandable) return return_list - def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, limit=None, parent_id=False): + def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, parent_id=False, limit=None): """ Read messages from mail.message, and get back a structured tree of messages to be displayed as discussion threads. If IDs is set, fetch these records. Otherwise use the domain to fetch messages. @@ -278,11 +281,11 @@ class mail_message(osv.Model): further parents :return list: list of trees of messages """ - limit = limit or self._message_read_limit context = context or {} if not ids: ids = self.search(cr, uid, domain, context=context, limit=limit) messages = self.browse(cr, uid, ids, context=context) + add_expandable = (len(messages) >= limit) # key: ID, value: record tree = {} @@ -305,7 +308,7 @@ class mail_message(osv.Model): tree[msg.id] = record # Flatten the result - result = self.message_read_tree_flatten(cr, uid, None, result, domain, level, context=context) + result = self.message_read_tree_flatten(cr, uid, None, result, domain, level, context=context, limit=limit, add_expandable=add_expandable) return result #------------------------------------------------------ diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 2f9b35f1c95..8e4185b17f9 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -55,16 +55,6 @@ height: 28px; } -.openerp div.oe_mail_msg_content { - position: relative; - width: 486px; -} - -.openerp div.oe_mail_msg_content > li { - float: left; - margin-right: 3px; -} - .openerp div.oe_mail_thread_subthread div.oe_mail_msg_content { width: 440px; } @@ -196,14 +186,16 @@ margin: 0 0 4px 0; } -.openerp .oe_mail_msg_notification, -.openerp .oe_mail_msg_comment, +.openerp .oe_mail_msg_notification, +.openerp .oe_mail_msg_expandable, +.openerp .oe_mail_msg_comment, .openerp .oe_mail_msg_email { padding: 8px; background: white; border-top: 1px solid #ccc; } +.openerp div.oe_mail_thread_subthread .oe_mail_msg_expandable, .openerp div.oe_mail_thread_subthread .oe_mail_msg_comment { background: #eee; } @@ -216,8 +208,15 @@ clear: both; } -.openerp .oe_mail_msg_content { +.openerp div.oe_mail_msg_content { + float: right; + position: relative; + width: 486px; +} + +.openerp div.oe_mail_msg_content > li { float: left; + margin-right: 3px; } .openerp .oe_mail_msg_content:after { diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 3ab566d2e21..eb25084f530 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -32,27 +32,6 @@ openerp.mail = function(session) { }); - /** - * ------------------------------------------------------------ - * Sidebar - * ------------------------------------------------------------ - * - * Override of sidebar do_attachment_new method, to catch attachments added - * through the sidebar and show them in the Chatter composition form. - */ - - // session.web.Sidebar = session.web.Sidebar.extend({ - // do_attachment_new: function(attachment) { - // this._super(attachment); - // var message_ids = this.getParent().fields.message_ids || undefined; - // if (! message_ids) { return; } - // var compose_message_widget = message_ids.thread.compose_message_widget; - // if (! compose_message_widget) { return; } - // compose_message_widget.attachments.push(attachment); - // compose_message_widget.display_attachments(); - // }, - // }); - /** * ------------------------------------------------------------ * ChatterUtils @@ -308,7 +287,6 @@ openerp.mail = function(session) { show_dd_reply_by_email:options.show_dd_reply_by_email != undefined ? options.show_dd_reply_by_email: true, show_dd_delete: options.show_dd_delete || false, show_dd_hide: options.show_dd_hide || false, - show_more: options.show_more || false, truncate_limit: options.truncate_limit || 250, } // datasets and internal vars @@ -346,7 +324,7 @@ openerp.mail = function(session) { bind_events: function() { var self = this; // event: click on 'More' at bottom of thread - this.$el.on('click', 'button.oe_mail_button_more', this.do_message_fetch_more); + this.$el.on('click', 'a.oe_mail_fetch_more', this.do_message_fetch_more); // event: writing in basic textarea of composition form (quick reply) this.$el.find('textarea.oe_mail_compose_textarea').keyup(function (event) { var charCode = (event.which) ? event.which : window.event.keyCode; @@ -421,7 +399,6 @@ openerp.mail = function(session) { 'default_parent_id': this.context.default_parent_id, 'default_content_subtype': 'plain'} ); } - // return this._super(action, on_close); }, /** Instantiate the composition form, with every parameters in context @@ -459,14 +436,14 @@ openerp.mail = function(session) { message_fetch: function (initial_mode, additional_domain, additional_context) { var self = this; // domain and context: options + additional - fetch_domain = _.flatten([this.domain, additional_domain || []], true) - fetch_context = _.extend(this.context, additional_context || {}) + fetch_domain = _.flatten([this.domain, additional_domain || []], true); + fetch_context = _.extend({}, this.context, additional_context || {}); // initial mode: try to use message_data or message_ids if (initial_mode && this.options.message_data) { return this.message_display(this.options.message_data); } message_ids = initial_mode && this.options.message_ids != null && this.options.message_ids || false; - return this.ds_message.call('message_read', [message_ids, fetch_domain, this.options.thread_level, fetch_context] + return this.ds_message.call('message_read', [message_ids, fetch_domain, this.options.thread_level, fetch_context, this.context.default_parent_id || undefined] ).then(this.proxy('message_display')); }, @@ -476,13 +453,12 @@ openerp.mail = function(session) { */ message_display: function (records) { var self = this; - var _expendable = false; _(records).each(function (record) { if (record.type == 'expandable') { - _expendable = true; - self.update_fetch_more(true); self.fetch_more_domain = record.domain; self.fetch_more_context = record.context; + var rendered = session.web.qweb.render('mail.thread.message.expandable', {'record': record}); + $(rendered).appendTo(self.$el.children('div.oe_mail_thread_display:first')); } else { self.display_record(record); @@ -501,9 +477,6 @@ openerp.mail = function(session) { self.thread.appendTo(self.$el.find('div.oe_mail_thread_subthread:last')); } }); - if (! _expendable) { - this.update_fetch_more(false); - } }, /** Displays a record and performs some formatting on the record : @@ -558,15 +531,6 @@ openerp.mail = function(session) { vote_node.html(vote_element); }, - /** Display 'show more' button */ - update_fetch_more: function (new_value) { - if (new_value) { - this.$el.find('div.oe_mail_thread_more:last').show(); - } else { - this.$el.find('div.oe_mail_thread_more:last').hide(); - } - }, - display_user_avatar: function () { var avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); return this.$el.find('img.oe_mail_icon').attr('src', avatar); @@ -581,45 +545,15 @@ openerp.mail = function(session) { } return this.ds_thread.call('message_post', [ [this.context.default_res_id], body, false, 'comment', this.context.default_parent_id, undefined] - ).then(self.message_fetch()); + ).pipe(self.message_clean()).pipe(self.message_fetch(false)); }, /** Action: 'shows more' to fetch new messages */ - do_message_fetch_more: function () { + do_message_fetch_more: function (event) { + event.stopPropagation(); + $(event.srcElement).parents('li').eq(0).remove(); return this.message_fetch(false, this.fetch_more_domain, this.fetch_more_context); }, - - // TDE: keep currently because need something similar - // /** - // * Create a domain to fetch new comments according to - // * comment already present in comments_structure - // * @param {Object} comments_structure (see chatter utils) - // * @returns {Array} fetch_domain (OpenERP domain style) - // */ - // get_fetch_domain: function (comments_structure) { - // var domain = []; - // var ids = comments_structure.root_ids.slice(); - // var ids2 = []; - // // must be child of current parent - // if (this.options.parent_id) { domain.push(['id', 'child_of', this.options.parent_id]); } - // _(comments_structure.root_ids).each(function (id) { // each record - // ids.push(id); - // ids2.push(id); - // }); - // if (this.options.parent_id != false) { - // ids2.push(this.options.parent_id); - // } - // // must not be children of already fetched messages - // if (ids.length > 0) { - // domain.push('&'); - // domain.push('!'); - // domain.push(['id', 'child_of', ids]); - // } - // if (ids2.length > 0) { - // domain.push(['id', 'not in', ids2]); - // } - // return domain; - // }, }); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index e3586e723e4..cddccedbf6a 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -101,9 +101,9 @@
                            -
                            + @@ -161,6 +161,21 @@
                          • + +
                          • +
                            +
                            + + +
                            +
                          • + - -
                            @@ -441,11 +437,7 @@
                            - - - -
                            diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index f06960ba7d2..5e26c366778 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -108,11 +108,7 @@
                            - - - -
                            diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 03dc6b33fa2..c41ed6d5577 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -239,11 +239,7 @@
                            - - - -
                            @@ -412,11 +408,7 @@
                            - - - -
                            diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 2affc51b667..5bcecfa268e 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -146,11 +146,7 @@
                            - - - -
                            @@ -305,11 +301,7 @@
                            - - - -
                            diff --git a/addons/analytic/analytic_view.xml b/addons/analytic/analytic_view.xml index 8f25d03ce30..51f5428002f 100644 --- a/addons/analytic/analytic_view.xml +++ b/addons/analytic/analytic_view.xml @@ -53,11 +53,7 @@
                            - - - -
                            diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index 5c0a3790fd6..b963de68130 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -229,11 +229,7 @@
                            - - - -
                            diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 5f52f3e0d93..f91a8756598 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -223,11 +223,7 @@
                            - - - -
                            @@ -529,11 +525,7 @@
                            - - - -
                            diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index f3ce57f10a9..ea20624d738 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -149,11 +149,7 @@
                            - - - -
                            diff --git a/addons/crm_claim/crm_claim_view.xml b/addons/crm_claim/crm_claim_view.xml index 38b7e9891cf..820fb38e58a 100644 --- a/addons/crm_claim/crm_claim_view.xml +++ b/addons/crm_claim/crm_claim_view.xml @@ -181,11 +181,7 @@
                            - - - -
                            diff --git a/addons/crm_helpdesk/crm_helpdesk_view.xml b/addons/crm_helpdesk/crm_helpdesk_view.xml index d914cd601e8..5399c9880ca 100644 --- a/addons/crm_helpdesk/crm_helpdesk_view.xml +++ b/addons/crm_helpdesk/crm_helpdesk_view.xml @@ -99,11 +99,7 @@
                            - - - -
                            diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 9f9130ced4d..e7c14aab18f 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -197,11 +197,7 @@
                            - - - -
                            @@ -483,11 +479,7 @@
                            - - - -
                            diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index 265c07328e6..8049255afbf 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -139,11 +139,7 @@
                            - - - -
                            diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index 84a48e46615..347e2b17ca5 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -121,11 +121,7 @@
                            - - - -
                            @@ -162,11 +158,7 @@
                            - - - -
                            diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 9e3045d766e..08e5f31a2d2 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -183,11 +183,7 @@
                            - - - -
                            diff --git a/addons/idea/idea_view.xml b/addons/idea/idea_view.xml index 7f42eeb3751..eab3d03ceea 100644 --- a/addons/idea/idea_view.xml +++ b/addons/idea/idea_view.xml @@ -77,11 +77,7 @@
                            - - - -
                            diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml index 869c76d2110..40f0a754e4f 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -15,12 +15,10 @@ - - - - + +
                            @@ -84,12 +82,8 @@
                            - - - -
                            diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 97e78cfdd15..71d4bfd099b 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -169,6 +169,7 @@ class mail_thread(osv.AbstractModel): for subtype in fol.subtype_ids: thread_subtype_dict[subtype.name]['followed'] = True res[fol.res_id]['message_subtype_data'] = thread_subtype_dict + return res def _search_unread(self, cr, uid, obj=None, name=None, domain=None, context=None): @@ -679,6 +680,11 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, subtype_ids=subtype_ids, context=context) + def get_message_subtypes(self, cr, uid, ids, context=None): + """ message_subtype_data: data about document subtypes: which are + available, which are followed if any """ + return self._get_subscription_data(cr, uid, ids, None, None, context=context) + def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) diff --git a/addons/mail/res_partner_view.xml b/addons/mail/res_partner_view.xml index 3ef68ac8c59..2a8430926d5 100644 --- a/addons/mail/res_partner_view.xml +++ b/addons/mail/res_partner_view.xml @@ -9,12 +9,8 @@
                            - - - -
                            diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 895aa57bdc5..3fde4cbc67b 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -14,7 +14,6 @@ margin: 0; } - /* ------------------------------------------------------------ */ /* Wall /* ------------------------------------------------------------ */ @@ -37,6 +36,29 @@ list-style-type: none; } +/* ------------------------------------------------------------ */ +/* Followers +/* ------------------------------------------------------------ */ + +.openerp div.oe_mail_recthread_aside h4 { + display: inline-block; +} +.openerp div.oe_mail_recthread_aside button { + position: relative; +} +.openerp div.oe_mail_recthread_aside label, +.openerp div.oe_mail_recthread_aside input { + cursor:pointer; +} +.openerp div.oe_mail_recthread_subtypes { + display:none; +} +.openerp div.oe_mail_recthread_aside button span { + position: absolute; + top:-7px; + right:5px; +} + /* Specific display of threads in the wall */ /* ------------------------------------------------------------ */ @@ -113,15 +135,6 @@ margin-bottom: 8px; } - -/* ------------------------------------------------------------ */ -/* Followers -/* ------------------------------------------------------------ */ - -.openerp div.oe_mail_recthread_aside h4 { - display: inline-block; -} - /* ------------------------------------------------------------ */ /* Thread /* ------------------------------------------------------------ */ diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 0efbf9ca76e..a3ba6f91a04 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -27,9 +27,9 @@ openerp_mail_followers = function(session, mail) { this.options.image = this.node.attrs.image || 'image_small'; this.options.title = this.node.attrs.title || 'Followers'; this.ds_model = new session.web.DataSetSearch(this, this.view.model); - this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype') + this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype'); this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); - this.follower_model = new session.web.DataSetSearch(this,'mail.followers') + this.follower_model = new session.web.DataSetSearch(this,'mail.followers'); }, start: function() { @@ -51,11 +51,12 @@ openerp_mail_followers = function(session, mail) { bind_events: function() { var self = this; - this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) - .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) - .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); - this.$el.on('click', 'ul.oe_mail_subtypes', function () {self.do_update_subscription(); }) + this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); self.clear_subtypes(); }) + .mouseover(function () { $(this).removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover').find('p').html('Unfollow');}) + .mouseleave(function () { $(this).removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout').find('p').html('Following'); }); + + this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.clear_subtypes(); }); + this.$el.on('click', 'ul.oe_mail_subtypes input', function () {self.do_update_subscription(); }) this.$el.on('click', 'button.oe_mail_button_invite', function(event) { action = { type: 'ir.actions.act_window', @@ -71,37 +72,34 @@ openerp_mail_followers = function(session, mail) { } self.do_action(action, function() { self.read_value(); }); }); + + this.$el.find('button span') + .click(function (e) { self.display_subtypes(); e.stopPropagation(); }) }, read_value: function() { var self = this; - return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids', 'message_is_follower', 'message_subtype_data']).pipe(function (results) { - self.set_value(results[0].message_follower_ids, results[0].message_is_follower, results[0].message_subtype_data); + return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { + self.set_value(results[0].message_follower_ids); }); }, - get_or_set: function(field_name, value) { - if (this.view.fields[field_name]) { - if (value !== undefined) { - this.view.fields[field_name].set_value(value); - } - return this.view.fields[field_name].get_value(); - } - else { - return value; - } + set_value: function(value_) { + console.log("set_value", value_); + this.reinit(); + return this.fetch_followers(value_ || this.get_value()); }, - set_value: function(value_, message_is_follower_value_, message_subtype_data_value_) { - this.reinit(); - if (! this.view.datarecord.id || - session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) { - this.$el.find('div.oe_mail_recthread_aside').hide(); - return; + set_is_follower: function(value_) { + for(var i in value_){ + if(value_[i]['user_ids'][0]==this.session.uid) + this.message_is_follower=true; + this.display_buttons(); + return true; } - this.message_is_follower_value_ = this.get_or_set('message_is_follower', message_is_follower_value_) || false; - this.message_subtype_data_value_ = this.get_or_set('message_subtype_data', message_subtype_data_value_) || {}; - return this.fetch_followers(value_ || this.get_value()); + this.message_is_follower=false; + this.display_buttons(); + return false; }, fetch_followers: function (value_, message_is_follower) { @@ -136,12 +134,11 @@ openerp_mail_followers = function(session, mail) { record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); - this.display_buttons(); - return this.display_subtypes(this.message_subtype_data_value_); + self.set_is_follower(records); }, display_buttons: function () { - if (this.message_is_follower_value_) { + if (this.message_is_follower) { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').show(); } @@ -156,24 +153,48 @@ openerp_mail_followers = function(session, mail) { this.$el.find('span.oe_mail_invite_wrapper').show(); }, - /** Display subtypes: {'name': default, followed} */ - display_subtypes: function (records) { - var subtype_list = this.$el.find('ul.oe_mail_subtypes').empty(); - if (! this.message_is_follower_value_) { - return; - } + set_subtypes:function(data){ + var self = this; + var records = data[this.view.datarecord.id].message_subtype_data; _(records).each(function (record, record_name) { record.name = record_name; record.followed = record.followed || undefined; - $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo(subtype_list); + $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( self.$el.find('ul.oe_mail_subtypes') ); }); }, - + + /** Display subtypes: {'name': default, followed} */ + display_subtypes: function () { + var self = this; + var recthread_subtypes = self.$el.find('.oe_mail_recthread_subtypes'); + subtype_list_ul = self.$el.find('ul.oe_mail_subtypes'); + + if(recthread_subtypes.is(":visible")) { + self.hidden_subtypes(); + } else { + if(subtype_list_ul.is(":empty")) { + var context = new session.web.CompoundContext(this.build_context(), {}); + this.ds_model.call('get_message_subtypes',[[self.view.datarecord.id], context]).pipe(this.proxy('set_subtypes')); + } + + recthread_subtypes.show(); + } + }, + + clear_subtypes: function(){ + this.$el.find('ul.oe_mail_subtypes').empty(); + this.hidden_subtypes(); + }, + + hidden_subtypes: function (){ + this.$el.find('.oe_mail_recthread_subtypes').hide(); + }, + do_follow: function () { var context = new session.web.CompoundContext(this.build_context(), {}); return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(this.proxy('read_value')); }, - + do_unfollow: function () { var context = new session.web.CompoundContext(this.build_context(), {}); return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); @@ -182,13 +203,15 @@ openerp_mail_followers = function(session, mail) { do_update_subscription: function () { var context = new session.web.CompoundContext(this.build_context(), {}); var self = this; + var checklist = new Array(); _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ if($(record).is(':checked')) { - checklist.push(parseInt($(record).attr('id')))} + checklist.push(parseInt($(record).data('id')))} }); + return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value')); }, }); -}; +}; \ No newline at end of file diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 05eb349ea5d..9d0543bbdca 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -7,9 +7,9 @@ -->
                            - - - + + +

                            Message types to follow

                              @@ -39,8 +39,8 @@
                            • - - + +
                            • diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index b49123b8a38..d05893cf778 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -410,9 +410,6 @@
                              - - -
                              @@ -790,11 +787,7 @@
                              - - - -
                              diff --git a/addons/mrp_operations/mrp_operations_view.xml b/addons/mrp_operations/mrp_operations_view.xml index 715f0a53531..834f3000472 100644 --- a/addons/mrp_operations/mrp_operations_view.xml +++ b/addons/mrp_operations/mrp_operations_view.xml @@ -107,11 +107,7 @@
                              - - - -
                              diff --git a/addons/mrp_repair/mrp_repair_view.xml b/addons/mrp_repair/mrp_repair_view.xml index 94a06e6b40d..55cbe49c75b 100644 --- a/addons/mrp_repair/mrp_repair_view.xml +++ b/addons/mrp_repair/mrp_repair_view.xml @@ -189,11 +189,7 @@
                              - - - -
                              diff --git a/addons/note/note_view.xml b/addons/note/note_view.xml index 789a112b868..19eff9bc250 100644 --- a/addons/note/note_view.xml +++ b/addons/note/note_view.xml @@ -50,7 +50,6 @@ - @@ -119,9 +118,6 @@
                              - - -
                              diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml index 64b10bd2bbf..bf73b383216 100644 --- a/addons/procurement/procurement_view.xml +++ b/addons/procurement/procurement_view.xml @@ -103,11 +103,7 @@
                              - - - -
                              diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index d175ea391d5..c08bbc412e3 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -203,11 +203,7 @@
                              - - - -
                              diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index fa639f46c6d..93d01a5619b 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -152,11 +152,7 @@
                              - - - -
                              @@ -482,11 +478,7 @@
                              - - - -
                              diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index f9e04e7420e..8d54520261f 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -161,11 +161,7 @@
                              - - - -
                              diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 69042a2fa1a..759c0561631 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -285,11 +285,7 @@
                              - - - -
                              diff --git a/addons/purchase_requisition/purchase_requisition_view.xml b/addons/purchase_requisition/purchase_requisition_view.xml index cba22f384ca..80bdd9aa95b 100644 --- a/addons/purchase_requisition/purchase_requisition_view.xml +++ b/addons/purchase_requisition/purchase_requisition_view.xml @@ -103,9 +103,6 @@
                              - - -
                              diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 54fdcb8c140..5c2320a7d5c 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -351,11 +351,7 @@
                              - - - -
                              diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 2f2dc3a2d8a..83fed186f42 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -917,11 +917,7 @@
                              - - - -
                              @@ -1047,11 +1043,7 @@
                              - - - -
                              From ac7adf29d2e59a9dc31e4c59b0969b448bb5742e Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 24 Sep 2012 12:11:08 +0200 Subject: [PATCH 167/245] [IMP] mail_follower: unfollow when no subtypes following bzr revid: chm@openerp.com-20120924101108-iyhv21w0zkvzb4jb --- addons/mail/static/src/js/mail_followers.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index a3ba6f91a04..85bd4c37987 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -85,7 +85,6 @@ openerp_mail_followers = function(session, mail) { }, set_value: function(value_) { - console.log("set_value", value_); this.reinit(); return this.fetch_followers(value_ || this.get_value()); }, @@ -209,8 +208,11 @@ openerp_mail_followers = function(session, mail) { if($(record).is(':checked')) { checklist.push(parseInt($(record).data('id')))} }); - - return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value')); + + if(!checklist.length) + return this.do_unfollow(); + else + return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value')); }, }); From a74b35ee3758545dabd811fe8ac9d0c68a3420ca Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 24 Sep 2012 12:39:31 +0200 Subject: [PATCH 168/245] [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 169/245] [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 170/245] [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 171/245] [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 172/245] [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 4525190e726a3f9fadeade2fba40c41a69a4bb72 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 25 Sep 2012 10:58:09 +0200 Subject: [PATCH 173/245] [IMP] mail: auto display subtypes on subscription (web) bzr revid: chm@openerp.com-20120925085809-u8f7tvtbdxnftbu4 --- addons/mail/mail_thread.py | 36 +++++++++++++++++---- addons/mail/static/src/js/mail_followers.js | 30 ++++++++++------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 71d4bfd099b..665ca664994 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -625,10 +625,17 @@ class mail_thread(osv.AbstractModel): ``(name,content)``, where content is NOT base64 encoded :return: ID of newly created mail.message """ + # message_post + # [26] False notification mt_crm_stage False + + # message_post + # [26] False notification mt_crm_won False + context = context or {} attachments = attachments or [] assert (not thread_id) or isinstance(thread_id, (int, long)) or \ (isinstance(thread_id, (list, tuple)) and len(thread_id) == 1), "Invalid thread_id" + if isinstance(thread_id, (list, tuple)): thread_id = thread_id and thread_id[0] @@ -652,9 +659,19 @@ class mail_thread(osv.AbstractModel): else: subtype_id = False + + #auto link messages for same id and object + messages = self.pool.get('mail.message') + model = context.get('thread_model', self._name) if thread_id else False + if model != 'res.partner': + message_ids = messages.search(cr, uid, ['&',('res_id', '=', thread_id),('model','=',model)], context=context) + if len(message_ids): + parent_id = min(message_ids) + + values = kwargs values.update({ - 'model': context.get('thread_model', self._name) if thread_id else False, + 'model': model, 'res_id': thread_id or False, 'body': body, 'subject': subject, @@ -666,12 +683,22 @@ class mail_thread(osv.AbstractModel): # Avoid warnings about non-existing fields for x in ('from', 'to', 'cc'): values.pop(x, None) - return self.pool.get('mail.message').create(cr, uid, values, context=context) + + print "------------------------------------------" + print values, "mail_thread 688" + print "--------≃============----------------------------------" + + return messages.create(cr, uid, values, context=context) #------------------------------------------------------ # Followers API #------------------------------------------------------ + def get_message_subtypes(self, cr, uid, ids, context=None): + """ message_subtype_data: data about document subtypes: which are + available, which are followed if any """ + return self._get_subscription_data(cr, uid, ids, None, None, context=context) + def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, subscribe uid instead. """ @@ -680,11 +707,6 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, subtype_ids=subtype_ids, context=context) - def get_message_subtypes(self, cr, uid, ids, context=None): - """ message_subtype_data: data about document subtypes: which are - available, which are followed if any """ - return self._get_subscription_data(cr, uid, ids, None, None, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 85bd4c37987..4ceb936c623 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -51,11 +51,11 @@ openerp_mail_followers = function(session, mail) { bind_events: function() { var self = this; - this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); self.clear_subtypes(); }) + this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) .mouseover(function () { $(this).removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover').find('p').html('Unfollow');}) .mouseleave(function () { $(this).removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout').find('p').html('Following'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.clear_subtypes(); }); + this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); this.$el.on('click', 'ul.oe_mail_subtypes input', function () {self.do_update_subscription(); }) this.$el.on('click', 'button.oe_mail_button_invite', function(event) { action = { @@ -101,9 +101,9 @@ openerp_mail_followers = function(session, mail) { return false; }, - fetch_followers: function (value_, message_is_follower) { - this.value = value_; - this.message_is_follower = message_is_follower || (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); + fetch_followers: function (value_) { + this.value = value_ || {}; + this.message_is_follower = (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers'), this.proxy('display_generic')); }, @@ -163,7 +163,7 @@ openerp_mail_followers = function(session, mail) { }, /** Display subtypes: {'name': default, followed} */ - display_subtypes: function () { + display_subtypes: function (visible) { var self = this; var recthread_subtypes = self.$el.find('.oe_mail_recthread_subtypes'); subtype_list_ul = self.$el.find('ul.oe_mail_subtypes'); @@ -180,21 +180,27 @@ openerp_mail_followers = function(session, mail) { } }, - clear_subtypes: function(){ - this.$el.find('ul.oe_mail_subtypes').empty(); - this.hidden_subtypes(); - }, - hidden_subtypes: function (){ this.$el.find('.oe_mail_recthread_subtypes').hide(); }, do_follow: function () { + var self =this; + _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ + $(record).attr('checked','checked'); + }); var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(this.proxy('read_value')); + return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(function(value_){ + self.read_value(value_); + if(!self.$el.find('.oe_mail_recthread_subtypes').is(":visible")) + self.display_subtypes(true); + }); }, do_unfollow: function () { + _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ + $(record).attr('checked',false); + }); var context = new session.web.CompoundContext(this.build_context(), {}); return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); }, From bf3cb4bcd6de46ec86b9bb335008a3722e817276 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 25 Sep 2012 11:12:36 +0200 Subject: [PATCH 174/245] [FIX] mail: rpc with not false value bzr revid: chm@openerp.com-20120925091236-l9ywccbyjsoa31ph --- addons/mail/static/src/js/mail_followers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 4ceb936c623..5836bd94ba1 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -104,7 +104,8 @@ openerp_mail_followers = function(session, mail) { fetch_followers: function (value_) { this.value = value_ || {}; this.message_is_follower = (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers'), this.proxy('display_generic')); + if(value_) + return this.ds_follow.call('read', [this.value, ['name', 'user_ids']]).pipe(this.proxy('display_followers'), this.proxy('display_generic')); }, /* Display generic info about follower, for people not having access to res_partner */ From a19717019449a86973269ef7cefa492dd44ca97d Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 25 Sep 2012 11:51:19 +0200 Subject: [PATCH 175/245] [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 176/245] [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 177/245] [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 178/245] [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 4ddb50dbf920a02bbb6f1c210a1215abd8a0b428 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 26 Sep 2012 09:17:09 +0200 Subject: [PATCH 179/245] [IMP] mail: subtype adapted for css onhover box bzr revid: chm@openerp.com-20120926071709-v51ra4mzn2hp121j --- addons/mail/mail_message.py | 2 + addons/mail/mail_thread.py | 15 ++-- addons/mail/static/src/css/mail.css | 44 ++++++--- addons/mail/static/src/js/mail.js | 90 +++++++++++++------ addons/mail/static/src/js/mail_followers.js | 89 +++++++++--------- addons/mail/static/src/xml/mail.xml | 13 +-- addons/mail/static/src/xml/mail_followers.xml | 16 ++-- 7 files changed, 165 insertions(+), 104 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index fc830a3c214..08834686088 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -201,6 +201,7 @@ class mail_message(osv.Model): partner_ids = self.pool.get('res.partner').name_get(cr, uid, [x.id for x in msg.partner_ids], context=context) except (orm.except_orm, osv.except_osv): partner_ids = [] + return { 'id': msg.id, 'type': msg.type, @@ -216,6 +217,7 @@ class mail_message(osv.Model): 'partner_ids': partner_ids, 'child_ids': [], 'child_nbr': child_nbr, + 'parent_id': msg.parent_id and msg.parent_id.id or False, 'vote_user_ids': vote_ids, 'has_voted': has_voted } diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 665ca664994..f004dd9a900 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -625,11 +625,6 @@ class mail_thread(osv.AbstractModel): ``(name,content)``, where content is NOT base64 encoded :return: ID of newly created mail.message """ - # message_post - # [26] False notification mt_crm_stage False - - # message_post - # [26] False notification mt_crm_won False context = context or {} attachments = attachments or [] @@ -653,6 +648,7 @@ class mail_thread(osv.AbstractModel): } attachment_ids.append((0, 0, data_attach)) + # get subtype if subtype: ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype) subtype_id = ref and ref[1] or False @@ -684,11 +680,10 @@ class mail_thread(osv.AbstractModel): for x in ('from', 'to', 'cc'): values.pop(x, None) - print "------------------------------------------" - print values, "mail_thread 688" - print "--------≃============----------------------------------" - - return messages.create(cr, uid, values, context=context) + added_message_id = messages.create(cr, uid, values, context=context) + added_message = self.pool.get('mail.message').message_read(cr, uid, [added_message_id]) + + return added_message #------------------------------------------------------ # Followers API diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 3fde4cbc67b..497e5940791 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -50,14 +50,6 @@ .openerp div.oe_mail_recthread_aside input { cursor:pointer; } -.openerp div.oe_mail_recthread_subtypes { - display:none; -} -.openerp div.oe_mail_recthread_aside button span { - position: absolute; - top:-7px; - right:5px; -} /* Specific display of threads in the wall */ /* ------------------------------------------------------------ */ @@ -108,7 +100,7 @@ width: 120px; } -.openerp button.oe_mail_button_mouseout { +.openerp .oe_mail_recthread_aside .oe_follower.oe_follow { color: white; background-color: #8a89ba; background-image: -webkit-gradient(linear, left top, left bottom, from(#8a89ba), to(#807fb4)); @@ -118,9 +110,7 @@ background-image: -o-linear-gradient(top, #8a89ba, #807fb4); background-image: linear-gradient(to bottom, #8a89ba, #807fb4); } - -.openerp button.oe_mail_button_mouseover { - display: none; +.openerp .oe_mail_recthread_aside .oe_follower.oe_following { color: white; background-color: #dc5f59; background-image: -webkit-gradient(linear, left top, left bottom, from(#dc5f59), to(#b33630)); @@ -131,10 +121,40 @@ background-image: linear-gradient(to bottom, #dc5f59, #b33630); } + +.openerp .oe_mail_recthread_aside .oe_follower span { + display:none; +} +.openerp .oe_mail_recthread_aside .oe_following span.oe_following, +.openerp .oe_mail_recthread_aside .oe_notfollow span.oe_follow { + display:block; +} + .openerp div.oe_mail_recthread_followers { margin-bottom: 8px; } + +/* ------------------------------------------------------------ */ +/* subtypes +/* ------------------------------------------------------------ */ + +.openerp .oe_mouse_subtypes { + display:inline-block; + position: relative; + z-index: 5; +} +.openerp .oe_mouse_subtypes .oe_recthread_subtypes { + position: absolute; + z-index: 2; +} +.openerp .oe_mouse_subtypes.oe_mouseout .oe_recthread_subtypes { + display: none; +} +.openerp .oe_mouse_subtypes.oe_mouseover .oe_recthread_subtypes { + display: block; +} + /* ------------------------------------------------------------ */ /* Thread /* ------------------------------------------------------------ */ diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 8adba39507c..f4ae9018df1 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -110,8 +110,8 @@ openerp.mail = function(session) { this._super.apply(this, arguments); // customize display: add avatar, clean previous content var user_avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); - this.$el.find('img.oe_mail_icon').attr('src', user_avatar); - this.$el.find('div.oe_mail_msg_content').empty(); + this.$('img.oe_mail_icon').attr('src', user_avatar); + this.$('div.oe_mail_msg_content').empty(); // create a context for the dataset and default_get of the wizard var context = _.extend({}, this.options.context); this.ds_compose = new session.web.DataSetSearch(this, 'mail.compose.message', context); @@ -139,21 +139,21 @@ openerp.mail = function(session) { disable_autofocus: true, }); // add the form, bind events, activate the form - var msg_node = this.$el.find('div.oe_mail_msg_content'); + var msg_node = this.$('div.oe_mail_msg_content'); return $.when(this.form_view.appendTo(msg_node)).pipe(this.proxy('postprocess_create_form_view')); }, postprocess_create_form_view: function () { // handle attachment button this.fileupload_id = _.uniqueId('oe_fileupload'); - var button_attach = this.$el.find('button.oe_mail_compose_message_attachment'); + var button_attach = this.$('button.oe_mail_compose_message_attachment'); var rendered = session.web.qweb.render('mail.compose_message.add_attachment', {'widget': this}); $(rendered).insertBefore(button_attach); // move the button inside div.oe_hidden_input_file - var input_node = this.$el.find('input[name=ufile]'); + var input_node = this.$('input[name=ufile]'); button_attach.detach().insertAfter(input_node); // set the function called when attachments are added - this.$el.find('input.oe_form_binary_file').change(this.on_attachment_change); + this.$('input.oe_form_binary_file').change(this.on_attachment_change); this.bind_events(); this.form_view.do_show(); }, @@ -161,7 +161,7 @@ openerp.mail = function(session) { on_attachment_change: function (event) { var $target = $(event.target); if ($target.val() !== '') { - this.$el.find('form.oe_form_binary_form').submit(); + this.$('form.oe_form_binary_form').submit(); session.web.blockUI(); } }, @@ -178,11 +178,11 @@ openerp.mail = function(session) { }, display_attachments: function () { - var attach_node = this.$el.find('div.oe_mail_compose_message_attachments'); + var attach_node = this.$('div.oe_mail_compose_message_attachments'); var rendered = session.web.qweb.render('mail.thread.message.attachments', {'record': this}); attach_node.empty(); $(rendered).appendTo(attach_node); - this.$el.find('.oe_mail_msg_attachments').show(); + this.$('.oe_mail_msg_attachments').show(); var composer_attachment_ids = _.pluck(this.attachment_ids, 'id'); var onchange_like = {'value': {'attachment_ids': composer_attachment_ids}} this.form_view.on_processed_onchange(onchange_like, []); @@ -283,6 +283,7 @@ openerp.mail = function(session) { show_dd_delete: options.show_dd_delete || false, show_dd_hide: options.show_dd_hide || false, truncate_limit: options.truncate_limit || 250, + mail_wall: options.mail_wall || this } // datasets and internal vars this.records = {}; @@ -309,7 +310,7 @@ openerp.mail = function(session) { * - show_header_compose: show the composition form in the header */ do_customize_display: function() { if (this.options.show_header_compose) { - this.$el.find('div.oe_mail_thread_action').eq(0).show(); + this.$('div.oe_mail_thread_action').eq(0).show(); } }, @@ -321,7 +322,7 @@ openerp.mail = function(session) { // event: click on 'More' at bottom of thread this.$el.on('click', 'a.oe_mail_fetch_more', this.do_message_fetch_more); // event: writing in basic textarea of composition form (quick reply) - this.$el.find('textarea.oe_mail_compose_textarea').keyup(function (event) { + this.$('textarea.oe_mail_compose_textarea').keyup(function (event) { var charCode = (event.which) ? event.which : window.event.keyCode; if (event.shiftKey && charCode == 13) { this.value = this.value+"\n"; } else if (charCode == 13) { return self.message_post(); } @@ -405,7 +406,7 @@ openerp.mail = function(session) { this.compose_message_widget = new mail.ComposeMessage(this, { 'context': _.extend(context || {}, this.context), }); - var composition_node = this.$el.find('div.oe_mail_thread_action'); + var composition_node = this.$('div.oe_mail_thread_action'); composition_node.empty(); var compose_done = this.compose_message_widget.appendTo(composition_node); return compose_done; @@ -418,7 +419,7 @@ openerp.mail = function(session) { /** Clean the thread */ message_clean: function() { - this.$el.find('div.oe_mail_thread_display').empty(); + this.$('div.oe_mail_thread_display').empty(); }, /** Fetch messages @@ -467,9 +468,10 @@ openerp.mail = function(session) { 'show_reply': self.options.show_reply && self.options.thread_level > 1, 'show_reply_by_email': self.options.show_reply_by_email, 'show_dd_hide': self.options.show_dd_hide, - 'show_dd_delete': self.options.show_dd_delete }); - self.$el.find('li.oe_mail_thread_msg:last').append('
                              '); - self.thread.appendTo(self.$el.find('div.oe_mail_thread_subthread:last')); + 'show_dd_delete': self.options.show_dd_delete, + 'mail_wall': self.options.mail_wall }); + self.$('li.oe_mail_thread_msg:last').append('
                              '); + self.thread.appendTo(self.$('div.oe_mail_thread_subthread:last')); } }); }, @@ -497,7 +499,7 @@ openerp.mail = function(session) { // render, add the expand feature var rendered = session.web.qweb.render('mail.thread.message', {'record': record, 'thread': this, 'options': this.options}); $(rendered).appendTo(this.$el.children('div.oe_mail_thread_display:first')); - this.$el.find('div.oe_mail_msg_body').expander({ + this.$('div.oe_mail_msg_body').expander({ slicePoint: this.options.truncate_limit, expandText: 'read more', userCollapseText: '[^]', @@ -526,19 +528,41 @@ openerp.mail = function(session) { display_user_avatar: function () { var avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); - return this.$el.find('img.oe_mail_icon').attr('src', avatar); + return this.$('img.oe_mail_icon').attr('src', avatar); }, + /* Display the message if if the msg_id don't exists. + * If the record have a parent, insert parent or inside parent */ + message_fetch_new_data: function(records) { + var self=this; + + _(records).each(function (record) { + if( !self.options.mail_wall.$('.oe_mail_thread_msg[data-msg_id="'+record.id+'"]').size() ) { + self.display_record( record ); + } + }); + }, + + search_thread: function() { + + }, + + animated_destroy: function(animated) { + //graphic effects + this.destroy(); + }, + + /*post a message and flatch the message*/ message_post: function (body) { var self = this; if (! body) { - var comment_node = this.$el.find('textarea'); + var comment_node = this.$('textarea'); var body = comment_node.val(); comment_node.val(''); } return this.ds_thread.call('message_post', [ - [this.context.default_res_id], body, false, 'comment', this.context.default_parent_id, undefined] - ).pipe(self.message_clean()).pipe(self.message_fetch(false)); + [this.context.default_res_id], body, false, 'comment', false, this.context.default_parent_id, undefined]) + .then(this.proxy('message_fetch_new_data')); }, /** Action: 'shows more' to fetch new messages */ @@ -585,7 +609,7 @@ openerp.mail = function(session) { var self = this; this._super.apply(this, arguments); if (! this.view.datarecord.id || session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) { - this.$el.find('oe_mail_thread').hide(); + this.$('oe_mail_thread').hide(); return; } // update context @@ -597,14 +621,14 @@ openerp.mail = function(session) { // create and render Thread widget var show_header_compose = this.view.is_action_enabled('edit') || (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); - this.$el.find('div.oe_mail_recthread_main').empty(); + this.$('div.oe_mail_recthread_main').empty(); var thread = new mail.Thread(self, domain, this.options.context, { 'thread_level': this.options.thread_level, 'show_header_compose': show_header_compose, 'use_composer': show_header_compose, 'show_dd_delete': true, 'show_reply_by_email': show_header_compose }); - return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); + return thread.appendTo(this.$('div.oe_mail_recthread_main')); }, }); @@ -656,7 +680,7 @@ openerp.mail = function(session) { load_searchview: function (defaults, hidden) { var self = this; this.searchview = new session.web.SearchView(this, this.ds_msg, false, defaults || {}, hidden || false); - return this.searchview.appendTo(this.$el.find('.oe_view_manager_view_search')).then(function () { + return this.searchview.appendTo(this.$('.oe_view_manager_view_search')).then(function () { self.searchview.on_search.add(self.do_searchview_search); }); }, @@ -681,21 +705,29 @@ openerp.mail = function(session) { return self.message_render(); }); }, + + search_thread: function(id) { + var self=this; + + /*this.thread*/ + }, /** Clean and display the threads */ message_render: function () { - this.$el.find('ul.oe_mail_wall_threads').empty(); + this.$('ul.oe_mail_wall_threads').empty(); var domain = this.options.domain.concat(this.search_results['domain']); var render_res = session.web.qweb.render('mail.wall_thread_container', {}); - $(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); - var thread = new mail.Thread(this, domain, this.options.context, + $(render_res).appendTo(this.$('ul.oe_mail_wall_threads')); + + this.thread = new mail.Thread(this, domain, this.options.context, { 'thread_level': this.options.thread_level, 'use_composer': true, 'show_reply': this.options.thread_level > 0, 'show_dd_hide': true, + 'mail_wall': self } ); - return thread.appendTo(this.$el.find('li.oe_mail_wall_thread:last')); + return this.thread.appendTo(this.$('li.oe_mail_wall_thread:last')); }, }); }; diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 5836bd94ba1..47bf9f74223 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -51,13 +51,33 @@ openerp_mail_followers = function(session, mail) { bind_events: function() { var self = this; - this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) - .mouseover(function () { $(this).removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover').find('p').html('Unfollow');}) - .mouseleave(function () { $(this).removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout').find('p').html('Following'); }); + this.$('div.oe_mouse_subtypes') + .on('mouseover', function () { + $(this).removeClass('oe_mouseout').addClass('oe_mouseover'); + self.display_subtypes(); + }) + .on('mouseleave', function () { + $(this).removeClass('oe_mouseover').addClass('oe_mouseout'); + self.display_subtypes(); + }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); - this.$el.on('click', 'ul.oe_mail_subtypes input', function () {self.do_update_subscription(); }) - this.$el.on('click', 'button.oe_mail_button_invite', function(event) { + this.$('button.oe_follower') + .on('click', function () { + if($(this).hasClass('oe_notfollow')) + self.do_follow(); + else + self.do_unfollow(); + }) + .on('mouseover', function () { + $(this).removeClass('oe_mouseout').addClass('oe_mouseover'); + }) + .on('mouseleave', function () { + $(this).removeClass('oe_mouseover').addClass('oe_mouseout'); + }); + + this.$el.on('click', 'ul.oe_subtypes input', function () { self.do_update_subscription(); }) + + this.$el.on('click', 'button.oe_invite', function(event) { action = { type: 'ir.actions.act_window', res_model: 'mail.wizard.invite', @@ -72,9 +92,6 @@ openerp_mail_followers = function(session, mail) { } self.do_action(action, function() { self.read_value(); }); }); - - this.$el.find('button span') - .click(function (e) { self.display_subtypes(); e.stopPropagation(); }) }, read_value: function() { @@ -111,7 +128,7 @@ openerp_mail_followers = function(session, mail) { /* Display generic info about follower, for people not having access to res_partner */ display_generic: function (error, event) { event.preventDefault(); - var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); + var node_user_list = this.$('ul.oe_mail_followers_display').empty(); // format content: Followers (You and 0 other) // Followers (3) var content = this.options.title; if (this.message_is_follower) { @@ -120,7 +137,7 @@ openerp_mail_followers = function(session, mail) { else { content += ' (' + this.value.length + ')' } - this.$el.find('div.oe_mail_recthread_followers h4').html(content); + this.$('div.oe_mail_recthread_followers h4').html(content); this.display_buttons(); return $.when(); }, @@ -128,29 +145,29 @@ openerp_mail_followers = function(session, mail) { /** Display the followers, evaluate is_follower directly */ display_followers: function (records) { var self = this; - var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); - this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); - _(records).each(function (record) { + var node_user_list = this.$('ul.oe_mail_followers_display').empty(); + this.$('div.oe_mail_recthread_followers h4').html(this.options.title + (records.length>=5 ? ' (' + records.length + ')' : '') ); + console.log(records); + for(var i=0; i -