From 8b61ed737c1e5da85dc75091246cab89ca6b85b0 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 15 Aug 2012 12:29:19 +0200 Subject: [PATCH] [IMP] need action new implementation bzr revid: fp@openerp.com-20120815102919-w3iuspeoz5fmz97u --- addons/base_calendar/crm_meeting.py | 4 ++++ addons/crm/crm_phonecall.py | 2 +- addons/hr_holidays/hr_holidays.py | 28 +++++++++++++--------------- addons/purchase/purchase.py | 8 ++------ addons/sale/sale.py | 8 ++------ 5 files changed, 22 insertions(+), 28 deletions(-) diff --git a/addons/base_calendar/crm_meeting.py b/addons/base_calendar/crm_meeting.py index cb96ff2a4d0..a66449a8b5d 100644 --- a/addons/base_calendar/crm_meeting.py +++ b/addons/base_calendar/crm_meeting.py @@ -70,6 +70,10 @@ class crm_meeting(base_state, osv.Model): # OpenChatter # ---------------------------------------- + # shows events of the day for this user + def needaction_domain_get(self, cr, uid, domain=[], context={}): + return [('date','<=',time.strftime('%Y-%M-%D 23:59:59')), ('date_deadline','>=', time.strftime('%Y-%M-%D 00:00:00')), ('user_id','=',uid)] + def case_get_note_msg_prefix(self, cr, uid, id, context=None): return 'Meeting' diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py index 8ffa8dd591e..7a544da5dc1 100644 --- a/addons/crm/crm_phonecall.py +++ b/addons/crm/crm_phonecall.py @@ -32,7 +32,7 @@ class crm_phonecall(base_state, osv.osv): _name = "crm.phonecall" _description = "Phonecall" _order = "id desc" - _inherit = ['ir.needaction_mixin', 'mail.thread'] + _inherit = ['mail.thread'] _columns = { # base_state required fields 'date_action_last': fields.datetime('Last Action', readonly=1), diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 7eedfa54ce5..0134fc79fdd 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -347,24 +347,22 @@ class hr_holidays(osv.osv): if leaves_rest < record.number_of_days_temp: raise osv.except_osv(_('Warning!'), _('There are not enough %s allocated for employee %s; please create an allocation request for this leave type.') % (record.holiday_status_id.name, record.employee_id.name)) return True - + # ----------------------------- # OpenChatter and notifications # ----------------------------- - - def get_needaction_user_ids(self, cr, uid, ids, context=None): - result = super(hr_holidays, self).get_needaction_user_ids(cr, uid, ids, context=context) - for obj in self.browse(cr, uid, ids, context=context): - if obj.state == 'confirm' and obj.employee_id.parent_id: - result[obj.id] = [obj.employee_id.parent_id.user_id.id] - elif obj.state == 'validate1': - # get group_hr_manager: everyone will be warned of second validation - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_hr_manager') or False - obj_id = res and res[1] or False - if obj_id: - hr_manager_group = self.pool.get('res.groups').read(cr, uid, [obj_id], ['users'], context=context)[0] - result[obj.id] = hr_manager_group['users'] - return result + + 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) + ] + # 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') ] + return dom def message_get_subscribers(self, cr, uid, ids, context=None): """ Override to add employee and its manager. """ diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index b02e959301f..705f55f5d5c 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -732,12 +732,8 @@ class purchase_order(osv.osv): # OpenChatter methods and notifications # -------------------------------------- - def get_needaction_user_ids(self, cr, uid, ids, context=None): - result = super(purchase_order, self).get_needaction_user_ids(cr, uid, ids, context=context) - for obj in self.browse(cr, uid, ids, context=context): - if obj.state == 'approved': - result[obj.id].append(obj.validator.id) - return result + def needaction_domain_get(self, cr, uid, ids, context=None): + return [('state','=','draft')] 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) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 722b22ba602..2a9aa08d3ca 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1022,12 +1022,8 @@ class sale_order(osv.osv): # OpenChatter methods and notifications # ------------------------------------------------ - def get_needaction_user_ids(self, cr, uid, ids, context=None): - result = super(sale_order, self).get_needaction_user_ids(cr, uid, ids, context=context) - for obj in self.browse(cr, uid, ids, context=context): - if (obj.state == 'manual' or obj.state == 'progress'): - result[obj.id].append(obj.user_id.id) - return result + def needaction_domain_get(self, cr, uid, ids, context=None): + return [('state', '=', 'draft'), ('user_id','=',uid)] def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context):