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 the following parent object, with One2many relationship to child object
class ParentObject(models.Model)I want to add a List of these items (either parent or specific children) to the crm.lead and hence I have the following:
_name = 'module.parentobject'
field1 = fields.Char(string="Field One")
child_ids = fields.One2many('module.childobject', 'parent_id', string="Children")
_name = 'module.childobject'
parent_id = fields.Many2one('module.parentobject', ondelete='cascade', string="Parent", required="True")
childField1 = fields.Char()
#A line can be linked to "a parent" OR "0 to many children"
_name = "module.line"
parent_id = fields.Many2one('module.parent', string="Parent")
child_id = fields.Many2many('module.child','module_line_child', 'line_id', 'child_id', string="Children")
lead_id = fields.Many2one('crm.lead')
_inherit = "crm.lead"
line_ids = fields.One2many('module.line', 'lead_id', string="Interested In")
On the lead form view I display the lines and I am trying to restrict the child selection options based on the parent. In other words - only children of the selected parent should appear in the dropdown and not all children. A user should also be able to select a parent without a child (he is interested in all children).
The domain below doesn't work, What am i doing wrong?
<record model="ir.ui.view" id="lead_webquery_form_view"> <field name="name">lead.webquery</field> <field name="model">crm.lead</field> <field name="inherit_id" ref="crm.crm_case_form_view_leads"/> <field name="arch" type="xml"> <notebook position="inside"> <page string="Interested In"> <field name="line_ids" widget="one2many_list" > <tree string="Objects" editable="bottom"> <field name="parent_id"/> <field name="child_id" widget="many2many_tags" domain="[('parent_id','=','parent_id')]"/> </tree> </field> </page> </notebook> </field> </record>
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: 4/14/15, 7:43 AM|
|Seen: 3584 times|
|Last updated: 5/19/15, 8:49 AM|