Skip to Content
Menu
This question has been flagged
3034 Views

I want to inherit complete model into another model. How can inherit?

I have to models. Model1, Model2

In Model1 there are many fields & buttons present. Can i call all the fields & buttons in Model2?

In Model2 also have its own fields.

Avatar
Discard

Why not just copy and past the second module in the first one if you just need the functions inside one module alternatively you can use the relation function. So anything in one module will also go to the appropriate field in the other. You can see how address works with Partner for example.

Or else you can inherit both themodel and your view as per your requirements, so that suppose if you wish to add some fields along with the old fields only after inheritance is possible. Thank you!

Author

I just want to add the whole model in my second model. So how can i add, python code & xml code.

What you can do is copy the first python file into the folder of the second module and then add copy the xml code of the first into the code of the second but you will have to change model name to the second or you can simply insert the ids of the models from first module inbetween those of the second. then add the first into the __init__ code of the second module as well i.e import first_module. You will need to be careful that no module depends on the first xml for display. If they are both your custom modules that are only associated with each other you should have no problem