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 is many2many field with readonly=True not saved in database and Is there a way to do this?

By
Mathias Neef
on 11/21/14, 9:40 AM 1,706 views

I have this columns:

_columns = {
    'pos_name': fields.many2one('pos.config', 'Point of Sale', required=True),
    'session_master_ids': fields.many2many('pos.session', 'pos_gta_session_rel', 'export_id', 'session_id', string='POS Sessions', readonly=True),
}

And this function:

    def on_change_pos_name(self, cr, uid, ids, pos_name, context=None):
        val = {}
        if pos_name:
            session_ids = self.pool.get('pos.session').search(cr, uid, [('config_id', '=', pos_name)], context=context)
            val = {
                'session_master_ids': session_ids
            }
        return {'value': val}

I konw that it is not sotred in the database becaus of the parameter "readonly=True". 
It would help me a lot if create="false" delete="false" in tree would work, but it does't.

                                <field name="session_master_ids" widget="many2many">
                                    <tree create="false" delete="false">
                                        <field name="name"/>
                                        <field name="user_id"/>
                                        <field name="state"/>
                                        <field name="create_date"/>
                                        <field name="write_date"/>
                                        <field name="start_at"/>
                                        <field name="stop_at"/>
                                    </tree>
                                </field>

1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 11/21/14, 1:06 PM

Hello Mathias,

 

In this case you need to programatically create the records for many2many fields, keeping the field as readonly.

Go to http://stackoverflow.com/questions/9377402/insert-into-many-to-many-openerp

This is the example where you can get to know how to programatically write the data in many2many fields

Sorry, I can't, need 20 karma for this.

Mathias Neef
on 11/21/14, 1:52 PM
0
Mathias Neef
On 11/22/14, 12:14 AM

Thank you very much, this helped me a lot. I only changed 'session_master_ids': session_ids to 'session_master_ids': [(6, 0, session_ids)] and it works perfectly.

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

1 follower(s)

Stats

Asked: 11/21/14, 9:40 AM
Seen: 1706 times
Last updated: 3/16/15, 8:10 AM