On Tuesday, February 2, 2016 at 4:23:28 PM UTC+7, Sergi Almacellas Abellana 
wrote:
>
> El 02/02/16 a les 10:16, Markus Bala ha escrit: 
> > Hi All, 
> > 
> > I had inherit 'stock.location', and add a new boolean field  called 
> > 'staging'. 
> > 
> > I try to change the original 'storage.location' field as below: 
> >      storage_location = fields.Many2One( 
> >          "stock.location", "Storage", states={ 
> >              'invisible': Eval('type') != 'warehouse', 
> >              'readonly': ~Eval('active'), 
> >              'required': Eval('type') == 'warehouse', 
> >          }, 
> >          domain=[ 
> >              ('type', 'in', ['storage', 'view']),*('staging','=', 
> False),* 
> >              ['OR', 
> >                  ('parent', 'child_of', [Eval('id')]), 
> >                  ('parent', '=', None)]], 
> >          depends=['type', 'active', 'id']) 
> > 
> > At the domain, I add ('staging','=',False). 
> > When I checked the result, seem like it do not override the field? 
>
> You should override the domain in the __setup__ method of your function. 
> Something like: 
>
>     @classmethod 
>     def __setup__(cls) 
>         super(Class, cls).__setup__() 
>         clause = ('staging', '=', False) 
>         if clause not in cls.storage_location.domain: 
>             cls.storage_location.domain.append(clause) 
>
> So this will modify the field when you module is loaded. 
>

Hi Sergi,

You are really a savior. Thank you 

>
> -- 
> Sergi Almacellas Abellana 
> www.koolpi.com 
> Twitter: @pokoli_srk 
>

-- 
You received this message because you are subscribed to the Google Groups 
"tryton-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton-dev/08b50aaf-f14d-44f2-9238-d18b16fc61b4%40googlegroups.com.

Reply via email to