i have a many2one field. It is in a line(part of tree for one2many.)
<tree string="PLD" editable="bottom">
<field name="priority_set" />
<field name="shop_id" domain="[('is_shop', '=', True),('usage','=','internal')]" options="{'no_open':True,'no_create':1,'no_create_edit':1}" /> //shop_id = fields.many2one('stock.location')
<field name="temp_id" options="{'no_open':True,'no_create':1,'no_create_edit':1}" />
</tree>
i want to select a shop for 1st line. In the 2nd line, the selected shop value should not be shown in the many2one dropdown. How can it be done?
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ờ
2
Trả lời
8656
Lượt xem
this is from a custom application but does the job you want out of box in odoo way.
be careful: when you do changes on one2many columns with it, you might erase data!
in views
<record id="view_fc_animal_form" model="ir.ui.view">
<field name="name">fc.animal.tree</field>
<field name="model">fc.animal</field>
<field name="priority">4</field>
<field name="arch" type="xml">
<form string="Animals">
<sheet>
<group>
<field name="species_id" on_change="onchange_species_id(species_id, context)" options="{'no_create': True}"/>
</group>
<group>
<field name="breed_id" domain="[('species_id','=',species_id)]" options="{'no_create': True}" attrs="{'disabled': True}"/>
</group>
<group>
<group>
<!-- this is a sample for Selection/Boolean column. -->
<field name="gender" on_change="onchange_gender(gender, context)"/>
</group>
<group attrs="{'invisible': [('gender','not in', ('male', 'female'))]}">
<field name="castrated" attrs="{'invisible': [('gender','in', ('female'))]}"/>
<field name="sterilized" attrs="{'invisible': [('gender','in', ('male'))]}"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
in model.
class Animal(models.Model):
_name = 'fc.animal'
# columns
species_id = fields.Many2one('fc.species', string='Species', index=True, required=True)
breed_id = fields.Many2one('fc.breed', string='Breed', index=True)
def onchange_species_id(self, cr, uid, ids, species_id, context=None):
if not species_id:
return {'value': {'species_id': False, 'breed_id': False}}
return {'value': {'breed_id': False}}
I was searching solution for the similar problem. Did you solve it yet?
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 | |
---|---|---|---|---|
|
0
thg 4 17
|
6738 | ||
|
1
thg 12 19
|
9948 | ||
|
2
thg 4 24
|
2843 | ||
|
3
thg 10 22
|
21330 | ||
|
1
thg 7 20
|
8758 |