나는사용자 정의 필드를 작성 모드에서 저장할 수없는 이유는 odoo의 쓰기 모드에 저장 되었습니까?
partnumber = fields.Char(
'Part Number', compute='_compute_partnumber',
inverse='_set_partnumber', store=True)
은 내가 성공적으로 추가
@api.depends('product_variant_ids', 'product_variant_ids.partnumber')
def _compute_partnumber(self):
unique_variants = self.filtered(lambda template: len(template.product_variant_ids) == 1)
for template in unique_variants:
template.partnumber = template.product_variant_ids.partnumber
for template in (self - unique_variants):
template.partnumber = ''
@api.one
def _set_partnumber(self):
if len(self.product_variant_ids) == 1:
self.product_variant_ids.partnumber = self.partnumber
내부 참조 코드와 같은 함수를 작성 제품 템플릿 모델의 부품 번호 필드를 추가 이름에 대한 방법보다 사용 제품 form.I에서 부품 번호 취득 (제품 설명에서 부품 번호를 얻으려면)
제 부품 번호는 입니다. 생성 방법은입니다. 필드는 편집 모드에만 저장됩니다.
당신은 product_variants에서 len을 만들었습니까? – dccdany
@dccdany : 의견을 주셔서 감사합니다. 제품 변형의 수표와 길이는 0입니다. 마침내 여기에 설정되지 않을지 이해합니다. – aslamsha22