Odoo Help

3

2
2 Answers
3
Atchuthan India
6/11/13, 7:07 AM
Hi friendz,
     after analysing through various sites, I inferred how to define a many2many relational field like below for the same example:

class notebook(osv.osv):
_name = "notebook"
_columns = {
    'title' : fields.char('Title', size=30, required=True),
    'tag_ids': fields.many2many(
                'hello',
                'notebook_hello_rel',
                'notebook_id',
                'hello_id',
                string="Tags"
                            ),
}
 notebook()

class hello(osv.osv):
_name = 'hello'
_columns = {
        'name':fields.char('Name',size=30),
        'note_ids': fields.many2many(
                            'notebook',
                            'notebook_hello_rel',
                            'hello_id',
                            'notebook_id',
                            string="Notebooks"
                                    ),
                } 
 hello()

In this a relationship table "notebook_hello_rel" is created automatically at the time of module install and the columns in it are "notebook_id", "hello_id".

3
Avatar

ClueLogics Technologies Pvt. Ltd. India

--ClueLogics Technologies Pvt. Ltd.--
6213
| 7 5 10
Delhi NCR, India
--ClueLogics Technologies Pvt. Ltd.--

 ClueLogics Technologies Pvt Ltd is a Software product and services provider. We are positioned to deliver robust, rapid and reliable Information Technology solutions that work. What we succeed upon is Technology and Technical Expertise. The industry review of ClueLogics has been commendable for the past years as most of its business comes from repeat orders by highly satisfied clients.

ClueLogics Technologies Pvt. Ltd. India
6/10/13, 9:54 AM

Hi

class notebook(osv.osv):
_name = "notebook"
_description = "Simple Notebook"
_columns = {
    'title' : fields.char('Title', size=30, required=True),

}

 notebook()

This should like this, no need to add many2many here

class hello(osv.osv):
_name = 'hello'
_columns = {
        'name':fields.char('Name',size=30),
        'note_ids': fields.many2many(
                            'notebook',
                            'relation_table_note_hello',
                            'note_id',
                            'hello_id',
                             string="Notebooks"
                                    ),
                } 
  hello()

hope this will help you :)

Thanks
Sandeep

3 Comments
Atchuthan India
6/10/13, 11:04 AM

if there is no m2m field in notebook, how can it reference the relationship between the 2 tables in DB

ClueLogics Technologies Pvt. Ltd. India
6/10/13, 11:09 AM

no need add it in notebook the relation is made on the given first para in many2many notbook thats it

Atchuthan India
6/11/13, 2:53 AM

how can i access the tags from notebook_view.xml without having a m2m field there?

Ask a Question
Writer
Keep Informed
4 follower(s)
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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now