I have
many2one
fieldname_id
inmy_model.xml
view.I want to filter and have possibility select from
name_id
field only these values which have a relation with active form view model.Example:
I have
'my.model'
class records:id = 1 title = 'Aloha' id = 2 title = 'Bye'
'my.model.line'
class records:id = 1 name = 'first' my_model_id = 1 id = 2 name = 'second' my_model_id = 1 id = 3 name = 'item' my_model_id = 2
So when I open form view, and click on add an item from
name_id many2one field I want to have selection only from values: 'first', 'second' if active 'my.model' id = 1. If 'my.model' id = 2
name_id many2one field selection just from 'item' value.my_model.xml <record model="ir.ui.view" id="view_my_model_form"> <field name="name">my.model.form</field> <field name="model">my.model</field> <field name="arch" type="xml"> <form string="My Model"> <header> <field name="my_model_line"> <tree> field name="name"/> </tree> </field> <notebook> <page> <field name="supply_conditions_status"> <tree string="My model Lines"> <field name="name_id"/> </tree>
Models:
class SupplyConditions(models.Model): _name = 'supply.conditions' name_id = fields.Many2one('my.model.line', string='Product') model_id = fields.Many2one('my.model') class MyModelLine(models.Model): _name = 'my.model.line' name = fields.Char('Name') my_model_id = fields.Many2one('my.model') class MyModel(models.Model): _name = 'my.model' title = fields.Char('Title') my_model_line = fields.One2many('my.model.line', 'my_model_id') supply_conditions_status = fields.One2many('supply.conditions', 'model_id')
I have no idea how to do this. Can't use domain on xml view because can't reach active 'my.model' id. Tried on name_id use _default_value but nothing.. Maybe with relations but also have no idea how. Need any hints..
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
This question has been flagged
2314
Views