Skip to Content
Menu
This question has been flagged
1 Reply
1605 Views

Hello,

I have a student registration form. I want to make a student as Partner. so that we can generate an invoice for him?

How can I do that?

Avatar
Discard
Best Answer

The idea same as the creation of the user, when you create a user the related partner will be created automatically so you can use delegation inheritance as below:

https://github.com/odoo/odoo/blob/11.0/odoo/addons/base/res/res_users.py#L182

See how to use delegation  inheritance:

https://www.odoo.com/documentation/13.0/reference/orm.html#delegation 

modify your student model, when you create a student, a related partner will be create automatically:

class Student(models.Model):
_name = "Your model"
_description = 'Your model name'
_inherits = {'res.partner': 'partner_id'}
partner_id = fields.Many2one('res.partner', required=True, ondelete='restrict', auto_join=True,string='Related Partner', help='Partner-related data of the student')
# overridden inherited fields to bypass access rights, in case you have
        # access to the student but not its corresponding partner
 # Use the pass name and email from student to partner, if there is no email for student you can remove the below line
    name = fields.Char(related='partner_id.name', inherited=True, readonly=False)
    email = fields.Char(related='partner_id.email', inherited=True, readonly=False)

Avatar
Discard