Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
15970 Weergaven

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):
    _name='container'
    _columns={
        'calculation_id': fields.many2one('calculation','Calculation'),
        'name': fields.char('Name', size=32),
        }
container()
class calculation(osv.osv):
    _name='calculation'
    _columns={
        'container_id': fields.many2one('container','Container'),
        'namefull': fields.char('Name Full', size=32),
        }
calculation()

xml code:

<?xml version="1.0"?>
<openerp>
<data>

    <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}"  />


            </form>
        </field>
    </record>
    
   
    
    <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>
    </record>
    
    <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" />


            </form>
        </field>
    </record>
    
   
    
    <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>
    </record>

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

</data>
</openerp>

 

 

Avatar
Annuleer
Beste antwoord

Hi.

          <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.

B.R.

L.

Avatar
Annuleer
Auteur Beste antwoord

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:

 <act_window
            context="{'search_default_product_id': active_id, 'default_product_id': active_id}"
            id="action_order_line_product_tree"
            name="Sales Order Lines"
            res_model="sale.order.line"
            src_model="product.product"
            groups="base.group_sale_salesman"/>

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}"  />

 

Avatar
Annuleer