コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
3960 ビュー

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?

アバター
破棄
最善の回答


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 





アバター
破棄
最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
1
11月 24
3385
5
3月 25
5027
2
4月 24
1450
1
3月 24
750
2
3月 24
1071