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
=== modified file 'bin/addons/consumption_calculation/expiry_calculation.py'
--- bin/addons/consumption_calculation/expiry_calculation.py 2021-05-06 10:22:29 +0000
+++ bin/addons/consumption_calculation/expiry_calculation.py 2021-10-04 08:49:54 +0000
@@ -524,22 +524,29 @@
524 product_lot_ids = lot_obj.search(new_cr, uid, domain, order='life_date', context=context)524 product_lot_ids = lot_obj.search(new_cr, uid, domain, order='life_date', context=context)
525525
526 tmp_last_expiry_date = False526 tmp_last_expiry_date = False
527 # Create an item line for each lot and each location
528 for product_lot in lot_obj.browse(new_cr, uid, product_lot_ids, context=context):527 for product_lot in lot_obj.browse(new_cr, uid, product_lot_ids, context=context):
528 # each BN that expires in the month ordered by life_date
529 if from_segment and segment_product_fmc:529 if from_segment and segment_product_fmc:
530 life_date = DateFrom(product_lot.life_date)530 life_date = DateFrom(product_lot.life_date)
531 consum = 0531 consum = 0
532 # consum is the sum of FMC for the period:
533 # period is: from today to expiry_date for the 1st BN
534 # or from previous_bn_expiry to expiry_date if previous BN found
535 # note: the period may be covered by several FMC intervals
536
537 # ignore FMC if BN is already expired
532 if life_date > last_expiry_date:538 if life_date > last_expiry_date:
533 tmp_last_expiry_date = last_expiry_date539 tmp_last_expiry_date = last_expiry_date
534 for fmc in segment_product_fmc.setdefault(lot.product_id.id, []):540 for fmc in segment_product_fmc.setdefault(lot.product_id.id, []):
535 if life_date >= fmc['from'] and tmp_last_expiry_date <= fmc['to']:541 if life_date >= fmc['from'] and tmp_last_expiry_date <= fmc['to']:
542 # if the given period overlaps FMC interval
536 end_fmc = min(life_date, fmc['to'])543 end_fmc = min(life_date, fmc['to'])
537 lot_days = Age(DateFrom(end_fmc), tmp_last_expiry_date)544 lot_days = Age(DateFrom(end_fmc), tmp_last_expiry_date)
538 consum += fmc['fmc'] * (lot_days.years*364.8 + lot_days.months*30.44 + lot_days.days)/30.44545 consum += fmc['fmc'] * (lot_days.years*364.8 + lot_days.months*30.44 + lot_days.days)/30.44
546 tmp_last_expiry_date = end_fmc
539 if life_date <= fmc['to']:547 if life_date <= fmc['to']:
548 # no need to check other FMCs
540 break549 break
541 else:
542 tmp_last_expiry_date = end_fmc
543550
544 else:551 else:
545 lot_days = Age(DateFrom(product_lot.life_date), last_expiry_date)552 lot_days = Age(DateFrom(product_lot.life_date), last_expiry_date)
@@ -568,6 +575,7 @@
568 lot_context = context.copy()575 lot_context = context.copy()
569 lot_context.update({'prodlot_id': product_lot.id})576 lot_context.update({'prodlot_id': product_lot.id})
570 lot_expired_qty = l_expired_qty577 lot_expired_qty = l_expired_qty
578 # Create an item line for each lot and each location
571 for location in location_ids:579 for location in location_ids:
572 new_lot_context = lot_context.copy()580 new_lot_context = lot_context.copy()
573 new_lot_context.update({'location': location, 'compute_child': False})581 new_lot_context.update({'location': location, 'compute_child': False})
574582
=== modified file 'bin/addons/procurement_cycle/replenishment.py'
--- bin/addons/procurement_cycle/replenishment.py 2021-08-26 07:25:26 +0000
+++ bin/addons/procurement_cycle/replenishment.py 2021-10-04 08:49:54 +0000
@@ -1220,7 +1220,7 @@
1220 )1220 )
1221 pipe_data = {}1221 pipe_data = {}
1222 for x in cr.fetchall():1222 for x in cr.fetchall():
1223 pipe_data[datetime.strptime('%s 23:59:59' % (x[0].split(' ')[0], ), '%Y-%m-%d %H:%M:%S')] = x[1]1223 pipe_data[datetime.strptime('%s 00:00:00' % (x[0].split(' ')[0], ), '%Y-%m-%d %H:%M:%S')] = x[1]
12241224
1225 pipe_date = sorted(pipe_data.keys())1225 pipe_date = sorted(pipe_data.keys())
12261226
@@ -1272,21 +1272,21 @@
1272 period_conso = month*num_fmc1272 period_conso = month*num_fmc
1273 if period_conso <= pas_full:1273 if period_conso <= pas_full:
1274 pas_full -= period_conso1274 pas_full -= period_conso
1275 else:
1276 # missing stock to cover the full period
1277 for x in pipe_date[:]:1275 for x in pipe_date[:]:
1278 # add pipe before period1276 # add pipe before end of period
1279 if x <= begin:1277 if x <= end:
1280 pas_full += pipe_data[x]1278 pas_full += pipe_data[x]
1281 pipe_date.pop(0)1279 pipe_date.pop(0)
1282 else:1280 else:
1283 break1281 break
1282 else:
1283 # missing stock to cover the full period
1284 if period_conso > pas_full:1284 if period_conso > pas_full:
1285 # still not enough stock1285 # still not enough stock
1286 for x in pipe_date[:]:1286 for x in pipe_date[:]:
1287 if x <= end:1287 if x <= end:
1288 # compute missing just before the next pipe1288 # compute missing just before the next pipe
1289 ndays = (x - new_begin).days + 11289 ndays = (x - new_begin).days
1290 qty = num_fmc/30.44*ndays1290 qty = num_fmc/30.44*ndays
1291 pas_full -= qty1291 pas_full -= qty
1292 if pas_full < 0:1292 if pas_full < 0:

Subscribers

People subscribed via source and target branches