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 001/113] [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 002/113] [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 4e1ee61eecd1addc26525c704cc71302e282834b Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 20 Apr 2012 16:56:05 +0530 Subject: [PATCH 003/113] [IMP] rename field message_ids_social to message_ids. bzr revid: tpa@tinyerp.com-20120420112605-cctm0yw34vedqco8 --- addons/account/account_invoice_view.xml | 4 ++-- addons/crm/crm_lead_view.xml | 4 ++-- addons/crm/crm_meeting_view.xml | 2 +- addons/crm/crm_phonecall_view.xml | 2 +- addons/hr_holidays/hr_holidays_view.xml | 4 ++-- addons/hr_recruitment/hr_recruitment_view.xml | 2 +- addons/mail/doc/mail_openchatter_howto.rst | 4 ++-- addons/mail/mail_group_view.xml | 2 +- addons/mail/res_users_view.xml | 2 +- addons/mrp/mrp_view.xml | 4 ++-- addons/mrp_operations/mrp_operations_view.xml | 2 +- addons/product/product_view.xml | 2 +- addons/project/project_view.xml | 4 ++-- addons/project_issue/project_issue_view.xml | 2 +- addons/purchase/purchase_view.xml | 2 +- addons/sale/sale_view.xml | 2 +- addons/stock/stock_view.xml | 4 ++-- 17 files changed, 24 insertions(+), 24 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index ca8530fb082..c8822ae5c6f 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -243,7 +243,7 @@ - + @@ -339,7 +339,7 @@ - + diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 7de9858713a..559c31d0c66 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -156,7 +156,7 @@
- +
@@ -525,7 +525,7 @@
- +
diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index d740a00cf02..28b9932a1fc 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -212,7 +212,7 @@ - + diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index eb836428b6e..4a317e87292 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -121,7 +121,7 @@ states="cancel" type="object" icon="gtk-convert" /> - + diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index 066ac29c6e3..595e319f492 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -95,7 +95,7 @@