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

Proposed by jftempo
Status: Merged
Merged at revision: 5586
Proposed branch: lp:~dorian-kemps/unifield-server/US-6965
Merge into: lp:unifield-server
Diff against target: 97 lines (+17/-27)
2 files modified
bin/addons/stock/physical_inventory.py (+11/-19)
bin/addons/stock/wizard/physical_inventory_generate_counting_sheet.py (+6/-8)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-6965
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+378094@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/stock/physical_inventory.py'
2--- bin/addons/stock/physical_inventory.py 2020-01-06 11:38:19 +0000
3+++ bin/addons/stock/physical_inventory.py 2020-01-27 10:41:25 +0000
4@@ -600,27 +600,19 @@
5 ('state', '=', 'done')]
6
7 moves_at_location_ids = move_obj.search(cr, uid, move_for_products_at_location, context=context)
8- moves_at_location = move_obj.read(cr, uid, moves_at_location_ids,
9- ["product_id",
10- "product_qty",
11- "prodlot_id",
12- "expired_date",
13- "location_id",
14- "product_uom",
15- "location_dest_id"],
16- context=context)
17+ ftf = ["product_id", "product_qty", "prodlot_id", "expired_date", "location_id", "product_uom", "location_dest_id"]
18+ moves_at_location = move_obj.browse(cr, uid, moves_at_location_ids, fields_to_fetch=ftf, context=context)
19
20 # Sum all lines to get a set of (product, batchnumber) -> qty
21 stocks = {}
22 for move in moves_at_location:
23
24- product_id = move["product_id"][0]
25- product_qty = move["product_qty"]
26- batch_number = move["prodlot_id"][1] if move["prodlot_id"] else False
27- expiry_date = move["expired_date"]
28+ product_id = move.product_id.id
29+ product_qty = move.product_qty
30+ batch_number = move.prodlot_id and move.prodlot_id.name or False
31+ expiry_date = move.expired_date
32
33- # Dirty hack to ignore/hide internal batch numbers ("MSFBN")
34- if batch_number and batch_number.startswith("MSFBN"):
35+ if batch_number and move.prodlot_id.type == 'internal':
36 batch_number = False
37
38 product_batch_expirydate = (product_id, batch_number, expiry_date)
39@@ -630,14 +622,14 @@
40 if not product_batch_expirydate in stocks.keys():
41 stocks[product_batch_expirydate] = 0.0
42
43- move_out = (move["location_id"][0] == location_id)
44- move_in = (move["location_dest_id"][0] == location_id)
45+ move_out = (move.location_id.id == location_id)
46+ move_in = (move.location_dest_id.id == location_id)
47
48 if move_in and move_out:
49 continue
50
51- if move['product_uom'] and default_uom.get(product_id) and move['product_uom'][0] != default_uom[product_id]:
52- product_qty = uom_obj._compute_qty(cr, uid, move['product_uom'][0], product_qty, default_uom[product_id])
53+ if move.product_uom and default_uom.get(product_id) and move.product_uom.id != default_uom[product_id]:
54+ product_qty = uom_obj._compute_qty(cr, uid, move.product_uom.id, product_qty, default_uom[product_id])
55
56 if move_in:
57 stocks[product_batch_expirydate] += product_qty
58
59=== modified file 'bin/addons/stock/wizard/physical_inventory_generate_counting_sheet.py'
60--- bin/addons/stock/wizard/physical_inventory_generate_counting_sheet.py 2020-01-06 11:38:19 +0000
61+++ bin/addons/stock/wizard/physical_inventory_generate_counting_sheet.py 2020-01-27 10:41:25 +0000
62@@ -135,7 +135,6 @@
63 if context is None:
64 context = {}
65
66-
67 prod_info = {}
68 move_obj = self.pool.get('stock.move')
69 prod_obj = self.pool.get('product.product')
70@@ -162,11 +161,10 @@
71
72 move_ids = move_obj.search(cr, uid, domain, context=context)
73
74- for move in move_obj.read(cr, uid, move_ids, ['product_id', 'prodlot_id', 'expired_date']):
75- product_id = move["product_id"][0]
76-
77-
78- if move['prodlot_id'] and move["prodlot_id"][1].startswith("MSFBN"):
79+ for move in move_obj.browse(cr, uid, move_ids, fields_to_fetch=['product_id', 'prodlot_id', 'expired_date'], context=context):
80+ product_id = move.product_id.id
81+
82+ if move.prodlot_id and move.prodlot_id.type == 'internal':
83 if prod_info.get(product_id, {}).get('batch_management'):
84 # old move when product was ED only, now it's BN so ignore the move
85 continue
86@@ -175,10 +173,10 @@
87 if not prod_info.get(product_id, {}).get('batch_management'):
88 # old move when this product was BN, now it's ED only so ignore this stock move
89 continue
90- batch_number = move["prodlot_id"][1]
91+ batch_number = move.prodlot_id.name
92
93 key = (product_id, default_code_dict.get(product_id))
94- BN_and_ED[key].add((batch_number, move["expired_date"], move["prodlot_id"][0]))
95+ BN_and_ED[key].add((batch_number, move.expired_date, move.prodlot_id.id))
96
97 return BN_and_ED
98

Subscribers

People subscribed via source and target branches