I'm creating a new record in "stock.picking" model , in order field has "onchange logic".
If order selected then it will add order lines in 'stock.move' upto this working good.
My problem is when am saving a record in 'stock.picking' , getting error
Following fields invalid: "Stock Moves"
My Code:
@api.onchange('po_id')
def onchange_po_id(self):
print self.id
if self.po_id:
pur_line = self.env['purchase.order.line'].search(
[('order_id', '=', self.po_id.id)])
move_lines = []
for line in pur_line:
date_planned = datetime.today().strftime(
DEFAULT_SERVER_DATETIME_FORMAT)
move_line = {
'name': line.product_id.name,
'price_unit': line.price_unit,
'product_uom': line.product_uom.id,
'product_uom_qty': line.product_qty,
'product_qty': line.product_qty,
'date': date_planned,
'date_expected': date_planned,
'product_id': line.product_id.id,
'state': 'draft',
'origin': line.order_id.name,
'location_id': line.product_id.property_stock_production.id,
'location_dest_id': self.location_dest_id.id,
}
move_lines += [(0, 0, move_line)]
self.move_lines = move_lines
please anyone help us to resolve this issue.