Merge lp:~rr.clearcorp/openobject-addons/7.0-base_intercompany_sale into lp:~clearcorp-drivers/openobject-addons/elico-7.0-ccorp

Proposed by Ronald Rubi on 2015-08-21
Status: Merged
Merged at revision: 41
Proposed branch: lp:~rr.clearcorp/openobject-addons/7.0-base_intercompany_sale
Merge into: lp:~clearcorp-drivers/openobject-addons/elico-7.0-ccorp
Diff against target: 91 lines (+28/-10)
4 files modified
base_intercompany_sale/purchase.py (+13/-1)
base_intercompany_sale/purchase_view.xml (+1/-4)
base_intercompany_sale/sale.py (+13/-1)
base_intercompany_sale/sale_view.xml (+1/-4)
To merge this branch: bzr merge lp:~rr.clearcorp/openobject-addons/7.0-base_intercompany_sale
Reviewer Review Type Date Requested Status
ClearCorp drivers 2015-08-21 Pending
Review via email: mp+268781@code.launchpad.net

Description of the change

[IMP] base_intercompany_sale: Improve to automatic unlock

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_intercompany_sale/purchase.py'
2--- base_intercompany_sale/purchase.py 2014-08-11 20:46:51 +0000
3+++ base_intercompany_sale/purchase.py 2015-08-21 16:36:45 +0000
4@@ -60,7 +60,19 @@
5
6 def write(self, cr, uid, ids, data, context=None):
7 self._check_icops(cr, uid, ids, context=context)
8- return super(purchase_order, self).write(cr, uid, ids, data, context)
9+ res = super(purchase_order, self).write(cr, uid, ids, data, context)
10+ icops_record_obj = self.pool.get('icops.record')
11+ sale_order_obj = self.pool.get('sale.order')
12+ #Improve to unlock when the user confirm the purchase
13+ if 'state' in data and data['state'] =='approved':
14+ purchases = self.browse(cr, uid, ids, context=context)
15+ for purchase in purchases:
16+ if purchase.icops_bind_ids:
17+ for icops_bind_id in purchase.icops_bind_ids:
18+ icops_record_id = icops_record_obj.search(cr, uid, [('binding_id','=',icops_bind_id.id)], context=context)[0]
19+ icops_record =icops_record_obj.browse(cr, uid, [icops_record_id], context=context)[0]
20+ sale_order_obj.action_unlock(cr, uid, [icops_record.record_id], context=context)
21+ return res
22
23 def unlink(self, cr, uid, ids, context=None):
24 self._check_icops(cr, uid, ids, context=context)
25
26=== modified file 'base_intercompany_sale/purchase_view.xml'
27--- base_intercompany_sale/purchase_view.xml 2014-01-17 22:42:32 +0000
28+++ base_intercompany_sale/purchase_view.xml 2015-08-21 16:36:45 +0000
29@@ -6,9 +6,6 @@
30 <field name="model">purchase.order</field>
31 <field name="inherit_id" ref="purchase.purchase_order_form" />
32 <field name="arch" type="xml">
33- <xpath expr="//header/button[last()]" position="after">
34- <button name="action_unlock" string="Unlock" type="object" attrs="{'invisible':[('locked', '=', False)]}" class="oe_highlight" />
35- </xpath>
36 <xpath expr="//page[last()]" position="after">
37 <page string="ICOPS">
38 <field name="locked" invisible="1" />
39@@ -23,4 +20,4 @@
40 </field>
41 </record>
42 </data>
43-</openerp>
44\ No newline at end of file
45+</openerp>
46
47=== modified file 'base_intercompany_sale/sale.py'
48--- base_intercompany_sale/sale.py 2014-08-19 17:10:55 +0000
49+++ base_intercompany_sale/sale.py 2015-08-21 16:36:45 +0000
50@@ -59,7 +59,19 @@
51
52 def write(self, cr, uid, ids, data, context=None):
53 self._check_icops(cr, uid, ids, context=context)
54- return super(sale_order, self).write(cr, uid, ids, data, context)
55+ res= super(sale_order, self).write(cr, uid, ids, data, context)
56+ icops_record_obj = self.pool.get('icops.record')
57+ purchase_order_obj = self.pool.get('purchase.order')
58+ #Improve to unlock when the user confirm the sale
59+ if 'state' in data and data['state'] =='progress':
60+ sales = self.browse(cr, uid, ids, context=context)
61+ for sale in sales:
62+ if sale.icops_bind_ids:
63+ for icops_bind_id in sale.icops_bind_ids:
64+ icops_record_id = icops_record_obj.search(cr, uid, [('binding_id','=',icops_bind_id.id)], context=context)[0]
65+ icops_record =icops_record_obj.browse(cr, uid, [icops_record_id], context=context)[0]
66+ purchase_order_obj.action_unlock(cr, 1, [icops_record.record_id], context=context)
67+ return res
68
69 def unlink(self, cr, uid, ids, context=None):
70 self._check_icops(cr, uid, ids, context=context)
71
72=== modified file 'base_intercompany_sale/sale_view.xml'
73--- base_intercompany_sale/sale_view.xml 2014-01-17 22:42:32 +0000
74+++ base_intercompany_sale/sale_view.xml 2015-08-21 16:36:45 +0000
75@@ -6,9 +6,6 @@
76 <field name="model">sale.order</field>
77 <field name="inherit_id" ref="sale.view_order_form" />
78 <field name="arch" type="xml">
79- <xpath expr="//header/button[last()]" position="after">
80- <button name="action_unlock" string="Unlock" type="object" attrs="{'invisible':[('locked', '=', False)]}" class="oe_highlight" />
81- </xpath>
82 <xpath expr="//page[last()]" position="after">
83 <page string="ICOPS">
84 <field name="locked" invisible="1" />
85@@ -23,4 +20,4 @@
86 </field>
87 </record>
88 </data>
89-</openerp>
90\ No newline at end of file
91+</openerp>

Subscribers

People subscribed via source and target branches

to all changes: