Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
5 Replies
6611 Tampilan

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

Avatar
Buang
Penulis

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

Penulis

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

Jawaban Terbai

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

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Jawaban Terbai

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>

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Jul 25
2726
0
Mei 23
2420
3
Mar 25
24329
1
Nov 22
2353
1
Mei 22
5840