Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Inheritet Model's field can not be changed over method

By
isak
on 4/18/16, 6:15 AM 282 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/18/16, 6:15 AM
Seen: 282 times
Last updated: 4/18/16, 6:56 AM