Odoo Help


2 Answers
Fatih Piristine
14‏/9‏/2017 1:23 م

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">
<field name="species_id" on_change="onchange_species_id(species_id, context)" options="{'no_create': True}"/>
<field name="breed_id" domain="[('species_id','=',species_id)]" options="{'no_create': True}" attrs="{'disabled': True}"/>

<!-- this is a sample for Selection/Boolean column. -->
<field name="gender" on_change="onchange_gender(gender, context)"/>


<group attrs="{'invisible': [('gender','not in', ('male', 'female'))]}">
<field name="castrated" attrs="{'invisible': [('gender','in', ('female'))]}"/>
<field name="sterilized" attrs="{'invisible': [('gender','in', ('male'))]}"/>

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}}

Mike Ross
7‏/3‏/2017 1:50 ص

I was searching solution for the similar problem. Did you solve it yet?

Ask a Question
Keep Informed
1 follower(s)
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.

Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now