Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I have models A and B:
class A (models.Model):
_name = 'example.a'
name = fields.Char(string="Model A")
b_id = fields.Many2one('example.b', string='Model B')
class B (models.Model):
_name = 'example.b'
name = fields.Char(string="Model B")
a_ids = fields.One2many('example.a', 'b_id', string="Models A")
I want to Add an item in a_ids from the existing records of A, not create new ones, how can this be achieved ? the autogenerated view for a_ids field only allows me to insert new records everytime I click Add an item, How can I show a list of existing records from the Many2One b_id field in model A. I though odoo will automagically show me a list of such values since the declaration of the field explicitly names the field in the Many2One relationship, thanks in advance
Actually what you wrote must work. I have something very similar in my extension of res.partner:
wo_ids = fields.One2many('inspection_tech.work_order',
inverse_name = "customer",
In my partner view I have added the work order view in a tab:
<page string="Work Orders">
And it works as a charm. Are you sure you have example.a records with b_id point to the viewed example.b instance?
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 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
|Asked: 12/8/14, 6:06 PM|
|Seen: 1515 times|
|Last updated: 3/16/15, 8:10 AM|