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

Proposed by jftempo
Status: Merged
Merged at revision: 6284
Proposed branch: lp:~dorian-kemps/unifield-server/US-9229
Merge into: lp:unifield-server
Diff against target: 327 lines (+123/-27)
11 files modified
bin/addons/msf_outgoing/msf_outgoing.py (+2/-1)
bin/addons/msf_outgoing/msf_outgoing_view.xml (+1/-3)
bin/addons/msf_profile/data/patches.xml (+4/-0)
bin/addons/msf_profile/i18n/fr_MF.po (+5/-0)
bin/addons/msf_profile/msf_profile.py (+58/-0)
bin/addons/reason_types_moves/reason_type.py (+21/-8)
bin/addons/reason_types_moves/reason_type_data.xml (+6/-1)
bin/addons/stock/stock.py (+1/-2)
bin/addons/stock/stock_move.py (+12/-4)
bin/addons/stock_override/stock.py (+12/-5)
bin/addons/stock_override/stock_view.xml (+1/-3)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-9229
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+424507@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/msf_outgoing/msf_outgoing.py'
2--- bin/addons/msf_outgoing/msf_outgoing.py 2022-04-05 07:24:53 +0000
3+++ bin/addons/msf_outgoing/msf_outgoing.py 2022-06-13 12:48:07 +0000
4@@ -3148,6 +3148,7 @@
5 'composition_list_id': line.composition_list_id and line.composition_list_id.id or False,
6 'original_qty_partial': orig_qty,
7 'location_id': line.location_id and line.location_id.id,
8+ 'reason_type_id': picking.reason_type_id.id,
9 }
10
11 # If claim expects replacement
12@@ -3508,7 +3509,7 @@
13 for x in cr.fetchall():
14 needed_qty.setdefault(x[1], {})
15 needed_qty[x[1]].setdefault(x[2], 0)
16- lot = lot_obj.browse(cr, uid, x[2], fields_to_fetch=['stock_available', 'product_id'], context={'location_id': x[1]})
17+ lot = lot_obj.browse(cr, uid, x[2], fields_to_fetch=['stock_available', 'product_id', 'name'], context={'location_id': x[1]})
18 if lot.product_id.uom_id.id != x[3]:
19 qty = uom_obj._compute_qty(cr, uid, x[3], x[0], lot.product_id.uom_id.id)
20 else:
21
22=== modified file 'bin/addons/msf_outgoing/msf_outgoing_view.xml'
23--- bin/addons/msf_outgoing/msf_outgoing_view.xml 2022-03-09 10:33:36 +0000
24+++ bin/addons/msf_outgoing/msf_outgoing_view.xml 2022-06-13 12:48:07 +0000
25@@ -357,9 +357,7 @@
26 <field name="dg_check" widget="null_boolean" />
27 <field name="np_check" widget="null_boolean" />
28 </group>
29- <field name="reason_type_id"
30- domain="[('outgoing_ok', '=', True)]"
31- attrs="{'readonly': [('state', '!=', 'draft')]}" widget="selection"/>
32+ <field name="reason_type_id" widget="selection" readonly="1"/>
33 </group>
34 <group colspan="2" col="2">
35 <separator string="Dates" colspan="2" />
36
37=== modified file 'bin/addons/msf_profile/data/patches.xml'
38--- bin/addons/msf_profile/data/patches.xml 2022-05-10 10:21:27 +0000
39+++ bin/addons/msf_profile/data/patches.xml 2022-06-13 12:48:07 +0000
40@@ -787,5 +787,9 @@
41 <field name="method">us_5722_update_accruals</field>
42 </record>
43
44+ <!-- UF26.0 -->
45+ <record id="us_9229_fix_rt" model="patch.scripts">
46+ <field name="method">us_9229_fix_rt</field>
47+ </record>
48 </data>
49 </openerp>
50
51=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
52--- bin/addons/msf_profile/i18n/fr_MF.po 2022-05-25 14:15:34 +0000
53+++ bin/addons/msf_profile/i18n/fr_MF.po 2022-06-13 12:48:07 +0000
54@@ -94758,6 +94758,11 @@
55 msgid "Deliver Partner"
56 msgstr "Livraison partenaire"
57
58+#. module: reason_types_moves
59+#: model:stock.reason.type,name:reason_types_moves.reason_type_deliver_unit
60+msgid "Deliver Unit"
61+msgstr "Unité de Livraison"
62+
63 #. module: base
64 #: model:ir.model,name:base.model_ir_property
65 msgid "ir.property"
66
67=== modified file 'bin/addons/msf_profile/msf_profile.py'
68--- bin/addons/msf_profile/msf_profile.py 2022-05-10 13:22:05 +0000
69+++ bin/addons/msf_profile/msf_profile.py 2022-06-13 12:48:07 +0000
70@@ -56,6 +56,64 @@
71 'model': lambda *a: 'patch.scripts',
72 }
73
74+ # UF26.0
75+ def us_9229_fix_rt(self, cr, uid, *a, **b):
76+ '''
77+ Updates to do:
78+ - All OUTs and Picks plus their lines created from IR with Ext CU to have RT Deliver Unit
79+ - All OUTs and Picks plus their lines created from FO to have RT Deliver Partner
80+ - All OUT-CONSOs plus their lines to have RT Consumption Report
81+ '''
82+ data_obj = self.pool.get('ir.model.data')
83+ deli_unit_rt_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_deliver_unit')[1]
84+ deli_partner_rt_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_deliver_partner')[1]
85+ consu_rep_rt_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_consumption_report')[1]
86+
87+ # To Deliver Unit
88+ cr.execute('''
89+ UPDATE stock_picking SET reason_type_id = %s
90+ WHERE id IN (SELECT p.id FROM stock_picking p
91+ LEFT JOIN sale_order s ON p.sale_id = s.id LEFT JOIN stock_location l ON s.location_requestor_id = l.id
92+ WHERE p.type = 'out' AND p.subtype IN ('standard', 'picking') AND s.procurement_request = 't'
93+ AND l.location_category = 'consumption_unit')
94+ ''', (deli_unit_rt_id,))
95+ self.log_info(cr, uid, "US-9229: %d OUTs/Picks and their lines had their Reason Type set to 'Deliver Unit'" % (cr.rowcount,))
96+ cr.execute('''
97+ UPDATE stock_move SET reason_type_id = %s
98+ WHERE picking_id IN (SELECT p.id FROM stock_picking p
99+ LEFT JOIN sale_order s ON p.sale_id = s.id LEFT JOIN stock_location l ON s.location_requestor_id = l.id
100+ WHERE p.type = 'out' AND p.subtype IN ('standard', 'picking') AND s.procurement_request = 't'
101+ AND l.location_category = 'consumption_unit')
102+ ''', (deli_unit_rt_id,))
103+
104+ # To Deliver Partner
105+ cr.execute('''
106+ UPDATE stock_picking SET reason_type_id = %s
107+ WHERE id IN (SELECT p.id FROM stock_picking p LEFT JOIN sale_order s ON p.sale_id = s.id
108+ WHERE p.type = 'out' AND p.subtype IN ('standard', 'picking') AND s.procurement_request = 'f')
109+ ''', (deli_partner_rt_id,))
110+ self.log_info(cr, uid, "US-9229: %d OUTs/Picks and their lines had their Reason Type set to 'Deliver Partner'" % (cr.rowcount,))
111+ cr.execute('''
112+ UPDATE stock_move SET reason_type_id = %s
113+ WHERE picking_id IN (SELECT p.id FROM stock_picking p LEFT JOIN sale_order s ON p.sale_id = s.id
114+ WHERE p.type = 'out' AND p.subtype IN ('standard', 'picking') AND s.procurement_request = 'f')
115+ ''', (deli_partner_rt_id,))
116+
117+ # To Consumption Report
118+ cr.execute('''
119+ UPDATE stock_picking SET reason_type_id = %s
120+ WHERE id IN (SELECT id FROM stock_picking WHERE type = 'out' AND subtype IN ('standard', 'picking')
121+ AND rac_id IS NOT NULL)
122+ ''', (consu_rep_rt_id,))
123+ self.log_info(cr, uid, "US-9229: %d OUT-CONSOs and their lines had their Reason Type set to 'Consumption Report'" % (cr.rowcount,))
124+ cr.execute('''
125+ UPDATE stock_move SET reason_type_id = %s
126+ WHERE picking_id IN (SELECT id FROM stock_picking WHERE type = 'out' AND subtype IN ('standard', 'picking')
127+ AND rac_id IS NOT NULL)
128+ ''', (consu_rep_rt_id,))
129+
130+ return True
131+
132 # UF25.0
133 def us_8451_split_rr(self, cr, uid, *a, **b):
134 if not cr.column_exists('replenishment_segment_line', 'rr_fmc_1') or not cr.column_exists('replenishment_segment_line', 'rr_max_1'):
135
136=== modified file 'bin/addons/reason_types_moves/reason_type.py'
137--- bin/addons/reason_types_moves/reason_type.py 2022-04-04 10:17:33 +0000
138+++ bin/addons/reason_types_moves/reason_type.py 2022-06-13 12:48:07 +0000
139@@ -269,37 +269,50 @@
140 if not context:
141 context = {}
142
143+ data_obj = self.pool.get('ir.model.data')
144 res = super(stock_picking, self).default_get(cr, uid, fields, context=context, from_web=from_web)
145
146+ deli_partner_rt_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_deliver_partner')[1]
147 if 'picking_type' in context:
148 if context.get('picking_type') == 'incoming_shipment':
149- res['reason_type_id'] = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_external_supply')[1]
150+ res['reason_type_id'] = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_external_supply')[1]
151 elif context.get('picking_type') == 'internal_move':
152- res['reason_type_id'] = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_internal_move')[1]
153- elif context.get('picking_type') in ('delivery_order', 'picking_ticket'):
154- res['reason_type_id'] = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_deliver_partner')[1]
155+ res['reason_type_id'] = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_internal_move')[1]
156+ elif context.get('picking_type') == 'delivery_order':
157+ if from_web:
158+ res['reason_type_id'] = deli_partner_rt_id
159+ else:
160+ res['reason_type_id'] = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_deliver_unit')[1]
161+ elif context.get('picking_type') == 'picking_ticket':
162+ res['reason_type_id'] = deli_partner_rt_id
163
164 return res
165
166 def _check_reason_type(self, cr, uid, ids, context=None):
167 """
168- Do not permit user to create/write a OUT from scratch with some reason types:
169+ Do not permit user to create/write an OUT from scratch with some reason types:
170 - GOODS RETURN UNIT
171 - GOODS REPLACEMENT
172+ - OTHER
173 """
174+ data_obj = self.pool.get('ir.model.data')
175 res = True
176 try:
177- rt_replacement_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_goods_replacement')[1]
178+ rt_replacement_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_goods_replacement')[1]
179 except ValueError:
180 rt_replacement_id = 0
181 try:
182- rt_return_unit_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_return_from_unit')[1]
183+ rt_return_unit_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_return_from_unit')[1]
184 except ValueError:
185 rt_return_unit_id = 0
186+ try:
187+ rt_other_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_other')[1]
188+ except ValueError:
189+ rt_other_id = 0
190
191 for sp in self.read(cr, uid, ids, ['purchase_id', 'sale_id', 'type', 'reason_type_id'], context=context):
192 if not sp['purchase_id'] and not sp['sale_id'] and sp['type'] == 'out' and sp['reason_type_id']:
193- if sp['reason_type_id'][0] in [rt_replacement_id, rt_return_unit_id]:
194+ if sp['reason_type_id'][0] in [rt_replacement_id, rt_return_unit_id, rt_other_id]:
195 return False
196 return res
197
198
199=== modified file 'bin/addons/reason_types_moves/reason_type_data.xml'
200--- bin/addons/reason_types_moves/reason_type_data.xml 2021-12-02 17:08:06 +0000
201+++ bin/addons/reason_types_moves/reason_type_data.xml 2022-06-13 12:48:07 +0000
202@@ -162,6 +162,11 @@
203 <field name="incoming_ok" eval="False" />
204 <field name="outgoing_ok" eval="False" />
205 </record>
206-
207+
208+ <record id="reason_type_deliver_unit" model="stock.reason.type">
209+ <field name="name">Deliver Unit</field>
210+ <field name="code">20</field>
211+ <field name="outgoing_ok">True</field>
212+ </record>
213 </data>
214 </openerp>
215
216=== modified file 'bin/addons/stock/stock.py'
217--- bin/addons/stock/stock.py 2022-05-02 15:04:12 +0000
218+++ bin/addons/stock/stock.py 2022-06-13 12:48:07 +0000
219@@ -1254,8 +1254,7 @@
220 if move.state == 'assigned':
221 todo.append(move.id)
222 if len(todo):
223- move_obj.action_done(cr, uid, todo,
224- return_goods=return_goods, context=context)
225+ move_obj.action_done(cr, uid, todo, return_goods=return_goods, context=context)
226 return True
227
228 def get_currency_id(self, cr, uid, picking):
229
230=== modified file 'bin/addons/stock/stock_move.py'
231--- bin/addons/stock/stock_move.py 2022-05-06 13:36:38 +0000
232+++ bin/addons/stock/stock_move.py 2022-06-13 12:48:07 +0000
233@@ -701,23 +701,29 @@
234
235 def _check_reason_type(self, cr, uid, ids, context=None):
236 """
237- Do not permit user to create/write a OUT from scratch with some reason types:
238+ Do not permit user to create/write an OUT from scratch with some reason types:
239 - GOODS RETURN UNIT
240 - GOODS REPLACEMENT
241+ - OTHER
242 """
243+ data_obj = self.pool.get('ir.model.data')
244 res = True
245 try:
246- rt_replacement_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_goods_replacement')[1]
247+ rt_replacement_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_goods_replacement')[1]
248 except ValueError:
249 rt_replacement_id = 0
250 try:
251- rt_return_unit_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_return_from_unit')[1]
252+ rt_return_unit_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_return_from_unit')[1]
253 except ValueError:
254 rt_return_unit_id = 0
255+ try:
256+ rt_other_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_other')[1]
257+ except ValueError:
258+ rt_other_id = 0
259
260 for sm in self.read(cr, uid, ids, ['reason_type_id', 'picking_id']):
261 if sm['reason_type_id'] and sm['picking_id']:
262- if sm['reason_type_id'][0] in [rt_replacement_id, rt_return_unit_id]:
263+ if sm['reason_type_id'][0] in [rt_replacement_id, rt_return_unit_id, rt_other_id]:
264 pick = self.pool.get('stock.picking').read(cr, uid, sm['picking_id'][0], ['purchase_id', 'sale_id', 'type'], context=context)
265 if not pick['purchase_id'] and not pick['sale_id'] and pick['type'] == 'out':
266 return False
267@@ -1881,6 +1887,8 @@
268 vals = {}
269 if move.picking_id:
270 picking_ids.append(move.picking_id.id)
271+ if move.type == 'out':
272+ vals.update({'reason_type_id': move.picking_id.reason_type_id.id})
273 if self._hook_action_done_update_out_move_check(cr, uid, ids, context=context, move=move,):
274 vals.update({'move_history_ids': [(4, move.move_dest_id.id)]})
275 #cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id))
276
277=== modified file 'bin/addons/stock_override/stock.py'
278--- bin/addons/stock_override/stock.py 2022-04-14 10:10:19 +0000
279+++ bin/addons/stock_override/stock.py 2022-06-13 12:48:07 +0000
280@@ -1315,8 +1315,8 @@
281 picking = False
282 sync_dpo_in = False
283 if vals.get('picking_id', False):
284- picking = pick_obj.read(cr, uid, vals['picking_id'],
285- ['move_sequence_id', 'type', 'reason_type_id', 'sync_dpo_in'], context=context)
286+ picking = pick_obj.read(cr, uid, vals['picking_id'], ['move_sequence_id', 'type', 'reason_type_id',
287+ 'sync_dpo_in', 'sale_id'], context=context)
288 if not vals.get('line_number', False):
289 # new number need - gather the line number form the sequence
290 sequence_id = picking['move_sequence_id'][0]
291@@ -1392,11 +1392,18 @@
292 vals['state'] = 'done'
293
294 # Change the reason type of the picking if it is not the same
295- other_type_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', 'reason_type_other')[1]
296+ rt_name = 'reason_type_other'
297+ if picking['type'] == 'out' and (picking['sale_id'] and self.pool.get('sale.order').search_exist(cr, uid,
298+ [('id', '=', picking['sale_id'][0]), ('procurement_request', '=', 't'),
299+ ('location_requestor_id.location_category', '=', 'consumption_unit')], context=context))\
300+ or not picking['sale_id']:
301+ rt_name = 'reason_type_deliver_unit'
302+ rt_id = data_obj.get_object_reference(cr, uid, 'reason_types_moves', rt_name)[1]
303 if picking and not context.get('from_claim') and not context.get('from_chaining') \
304- and picking['reason_type_id'][0] != other_type_id \
305+ and picking['reason_type_id'][0] != rt_id \
306 and vals.get('reason_type_id', False) != picking['reason_type_id'][0]:
307- pick_obj.write(cr, uid, [picking['id']], {'reason_type_id': other_type_id}, context=context)
308+ pick_obj.write(cr, uid, [picking['id']], {'reason_type_id': rt_id}, context=context)
309+ vals.update({'reason_type_id': rt_id})
310
311 return super(stock_move, self).create(cr, uid, vals, context=context)
312
313
314=== modified file 'bin/addons/stock_override/stock_view.xml'
315--- bin/addons/stock_override/stock_view.xml 2022-04-27 14:43:45 +0000
316+++ bin/addons/stock_override/stock_view.xml 2022-06-13 12:48:07 +0000
317@@ -893,9 +893,7 @@
318 <field name="dg_check" widget="null_boolean" />
319 <field name="np_check" widget="null_boolean" />
320 </group>
321- <field name="reason_type_id" widget="selection"
322- domain="[('outgoing_ok', '=', True)]"
323- attrs="{'readonly': ['|', ('state', 'not in', ['draft', 'confirmed', 'assigned']), ('from_wkf_line', '=', True)]}"/>
324+ <field name="reason_type_id" widget="selection" readonly="1"/>
325 </group>
326
327 <group colspan="2" col="2">

Subscribers

People subscribed via source and target branches