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
1=== modified file 'purchase_order_department/__openerp__.py'
2--- purchase_order_department/__openerp__.py 2014-06-18 21:27:27 +0000
3+++ purchase_order_department/__openerp__.py 2014-07-01 17:27:23 +0000
4@@ -45,6 +45,7 @@
5 'purchase',
6 'hr',
7 'purchase_order_requisitor',
8+ 'purchase_requisition_department',
9 ],
10 'data': [
11 'view/purchase_order_view.xml',
12
13=== modified file 'purchase_order_department/model/purchase_order.py'
14--- purchase_order_department/model/purchase_order.py 2014-06-18 21:36:10 +0000
15+++ purchase_order_department/model/purchase_order.py 2014-07-01 17:27:23 +0000
16@@ -51,3 +51,24 @@
17 and ru_brw.employee_ids[0].department_id.id or False)
18 res.update({'value': {'department_id': department_id}})
19 return res
20+
21+
22+class purchase_requisition(osv.Model):
23+
24+ _inherit = "purchase.requisition"
25+
26+ def make_purchase_order(self, cur, uid, ids, partner_id, context=None):
27+ """
28+ Over write the method to also extract the department_id from the
29+ purchase requisition.
30+ """
31+ context = context or {}
32+ res = super(purchase_requisition, self).make_purchase_order(
33+ cur, uid, ids, partner_id, context=context)
34+ if res:
35+ req_id = res.keys()[0]
36+ req_brw = self.browse(cur, uid, req_id, context=context)
37+ po_obj = self.pool.get('purchase.order')
38+ po_obj.write(cur, uid, res[req_id], {'department_id':
39+ req_brw.department_id.id}, context=context)
40+ return res
41
42=== modified file 'purchase_requisition_department/model/purchase_requisition.py'
43--- purchase_requisition_department/model/purchase_requisition.py 2014-06-06 20:59:04 +0000
44+++ purchase_requisition_department/model/purchase_requisition.py 2014-07-01 17:27:23 +0000
45@@ -37,9 +37,20 @@
46 help='The department where this purchase requisition belongs'),
47 }
48
49- _defaults = {
50- 'department_id': lambda self, cur, uid, cxt: self.pool.get('res.users').browse(cur, uid, uid, cxt).employee_ids[0].department_id.id,
51- }
52+ def onchange_user_id(self, cr, uid, ids, user_id, context=None):
53+ """ Return the department depending of the user.
54+ @param user_id: user id
55+ """
56+ context = context or {}
57+ res = {}
58+ ru_obj = self.pool.get('res.users')
59+ if user_id:
60+ ru_brw = ru_obj.browse(cr, uid, user_id, context=context)
61+ department_id = (ru_brw.employee_ids
62+ and ru_brw.employee_ids[0].department_id
63+ and ru_brw.employee_ids[0].department_id.id or False)
64+ res.update({'value': {'department_id': department_id}})
65+ return res
66
67 #def fields_view_get(self, cr, uid, view_id=None, view_type='form',
68 # context=None, toolbar=False, submenu=False):
69
70=== modified file 'purchase_requisition_department/view/purchase_requisition_view.xml'
71--- purchase_requisition_department/view/purchase_requisition_view.xml 2014-06-06 19:24:33 +0000
72+++ purchase_requisition_department/view/purchase_requisition_view.xml 2014-07-01 17:27:23 +0000
73@@ -10,6 +10,10 @@
74 <xpath expr="//field[@name='user_id']" position="after">
75 <field name="department_id"/>
76 </xpath>
77+ <xpath expr="//field[@name='user_id']" position="attributes">
78+ <attribute name="on_change">onchange_user_id(user_id)</attribute>
79+ </xpath>
80+
81 </field>
82 </record>
83

Subscribers

People subscribed via source and target branches

to all changes: