This question has been flagged
2404 Views

I got some issue that lot_name is not showing same value from another compute field in same recordset, stock.move.line. below is my code:

class StockMoveLine(models.Model):
_name = 'stock.move.line'
_inherit = 'stock.move.line'

lotter = fields.Char(string="Supplier Lot", compute='_compute_partner')

def _compute_partner(self):
    
    if not self.lotter:
        partner_id = self.env['stock.picking'].search([('name','=',self.reference)]).partner_id.id    
        self.lotter = str(partner_id) 
       
    if self.lot_name == "":
        self.lot_name = self.lotter
    else:
        self.lot_name = "blank"

I got some issue that lot_name is not showing same value from another compute field in same recordset, stock.move.line. below is my code:

class StockMoveLine(models.Model):
_name = 'stock.move.line'
_inherit = 'stock.move.line'

lotter = fields.Char(string="Supplier Lot", compute='_compute_partner')

def _compute_partner(self):
    
    if not self.lotter:
        partner_id = self.env['stock.picking'].search([('name','=',self.reference)]).partner_id.id    
        self.lotter = str(partner_id) 
       
    if self.lot_name == "":
        self.lot_name = self.lotter
    else:
        self.lot_name = "blank"

the lot_name had been already existed in base module field. So I would like to show partner_id in lot_name field as well. now I only see it in my new compute fieldl. I tried using @api.onchange but it is only work when the textfield of lotter is lost focus. how can I do to show the same value on both lotter and lot_name fields if there is no value earlier?

Avatar
Discard