跳至內容
選單
此問題已被標幟
5 回覆
6612 瀏覽次數

i want to add a filed in the form view of res_config_settings_view_form (pricisly right after po_order_approval field) i trid this code on the xml field 

 <record id="view_res_config_tech_inherit" model="ir.ui.view">
<field name="name">tech.config.form.inherit</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@class='app_settings_block']" position="before">
<div class="row mt16">
<field name="first_ki"/>
</div>
        </xpath>
</field>
</record>


and on my .py file 

 
class purchase(models.TransientModel):
_inherit = "res.config.settings"

first_ki = fields.Monetary('Ki')


but i stiil can't displaying the field

頭像
捨棄
作者

thanks for replay @Arun but the field still dosent shows up

作者

thanks @Paresh, but it seems that i was trigering on the rong external_id, i change

<field name="inherit_id" ref="purchase.res_config_settings_view_form_purchase"/>

and it works now

最佳答案

Try changing the name of the class to ResConfigSettings and add the get_values and set_values methods to the class, as required.

Here's an example:

https://github.com/odoo/odoo/blob/13.0/addons/hr_expense/models/res_config_settings.py#L6

頭像
捨棄
最佳答案

res.config.settings to add field and save data. Required to set and get value or default method value pass. Based on odoo version will vary. See the below link.

https://www.odoo.com/forum/help-1/question/problems-on-saving-data-to-res-config-settings-in-odoo-12-153308

https://odoo-development.readthedocs.io/en/latest/dev/py/res.config.settings.html

頭像
捨棄
最佳答案

I believe you'd need to add the "action_window" that set's up your module as the context and link's it to your view. Something like this...

     <record id="custom_purchase_module_settings_action" model="ir.actions.act_window">

        <field name="name">Settings</field>

        <field name="type">ir.actions.act_window</field>

        <field name="res_model">res.config.settings</field>

        <field name="view_id" ref="view_res_config_tech_inherit"/>

        <field name="view_mode">form</field>

        <field name="target">inline</field>

        <field name="context">{'module' : 'my_custom_purchase_module'}</field>

    </record>

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
7月 25
2726
0
5月 23
2420
3
3月 25
24329
1
11月 22
2353
1
5月 22
5840