Merge lp:~vauxoo/addons-vauxoo/7.0-purchase_order_requisitor-rev-1750-kty into lp:~vauxoo/addons-vauxoo/addons-vauxoo-cicsa

Proposed by Katherine Zaoral (Vauxoo)
Status: Merged
Merged at revision: 1066
Proposed branch: lp:~vauxoo/addons-vauxoo/7.0-purchase_order_requisitor-rev-1750-kty
Merge into: lp:~vauxoo/addons-vauxoo/addons-vauxoo-cicsa
Diff against target: 82 lines (+40/-3)
4 files modified
purchase_order_department/__openerp__.py (+1/-0)
purchase_order_department/model/purchase_order.py (+21/-0)
purchase_requisition_department/model/purchase_requisition.py (+14/-3)
purchase_requisition_department/view/purchase_requisition_view.xml (+4/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/7.0-purchase_order_requisitor-rev-1750-kty
Reviewer Review Type Date Requested Status
Katherine Zaoral (Vauxoo) Approve
Review via email: mp+225210@code.launchpad.net

Description of the change

[MERGE] get with a onchange method the department_id from the purchase requisition user (requisitor). In the case that the purchase requisition generate a purchase orderand set the purchase order the department of the purchase order is set with the one given in the purchase requisition

To post a comment you must log in.
Revision history for this message
Katherine Zaoral (Vauxoo) (kathy-zaoral) wrote :

waiting for runbot

Revision history for this message
Katherine Zaoral (Vauxoo) (kathy-zaoral) wrote :

runbot is green

Revision history for this message
Katherine Zaoral (Vauxoo) (kathy-zaoral) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'purchase_order_department/__openerp__.py'
--- purchase_order_department/__openerp__.py 2014-06-18 21:27:27 +0000
+++ purchase_order_department/__openerp__.py 2014-07-01 17:27:23 +0000
@@ -45,6 +45,7 @@
45 'purchase',45 'purchase',
46 'hr',46 'hr',
47 'purchase_order_requisitor',47 'purchase_order_requisitor',
48 'purchase_requisition_department',
48 ],49 ],
49 'data': [50 'data': [
50 'view/purchase_order_view.xml',51 'view/purchase_order_view.xml',
5152
=== modified file 'purchase_order_department/model/purchase_order.py'
--- purchase_order_department/model/purchase_order.py 2014-06-18 21:36:10 +0000
+++ purchase_order_department/model/purchase_order.py 2014-07-01 17:27:23 +0000
@@ -51,3 +51,24 @@
51 and ru_brw.employee_ids[0].department_id.id or False)51 and ru_brw.employee_ids[0].department_id.id or False)
52 res.update({'value': {'department_id': department_id}})52 res.update({'value': {'department_id': department_id}})
53 return res53 return res
54
55
56class purchase_requisition(osv.Model):
57
58 _inherit = "purchase.requisition"
59
60 def make_purchase_order(self, cur, uid, ids, partner_id, context=None):
61 """
62 Over write the method to also extract the department_id from the
63 purchase requisition.
64 """
65 context = context or {}
66 res = super(purchase_requisition, self).make_purchase_order(
67 cur, uid, ids, partner_id, context=context)
68 if res:
69 req_id = res.keys()[0]
70 req_brw = self.browse(cur, uid, req_id, context=context)
71 po_obj = self.pool.get('purchase.order')
72 po_obj.write(cur, uid, res[req_id], {'department_id':
73 req_brw.department_id.id}, context=context)
74 return res
5475
=== modified file 'purchase_requisition_department/model/purchase_requisition.py'
--- purchase_requisition_department/model/purchase_requisition.py 2014-06-06 20:59:04 +0000
+++ purchase_requisition_department/model/purchase_requisition.py 2014-07-01 17:27:23 +0000
@@ -37,9 +37,20 @@
37 help='The department where this purchase requisition belongs'),37 help='The department where this purchase requisition belongs'),
38 }38 }
3939
40 _defaults = {40 def onchange_user_id(self, cr, uid, ids, user_id, context=None):
41 'department_id': lambda self, cur, uid, cxt: self.pool.get('res.users').browse(cur, uid, uid, cxt).employee_ids[0].department_id.id,41 """ Return the department depending of the user.
42 }42 @param user_id: user id
43 """
44 context = context or {}
45 res = {}
46 ru_obj = self.pool.get('res.users')
47 if user_id:
48 ru_brw = ru_obj.browse(cr, uid, user_id, context=context)
49 department_id = (ru_brw.employee_ids
50 and ru_brw.employee_ids[0].department_id
51 and ru_brw.employee_ids[0].department_id.id or False)
52 res.update({'value': {'department_id': department_id}})
53 return res
4354
44 #def fields_view_get(self, cr, uid, view_id=None, view_type='form',55 #def fields_view_get(self, cr, uid, view_id=None, view_type='form',
45 # context=None, toolbar=False, submenu=False):56 # context=None, toolbar=False, submenu=False):
4657
=== modified file 'purchase_requisition_department/view/purchase_requisition_view.xml'
--- purchase_requisition_department/view/purchase_requisition_view.xml 2014-06-06 19:24:33 +0000
+++ purchase_requisition_department/view/purchase_requisition_view.xml 2014-07-01 17:27:23 +0000
@@ -10,6 +10,10 @@
10 <xpath expr="//field[@name='user_id']" position="after">10 <xpath expr="//field[@name='user_id']" position="after">
11 <field name="department_id"/>11 <field name="department_id"/>
12 </xpath>12 </xpath>
13 <xpath expr="//field[@name='user_id']" position="attributes">
14 <attribute name="on_change">onchange_user_id(user_id)</attribute>
15 </xpath>
16
13 </field>17 </field>
14 </record> 18 </record>
1519

Subscribers

People subscribed via source and target branches

to all changes: