Reputation: 453
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.
Upvotes: 0
Views: 1350
Reputation: 194
How to override the write method in res.users class: You just need to write this code to override the write method:
class User(models.Model):
_inherit = 'res.users'
@api.multi
def write(self, vals):
res = super(User, self).write(vals)
your code here...
return res
Upvotes: 1
Reputation: 214
When you call write(), try passing any argument or context.
For example:
@api.multi
def action_cancel(self):
res = super(SaleOrder, self).action_cancel()
.
.
your logic
.
.
return res
Upvotes: 0
Reputation: 322
When you call write(), you should pass any argument or context. So you can pass values in write() method. Like below
super(User, self).write(values)
because write() take dictionary type data.
Upvotes: 0
Reputation: 378
You can try this: replace super(User, self).write()
with super(User, self).write(values)
. That should work.
Upvotes: 2