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

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.
아바타
취소
관련 게시물 답글 화면 활동
1
3월 16
5915
Download Odoo 8 해결 완료
1
5월 22
25617
1
5월 21
4112
4
10월 19
9912
1
1월 18
9284