Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Why my bidirectional many2many is not showing data?

Subscribe

Get notified when there's activity on this post

This question has been flagged
inheritancerelationshipmany2many
2 Replies
12651 Views
Avatar
Stefan Reisich

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
Avatar
Discard
Avatar
Stefan Reisich
Author Best Answer

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

0
Avatar
Discard
Avatar
Soohoo
Best Answer

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>
2
Avatar
Discard
Stefan Reisich
Author

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.

Soohoo

have to created any dhl label

Stefan Reisich
Author

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

Stefan Reisich
Author

I got it. Thank you for your help!

Soohoo

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

Stefan Reisich
Author

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

Soohoo

can't we do it from code ??

Stefan Reisich
Author

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'})...

Soohoo

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

Stefan Reisich
Author

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

Soohoo

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

Stefan Reisich
Author

i don't know...

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Error with inheritance odoo v16
inheritance relationship
Avatar
1
Jan 23
2467
many2many relation with attributes Solved
relationship many2many attribute
Avatar
Avatar
Avatar
2
Dec 23
25176
How to get Value for Relation table in odoo 10 Solved
relationship many2many odoo10
Avatar
Avatar
2
Jun 17
7130
Many2many relation on the same model does not work Solved
fields relationship many2many model
Avatar
Avatar
3
Jun 18
15810
Allowing groups to only edit relationship fields in a model
security relationship many2many groups
Avatar
0
Oct 16
3363
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now