Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3712 มุมมอง

Been stuck on this for half an hour. I just dont see where i am wrong


classProductProduct(models.Model):
    _inherit = "product.product"

    product_website_document_ids = fields.One2many('documents.document', string='Variant website documents', compute='_compute_product_document_ids')

    def_compute_product_document_ids(self):
        product_website_tag = self.env.user.company_id.product_document_website_tag
        product_documents = self.env['documents.document'].search([('res_model', '=', self._name), ('res_id', '=', self.id), ('type', '=', 'binary'), ]).filtered(lambdadoc: product_website_tag in doc.tag_ids)
        product_template_documents = self.env['documents.document'].search([('res_model', '=', self.product_tmpl_id._name), ('res_id', '=', self.product_tmpl_id.id), ('type', '=', 'binary'), ]).filtered(lambdadoc: product_website_tag in doc.tag_ids)        all_docs = product_documents | product_template_documents
        self.product_website_document_ids = all_docs

when adding this field in a template, i get


ValueError: Compute method failed to assign product.product(35,).product_website_document_ids


The thing is ... when debugging, it just does not even enter the

def_compute_product_document_ids method ...

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Ok i found the issue ... the def_compute_product_document_ids method was already defined in an another class in the inheritence tree, so that other method was called instead of this one.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ต.ค. 25
2885
1
ก.ย. 25
2875
3
ก.ค. 25
4212
1
พ.ค. 25
2304
4
พ.ค. 25
3670