Merge lp:~unifield-team/unifield-wm/pilot-27-supply-bugs into lp:unifield-wm

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~unifield-team/unifield-wm/pilot-27-supply-bugs
Merge into: lp:unifield-wm
Diff against target: 258 lines (+70/-19)
8 files modified
consumption_calculation/history_consumption.py (+2/-1)
kit/kit_creation.py (+44/-6)
kit/kit_creation_view.xml (+4/-2)
msf_doc_import/initial_stock_inventory.py (+1/-1)
msf_outgoing/msf_outgoing.py (+7/-3)
msf_supply_doc_export/msf_supply_doc_export.py (+4/-4)
specific_rules/specific_rules_view.xml (+1/-1)
stock_override/report/report_stock_move.py (+7/-1)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/pilot-27-supply-bugs
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+196101@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

1859. By Quentin THEURET @Amaris

UF-2207 [FIX] Picking Ticket : Display the good actions report

1858. By Quentin THEURET @Amaris

UF-2207 [MERGE] Merge UF-2207 branch
lp:~unifield-team/unifield-wm/uf-2207

1857. By Quentin THEURET @Amaris

UF-2210 [MERGE] Merge UF-2210 branch
lp:~unifield-team/unifield-wm/uf-2210

1856. By Quentin THEURET @Amaris

UF-2209 [MERGE] Merge UF-2209 branch
lp:~unifield-team/unifield-wm/uf-2209

1855. By Quentin THEURET @Amaris

UF-2206 [MERGE] Merge UF-2206 branch
lp:~unifield-team/unifield-wm/uf-2206

1854. By Quentin THEURET @Amaris

UF-2204 [MERGE] Merge UF-2204 branch
lp:~unifield-team/unifield-wm/uf-2204

1853. By Quentin THEURET @Amaris

UF-2191 [MERGE] Merge UF-2191 branch
lp:~unifield-team/unifield-wm/uf-2191

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'consumption_calculation/history_consumption.py'
2--- consumption_calculation/history_consumption.py 2013-11-05 15:44:32 +0000
3+++ consumption_calculation/history_consumption.py 2013-11-21 13:07:07 +0000
4@@ -66,7 +66,7 @@
5 _defaults = {
6 'date_to': lambda *a: (DateFrom(time.strftime('%Y-%m-%d')) + RelativeDateTime(months=1, day=1, days=-1)).strftime('%Y-%m-%d'),
7 'requestor_id': lambda obj, cr, uid, c: uid,
8- 'requestor_date': time.strftime('%Y-%m-%d %H:%M:%S'),
9+ 'requestor_date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
10 'status': 'draft',
11 }
12
13@@ -222,6 +222,7 @@
14
15 import threading
16 self.write(cr, uid, ids, {'status': 'in_progress'}, context=context)
17+ cr.commit()
18 new_thread = threading.Thread(target=self._create_lines, args=(cr, uid, ids, product_ids, new_context))
19 new_thread.start()
20 new_thread.join(10.0)
21
22=== modified file 'kit/kit_creation.py'
23--- kit/kit_creation.py 2013-10-07 14:53:32 +0000
24+++ kit/kit_creation.py 2013-11-21 13:07:07 +0000
25@@ -473,10 +473,11 @@
26 data = {}
27 # moves consolidated
28 move_list = []
29+ move_manual = []
30
31 for move in obj.consumed_ids_kit_creation:
32 # the stock move should not be canceled, but... we recycle them in case.
33- if move.state in ['confirmed', 'cancel']:
34+ if move.state in ['confirmed', 'cancel'] and not move.kol_lot_manual:
35 move_list.append(move.id)
36 # consolidate the moves qty
37 qty = data.setdefault(move.product_id.id, {}).setdefault('uoms', {}).setdefault(move.product_uom.id, {}).setdefault('qty', 0.0)
38@@ -489,8 +490,10 @@
39 data.setdefault(move.product_id.id, {}).setdefault('uoms', {})[move.product_uom.id]['qty'] = qty
40 # save object for efficiency
41 data.setdefault(move.product_id.id, {}).setdefault('object', move.product_id)
42+ elif move.kol_lot_manual:
43+ move_manual.append(move.id)
44
45- return data, move_list
46+ return data, move_list, move_manual
47
48 def consolidate_lines(self, cr, uid, ids, context=None):
49 '''
50@@ -510,7 +513,7 @@
51
52 for obj in self.browse(cr, uid, ids, context=context):
53 # consolidate data
54- data, move_list = self._consolidate_data(cr, uid, obj.id, context=context)
55+ data, move_list, move_manual = self._consolidate_data(cr, uid, obj.id, context=context)
56 # delete stock moves
57 move_obj.unlink(cr, uid, move_list, context=dict(context, call_unlink=True))
58 # default location
59@@ -561,16 +564,41 @@
60 loc_obj = self.pool.get('stock.location')
61 prodlot_obj = self.pool.get('stock.production.lot')
62 data_tools_obj = self.pool.get('data.tools')
63+ uom_obj = self.pool.get('product.uom')
64 # load data into the context
65 data_tools_obj.load_common_data(cr, uid, ids, context=context)
66
67 for obj in self.browse(cr, uid, ids, context=context):
68 # consolidate data
69- data, move_list = self._consolidate_data(cr, uid, obj.id, context=context)
70+ data, move_list, move_manual = self._consolidate_data(cr, uid, obj.id, context=context)
71+ # default location
72+ default_location_id = obj.default_location_src_id_kit_creation.id
73+
74+ # Check availability of manual moves
75+ for move in move_obj.browse(cr, uid, move_manual, context=context):
76+ if move.state != 'confirmed' or not move.prodlot_id:
77+ continue
78+
79+ location_ids = loc_obj.search(cr, uid, [('location_id', 'child_of', move.location_id.id)], context=context)
80+ needed_qty = move.product_qty
81+ for loc in location_ids:
82+ available_qty = prodlot_obj.browse(cr, uid, move.prodlot_id.id, context=dict(context, location_id=loc)).stock_virtual
83+ diff_qty = available_qty - uom_obj._compute_qty(cr, uid, move.product_uom.id, needed_qty, move.product_id.uom_id.id)
84+ if diff_qty >= 0:
85+ move_obj.write(cr, uid, [move.id], {'state': 'assigned'}, context=context)
86+ break
87+ else:
88+ if available_qty:
89+ move_obj.copy(cr, uid, move.id, {'product_qty': available_qty, 'state': 'assigned'}, context=context)
90+ needed_qty -= available_qty
91+ move_obj.write(cr, uid, [move.id], {'product_qty': needed_qty}, context=context)
92+ else:
93+ move_obj.write(cr, uid, [move.id], {'prodlot_id': False, 'kol_lot_manual': False}, context=context)
94+
95+ data, move_list, move_manual = self._consolidate_data(cr, uid, obj.id, context=context)
96 # delete stock moves
97 move_obj.unlink(cr, uid, move_list, context=dict(context, call_unlink=True))
98- # default location
99- default_location_id = obj.default_location_src_id_kit_creation.id
100+
101 # create consolidated stock moves
102 for product_id in data.keys():
103 for uom_id in data[product_id]['uoms'].keys():
104@@ -1250,6 +1278,7 @@
105 'hidden_creation_state': fields.function(_vals_get_kit_creation, method=True, type='selection', selection=KIT_CREATION_STATE, string='Hidden Creation State', multi='get_vals_kit_creation', store=False, readonly=True),
106 'assigned_qty_stock_move': fields.function(_vals_get_kit_creation, method=True, type='float', string='Assigned Qty', multi='get_vals_kit_creation', store=False, readonly=True),
107 'hidden_creation_qty_stock_move': fields.function(_vals_get_kit_creation, method=True, type='integer', string='Hidden Creation Qty', multi='get_vals_kit_creation', store=False, readonly=True),
108+ 'kol_lot_manual': fields.boolean(string='The batch is set manually'),
109 }
110
111 _defaults = {'to_consume_id_stock_move': False,
112@@ -1273,6 +1302,15 @@
113 # open the selected wizard
114 res = wiz_obj.open_wizard(cr, uid, ids, name=name, model=model, step=step, context=dict(context))
115 return res
116+
117+ def kol_prodlot_change(self, cr, uid, ids, prodlot_id, context=None):
118+ '''
119+ Set a new attribute on stock move if the prodolt is change manually in the Kit order creation
120+ '''
121+ if prodlot_id:
122+ return {'value': {'kol_lot_manual': True}}
123+
124+ return {'value': {'kol_lot_manual': False}}
125
126 def automatic_assignment(self, cr, uid, ids, context=None):
127 '''
128
129=== modified file 'kit/kit_creation_view.xml'
130--- kit/kit_creation_view.xml 2013-10-07 14:53:32 +0000
131+++ kit/kit_creation_view.xml 2013-11-21 13:07:07 +0000
132@@ -77,7 +77,8 @@
133 attrs="{'readonly': ['|', ('hidden_state', '!=', 'confirmed'), ('hidden_asset_check', '=', False)]}" />
134 <field name="prodlot_id"
135 context="{'location_id':location_id, 'product_id':product_id, 'hidden_perishable_mandatory': hidden_perishable_mandatory,
136- 'search_default_real': True}"
137+ 'search_default_real': True}"
138+ on_change="kol_prodlot_change(prodlot_id)"
139 domain="[('product_id', '=', product_id),('check_type','=', True)]"
140 attrs="{'readonly': ['|', ('hidden_state', '!=', 'confirmed'), ('hidden_exp_check', '=', False)],
141 'required': [('hidden_exp_check', '=', True)]}" />
142@@ -88,7 +89,8 @@
143 domain="[('usage', '=', 'internal')]" />
144 <field name="state" />
145 <field name="lot_check" />
146- <field name="exp_check" />
147+ <field name="exp_check" />
148+ <field name="kol_lot_manual" invisible="True" />
149 <field name="hidden_perishable_mandatory" invisible="True" />
150 <field name="hidden_exp_check" invisible="True" />
151 <field name="hidden_state" invisible="True" />
152
153=== modified file 'msf_doc_import/initial_stock_inventory.py'
154--- msf_doc_import/initial_stock_inventory.py 2013-10-04 14:01:53 +0000
155+++ msf_doc_import/initial_stock_inventory.py 2013-11-21 13:07:07 +0000
156@@ -250,7 +250,7 @@
157 product = product_obj.browse(cr, uid, product_id)
158 product_uom = product.uom_id.id
159 hidden_batch_management_mandatory = product.batch_management
160- hidden_perishable_mandatory = product.perishable
161+ hidden_perishable_mandatory = product.perishable and not product.batch_management
162 if hidden_batch_management_mandatory and not batch:
163 comment += _('Batch is missing.\n')
164 if hidden_perishable_mandatory and not expiry:
165
166=== modified file 'msf_outgoing/msf_outgoing.py'
167--- msf_outgoing/msf_outgoing.py 2013-11-07 17:06:54 +0000
168+++ msf_outgoing/msf_outgoing.py 2013-11-21 13:07:07 +0000
169@@ -497,7 +497,8 @@
170 self.log(cr, uid, draft_shipment_id, _("Packs from the draft Shipment (%s) have been returned to stock.")%(draft_shipment_name,))
171 log_flag = True
172 res = obj_data.get_object_reference(cr, uid, 'msf_outgoing', 'view_picking_ticket_form')[1]
173- self.pool.get('stock.picking').log(cr, uid, draft_picking_id, _("The corresponding Draft Picking Ticket (%s) has been updated.")%(draft_picking.name,), context={'view_id': res,})
174+ context.update({'view_id': res, 'picking_type': 'picking.ticket'})
175+ self.pool.get('stock.picking').log(cr, uid, draft_picking_id, _("The corresponding Draft Picking Ticket (%s) has been updated.")%(draft_picking.name,), context=context)
176
177 # call complete_finished on the shipment object
178 # if everything is alright (all draft packing are finished) the shipment is done also
179@@ -517,6 +518,7 @@
180 'res_id': draft_picking_id ,
181 'type': 'ir.actions.act_window',
182 'target': 'crush',
183+ 'context': context
184 }
185
186 def return_packs_from_shipment(self, cr, uid, ids, context=None):
187@@ -2849,7 +2851,8 @@
188 res = obj_data.get_object_reference(cr, uid, 'msf_outgoing', 'view_ppl_form')[1]
189 self.log(cr, uid, picking.id, _("Products from Pre-Packing List (%s) have been returned to stock.")%(picking.name,), context={'view_id': res,})
190 res = obj_data.get_object_reference(cr, uid, 'msf_outgoing', 'view_picking_ticket_form')[1]
191- self.log(cr, uid, draft_picking_id, _("The corresponding Draft Picking Ticket (%s) has been updated.")%(picking.previous_step_id.backorder_id.name,), context={'view_id': res,})
192+ context.update({'view_id': res, 'picking_type': 'picking_ticket'})
193+ self.log(cr, uid, draft_picking_id, _("The corresponding Draft Picking Ticket (%s) has been updated.")%(picking.previous_step_id.backorder_id.name,), context=context)
194 # if all moves are done or canceled, the ppl is canceled
195 cancel_ppl = True
196 for move in picking.move_lines:
197@@ -2935,7 +2938,8 @@
198 # TODO refactoring needed
199 obj_data = self.pool.get('ir.model.data')
200 res = obj_data.get_object_reference(cr, uid, 'msf_outgoing', 'view_picking_ticket_form')[1]
201- self.log(cr, uid, draft_picking_id, _("The corresponding Draft Picking Ticket (%s) has been updated.")%(picking.backorder_id.name,), context={'view_id': res,})
202+ context.update({'view_id': res, 'picking_type': 'picking_ticket'})
203+ self.log(cr, uid, draft_picking_id, _("The corresponding Draft Picking Ticket (%s) has been updated.")%(picking.backorder_id.name,), context=context)
204
205 if picking.subtype == 'packing':
206 # for each packing we get the draft packing
207
208=== modified file 'msf_supply_doc_export/msf_supply_doc_export.py'
209--- msf_supply_doc_export/msf_supply_doc_export.py 2013-10-30 16:03:55 +0000
210+++ msf_supply_doc_export/msf_supply_doc_export.py 2013-11-21 13:07:07 +0000
211@@ -299,11 +299,11 @@
212 Delivery_Order = trans_obj.tr_view(cr, 'Delivery Order', context)
213 Internal_Moves = trans_obj.tr_view(cr, 'Internal Moves', context)
214 for v in values:
215- if '_terp_view_name' in context and v[2]['report_name'] == 'picking.ticket' and context['_terp_view_name'] in (Picking_Tickets, Picking_Ticket) and context.get('picking_screen', False)\
216- or '_terp_view_name' in context and v[2]['report_name'] == 'pre.packing.list' and context['_terp_view_name'] in (Pre_Packing_Lists, Pre_Packing_List) and context.get('ppl_screen', False)\
217- or '_terp_view_name' in context and v[2]['report_name'] == 'labels' and context['_terp_view_name'] in [Picking_Ticket, Picking_Tickets, Pre_Packing_List, Pre_Packing_Lists, Delivery_Orders, Delivery_Order]\
218+ if v[2]['report_name'] == 'picking.ticket' and (context.get('_terp_view_name') in (Picking_Tickets, Picking_Ticket) or context.get('picking_type') == 'picking_ticket') and context.get('picking_screen', False)\
219+ or v[2]['report_name'] == 'pre.packing.list' and context.get('_terp_view_name') in (Pre_Packing_Lists, Pre_Packing_List) and context.get('ppl_screen', False)\
220+ or v[2]['report_name'] == 'labels' and (context.get('_terp_view_name') in [Picking_Ticket, Picking_Tickets, Pre_Packing_List, Pre_Packing_Lists, Delivery_Orders, Delivery_Order] or context.get('picking_type', False) in ('delivery_order', 'picking_ticket'))\
221 or v[2]['report_name'] in ('internal.move.xls', 'internal.move') and (('_terp_view_name' in context and context['_terp_view_name'] in [Internal_Moves]) or context.get('picking_type') == 'internal_move') \
222- or v[2]['report_name'] == 'delivery.order' and context.get('_terp_view_name') in [Delivery_Orders, Delivery_Order]:
223+ or v[2]['report_name'] == 'delivery.order' and (context.get('_terp_view_name') in [Delivery_Orders, Delivery_Order] or context.get('picking_type', False) == 'delivery_order'):
224 new_act.append(v)
225 values = new_act
226 elif context.get('_terp_view_name') and key == 'action' and key2 == 'client_print_multi' and 'shipment' in [x[0] for x in models]:
227
228=== modified file 'specific_rules/specific_rules_view.xml'
229--- specific_rules/specific_rules_view.xml 2013-10-04 15:24:12 +0000
230+++ specific_rules/specific_rules_view.xml 2013-11-21 13:07:07 +0000
231@@ -144,7 +144,7 @@
232 <field name="type">tree</field>
233 <field name="priority" eval="200" />
234 <field name="arch" type="xml">
235- <tree string="Expiry Dates" hide_new_button="True" hide_delete_button="True">
236+ <tree string="Expiry Dates" hide_new_button="True" hide_delete_button="True" colors="red:life_date &lt; current_date">
237 <field name="prefix" invisible="True" />
238 <field name="type" invisible="True" />
239 <field name="life_date" />
240
241=== modified file 'stock_override/report/report_stock_move.py'
242--- stock_override/report/report_stock_move.py 2013-09-03 08:27:31 +0000
243+++ stock_override/report/report_stock_move.py 2013-11-21 13:07:07 +0000
244@@ -163,7 +163,13 @@
245 sm.prodlot_id as prodlot_id,
246 sm.comment as comment,
247 sm.tracking_id as tracking_id,
248- sum((sm.product_qty / pu.factor) * u.factor) as product_qty,
249+ CASE
250+ WHEN sp.type in ('out') THEN
251+ sum((-sm.product_qty / pu.factor) * u.factor)
252+ WHEN sp.type in ('in') THEN
253+ sum((sm.product_qty / pu.factor) * u.factor)
254+ ELSE 0.0
255+ END AS product_qty,
256 pt.nomen_manda_2 as categ_id,
257 sp.partner_id2 as partner_id,
258 sm.product_id as product_id,

Subscribers

People subscribed via source and target branches