Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3915 Представления

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?

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
июн. 24
2659
0
нояб. 23
2330
1
июн. 19
2936
0
апр. 23
2940
1
мар. 23
2292