SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # production_ids = env['mrp.production'].search([('create_date', '<=', '2019-07-07 00:00:01'), ('state', '=', 'done'), ('write_date', '>=', '2019-07-08 10:00:00'), ('write_date', '<=', '2019-08-07 09:00:00')])
  2. # for production in production_ids:
  3. for production in records:
  4.   bom = production.bom_id
  5.   operations = bom.routing_id.operation_ids
  6.   workorders = production.workorder_ids
  7.   for wo in workorders:
  8.     wo_name = ' - %s' % wo.product_id.name
  9.     wo_name = wo.name.replace(wo_name, '')
  10.     # operation = operations.filtered(lambda op: op.name == wo_name)
  11.     # if operation:
  12.       # cycle_number = production.product_qty / operation.workcenter_id.capacity
  13.       # duration_expected = (operation.workcenter_id.time_start + operation.workcenter_id.time_stop + cycle_number * operation.time_cycle * 100.0 / operation.workcenter_id.time_efficiency)
  14.       # wo.write({'operation_id': operation[0].id})
  15.     env.cr.execute('''
  16.       UPDATE
  17.         mrp_workorder as wo
  18.       SET
  19.         operation_id = mrw.id,
  20.         duration_expected = (mw.time_start + mw.time_stop + (mp.product_qty / mw.capacity) * mrw.time_cycle_manual * 100.0 / mw.time_efficiency)
  21.       FROM
  22.         mrp_production as mp
  23.       INNER JOIN
  24.         mrp_routing_workcenter as mrw
  25.       ON
  26.         mp.routing_id = mrw.routing_id
  27.       AND
  28.         mp.id = %d
  29.       AND
  30.         mrw.name = '%s'
  31.       INNER JOIN
  32.         mrp_workcenter as mw
  33.       ON
  34.         mw.id = mrw.workcenter_id
  35.       WHERE
  36.         wo.id = %d
  37.       AND
  38.         wo.production_id = mp.id
  39.     ;''' % (production.id, wo_name, wo.id))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top