我创建了一个模块,我在res.partner模型和res.user模型上覆盖了create方法:
class Partner(models.Model):
_inherit = 'res.partner'
is_commercial = fields.Boolean(string= 'is Commercial')
class User(models.Model):
_inherit = 'res.users'
is_commercial = fields.Boolean(string= 'is Commercial')
@api.model
def create(self, vals):
user = super(User, self).create(vals)
user.partner_id.active = user.active
user.partner_id.is_commercial = user.is_commercial
if user.partner_id.company_id:
user.partner_id.write({'company_id': user.company_id.id})
return user
@api.multi
@api.onchange('is_commercial')
def onchange_is_commercial(self):
for partner in self.partner_id:
if self.is_commercial == True:
partner.write({'is_commercial': True})
else:
if self.is_commercial == False:
partner.write({'is_commercial': False})
此代码运行良好,现在我卸载了此模块并返回销售 - >顾客。我收到了这个错误:
File "D:\Projet\erp\odoo\osv\expression.py", line 821, in parse
raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf)))
ValueError: Invalid field u'is_commercial' in leaf "<osv.ExtendedLeaf: (u'is_commercial', u'=', True) on res_partner (ctx: )>"
我正在使用odoo10,postgresql-9.5