Skip to Content
Menu
This question has been flagged
2 Replies
3644 Views

I am using V13. I have a parent model called fixed_asset. As children models I have fixed_asset.ups and fixed_asset.camera.

Is it possible to see all of my assets in the same list view using only the fields from the parent model?

I currently have a list view for each, and can see them separately, but I would have expected to see all types of assets in the parent view.

class Fixed_Asset(models.Model):
_name = 'my.fixed_asset'
_description = 'Fixed Asset'
   
    serial_number = fields.Char()
    ...

class UPS(models.Model):
_name = 'my.fixed_asset.ups'
_description = 'UPS'
_inherit = 'my.fixed_asset'

    ups_rate = fields.Float()

class Camera(models.Model):
_name = 'my.fixed_asset.camera'
_description = 'Camera'
_inherit = 'my.fixed_asset'

    resolution = fields.Float()


<!-- Tree/List View -->
<record id="fixed_asset_list_view" model="ir.ui.view">
<field name="name">Fixed Asset List</field>
<field name="model">my.fixed_asset</field>
<field name="arch" type="xml">
<tree string="Fixed Assets" expand="True">
<field name="product_id" optional="show"/>
<field name="serial_number" optional="show"/>
<field name="status" optional="show"/>
<field name="location_id" optional="show"/>
</tree>
</field>
</record>
Avatar
Discard
Author

Please, any help would be appreciated

Author Best Answer

I solved this by using _inherits instead of _inherit. This way a record on the parent model is created every time I create on in a child model.

The plan is to add a button in the parent form view that redirects users to "further details" shown in the children views

Avatar
Discard
Author

My new problem is that, as per ORM documentation, _inherits delegation inheritance doesn't inherit methods, only fields.

This means that my @onchange methods are not inherited naturally, which is a pain but I plan force a new call on the children methods.