Merge lp:~dorian-kemps/unifield-server/US-5713 into lp:unifield-server

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~dorian-kemps/unifield-server/US-5713
Merge into: lp:unifield-server
Diff against target: 83 lines (+25/-6)
2 files modified
bin/addons/order_nomenclature/order_nomenclature.py (+21/-3)
bin/addons/purchase/purchase_view.xml (+4/-3)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-5713
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+366897@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

5318. By Dorian

US-5713 [FIX] PO line: Added state field

5317. By Dorian

US-5713 [FIX] PO line: Fixed price on qty on_change

5316. By Dorian

US-5713 [FIX] PO line: Fixed price on qty on_change

5315. By Dorian

US-5713 [IMP] PO line: Change price unit according to product's suppliers on draft lines when qty is changed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/order_nomenclature/order_nomenclature.py'
2--- bin/addons/order_nomenclature/order_nomenclature.py 2019-02-28 14:57:40 +0000
3+++ bin/addons/order_nomenclature/order_nomenclature.py 2019-05-03 09:52:04 +0000
4@@ -118,12 +118,11 @@
5
6 def product_qty_change(self, cr, uid, ids, pricelist, product, qty, uom,
7 partner_id, date_order=False, fiscal_position=False, date_planned=False,
8- name=False, price_unit=False, notes=False, state=False, old_unit_price=False,
9- nomen_manda_0=False, comment=False,context=None):
10+ name=False, price_unit=False, notes=False, state=False, line_state=False,
11+ old_unit_price=False, nomen_manda_0=False, comment=False,context=None):
12 '''
13 interface product_id_change to avoid the reset of Comment field when the qty is changed
14 '''
15-
16 if not context:
17 context = {}
18
19@@ -153,6 +152,25 @@
20 if qty:
21 uom = uom or result.get('value', {}).get('product_uom')
22 result = self.pool.get('product.uom')._change_round_up_qty(cr, uid, uom, qty, 'product_qty', result=result)
23+ if product and line_state == 'draft':
24+ prod = self.pool.get('product.product').browse(cr, uid, product, fields_to_fetch=['standard_price', 'seller_ids'], context=context)
25+ if prod.seller_ids:
26+ cat_found = False
27+ cr.execute("""
28+ SELECT cal.unit_price
29+ FROM product_supplierinfo ps, supplier_catalogue_line cal
30+ WHERE cal.supplier_info_id = ps.id AND ps.id IN %s AND cal.product_id = %s
31+ AND cal.min_qty <= %s AND ps.name = %s
32+ ORDER BY ps.sequence
33+ """ % (tuple([s.id for s in prod.seller_ids]), product, qty, partner_id))
34+ for cat_line in cr.fetchall():
35+ result['value']['price_unit'] = cat_line[0]
36+ cat_found = True
37+ break
38+ if not cat_found:
39+ result['value']['price_unit'] = prod.standard_price
40+ elif price_unit != 0:
41+ result['value']['price_unit'] = price_unit
42
43 self.check_digits(cr, uid, result, context=context)
44 return result
45
46=== modified file 'bin/addons/purchase/purchase_view.xml'
47--- bin/addons/purchase/purchase_view.xml 2019-02-27 14:15:35 +0000
48+++ bin/addons/purchase/purchase_view.xml 2019-05-03 09:52:04 +0000
49@@ -245,7 +245,7 @@
50 <field name="internal_code" invisible="True"/>
51 <field name="internal_name" invisible="True"/>
52 <field name="supplier_name" invisible="True"/>
53- <field name="product_qty" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_qty_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,parent.state,old_price_unit,'','', context)" string="Qty"/>
54+ <field name="product_qty" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_qty_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,parent.state,state,old_price_unit,'','', context)" string="Qty"/>
55 <field name="product_uom" on_change="product_uom_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)" domain="[('uom_by_product', '=', product_id)]"/>
56 <field name="price_unit" on_change="price_unit_change(fake_id, price_unit, product_id, product_uom, product_qty, parent.pricelist_id, parent.partner_id, parent.date_order, change_price_ok, parent.state, old_price_unit, '', '', context)"/>
57 <field name="price_subtotal"/>
58@@ -265,6 +265,7 @@
59 <field name="tender_line_id" invisible="1"/>
60 <field name="to_correct_ok" invisible="1"/>
61 <field name="esc_confirmed" readonly="1" invisible="context.get('partner_type', False) != 'esc'" attrs="{'invisible': [('fake_state', '!=', 'draft')]}"/>
62+ <field name="state" invisible="1"/>
63 <field name="fake_state" invisible="1"/>
64 <field name="state_to_display"/>
65 <field name="inactive_product" invisible="1"/>
66@@ -642,7 +643,7 @@
67 <field name="original_price" colspan="1" readonly="1"/>
68 <field name="original_uom" colspan="1" readonly="1"/>
69 <field name="original_product" colspan="2" readonly="1" />
70- <field name="product_qty" string="Current Qty" colspan="1" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_qty_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,parent.state,old_price_unit,nomen_manda_0,comment, context)" />
71+ <field name="product_qty" string="Current Qty" colspan="1" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_qty_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,parent.state,state,old_price_unit,nomen_manda_0,comment, context)" />
72 <field name="price_unit" string="Current Price" colspan="1" on_change="price_unit_change(fake_id, price_unit, product_id, product_uom, product_qty, parent.pricelist_id, parent.partner_id, parent.date_order, change_price_ok, parent.state, old_price_unit, nomen_manda_0, comment, context)"/>
73 <field name="original_currency_id" colspan="1" readonly="1"/>
74 <field name="modification_comment" colspan="2" />
75@@ -775,7 +776,7 @@
76 </html>
77 </group>
78 <field name="product_id" colspan="4" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id, available_for_restriction=parent.partner_type,search_default_not_restricted=1,categ=parent.categ" on_change="product_id_on_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,parent.state,old_price_unit,nomen_manda_0,comment,context)" attrs="{'readonly': [('tender_line_id', '!=', False)]}" default_focus="1"/>
79- <field name="product_qty" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_qty_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,parent.state,old_price_unit,nomen_manda_0,comment, context)"/>
80+ <field name="product_qty" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_qty_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,parent.state,state,old_price_unit,nomen_manda_0,comment, context)"/>
81 <field name="product_uom" on_change="product_uom_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)" domain="[('uom_by_product', '=', product_id)]"/>
82 <field name="price_unit" on_change="price_unit_change(fake_id, price_unit, product_id, product_uom, product_qty, parent.pricelist_id, parent.partner_id, parent.date_order, change_price_ok, parent.state, old_price_unit, nomen_manda_0, comment, context)"/>
83 <field name="currency_id"/>

Subscribers

People subscribed via source and target branches