In the folloing code i extend the model partnet in my custommodule. I want to set sequence number for the new field "kundennummer" on a partner. But in the vals of the model partner you can't find the new field "kundennummer", so the method create doesn't work! What should i do?
class Partner(models.Model):
#_name='extendedpartner'
_inherit= 'res.partner'
instructor=fields.Boolean("Instructor", default=False)
kundennummer=fields.Char(required=True, copy=False, readonly=True, index=True, default=lambda self: _('New'))
session_ids=fields.Many2many('openacademy.session',
string="Attended Sessions", readonly=True)
@api.model
def create(self, vals):
print(self.env['ir.sequence'].next_by_code('code'))
print(vals['function'])
vals['function']=self.env['ir.sequence'].next_by_code('code') or 'New'
if vals.get('kundennummer', 'New') == 'New':
vals['kundennummer'] = self.env['ir.sequence'].next_by_code('code') or 'New'
result = super(res_partner, self).create(vals)
return result