odoo 8 / open erp中的相关下拉列表

时间:2022-01-01 23:41:43

I have made two drop-down lists. Second drop-down list's data is dependent on first drop-down list's chosen value i.e it changes dynamically.
First DDL is Region which contains one or many Departments that provide second *DDL.

我制作了两个下拉列表。第二个下拉列表的数据取决于第一个下拉列表的选择值,即它会动态变化。第一个DDL是Region,它包含一个或多个提供第二个* DDL的Departments。

I have tried multiple methods like this one but didn't find any relevant solution.

我尝试了多种这样的方法,但没有找到任何相关的解决方案。

would somebody like help me?
*DDL = DropDownList

有人会帮帮我吗? * DDL = DropDownList

1 个解决方案

#1


1  


I found a way and it's work nicely.

我找到了一种方法,它的工作很好。

class Region(models.Model):
    _name = 'obertys.region'
     name = fields.Char(string=u'Region', required=True )

class Department(models.Model):
    _name = 'obertys.department'
     name = fields.Char(string=u'Departement')
     reg_id = fields.Many2one(store=True, string=u'Région',
                             comodel_name='obertys.region',)

After having put in relation region and departement, the whole is played at the level of the view (file xml). This piece of code below for illustration
<group string="Lieux"> <field name="reg" class="oe_inline"/> <field name="dept" domain="[('reg_id','=',reg)]" class="oe_inline"/> </group>

在放入关系区域和部门之后,整个视图(文件xml)的级别进行播放。下面这段代码用于说明

PS: I also use region in other model by Many2one to have it in DDL

PS:我也使用Many2one在其他模型中的区域来使用DDL

#1


1  


I found a way and it's work nicely.

我找到了一种方法,它的工作很好。

class Region(models.Model):
    _name = 'obertys.region'
     name = fields.Char(string=u'Region', required=True )

class Department(models.Model):
    _name = 'obertys.department'
     name = fields.Char(string=u'Departement')
     reg_id = fields.Many2one(store=True, string=u'Région',
                             comodel_name='obertys.region',)

After having put in relation region and departement, the whole is played at the level of the view (file xml). This piece of code below for illustration
<group string="Lieux"> <field name="reg" class="oe_inline"/> <field name="dept" domain="[('reg_id','=',reg)]" class="oe_inline"/> </group>

在放入关系区域和部门之后,整个视图(文件xml)的级别进行播放。下面这段代码用于说明

PS: I also use region in other model by Many2one to have it in DDL

PS:我也使用Many2one在其他模型中的区域来使用DDL