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

Proposed by jftempo
Status: Merged
Merged at revision: 6082
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-9114
Merge into: lp:unifield-server
Diff against target: 84 lines (+17/-9)
2 files modified
bin/addons/consumption_calculation/expiry_calculation.py (+11/-3)
bin/addons/procurement_cycle/replenishment.py (+6/-6)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-9114
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+409195@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/consumption_calculation/expiry_calculation.py'
2--- bin/addons/consumption_calculation/expiry_calculation.py 2021-05-06 10:22:29 +0000
3+++ bin/addons/consumption_calculation/expiry_calculation.py 2021-10-04 08:49:54 +0000
4@@ -524,22 +524,29 @@
5 product_lot_ids = lot_obj.search(new_cr, uid, domain, order='life_date', context=context)
6
7 tmp_last_expiry_date = False
8- # Create an item line for each lot and each location
9 for product_lot in lot_obj.browse(new_cr, uid, product_lot_ids, context=context):
10+ # each BN that expires in the month ordered by life_date
11 if from_segment and segment_product_fmc:
12 life_date = DateFrom(product_lot.life_date)
13 consum = 0
14+ # consum is the sum of FMC for the period:
15+ # period is: from today to expiry_date for the 1st BN
16+ # or from previous_bn_expiry to expiry_date if previous BN found
17+ # note: the period may be covered by several FMC intervals
18+
19+ # ignore FMC if BN is already expired
20 if life_date > last_expiry_date:
21 tmp_last_expiry_date = last_expiry_date
22 for fmc in segment_product_fmc.setdefault(lot.product_id.id, []):
23 if life_date >= fmc['from'] and tmp_last_expiry_date <= fmc['to']:
24+ # if the given period overlaps FMC interval
25 end_fmc = min(life_date, fmc['to'])
26 lot_days = Age(DateFrom(end_fmc), tmp_last_expiry_date)
27 consum += fmc['fmc'] * (lot_days.years*364.8 + lot_days.months*30.44 + lot_days.days)/30.44
28+ tmp_last_expiry_date = end_fmc
29 if life_date <= fmc['to']:
30+ # no need to check other FMCs
31 break
32- else:
33- tmp_last_expiry_date = end_fmc
34
35 else:
36 lot_days = Age(DateFrom(product_lot.life_date), last_expiry_date)
37@@ -568,6 +575,7 @@
38 lot_context = context.copy()
39 lot_context.update({'prodlot_id': product_lot.id})
40 lot_expired_qty = l_expired_qty
41+ # Create an item line for each lot and each location
42 for location in location_ids:
43 new_lot_context = lot_context.copy()
44 new_lot_context.update({'location': location, 'compute_child': False})
45
46=== modified file 'bin/addons/procurement_cycle/replenishment.py'
47--- bin/addons/procurement_cycle/replenishment.py 2021-08-26 07:25:26 +0000
48+++ bin/addons/procurement_cycle/replenishment.py 2021-10-04 08:49:54 +0000
49@@ -1220,7 +1220,7 @@
50 )
51 pipe_data = {}
52 for x in cr.fetchall():
53- pipe_data[datetime.strptime('%s 23:59:59' % (x[0].split(' ')[0], ), '%Y-%m-%d %H:%M:%S')] = x[1]
54+ pipe_data[datetime.strptime('%s 00:00:00' % (x[0].split(' ')[0], ), '%Y-%m-%d %H:%M:%S')] = x[1]
55
56 pipe_date = sorted(pipe_data.keys())
57
58@@ -1272,21 +1272,21 @@
59 period_conso = month*num_fmc
60 if period_conso <= pas_full:
61 pas_full -= period_conso
62- else:
63- # missing stock to cover the full period
64 for x in pipe_date[:]:
65- # add pipe before period
66- if x <= begin:
67+ # add pipe before end of period
68+ if x <= end:
69 pas_full += pipe_data[x]
70 pipe_date.pop(0)
71 else:
72 break
73+ else:
74+ # missing stock to cover the full period
75 if period_conso > pas_full:
76 # still not enough stock
77 for x in pipe_date[:]:
78 if x <= end:
79 # compute missing just before the next pipe
80- ndays = (x - new_begin).days + 1
81+ ndays = (x - new_begin).days
82 qty = num_fmc/30.44*ndays
83 pas_full -= qty
84 if pas_full < 0:

Subscribers

People subscribed via source and target branches