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

Proposed by jftempo
Status: Merged
Merged at revision: 5263
Proposed branch: lp:~dorian-kemps/unifield-server/US-4576
Merge into: lp:unifield-server
Diff against target: 111 lines (+33/-5)
5 files modified
bin/addons/sale/sale_workflow.py (+6/-0)
bin/addons/sourcing/sale_order_line.py (+3/-0)
bin/addons/sourcing/sourcing_view.xml (+1/-1)
bin/addons/sourcing/wizard/multiple_sourcing.py (+21/-2)
bin/addons/sourcing/wizard/multiple_sourcing_view.xml (+2/-2)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-4576
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+362326@code.launchpad.net
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 'bin/addons/sale/sale_workflow.py'
2--- bin/addons/sale/sale_workflow.py 2018-11-12 14:03:59 +0000
3+++ bin/addons/sale/sale_workflow.py 2019-01-28 14:18:02 +0000
4@@ -570,6 +570,12 @@
5 _('Line #%s: You have to select a product UoM in the same category than the UoM of the product.')
6 % (sol.line_number,)
7 )
8+
9+ # US-4576: Set supplier
10+ if sol.type == 'make_to_order' and sol.order_id.order_type not in ['loan', 'donation_st', 'donation_exp']\
11+ and sol.product_id and sol.product_id.seller_id:
12+ to_write['supplier'] = sol.product_id.seller_id.id
13+
14 if not sol.stock_take_date and sol.order_id.stock_take_date:
15 to_write['stock_take_date'] = sol.order_id.stock_take_date
16 if sol.order_id.order_type == 'loan':
17
18=== modified file 'bin/addons/sourcing/sale_order_line.py'
19--- bin/addons/sourcing/sale_order_line.py 2018-11-09 16:10:16 +0000
20+++ bin/addons/sourcing/sale_order_line.py 2019-01-28 14:18:02 +0000
21@@ -2187,6 +2187,8 @@
22 'title': _('Warning'),
23 'message': _('You cannot choose \'from stock\' as method to source a %s product !') % product_type,
24 })
25+ if l_type == 'make_to_order' and line.product_id and line.product_id.seller_id:
26+ value['supplier'] = line.product_id.seller_id.id
27
28 if l_type == 'make_to_stock':
29 if not location_id:
30@@ -2198,6 +2200,7 @@
31 'po_cft': False,
32 'related_sourcing_ok': False,
33 'related_sourcing_id': False,
34+ 'supplier': False,
35 })
36
37 res = {'value': value, 'warning': message}
38
39=== modified file 'bin/addons/sourcing/sourcing_view.xml'
40--- bin/addons/sourcing/sourcing_view.xml 2017-11-14 14:38:28 +0000
41+++ bin/addons/sourcing/sourcing_view.xml 2019-01-28 14:18:02 +0000
42@@ -67,7 +67,7 @@
43 <field name="supplier" colspan="2"
44 domain="[('id', '!=', company_id), ('available_for_dpo', '=', po_cft),('check_partner', '=', order_id)]"
45 context="{'product_id': product_id, 'choose_supplier': True, 'uom': product_uom, 'product_qty': product_uom_qty}"
46- attrs="{'readonly': ['|', ('po_cft', '=', 'cft'), '|', ('type', '=', 'make_to_stock'), ('state', '!=', 'validated')]}"
47+ attrs="{'readonly': ['|', ('po_cft', '=', 'cft'), ('state', '!=', 'validated')], 'invisible': [('type', '=', 'make_to_stock')]}"
48 on_change="onChangeSupplier(supplier, type)" />
49 <field name="customer" invisible="1" />
50 <field name="estimated_delivery_date" />
51
52=== modified file 'bin/addons/sourcing/wizard/multiple_sourcing.py'
53--- bin/addons/sourcing/wizard/multiple_sourcing.py 2018-06-26 13:27:10 +0000
54+++ bin/addons/sourcing/wizard/multiple_sourcing.py 2019-01-28 14:18:02 +0000
55@@ -306,7 +306,25 @@
56
57 return {'type': 'ir.actions.act_window_close'}
58
59- def change_type(self, cr, uid, ids, l_type, supplier, context=None):
60+ def get_same_seller(self, cr, uid, sols, context=None):
61+ if context is None:
62+ context = {}
63+
64+ res = False
65+ for line in self.pool.get('sale.order.line').browse(cr, uid, sols[0][2], fields_to_fetch=['product_id'], context=context):
66+ if line.product_id and line.product_id.seller_id:
67+ if res and res != line.product_id.seller_id.id:
68+ res = False
69+ break
70+ else:
71+ res = line.product_id.seller_id.id
72+ else:
73+ res = False
74+ break
75+
76+ return res
77+
78+ def change_type(self, cr, uid, ids, lines, l_type, supplier, context=None):
79 """
80 Unset the other fields if the type is 'from stock'
81 :param cr: Cursor to the database
82@@ -327,7 +345,8 @@
83 return {
84 'value': {
85 'location_id': False,
86- 'related_sourcing_ok': sol_obj._check_related_sourcing_ok(cr, uid, supplier, l_type, context=context)
87+ 'related_sourcing_ok': sol_obj._check_related_sourcing_ok(cr, uid, supplier, l_type, context=context),
88+ 'supplier_id': self.get_same_seller(cr, uid, lines, context=context),
89 },
90 }
91
92
93=== modified file 'bin/addons/sourcing/wizard/multiple_sourcing_view.xml'
94--- bin/addons/sourcing/wizard/multiple_sourcing_view.xml 2017-07-04 12:28:07 +0000
95+++ bin/addons/sourcing/wizard/multiple_sourcing_view.xml 2019-01-28 14:18:02 +0000
96@@ -18,14 +18,14 @@
97 <field name="line_ids" nolabel="1" colspan="4" />
98 <separator colspan="4" string="Procurement method" />
99 <field name="type"
100- on_change="change_type(type, supplier)"/>
101+ on_change="change_type(line_ids, type, supplier)"/>
102 <field name="po_cft" attrs="{'readonly': [('type', '=', 'make_to_stock')]}"
103 on_change="change_po_cft(po_cft)"/>
104 <field name="run_scheduler" />
105 <separator colspan="4" string="Supplier selection" />
106 <field name="supplier_id"
107 domain="[('id', '!=', company_id), ('available_for_dpo', '=', po_cft), ('line_contains_fo', '=', line_ids)]"
108- attrs="{'readonly': ['|', ('po_cft', '=', 'cft'), ('type', '=', 'make_to_stock')]}"
109+ attrs="{'readonly': [('po_cft', '=', 'cft')], 'invisible': [('type', '=', 'make_to_stock')]}"
110 on_change="change_supplier(supplier_id, type)"
111 />
112

Subscribers

People subscribed via source and target branches