diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py
index 164314c4573..0c3ac885e85 100644
--- a/addons/procurement/procurement.py
+++ b/addons/procurement/procurement.py
@@ -81,6 +81,7 @@ class procurement_order(osv.osv):
_name = "procurement.order"
_description = "Procurement"
_order = 'priority,date_planned desc'
+ _inherit = ['ir.needaction_mixin', 'mail.thread']
_log_create = False
_columns = {
'name': fields.char('Reason', size=64, required=True, help='Procurement name.'),
@@ -117,6 +118,7 @@ class procurement_order(osv.osv):
\nAfter confirming the state is set to \'Running\'.\n If any exception arises in the order then the state is set to \'Exception\'.\n Once the exception is removed the state becomes \'Ready\'.\n It is in \'Waiting\'. state when the procurement is waiting for another one to finish.'),
'note': fields.text('Note'),
'company_id': fields.many2one('res.company','Company',required=True),
+ 'user_id': fields.many2one('res.users', 'Salesman'),
}
_defaults = {
'state': 'draft',
@@ -124,6 +126,7 @@ class procurement_order(osv.osv):
'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'close_move': 0,
'procure_method': 'make_to_order',
+ 'user_id': lambda obj, cr, uid, context: uid,
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'procurement.order', context=c)
}
@@ -346,6 +349,7 @@ class procurement_order(osv.osv):
move_obj.action_confirm(cr, uid, [id], context=context)
self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1})
self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''})
+ self.confirm_send_note(cr, uid, ids, context)
return True
def action_move_assigned(self, cr, uid, ids, context=None):
@@ -354,6 +358,7 @@ class procurement_order(osv.osv):
"""
self.write(cr, uid, ids, {'state': 'running',
'message': _('from stock: products assigned.')})
+ self.running_send_note(cr, uid, ids, context)
return True
def _check_make_to_stock_service(self, cr, uid, procurement, context=None):
@@ -427,6 +432,7 @@ class procurement_order(osv.osv):
if len(todo):
move_obj.write(cr, uid, todo, {'state': 'assigned'})
self.write(cr, uid, ids, {'state': 'cancel'})
+ self.cancel_send_note(cr, uid, ids, context=None)
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'procurement.order', id, cr)
@@ -451,6 +457,7 @@ class procurement_order(osv.osv):
@return: True
"""
res = self.write(cr, uid, ids, {'state': 'ready'})
+ self.ready_send_note(cr, uid, ids, context)
return res
def action_done(self, cr, uid, ids):
@@ -463,11 +470,55 @@ class procurement_order(osv.osv):
if procurement.close_move and (procurement.move_id.state <> 'done'):
move_obj.action_done(cr, uid, [procurement.move_id.id])
res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')})
+ self.done_send_note(cr, uid, ids, context)
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'procurement.order', id, cr)
return res
+ # ----------------------------------------
+ # OpenChatter methods and notifications
+ # ----------------------------------------
+
+ def get_needaction_user_ids(self, cr, uid, ids, context=None):
+ result = dict.fromkeys(ids, [])
+ for obj in self.browse(cr, uid, ids, context=context):
+ if (obj.state == 'draft' or obj.state == 'waiting'):
+ result[obj.id] = [obj.user_id.id]
+ return result
+
+ def create(self, cr, uid, vals, context=None):
+ obj_id = super(procurement_order, self).create(cr, uid, vals, context)
+ self.create_send_note(cr, uid, [obj_id], context=context)
+ return obj_id
+
+ def create_send_note(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.message_subscribe(cr, uid, [obj.id], [obj.user_id.id], context=context)
+ self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been created."), context=context)
+
+ def confirm_send_note(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.message_subscribe(cr, uid, [obj.id], [obj.user_id.id], context=context)
+ self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been confirmed."), context=context)
+
+ def running_send_note(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.message_subscribe(cr, uid, [obj.id], [obj.user_id.id], context=context)
+ self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been run."), context=context)
+
+ def ready_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=_("Procurement has been redy."), 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=_("Procurement has been cancelled."), context=context)
+
+ def done_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=_("Procurement has been done."), context=context)
+
procurement_order()
class StockPicking(osv.osv):
diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml
index 6ce26ecb98c..6cef9586669 100644
--- a/addons/procurement/procurement_view.xml
+++ b/addons/procurement/procurement_view.xml
@@ -46,7 +46,8 @@
procurement.order
form
-