Wed, 25 Apr 2018 09:40:58 +0200 Cédric Krier <cedric.kr...@b2ck.com>:
>On 2018-04-24 17:53, Udo Spallek wrote: >It can not work because clients build first the view before bind it >with record values. Thank you for the explanation. >I think it will be better to have a configuration option that defines >if the company is working with variants or not. This configuration >will be used to set a proper mode. I thought about a configuration, too. IMHO a configuration has limitations, as it is company-wide and not product specific: * Even when using variants in a setup, there can also be other products which are not variants. * When using variants it can be useful to have the product (variant) form view shown on new product templates, just for quick encoding. But I found another solution. I put two products fields in the view. There is one for mode="tree,form" and another for mode="form,tree", each of them surrounded by a group with a separate id:: <xpath expr="/form/notebook/page[@id='general']/field[@name='products']" position="replace"> <group id="products" colspan="2" col="1" yexpand="1" yfill="1"> <group id="products-tree" yexpand="1" yfill="1"> <field name="products" mode="tree,form" view_ids="product.product_view_tree_simple,product.product_view_form_simple"/> </group> <group id="products-form" yexpand="1" yfill="1"> <field name="products" mode="form,tree" view_ids="product.product_view_form_simple,product.product_view_tree_simple"/> </group> </group> </xpath> (Maybe it can be done simpler with less use of groups) And now each group can be switched by view attributes:: class Template: __metaclass__ = PoolMeta __name__ = "product.template" @classmethod def view_attributes(cls): res = super(Template, cls).view_attributes() res.append(( "//group[@id='products-form']", 'states', {'invisible': Greater(Len(Eval('products')), 1)}, )) res.append(( "//group[@id='products-tree']", 'states', {'invisible': Less(Len(Eval('products')), 2)}, )) return res For me it is the perfect solution: if the Variants have more than one record, it is shown as a list if the Variants have less than two records, it is shown as a form Is it an interesting enhancement of the product module? Regards Udo -- virtual things Preisler & Spallek GbR Windeckstr. 77 81375 München Tel: +49 (89) 710 481 55 i...@virtual-things.biz https://www.virtual-things.biz -- 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/20180425140700.3f2b971a%40bender.fritz.box.
pgppdRVdKlOHY.pgp
Description: Digitale Signatur von OpenPGP