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

Hi dear odooers,

Is it possible to inherit data file and modify it in odoo? 

For example: 


<record id="product_order_01" model="product.product">
<field name="name">Office Design Software</field>
<field name="categ_id" ref="product_category_4"/>
<field name="standard_price">235.0</field>
<field name="list_price">280.0</field>
<field name="detailed_type">consu</field>
<field name="weight">0.01</field>
<field name="uom_id" ref="uom.product_uom_unit"/>
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="default_code">FURN_9999</field>
<field name="image_1920" type="base64" file="product/static/img/product_product_43-image.jpg"/>
</record>


This is a record in data file of product, I want to access that through code and modify it. What is the best possible way?

Avatar
Discard
Best Answer


Hello Michelangelo,


You can modify/update this XML record in two ways:



1. From XML:




<record id="module_name.product_order_01" model="product.product">
<field name="weight">1111</field>
<field name="new_field">new value</field>
</record>



2. From Python:




record = self.env.ref('module_name.product_order_01')
record.weight = 1111 // to update the record
record.new_field = 3 // if 'new_field' is added in the module



I hope this helps! If you have any further questions, feel free to ask.



Best regards,


Thanks & Regards, 

 

Brain Station 23 Ltd. 

Mobile: (+880) 1404055226 

Email: sales@brainstation-23.com 

Web: https://brainstation-23.com/ 

Address: (Building-1) 8th Floor, 2 Bir Uttam AK Khandakar Road, Mohakhali C/A, Dhaka 1212, Bangladesh 





Avatar
Discard
Best Answer

Hi,

it is possible to inherit a data file and manipulate it.

For that you can use,

self.env.ref('module_name.record_id')

to get the record and update the values.

Regards

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 24
3305
5
Mar 25
4967
2
Apr 24
1374
1
Mar 24
741
2
Mar 24
1029