Merge lp:~jfb-tempo-consulting/unifield-server/US-6705-US-6706 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5563
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-6705-US-6706
Merge into: lp:unifield-server
Diff against target: 69 lines (+19/-9)
2 files modified
bin/addons/msf_outgoing/msf_outgoing.py (+7/-6)
bin/addons/purchase/purchase_workflow.py (+12/-3)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-6705-US-6706
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+375489@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 2019-10-30 08:44:20 +0000
3+++ bin/addons/msf_outgoing/msf_outgoing.py 2019-11-13 14:34:43 +0000
4@@ -954,8 +954,8 @@
5
6 context['non_stock_noupdate'] = False
7
8- # Find the corresponding move in draft in the draft picking ticket
9- draft_move = move.backmove_id
10+ # Find the corresponding move in draft in the draft picking ticket: use browse to invalidate cache
11+ draft_move = move_obj.browse(cr, uid, move.backmove_id.id, fields_to_fetch=['product_qty', 'qty_processed'], context=context)
12 # Increase the draft move with the move quantity
13
14 draft_initial_qty = draft_move.product_qty + return_qty
15@@ -3572,11 +3572,12 @@
16
17 diff_qty = line.product_qty - line.qty_to_process
18 if line.backmove_id:
19+ backmove_line = move_obj.browse(cr, uid, line.backmove_id.id, fields_to_fetch=['qty_processed', 'product_qty'], context=context)
20 if line.backmove_id.product_uom.id != line.product_uom.id:
21 diff_qty = uom_obj._compute_qty(cr, uid, line.product_uom.id, diff_qty, line.backmove_id.product_uom.id)
22- backorder_qty = max(line.backmove_id.product_qty + diff_qty, 0)
23+ backorder_qty = max(backmove_line.product_qty + diff_qty, 0)
24 if backorder_qty != 0.00:
25- new_val = {'product_qty': backorder_qty, 'qty_processed': line.backmove_id.qty_processed and line.backmove_id.qty_processed - diff_qty or 0, 'qty_to_process': backorder_qty}
26+ new_val = {'product_qty': backorder_qty, 'qty_processed': backmove_line.qty_processed and backmove_line.qty_processed - diff_qty or 0, 'qty_to_process': backorder_qty}
27 move_obj.write(cr, uid, [line.backmove_id.id], new_val, context=context)
28
29 if line.qty_to_process:
30@@ -4068,8 +4069,8 @@
31 context['keepLineNumber'] = True
32 move_obj.copy(cr, uid, line.move_id.id, return_values, context=context)
33 context['keepLineNumber'] = False
34- # Increase the draft move with the returned quantity
35- draft_move = line.move_id.backmove_id
36+ # Increase the draft move with the returned quantity : must broswe the record again to invalidate cache
37+ draft_move = move_obj.browse(cr, uid, line.move_id.backmove_id.id, fields_to_fetch=['product_qty', 'qty_processed'], context=context)
38 draft_move_qty = draft_move.product_qty + return_qty
39 qty_processed = max(draft_move.qty_processed - return_qty, 0)
40 move_obj.write(cr, uid, [draft_move.id], {'product_qty': draft_move_qty, 'qty_to_process': draft_move_qty, 'qty_processed': qty_processed}, context=context)
41
42=== modified file 'bin/addons/purchase/purchase_workflow.py'
43--- bin/addons/purchase/purchase_workflow.py 2019-10-30 16:33:21 +0000
44+++ bin/addons/purchase/purchase_workflow.py 2019-11-13 14:34:43 +0000
45@@ -213,12 +213,21 @@
46 netsvc.LocalService('workflow').trg_validate(uid, 'sale.order.line', new_sol, 'sourced', cr)
47 linked_out_moves = self.pool.get('stock.move').search(cr, uid, [
48 ('sale_line_id', '=', sol_values['original_line_id']),
49- ('type', '=', 'out')],
50+ ('type', '=', 'out'),
51+ ('state', 'in', ['assigned', 'confirmed'])],
52 context=context)
53 if len(linked_out_moves) > 1:
54+ # try first confirmed OUT, if not found link assigned OUT
55+ out_to_update = False
56 for out_move in self.pool.get('stock.move').browse(cr, uid, linked_out_moves, context=context):
57- if out_move.state in ('assigned', 'confirmed') and out_move.product_qty == sol_values['product_uom_qty']:
58- self.pool.get('stock.move').write(cr, uid, [out_move.id], {'sale_line_id': new_sol}, context=context)
59+ if out_move.product_qty == sol_values['product_uom_qty']:
60+ if out_move.state == 'confirmed':
61+ out_to_update = out_move.id
62+ break
63+ elif out_move.state == 'assigned':
64+ out_to_update = out_move.id
65+ if out_to_update:
66+ self.pool.get('stock.move').write(cr, uid, [out_to_update], {'sale_line_id': new_sol}, context=context)
67
68 else: # update FO line
69 if pol.linked_sol_id and not pol.linked_sol_id.analytic_distribution_id and not pol.linked_sol_id.order_id.analytic_distribution_id and ad_id and not sale_order.procurement_request:

Subscribers

People subscribed via source and target branches