Skip to Content
Menu
This question has been flagged
2 Replies
17842 Views

I want to inherit the res.users class and override her write method, so I wrote this code:

class User(models.Model):
    _inherit = 'res.users'

    is_commercial = fields.Boolean(string= 'is Commercial')

    @api.multi
    def write(self, values):
        super(User, self).write()
        for partner in self.partner_id:
            partner.is_commercial = self.is_commercial

and I created this res.partner class too:

class Partner(models.Model):
    _inherit = 'res.partner'

    is_commercial = fields.Boolean(string= 'is Commercial')

Now when I try to change the is_commercial content it appears this error:

TypeError: write() got an unexpected keyword argument 'context'

It appears to me that there's a syntaxe error in overriding the write method in res.users class.

Can someone help me? Thanks.

Avatar
Discard
Best Answer

Hello,

Try This,

@api.multi
def write(self, values):
res = super(User, self).write(values)
for partner in self.partner_id: partner.is_commercial = self.is_commercial
return res

Thanks

Avatar
Discard
Best Answer

Hello Tessnim,

You are not passing arguments in write method (i.e: 'vals').

Try with following code:

         @api.multi

         def write(self, vals):

            ....

            return super(MyClass, self).write(vals)


Regards,

Mayank Gosai

Avatar
Discard