콘텐츠로 건너뛰기
메뉴
신고된 질문입니다
1 회신
1072 화면

so i have a field named "delay_id" in purchase order line and the field is editable and the value cannot surpass field value "delay" in product supplier info, i tried this code

@api.constrains('delay_id')    

    def_check_delay(self):        

        forrecordinself:            

            dly = self.env['product.supplierinfo'].search([('delay', ',record.delay_id),('id', '=',record.id)])            

        ifdly:                

            raise ValidationError("")

but the value can still surpass the value in product supplier info .

the "delay" field is from another module

아바타
취소
베스트 답변

You need to get the delay for each product in purchase line for the same vendor selected in the PO header and then compare the values. The delay_id should be an integer to compare it with delay from product supplier info.

Please check the below:


@api.constrains('delay_id')
def _check_delay(self):
for record in self:
dly = self.env['product.supplierinfo'].search(
[('name', '=', record.order_id.id), ('product_tmpl_id.id', '=', record.product_id.product_tmpl_id.id)])
if dly:
if record.delay_id > dly.delay:
raise ValidationError("")

아바타
취소