Here is my code
@api.multi
def button_plan(self):
quantity = []
res = super(MrpProduction, self).button_plan()
for production in self:
planned_date = fields.Datetime.from_string(self.date_planned_start)
production_values = {'date_planned_start_wo': False,
'date_planned_finished_wo': False,
'quantity': 0}
values = {}
print quantity
for workorder in production.workorder_ids:
date_start = planned_date
date_end = date_start + timedelta(minutes=workorder.duration_expected)
values['date_planned_start'] = fields.Datetime.to_string(date_start)
values['date_planned_finished'] = fields.Datetime.to_string(date_end)
values['quantity'] = fields.Float(quantity)
for operation in self.routing_id.operation_ids:
if operation.compute_equals_order_qty == True:
quantity = self.product_qty
print 'quantity', quantity
if operation.compute_equals_always_one == True:
quantity = 1.0
print 'quantity', quantity
if operation.compute_equals_workcenter == True:
quantity = operation.workcenter_quantity
print 'quantity', quantity
workorder.qty_workorder = quantity
print 'workorder.qty_workorder ::::',workorder.qty_workorder
workorder.write(values)
production_values['date_planned_finished_wo'] = fields.Datetime.to_string(planned_date)
production.write(production_values)
# production.write(values)
return res
The terminal output is
quantity 1.0
quantity 35.0
quantity 56.0
workorder.qty_workorder :::: 56.0
2018-01-11 09:37:55,163 15380 WARNING odoo10 odoo.models: mrp.workorder.write() with unknown fields: quantity
quantity 1.0
quantity 35.0
quantity 56.0
workorder.qty_workorder :::: 56.0
2018-01-11 09:37:55,174 15380 WARNING odoo10 odoo.models: mrp.workorder.write() with unknown fields: quantity
quantity 1.0
quantity 35.0
quantity 56.0
workorder.qty_workorder :::: 56.0
Right output is:
workorder.qty_workorder is 1, 35, 56
Your code is not properly structured, it is difficult to understand.
Sorry, now understanding ?