From 3c5d0902df3fbd8942e074f9b10df1ecb3b35f7a Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 20 Apr 2012 15:59:12 +0530 Subject: [PATCH 01/16] [ADD] added code for social chatter in procurement module bzr revid: tpa@tinyerp.com-20120420102912-fplcrpuhs59y7o2o --- addons/procurement/procurement.py | 51 +++++++++++++++++++++++++ addons/procurement/procurement_view.xml | 7 +++- 2 files changed, 57 insertions(+), 1 deletion(-) 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 -
+ + @@ -91,6 +92,10 @@ + +
+ +
From 933f62a1404ed4bd6bb78f2e175cfd79a4a12d24 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 20 Apr 2012 16:25:55 +0530 Subject: [PATCH 02/16] [IMP] Improved code. bzr revid: tpa@tinyerp.com-20120420105555-ktnvach7catvr6xw --- addons/procurement/procurement.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 0c3ac885e85..2353f19be0c 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -398,6 +398,7 @@ class procurement_order(osv.osv): """ for procurement in self.browse(cr, uid, ids, context=context): self.write(cr, uid, [procurement.id], {'state': 'running'}) + self.running_send_note(cr, uid, ids, context=None) return True def action_produce_assign_product(self, cr, uid, ids, context=None): @@ -457,7 +458,7 @@ class procurement_order(osv.osv): @return: True """ res = self.write(cr, uid, ids, {'state': 'ready'}) - self.ready_send_note(cr, uid, ids, context) + self.ready_send_note(cr, uid, ids, context=None) return res def action_done(self, cr, uid, ids): @@ -509,7 +510,7 @@ class procurement_order(osv.osv): 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) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been set to redy."), context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): From c81a4f959f7f89da7cfcc3596a8984382a7360e3 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Mon, 23 Apr 2012 14:16:26 +0530 Subject: [PATCH 03/16] [IMP] improved string. bzr revid: tpa@tinyerp.com-20120423084626-656bm1r6jr2ijmuc --- addons/procurement/procurement.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 2353f19be0c..15da58dfd29 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -506,11 +506,11 @@ class procurement_order(osv.osv): 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) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been set to running state."), 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 set to redy."), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been set to redy state."), context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): From 82b6981314dd58a2977521d25c244b0ce917d6d6 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Mon, 23 Apr 2012 18:02:10 +0530 Subject: [PATCH 04/16] [IMP] Improved code. bzr revid: tpa@tinyerp.com-20120423123210-8wfd6tsovnnd8oic --- addons/procurement/procurement.py | 39 +++++++++---------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 15da58dfd29..2e1bace0881 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -349,7 +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) + self.state_change_send_note(cr, uid, ids ,'confirmed', context) return True def action_move_assigned(self, cr, uid, ids, context=None): @@ -358,7 +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) + self.change_state_send_note(cr, uid, ids, 'running', context) return True def _check_make_to_stock_service(self, cr, uid, procurement, context=None): @@ -398,7 +398,7 @@ class procurement_order(osv.osv): """ for procurement in self.browse(cr, uid, ids, context=context): self.write(cr, uid, [procurement.id], {'state': 'running'}) - self.running_send_note(cr, uid, ids, context=None) + self.change_state_send_note(cr, uid, ids, context=None) return True def action_produce_assign_product(self, cr, uid, ids, context=None): @@ -433,7 +433,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) + self.state_change_send_note(cr, uid, ids, 'cancelled', context=None) wf_service = netsvc.LocalService("workflow") for id in ids: wf_service.trg_trigger(uid, 'procurement.order', id, cr) @@ -458,7 +458,7 @@ class procurement_order(osv.osv): @return: True """ res = self.write(cr, uid, ids, {'state': 'ready'}) - self.ready_send_note(cr, uid, ids, context=None) + self.change_state_send_note(cr, uid, ids, 'ready', context=None) return res def action_done(self, cr, uid, ids): @@ -471,7 +471,7 @@ 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) + self.state_change_send_note(cr, uid, ids, 'done', context) wf_service = netsvc.LocalService("workflow") for id in ids: wf_service.trg_trigger(uid, 'procurement.order', id, cr) @@ -490,35 +490,18 @@ class procurement_order(osv.osv): 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) + self.state_change_send_note(cr, uid, [obj_id], 'created', context=context) return obj_id - def create_send_note(self, cr, uid, ids, context=None): + def state_change_send_note(self, cr, uid, ids, state, 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) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been %s.") % (state), context=context) - def confirm_send_note(self, cr, uid, ids, context=None): + def change_state_send_note(self, cr, uid, ids, state, 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 set to running state."), 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 set to redy state."), 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) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been set to %s state.") % (state), context=context) procurement_order() From 56eea9ebaa05df95e63e269bf616aa661939822c Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Tue, 24 Apr 2012 17:18:38 +0530 Subject: [PATCH 05/16] [IMP] Improved code bzr revid: tpa@tinyerp.com-20120424114838-f8w03u417ba0hsmt --- addons/procurement/procurement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 2e1bace0881..fef150cf0aa 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -471,7 +471,7 @@ 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.state_change_send_note(cr, uid, ids, 'done', context) + self.state_change_send_note(cr, uid, ids, 'done', context=None) wf_service = netsvc.LocalService("workflow") for id in ids: wf_service.trg_trigger(uid, 'procurement.order', id, cr) From 930144c80faaa54ab9c13bdcb55703fb4dcc9545 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Tue, 24 Apr 2012 18:32:02 +0530 Subject: [PATCH 06/16] [fix] purchase,mrp: inherited view error bzr revid: tpa@tinyerp.com-20120424130202-m99sbmem0z87r6df --- addons/mrp/mrp_view.xml | 4 ++-- addons/purchase/purchase_view.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 76062249d7d..95b65d69f94 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -963,10 +963,10 @@ form - + - + diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 45e0882edc8..edd4756130a 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -510,7 +510,7 @@ form - + From 05dde082df3a311ef4e1698edcb906897d93b08c Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 25 Apr 2012 11:02:23 +0530 Subject: [PATCH 07/16] [FIX] purchase_requisition: improved code bzr revid: tpa@tinyerp.com-20120425053223-la43e3jpggobhnim --- addons/purchase_requisition/purchase_requisition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 43cfe2de069..a458481e524 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -259,7 +259,7 @@ class procurement_order(osv.osv): })], 'purchase_ids': [(6,0,[po_id])] }) - self.write(cr,uid,proc_id,{'requisition_id':requisition_id}) + self.write(cr,uid,[proc_id],{'requisition_id':requisition_id}) return res procurement_order() From 8388742dcbde34e7687c38bc3aeab75da42b104d Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 27 Apr 2012 14:24:40 +0530 Subject: [PATCH 08/16] [IMP] improved code for functions bzr revid: tpa@tinyerp.com-20120427085440-1h6fgess80xil54b --- addons/procurement/procurement.py | 39 ++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index fef150cf0aa..11491ea8dcd 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -349,7 +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.state_change_send_note(cr, uid, ids ,'confirmed', context) + self.confirm_send_note(cr, uid, ids, context) return True def action_move_assigned(self, cr, uid, ids, context=None): @@ -358,7 +358,7 @@ class procurement_order(osv.osv): """ self.write(cr, uid, ids, {'state': 'running', 'message': _('from stock: products assigned.')}) - self.change_state_send_note(cr, uid, ids, 'running', context) + self.running_send_note(cr, uid, ids, context) return True def _check_make_to_stock_service(self, cr, uid, procurement, context=None): @@ -398,7 +398,7 @@ class procurement_order(osv.osv): """ for procurement in self.browse(cr, uid, ids, context=context): self.write(cr, uid, [procurement.id], {'state': 'running'}) - self.change_state_send_note(cr, uid, ids, context=None) + self.running_send_note(cr, uid, ids, context=None) return True def action_produce_assign_product(self, cr, uid, ids, context=None): @@ -433,7 +433,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.state_change_send_note(cr, uid, ids, 'cancelled', context=None) + 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) @@ -458,7 +458,7 @@ class procurement_order(osv.osv): @return: True """ res = self.write(cr, uid, ids, {'state': 'ready'}) - self.change_state_send_note(cr, uid, ids, 'ready', context=None) + self.ready_send_note(cr, uid, ids, context=None) return res def action_done(self, cr, uid, ids): @@ -471,7 +471,7 @@ 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.state_change_send_note(cr, uid, ids, 'done', context=None) + self.done_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) @@ -490,18 +490,35 @@ class procurement_order(osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(procurement_order, self).create(cr, uid, vals, context) - self.state_change_send_note(cr, uid, [obj_id], 'created', context=context) + self.create_send_note(cr, uid, [obj_id], context=context) return obj_id - def state_change_send_note(self, cr, uid, ids, state, context=None): + 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 %s.") % (state), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been created."), context=context) - def change_state_send_note(self, cr, uid, ids, state, context=None): + 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 set to %s state.") % (state), 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 set to running state."), 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 set to ready state."), 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() From a8310f8bc7e9014d410c4c9ade181169c32ae2aa Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 27 Apr 2012 14:26:38 +0530 Subject: [PATCH 09/16] [IMP] Improved lable name bzr revid: tpa@tinyerp.com-20120427085638-3j6voixygx08cahd --- addons/procurement/procurement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 11491ea8dcd..64bf5774475 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -118,7 +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'), + 'user_id': fields.many2one('res.users', 'Responsible user'), } _defaults = { 'state': 'draft', From 276b4d344a6eb5b430493516e9c894edc3fafd36 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Mon, 30 Apr 2012 18:30:25 +0530 Subject: [PATCH 10/16] [IMP] improved code bzr revid: tpa@tinyerp.com-20120430130025-kxjzlbeqds2vtjhs --- addons/procurement/procurement.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 64bf5774475..e30c81b7e18 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -358,7 +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) + self.running_send_note(cr, uid, ids, context=None) return True def _check_make_to_stock_service(self, cr, uid, procurement, context=None): @@ -495,17 +495,14 @@ class procurement_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_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 set to running state."), context=context) def ready_send_note(self, cr, uid, ids, context=None): From 2cb67664139aca38013279d58ff685c1c77a7587 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Tue, 1 May 2012 10:36:24 +0530 Subject: [PATCH 11/16] [IMP] improved code for running state. bzr revid: tpa@tinyerp.com-20120501050624-6cq0b839evr3sdx9 --- addons/mrp/procurement.py | 1 + addons/project_mrp/project_procurement.py | 1 + addons/purchase/purchase.py | 1 + 3 files changed, 3 insertions(+) diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 4086a401f56..74183660fa5 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -97,6 +97,7 @@ class procurement_order(osv.osv): }) res[procurement.id] = produce_id self.write(cr, uid, [procurement.id], {'state': 'running'}) + self.running_send_note(cr, uid, ids, context=None) bom_result = production_obj.action_compute(cr, uid, [produce_id], properties=[x.id for x in procurement.property_ids]) wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr) diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index 7d3045aede0..c27a3d547a3 100644 --- a/addons/project_mrp/project_procurement.py +++ b/addons/project_mrp/project_procurement.py @@ -81,6 +81,7 @@ class procurement_order(osv.osv): 'company_id': procurement.company_id.id, },context=context) self.write(cr, uid, [procurement.id], {'task_id': task_id, 'state': 'running'}, context=context) + self.running_send_note(cr, uid, ids, context=None) return task_id procurement_order() diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 687221f371b..18a65f08171 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -993,6 +993,7 @@ class procurement_order(osv.osv): } res[procurement.id] = self.create_procurement_purchase_order(cr, uid, procurement, po_vals, line_vals, context=context) self.write(cr, uid, [procurement.id], {'state': 'running', 'purchase_id': res[procurement.id]}) + self.running_send_note(cr, uid, ids, context=None) return res procurement_order() From cffb60c519a4e009fef205272b5be26d9f668ffa Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 3 May 2012 10:44:47 +0530 Subject: [PATCH 12/16] [IMP] stock_location: call running_send_note bzr revid: tpa@tinyerp.com-20120503051447-2tkh9vn0twnz8ndk --- addons/stock_location/procurement_pull.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/stock_location/procurement_pull.py b/addons/stock_location/procurement_pull.py index 33168a53e20..97ccb3eb38a 100644 --- a/addons/stock_location/procurement_pull.py +++ b/addons/stock_location/procurement_pull.py @@ -116,6 +116,7 @@ class procurement_order(osv.osv): move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) self.write(cr, uid, [proc.id], {'state':'running', 'message':_('Pulled from another location via procurement %d')%proc_id}) + self.running_send_note(cr, uid, ids, context=None) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) From e1a08c2074b9ef5da580c117d0d6a400e8b35c43 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 3 May 2012 10:50:12 +0530 Subject: [PATCH 13/16] [IMP] procurement: rename message_ids_social to message_ids bzr revid: tpa@tinyerp.com-20120503052012-a01z3n9qebvy9ii2 --- addons/procurement/procurement_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml index ba8b248bafe..f1430f480b7 100644 --- a/addons/procurement/procurement_view.xml +++ b/addons/procurement/procurement_view.xml @@ -94,7 +94,7 @@
- +
From 6e7f4025b51b862693360f4a7af0f2a705c9ac3c Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Mon, 7 May 2012 16:13:44 +0530 Subject: [PATCH 14/16] [IMP] procurement: improved code bzr revid: tpa@tinyerp.com-20120507104344-9hvypd5vvezrsetd --- addons/procurement/procurement.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index e30c81b7e18..4305550ec23 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -81,7 +81,7 @@ class procurement_order(osv.osv): _name = "procurement.order" _description = "Procurement" _order = 'priority,date_planned desc' - _inherit = ['ir.needaction_mixin', 'mail.thread'] + _inherit = ['mail.thread'] _log_create = False _columns = { 'name': fields.char('Reason', size=64, required=True, help='Procurement name.'), @@ -118,7 +118,6 @@ 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', 'Responsible user'), } _defaults = { 'state': 'draft', @@ -126,7 +125,6 @@ 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) } @@ -481,13 +479,6 @@ class procurement_order(osv.osv): # 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) @@ -503,11 +494,11 @@ class procurement_order(osv.osv): def running_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 set to running state."), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been set to running"), 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 set to ready state."), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been set to ready"), context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): From c853634ff9fb5fa8010402e1d623113d9af9bbb2 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Mon, 7 May 2012 16:26:29 +0530 Subject: [PATCH 15/16] [IMP] procurement: improved code. bzr revid: tpa@tinyerp.com-20120507105629-rgt4n2w694tg7f04 --- addons/procurement/procurement.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 4305550ec23..4a77522bca7 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -494,11 +494,11 @@ class procurement_order(osv.osv): def running_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 set to running"), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been set to running."), 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 set to ready"), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Procurement has been set to ready."), context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): From 89d8fee9a6691ca05506a1464b65dc699e19a450 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 9 May 2012 11:16:21 +0530 Subject: [PATCH 16/16] [IMP] remove log. bzr revid: tpa@tinyerp.com-20120509054621-ukk52fya3yqmiuex --- addons/mrp/procurement.py | 2 +- addons/procurement/procurement.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 74183660fa5..7b5c9ec1233 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -43,7 +43,7 @@ class procurement_order(osv.osv): cr.execute('update procurement_order set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id)) for (id, name) in self.name_get(cr, uid, procurement.id): message = _("Procurement '%s' has an exception: 'No BoM defined for this product !'") % name - self.log(cr, uid, id, message) + self.message_append_note(cr, uid, [procurement], body=message, context=context) return False return True diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 4a77522bca7..bc25985475f 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -386,7 +386,8 @@ class procurement_order(osv.osv): message = _("Not enough stock.") if message: - self.log(cr, uid, procurement.id, _("Procurement '%s' is in exception: ") % (procurement.name) + message) + message = _("Procurement '%s' is in exception: ") % (procurement.name) + message + self.message_append_note(cr, uid, [procurement], body=message, context=context) cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id)) return ok