[ADD] added code for social chatter in procurement module

bzr revid: tpa@tinyerp.com-20120420102912-fplcrpuhs59y7o2o
This commit is contained in:
Turkesh Patel (Open ERP)
2012-04-20 15:59:12 +05:30
parent f0b5466bca
commit 3c5d0902df
2 changed files with 57 additions and 1 deletions
+51
View File
@@ -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 <b>created</b>."), 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 <b>confirmed</b>."), 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 <b>run</b>."), 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 <b>redy</b>."), 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 <b>cancelled</b>."), 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 <b>done</b>."), context=context)
procurement_order()
class StockPicking(osv.osv):
+6 -1
View File
@@ -46,7 +46,8 @@
<field name="model">procurement.order</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Procurement">
<form string="Procurement" layout="manual">
<sheet layout="auto">
<group col="2" colspan="2">
<separator colspan="2" string="References"/>
<field name="name" string="Procurement Reason"/>
@@ -91,6 +92,10 @@
<field name="note" colspan="4" nolabel="1"/>
</page>
</notebook>
</sheet>
<div class="oe_form_sheet_width">
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</div>
</form>
</field>
</record>