Odoo Help


how send default value for field from view to other view

on 8/19/14, 10:47 AM 4,235 views

hi  thank you in advance for any help or comments 

i need to create one2one relation in openerp7 i read many articles about this idea and i could to type  the following code 

problem is : that openerp7  doesnot send value from parent view (calculation)to child (container) 

this my code 

testproject.py :

from osv import fields,osv
class container(osv.osv):
        'calculation_id': fields.many2one('calculation','Calculation'),
        'name': fields.char('Name', size=32),
class calculation(osv.osv):
        'container_id': fields.many2one('container','Container'),
        'namefull': fields.char('Name Full', size=32),

xml code:

<?xml version="1.0"?>

    <record model="ir.ui.view" id="view_container_form">
        <field name="name">container.form</field>
        <field name="model">container</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Container">
                <field name="name" select="1"/>
                <field name="calculation_id" context="{'default_container_id': active_id}"  />

    <record model="ir.actions.act_window" id="action_container">
        <field name="name">Container</field>
        <field name="res_model">container</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    <menuitem name="Container/Container" id="menu_container"/>-->
    <menuitem name="Container" id="menu_container_item" parent="menu_container" action="action_container"/>
    <record model="ir.ui.view" id="view_calculation_form">
        <field name="name">calculation.form</field>
        <field name="model">calculation</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Calculation">
                <field name="namefull" />
                <field name="container_id" />

    <record model="ir.actions.act_window" id="action_calculation">
        <field name="name">Calculation</field>
        <field name="res_model">calculation</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>

<menuitem name="Calculation" id="menu_calculation_item" parent="menu_container" action="action_calculation"/>




On 8/20/14, 3:37 AM

thank you klacus ..

active_id  is kewword or refer to current record  in other words it is mean id  and id is define  automatically .

furthermore in file sale_view.xml there is code that contains active_id field:

            context="{'search_default_product_id': active_id, 'default_product_id': active_id}"
            name="Sales Order Lines"

and i tried to send any value for example (4)  and  value did not send as following   :

<field name="calculation_id" context="{'default_container_id': 4}"  />


On 8/19/14, 12:02 PM


          <field name="calculation_id" context="{'default_container_id': active_id}"  />
where is this filed def? >> active_id?

If you want to send something in the context, you must define it somwhere (I use it in test with sending value, and use invivible="1" attrs. at final )

so, you can check it in src like sale_view.xml

context="{'partner_id':partner_id, 'contact_id':partner_order_id, 'pricelist_id':pricelist_id, 'default_name':name}"

example the partner_order_id is a field of sale_order like the other items too, you can find it in sale.py >> sale_order columns area.

May your trouble is the lack of the active_id in container object.

I think mutch better if you try to make a simple sketch about your wants, and you can plan the join according your plan.

Hope this is help to you.



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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

1 follower(s)


Asked: 8/19/14, 10:47 AM
Seen: 4235 times
Last updated: 3/16/15, 8:10 AM