Skip to Content
Menu
This question has been flagged
4 Replies
4507 Views

How To Inherit And Add Field which has computed function to Existing Views and get input In Odoo

Avatar
Discard
i have seen it. but i want to add field a which has compute function.
deduct_leave_value = fields.Float(string='Deduct Leave (Day)', compute='_compute_deduct_leave', store=True)

I want to add this field 

On Tue, 3 Mar 2020 at 13:14, Kanakinfosystems <forum@kanakinfosystems.com> wrote:

A new answer on How To Inherit And Add Field which has computed function has been posted. Click here to access the post :

See post

Sent by Odoo S.A. using Odoo.



--
Best Regards

Shoaib Ahmed

Software Engineer
CloudCreative Limited
Email: shoaib@cloudcreative.tech
Skype: live:shoaib_ahmed_1994
Phone: +8801677289689


Web: www.cloudcreative.tech

Inheritance in model and views: https://goo.gl/4Zyc9d

Best Answer
deduct_leave_value = fields.Float(string='Deduct Leave (Day)', compute='_compute_deduct_leave', store=True)
write a compute function for it with 'compute deduct leave' name. After that go to your xml file and add
<record id = "Your custom id" model="ir.ui.view">
<field name="name">your custom name</field>
<field name="model">model name</field>
<field name="inherit_id" ref="your form external id"/>
<xpath expr="//field[@name='field_name']" position="after">
<field name="deduct_leave_value"/>
</xpath>
</field>
</record>
 In this code you are using xpath to go into the required form grab a field and put your own field before , after or in replacement to that.
Avatar
Discard