This question has been flagged
2 Replies
775 Views

Hello everyone,

Can someone help me with this:

I'm trying to create a new field in the model repair.order with:

x_entrada_fecha = fields.Date("Fecha de entrada") in the file repair.py from this path /addons/repair/models

then i'm printing the field with the file repair_views.xml in the part of repair.form but when I try to update the model it give me the error that the field x_entrada_fecha do not exist

what am i doing wrong? Do i have to create the field in other file?

Avatar
Discard
Best Answer

Hi,
Make sure to upgrade the app after adding the new field.

Thanks

Avatar
Discard
Best Answer

Hi,

Please Check the Below Answer,

Inherit the repair.order model in your module's Python file and add your custom field to the inherited class.

class RepairOrder(models.Model):
_inherit = 'repair.order'

x_entrada_fecha = fields.Date("Fecha de entrada")

Inherit the existing view of the repair.order form in your module's XML file (e.g., views/repair_views.xml) and add your new field.

<record id="repair_order_form_view_inherit" model="ir.ui.view">
<field name="name">repair.order.form.inherit</field>
<field name="model">repair.order</field>
<field name="inherit_id" ref="repair.repair_order_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='date_planned']" position="after">
<field name="x_entrada_fecha"/>
</xpath>
</field>
</record>





Hope it helps

Avatar
Discard