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

I am trying to override the create() function of mrp.bom and in it i will change the value if a field in product.template , but when i press 'save' i face that error :

res = super(bom_override, self).create(vals)
TypeError: super(type, obj): obj must be an instance or subtype of type

i searched for the reason and every reason i found i checked my code for it and nothing to slove 
i hope that anyone can help me with that.

 here is my code:

class bom_override(models.Model):
    _name = 'mrp.bom'
    _inherit = 'mrp.bom'
   
    @api.model
    def create(self, vals):
        product_obj = self.env['product.template'].search([('id','=',vals['product_id'])])
        product_obj.write({'has_bom':True})
        res = super(bom_override, self).create(vals)
        return res

Thanks in advance ..,

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

i found the problem in the code 
someone was duplicating the class name in the same file

อวตาร
ละทิ้ง

Ashraf Hesham
I got the same problem cause I copy it and it has the same name

Thanks for your help :)

คำตอบที่ดีที่สุด
Remove the " _name = 'mrp.bom' " from class. Because you are inheriting an existing class and should not use it.
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 16
5884
Download Odoo 8 แก้ไขแล้ว
1
พ.ค. 22
25567
1
พ.ค. 21
4064
4
ต.ค. 19
9864
How to multiply sequence by non-int แก้ไขแล้ว
1
ม.ค. 18
9224