Turkesh Patel (openERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-social-procurement-tpa into 
lp:~openerp-dev/openobject-addons/trunk-openchatter.

Requested reviews:
  OpenERP R&D Team (openerp-dev)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-social-procurement-tpa/+merge/103409

 
                  procurement
==========================================================

[IMP]: added OpenChatter feature in the procurement module
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-social-procurement-tpa/+merge/103409
Your team OpenERP R&D Team is requested to review the proposed merge of 
lp:~openerp-dev/openobject-addons/trunk-social-procurement-tpa into 
lp:~openerp-dev/openobject-addons/trunk-openchatter.
=== modified file 'mrp/mrp_view.xml'
--- mrp/mrp_view.xml	2012-04-19 10:16:38 +0000
+++ mrp/mrp_view.xml	2012-04-25 06:02:19 +0000
@@ -963,10 +963,10 @@
             <field name="type">form</field>
             <field name="arch" type="xml">
             <data>
-                <xpath expr="/form/notebook/page/field[@name='move_id']" position="before">
+                <xpath expr="/form/sheet/notebook/page/field[@name='move_id']" position="before">
                     <field name="bom_id" domain="[('product_id','=',product_id),('bom_id','=',False)]"/>
                 </xpath>
-                <xpath expr="/form/notebook/page/field[@name='close_move']" position="after">
+                <xpath expr="/form/sheet/notebook/page/field[@name='close_move']" position="after">
                     <group colspan="4"  groups="product.group_mrp_properties">
                     <separator colspan="4" string="Properties" />
                     <field colspan="4" name="property_ids" nolabel="1"/>

=== modified file 'procurement/procurement.py'
--- procurement/procurement.py	2012-01-04 06:38:07 +0000
+++ procurement/procurement.py	2012-04-25 06:02:19 +0000
@@ -81,6 +81,7 @@
     _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 @@
             \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 @@
         '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 @@
                     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)
         return True
 
     def action_move_assigned(self, cr, uid, ids, context=None):
@@ -354,6 +358,7 @@
         """
         self.write(cr, uid, ids, {'state': 'running',
                 'message': _('from stock: products assigned.')})
+        self.change_state_send_note(cr, uid, ids, 'running', context)
         return True
 
     def _check_make_to_stock_service(self, cr, uid, procurement, context=None):
@@ -393,6 +398,7 @@
         """
         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)
         return True
 
     def action_produce_assign_product(self, cr, uid, ids, context=None):
@@ -427,6 +433,7 @@
         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)
         wf_service = netsvc.LocalService("workflow")
         for id in ids:
             wf_service.trg_trigger(uid, 'procurement.order', id, cr)
@@ -451,6 +458,7 @@
         @return: True
         """
         res = self.write(cr, uid, ids, {'state': 'ready'})
+        self.change_state_send_note(cr, uid, ids, 'ready', context=None)
         return res
 
     def action_done(self, cr, uid, ids):
@@ -463,11 +471,38 @@
                 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)
         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.state_change_send_note(cr, uid, [obj_id], 'created', context=context)
+        return obj_id
+
+    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 <b>%s</b>.") % (state), context=context)
+
+    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 set to <b>%s</b> state.") % (state), context=context)
+
 procurement_order()
 
 class StockPicking(osv.osv):

=== modified file 'procurement/procurement_view.xml'
--- procurement/procurement_view.xml	2012-03-22 11:19:39 +0000
+++ procurement/procurement_view.xml	2012-04-25 06:02:19 +0000
@@ -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>

=== modified file 'purchase/purchase_view.xml'
--- purchase/purchase_view.xml	2012-04-19 10:06:53 +0000
+++ purchase/purchase_view.xml	2012-04-25 06:02:19 +0000
@@ -510,7 +510,7 @@
             <field name="inherit_id" ref="procurement.procurement_form_view"/>
             <field name="type">form</field>
             <field name="arch" type="xml">
-                <xpath expr="/form/notebook/page/field[@name='close_move']" position="before">
+                <xpath expr="/form/sheet/notebook/page/field[@name='close_move']" position="before">
                     <field name="purchase_id"/>
                 </xpath>
             </field>

=== modified file 'purchase_requisition/purchase_requisition.py'
--- purchase_requisition/purchase_requisition.py	2012-03-06 12:05:25 +0000
+++ purchase_requisition/purchase_requisition.py	2012-04-25 06:02:19 +0000
@@ -259,7 +259,7 @@
                     })],
                     '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()

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to