I inherit the model stock.move and add serial_no in move lines.That field is readonly
class StockMove(models.Model):
_inherit = "stock.move"
serial_no = fields.Char(string="Serial#",readonly=True)
I use the onchange function to pass value from product
function
@api.onchange('product_id')
def on_change_product(self):
self.serial_no = self.product_id.serial_no
I override the create function to write that value
create function
@api.model
def create(self, vals):
product_obj = self.env['product.product']
product_records = product_obj.search([])
for record in product_records:
self.serial_no = record.serial_no
res = super(StockMove, self).create(vals)
return res
notes
When i save the record then there is an error occured like this
raise ValueError("Expected singleton: %s" % self) ValueError: Expected singleton: stock.move()
How to solve this issue ?