Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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')])
- # for production in production_ids:
- for production in records:
- bom = production.bom_id
- operations = bom.routing_id.operation_ids
- workorders = production.workorder_ids
- for wo in workorders:
- wo_name = ' - %s' % wo.product_id.name
- wo_name = wo.name.replace(wo_name, '')
- # operation = operations.filtered(lambda op: op.name == wo_name)
- # if operation:
- # cycle_number = production.product_qty / operation.workcenter_id.capacity
- # duration_expected = (operation.workcenter_id.time_start + operation.workcenter_id.time_stop + cycle_number * operation.time_cycle * 100.0 / operation.workcenter_id.time_efficiency)
- # wo.write({'operation_id': operation[0].id})
- env.cr.execute('''
- UPDATE
- mrp_workorder as wo
- SET
- operation_id = mrw.id,
- duration_expected = (mw.time_start + mw.time_stop + (mp.product_qty / mw.capacity) * mrw.time_cycle_manual * 100.0 / mw.time_efficiency)
- FROM
- mrp_production as mp
- INNER JOIN
- mrp_routing_workcenter as mrw
- ON
- mp.routing_id = mrw.routing_id
- AND
- mp.id = %d
- AND
- mrw.name = '%s'
- INNER JOIN
- mrp_workcenter as mw
- ON
- mw.id = mrw.workcenter_id
- WHERE
- wo.id = %d
- AND
- wo.production_id = mp.id
- ;''' % (production.id, wo_name, wo.id))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement