Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
1740 Tampilan

I've defined a new model that inherits from product_template. 

classTire(models.Model):
    _name="product.tire"
    _inherits={"product.template":"product_template_id"}

    product_template_id= fields.Many2one(
        "product.template",
        string="Related_product_id",
        auto_join=True,
        index=True,
        ondelete="cascade",
        required=True,
    )
    ...

I've also defined a view that extends the default product_template form.

<record id="product_tire_form"model="ir.ui.view">
    <field name="name">product.product.formfield>
    <field name="model">product.tirefield>
    <field name="mode">primaryfield>
    <field name="inherit_id"ref="product.product_template_form_view"/>
    <field name="arch"type="xml">
        <form position="attributes">
            <attribute name="string">Testattribute>
        form>
    field>
record>


I'm getting the following error when upgrading the module "action_open_label_layout is not a valid action on product.tire"

This is on Odoo v16. Anyone encounter this an have a solution?

Avatar
Buang
Jawaban Terbai

When you use  Delegation Inheritance, only the fields will be inherited but for the methods you need to redefine them in you new model. 

The error showing that the method named 'action_open_label_layout' (used to print label) is not defined in your new model as its used in the product_template_form_view view.

You can find the method code in product.product and product.template below:

action_open_label_layout method for product.product

action_open_label_layout method for product.template

Avatar
Buang