This question has been flagged
2 Replies
5304 Views

I am considering creating a one2one relationship from partner to another object so that I don't clutter the base partner table with a lot of redundant columns - to create a different type of partner with more attrinbutes.

I realize I need to use the many2one field since one2one is deprecated.

My question lies in the rendering of this data:

  • It seems that I can only represent the related object as a tree view list embedded in the parent object's form .
  • I can't find a way to show a form view directly within the parent object form.

It would be nice to show all this information directly if its just a one2one relationship.

Anyone have a similar situation? Is this where "properties" might be a good solution?

Avatar
Discard
Best Answer

Hello,

You have to inherit your parent object. For example:

  • Take project.task model and you want to have a new model project.task.request, that has all project.task fields and some other

You can define your new model like this:

class project_task_request(osv.Model):

_inherits = {
    'project.task': 'task_id',
}

_name = "project.task.request"
_description = 'Request (Issue)'

_columns = {
    'task_id': fields.many2one('project.task', required=True,
                               string='Related Task', ondelete='cascade',
                               help='Task-related data of the request'),
    #... many other fields ...
}

If you want to have a tree, form, kanban, etc view with all fields, you can create a view on this new object.

You can check inheritance info here:

Avatar
Discard
Author Best Answer

Thanks, I've never seen this syntax?

class project_task_request(osv.Model):

_inherits = {
    'project.task': 'task_id',
}

what is the difference between this and just

_inherits = 'project.task'
Avatar
Discard

this one add field in project_task database table, my proposal add a new table and inherit the first one.

This is another question... I guess you have to create a new one or add comments to comment your original question not add a answer as another question. From the forum rules: Answers should not add or expand questions. Instead either edit the question or add a comment. https://www.odoo.com/forum/help-1/faq