콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4314 화면

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
2874
0
11월 23
2691
1
6월 19
3128
0
4월 23
3196
1
3월 23
2490