Odoo Help

Welcome!

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

0

Why my bidirectional many2many is not showing data?

By
Stefan Reisich
on 1/15/14, 8:40 AM 2,685 views

I'm having a problem with many2many fields. Creating a dhl label with relation to stock_picking_out is no problem. Everything works. But when I go to delivery orders the "dhl_label" field shows me an empty list. Here the code:

class dhl_label(osv.osv):
    _name = 'dhl.label'

    _columns = {
        'stock_picking_out': fields.many2many('stock.picking.out', 'dhl_label_stock_picking_out_rel', 'dhl_label_id', 'stock_picking_out_id'),

class stock_picking_out(osv.osv):
    _inherit = 'stock.picking.out'

    _columns = {
        'dhl_label': fields.many2many('dhl.label', 'dhl_label_stock_picking_out_rel', 'stock_picking_out_id', 'dhl_label_id'),

<record id="view_dhl_label_form" model="ir.ui.view">
            <field name="name">dhl.label.form</field>
            <field name="model">dhl.label</field>
            <field name="arch" type="xml">
                <form string="DHL Label" version="7.0">
                    <sheet>
                        <group>
                            <group>
                                <field name="stock_picking_out" widget="many2many_tags"/>
                            </group>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

<record id="nfx_dhl_view_picking_out_form" model="ir.ui.view">
            <field name="name">nfx.dhl.stock.picking.out.form</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <data>

                    <notebook position="inside">
                        <page string="DHL Label">
                            <field name="dhl_label" select="1"/>
                        </page>
                    </notebook>

                </data>
            </field>
        </record>
0

Stefan Reisich

--Stefan Reisich--
831
| 7 7 8
Pfungstadt, Germany
--Stefan Reisich--
Stefan Reisich
On 1/17/14, 9:16 AM

I got the answer from the openerp support. Because stock_picking_out is not physical we must do it this way:

class stock_picking_out(osv.osv):
    _name = 'stock.picking.out'
    _inherit = 'stock.picking'
    _table = 'stock.picking'

Then everythin works...

2
Soohoo
On 1/17/14, 1:43 AM

Hi Stefan The working copy is below,, just copy and see if it works for let me know if you need any help it will create a menu like dev under that you add same dhl label and in warehouse delivery orders it is accessible while creating and editing .

Thanks

Py File

import logging
from osv import fields,osv
_logger = logging.getLogger(__name__)

class dhl_label(osv.osv):
    _name = 'dhl.label'

    _columns = {
        'name': fields.char('dhl Label', size=32),
        'stock_picking_out': fields.many2many('stock.picking.out', 'dhl_label_stock_picking_out_rel', 'dhl_label_id',
                                              'stock_picking_out_id','Stocking Picking Out'),

    }

#dev_person()

class stock_picking_out(osv.osv):
    _inherit = 'stock.picking.out'

    _columns = {
        'dhl_label': fields.many2many('dhl.label', 'dhl_label_stock_picking_out_rel', 'stock_picking_out_id',
                                      'dhl_label_id','SPO Dhl Label'),

    }

View File

<?xml version="1.0"?>
<openerp>
<data>
    <record id="view_dhl_label_form" model="ir.ui.view">
            <field name="name">dhl.label.form</field>
            <field name="model">dhl.label</field>
            <field name="arch" type="xml">
                <field name="name"/>
                <form string="DHL Label" version="7.0">
                    <sheet>
                        <group>
                            <group>
                                <field name="stock_picking_out" widget="many2many_tags"/>
                            </group>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

    <record model="ir.ui.view" id="view_person_tree">
        <field name="name">dhl.label.tree</field>
        <field name="model">dhl.label</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="dev.person">
                <field name="name"/>
                <field name="stock_picking_out"/>
            </tree>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_dhl_label">
        <field name="name">dhl.label</field>
        <field name="res_model">dhl.label</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>


<!--<menuitem id="menu_item_abi_notes" parent="menu_section_ramport" name="Abi Results" action="action_abi_results" />-->
<menuitem id="dev_menu" name="dev" />
 <menuitem id="menu_section_test" parent="dev_menu" name="Test" />
<menuitem id="menu_person" parent="menu_section_test" name="DHL Label" action="action_dhl_label" />
<!--<menuitem id="menu_prop" parent="dev_menu" name="prop" action="action_property" />-->

    <record id="nfx_dhl_view_picking_out_form" model="ir.ui.view">
            <field name="name">nfx.dhl.stock.picking.out.form</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <data>

                    <notebook position="inside">
                        <page string="DHL Label">
                            <field name="dhl_label" select="1"/>
                            <field name="origin" select="1"/>
                        </page>
                    </notebook>

                </data>
            </field>
        </record>

    <record model="ir.ui.view" id="view_property_tree">
        <field name="name">stock.picking.out</field>
        <field name="model">stock.picking.out</field>
        <field name="inherit_id" ref="stock.view_picking_out_tree"/>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <field name="name" position="after">
                <field name="dhl_label"/>
            </field>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_stock_picking_out_1">
        <field name="name">stock.picking.out</field>
        <field name="res_model">stock.picking.out</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>
<menuitem id="menu_prop" parent="menu_section_test" name="Stock picking out" action="action_stock_picking_out_1" />

</data>

</openerp>

i'm sorry but nothing have changed. when i go to the delivery order i cannot see the dhl label. the many2many list is empty.

Stefan Reisich
on 1/17/14, 5:06 AM

have to created any dhl label

Soohoo
on 1/17/14, 6:18 AM

yes, of course i have created one, but it doesn't appears in delivery orders.

Stefan Reisich
on 1/17/14, 6:40 AM

I got it. Thank you for your help!

Stefan Reisich
on 1/17/14, 9:17 AM

Hi stefan ! can you give me a example of load/save my own config

http://help.openerp.com/question/30123/how-can-i-saveload-my-own-configurationsettings/

This one is not working

please please give one live example

Soohoo
on 1/20/14, 2:11 AM

hi Soohoo, i decided to use the system parameters from openerp to save all my configurations. you need to activate the technical view for your user and then you can go to settings -> parameters -> system parameters. there i added new values like my_module.my_setting_key. you will get this value with self.pool.get('ir.config_parameter').get_param(cr, uid, 'my_module.my_setting_key'). don't forget to eval the values, they are always saved as string...

Stefan Reisich
on 1/20/14, 5:02 AM

can't we do it from code ??

Soohoo
on 1/20/14, 6:05 AM

I'm not doing this by code, but i think you can write to the ir.config_parameter model: self.pool.get('ir.config_parameter').create(cr, uid, {'key': 'your_key', 'value': 'your_value'})...

Stefan Reisich
on 1/20/14, 6:35 AM

but i wanted to know how the other module like account and stock using it

Soohoo
on 1/20/14, 6:50 AM

i'm sorry but i don't understand. as i wrote you can read the values with self.pool.get('ir.config_parameter').get_param(cr, uid, 'my_setting_key'). that's the way i'm saving/loading my configuration at the moment...

Stefan Reisich
on 1/20/14, 7:00 AM

so from the front end how can we create a form so that it can be changed , for multiple values

Soohoo
on 1/20/14, 7:04 AM

i don't know...

Stefan Reisich
on 1/20/14, 9:10 AM

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 1/15/14, 8:40 AM
Seen: 2685 times
Last updated: 3/16/15, 8:10 AM