Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3328 Vizualizări

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.

Imagine profil
Abandonează
Cel mai bun răspuns
from osv import fields,osv
class name_model(osv.osv):
    _name='name.model'
    _columns={
              'name':fields.char('Name',size=32)}
name_model()

class first_model(osv.osv):
    _name='first.model'
    _columns={
              'name1':fields.many2one('name.model','Name1'),
              'name2':fields.many2one('name.model','Name2'),
              'cost':fields.integer('Cost')}
first_model()

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

second_model()

and xml_code

<openerp>
    <data>

    <!-- Test model View -->
    <menuitem id="menu_institution_main" name="Institution Management"
             sequence="3"/>
    <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"/>
                </tree>
            </field>        
        </record>




        <!-- 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">
                    <group>             
                        <field name="name1"/>
                        <field name="name2"/>
                        <field name="cost"/>
                    </group>    
                </form>
            </field>        
        </record>

        <!--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"/>
        </record>


       <menuitem name="Sample Cost" action="action_cost" id="menu_action_cost" parent="sample_cost" sequence="0"/>
    </data>
</openerp>
Imagine profil
Abandonează

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

Autor

thanks.. Abhishek