On 05 Apr 05:41, Markus Bala wrote:
> class Template:
>     __name__ = 'product.template'
> 
>     packagings = fields.One2Many('product.uom-packaging.type', 
> 'template','Packaging')
> 
> 
> class TemplatePackageType(ModelSQL, ModelView,):
>     'Prouct Packaging Type'
>     __name__ = 'product.uom-packaging.type'
> 
>     template = fields.Many2One('product.template', 'Template', 
> required=True,
>         select=True, ondelete='CASCADE')
>     barcode = fields.Char('Label/Barcode', help="Barcode label or indicator 
> of the pack")
>     pack_uom = fields.Many2One('product.uom', 'Pack Uom', 
>                                domain=[
>                                        ('category', '=', 
> Eval('default_uom_category')),
>                                        ])
>     default_uom_category = fields.Function(
>         fields.Many2One('product.uom.category', 'Default UOM Category'),
>         'on_change_with_default_uom_category',
>         searcher='search_default_uom_category')
> 
> -----------------------------------------------------------------------------------------------------------------------
> When I am going to create "product.uom-packaging.type". 
> May I know how the "pack_uom" able to do the domain of the 
> "default_uom_category" from the "product.template"?

You have to create a Function field on packging type that compute this
value using a "on_change_with" as getter. Like that it will be computed
by the client also when the creating it from the one2many (even with a
non-saved template).

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Reply via email to