From 065821dfd68a3d08dd056ae70c71a7eb024c10b9 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 19 Dec 2012 00:49:07 +0100 Subject: [PATCH] [MOD] use read() instead of browse bzr revid: fp@tinyerp.com-20121218234907-j672neyvifmo4bur --- addons/account/account_invoice.py | 4 +- addons/crm/crm_lead.py | 8 +- addons/hr_expense/hr_expense.py | 6 +- addons/hr_holidays/hr_holidays.py | 6 +- addons/hr_recruitment/hr_recruitment.py | 8 +- addons/mail/mail_thread.py | 107 +++++++++--------------- addons/project/project.py | 10 ++- addons/project_issue/project_issue.py | 10 ++- addons/purchase/purchase.py | 4 +- addons/sale/sale.py | 4 +- 10 files changed, 72 insertions(+), 95 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 5c6d6f7e3a1..1bd97855fb2 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -186,8 +186,8 @@ class account_invoice(osv.osv): _order = "id desc" _track = { 'state': { - 'account.mt_invoice_paid': lambda self, cr, uid, obj, ctx=None: obj.state == 'paid' and obj.type in ('out_invoice','out_refund'), - 'account.mt_invoice_validated': lambda self, cr, uid, obj, ctx=None: obj.state == 'open' and obj.type in ('out_invoice','out_refund'), + 'account.mt_invoice_paid': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'paid' and obj['type'] in ('out_invoice','out_refund'), + 'account.mt_invoice_validated': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'open' and obj['type'] in ('out_invoice','out_refund'), }, } _columns = { diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 9079d8b24e8..e450aa81bb1 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -74,10 +74,12 @@ class crm_lead(base_stage, format_address, osv.osv): _inherit = ['mail.thread', 'ir.needaction_mixin'] _track = { + 'state': { + 'crm.mt_lead_won': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'done', + 'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'cancel', + }, 'stage_id': { - 'crm.mt_lead_won': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.state == 'done' and obj.probability == 100.0, - 'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.state == 'cancel' and obj.probability == 0.0, - 'crm.mt_lead_stage': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.state not in ['cancel', 'done'], + 'crm.mt_lead_stage': lambda self, cr, uid, obj, ctx=None: obj['state'] not in ['cancel', 'done'], }, } diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index b62c2003044..4287dbfc779 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -66,9 +66,9 @@ class hr_expense_expense(osv.osv): _order = "id desc" _track = { 'state': { - 'hr_expense.mt_expense_approved': lambda self, cr, uid, obj, ctx=None: obj.state == 'accepted', - 'hr_expense.mt_expense_refused': lambda self, cr, uid, obj, ctx=None: obj.state == 'cancelled', - 'hr_expense.mt_expense_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state == 'confirm', + 'hr_expense.mt_expense_approved': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'accepted', + 'hr_expense.mt_expense_refused': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'cancelled', + 'hr_expense.mt_expense_confirmed': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'confirm', }, } diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 35240c40423..63df9829aed 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -111,9 +111,9 @@ class hr_holidays(osv.osv): _inherit = ['mail.thread', 'ir.needaction_mixin'] _track = { 'state': { - 'hr_holidays.mt_holidays_approved': lambda self, cr, uid, obj, ctx=None: obj.state == 'validate', - 'hr_holidays.mt_holidays_refused': lambda self, cr, uid, obj, ctx=None: obj.state == 'refuse', - 'hr_holidays.mt_holidays_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state == 'confirm', + 'hr_holidays.mt_holidays_approved': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'validate', + 'hr_holidays.mt_holidays_refused': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'refuse', + 'hr_holidays.mt_holidays_confirmed': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'confirm', }, } diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index bd492b5cd83..b2e2cb17d4d 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -93,10 +93,12 @@ class hr_applicant(base_stage, osv.Model): _order = "id desc" _inherit = ['mail.thread', 'ir.needaction_mixin'] _track = { + 'state': { + 'hr_recruitment.mt_applicant_hired': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'done', + 'hr_recruitment.mt_applicant_refused': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'cancel', + }, 'stage_id': { - 'hr_recruitment.mt_applicant_hired': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.state == 'done' and obj.emp_id, - 'hr_recruitment.mt_applicant_refused': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.state == 'cancel' and not obj.emp_id, - 'hr_recruitment.mt_stage_changed': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.state not in ['done', 'cancel'], + 'hr_recruitment.mt_stage_changed': lambda self, cr, uid, obj, ctx=None: obj['state'] not in ['done', 'cancel'], }, } diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 9c3bfe4c4f4..338a46cd762 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -80,7 +80,7 @@ class mail_thread(osv.AbstractModel): %endif