On 06/10/10 02:26 -0700, Vincent wrote:
> Hi,
> 
> I've a little problem that's related to this.
> 
> I have the following models (changed the names to not distract from
> the problem):
> 
> class Model1(ModelSQL, ModelView):
>     _name = "model1.model1"
>     _description = __doc__
> 
>     is_parent = fields.Boolean('This item is a parent', help='')
> Model1()
> 
> class Model2(ModelSQL, ModelView):
>     _name = "model2.model2"
>      main_item = fields.Many2One('model1.model1', 'Main Item')
>      child_items = fields.Many2Many('model3', 'model2field',
> 'model1field', 'Example', help='',
>                                  domain = [
>                                             ('parent', '=',
> Eval('main_item'))
>                                           ],
>                                  states = {
>                                              'invisible':
> Not(Bool(Eval('_parent_main_item.is_parent'))),
>                                           },
>                                  )
> Model2()
> 
> class Model3(ModelSQL, ModelView):
>     _name = "model3.model3"
> 
>     model2field = fields.Many2One('model2.model2', 'Model 2 record',
> help='')
>     model1field = fields.Many2One('model1.model1', 'Model 1 record',
> help='')
> Model3()
> 
> Basically in Model2 you select a main_item. If this main_item is a
> parent, then the many2many field child_items should be visible so the
> user can select its childs. The domain= part works, but the control is
> always invisible regardless if a main_item is selected that is a
> parent.

This could only work if you edit Model2 from inside a one2many on Model1.

But anyway, this kind of difficulty generaly means that there is a problem in
the design.

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/

Attachment: pgpU6sVAzAgB6.pgp
Description: PGP signature

Reply via email to