跳至内容
菜单
此问题已终结
3475 查看

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?

形象
丢弃
相关帖文 回复 查看 活动
1
6月 24
2252
0
11月 23
1870
1
6月 19
2666
0
4月 23
2564
1
3月 23
1986