Odoo Help


changing the third field according to the first and second fields.

on 9/3/13, 3:24 AM 1,005 views

i have two tables. "fair.details" and "fare.charge" . In fair.detail table i have three fields from, to ,charge. then in the second table i have three fields.
like this . from: fields.many2one('from'.....), to: fields.many2one('to'.....), charge: fields.function('_change'.....),

                                     How can be fetch the charge from the first table in according to the corresponding 'from' and 'to' values in the first table.

Please provide the corresponding function for this change in the third field.

Abhishek H Menon
On 9/9/13, 10:47 AM
from osv import fields,osv
class name_model(osv.osv):

class first_model(osv.osv):

class second_model(osv.osv):
              'select_cost':fields.integer('Select Cost')}
    def onchange_cost(self,cr,uid,ids,name2,context=None):
        #print "Name 1",name1
        print "Name 2",name2
        return {'value':value}


and xml_code


    <!-- Test model View -->
    <menuitem id="menu_institution_main" name="Institution Management"
    <menuitem id="sample_cost" name="Sample" parent= "menu_institution_main" sequence="1"/>

    <!-- Name : Fee Type : Tree View -->

        <record id="view_cost_tree" model="ir.ui.view">
            <field name="name">first.model</field>
            <field name="model">first.model</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="First model">
                    <field name="name1"/>
                    <field name="name2"/>
                    <field name="cost"/>

        <!-- Name : Fee Type : Form View -->

        <record id="view_cost_form" model="ir.ui.view">
            <field name="name">first.model</field>
            <field name="model">first.model</field>

            <field name="arch" type="xml">
                <form string="First Model" version="7.0">
                        <field name="name1"/>
                        <field name="name2"/>
                        <field name="cost"/>

        <!--Name : Fee Type Action : Action Menu  -->

        <record id="action_cost" model="ir.actions.act_window">
            <field name="name">First Model</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">first.model</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_cost_tree"/>

       <menuitem name="Sample Cost" action="action_cost" id="menu_action_cost" parent="sample_cost" sequence="0"/>

the above programs have similar appearance to your model. So try this

Abhishek H Menon
on 9/9/13, 12:00 PM

thanks.. Abhishek

on 9/10/13, 10:27 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 9/3/13, 3:24 AM
Seen: 1005 times
Last updated: 3/16/15, 8:10 AM