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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
3294
Lượt xem
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 12 16
|
7332 | ||
|
5
thg 10 22
|
15851 | ||
|
0
thg 4 16
|
3310 | ||
|
1
thg 10 15
|
4697 | ||
|
0
thg 10 23
|
3062 |