Skip to Content
Menu
This question has been flagged
1895 Views

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

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 19
2479
3
Nov 24
26649
1
Aug 24
424
2
Nov 24
761
2
Jan 24
25839