Hello ! please can someone tell me how to create a new row in a table and fill it with the computed fields
class ProductImpo(models.Model):
_name = 'product.impo'
id = fields.Integer(string="ID", compute='_compute_id',Store=True)
Serial_No = fields.Char(string="N° de série", compute='_compute_serial_no')
@api.multi
def _compute_id(self):
i=0
for record in self:
i=i+1
record.id=i
@api.multi
def _compute_serial_no(self):
i=-1
for record in self:
i=i+1
record.Serial_No=result.Stock_Vehicule[i].Serial_No
Should I use :
product_impo = self.env['product.impo']
product_impo.sudo().write({'id':self.id, 'Serial_No': self.Serial_No })
If yes so where I must put it ??
PS: The table product_impo in PostgreSQL is empty that's why when I display the tree view I obtain it empty so how to create a new row in the table ?