Discussion:
[tryton] Filling a selection field based on value of another instance field.
Steven Lightfoot
2018-03-05 13:51:17 UTC
Permalink
Hi

What is the easiest way of filling a selection field dynamically? I need to fill it based on a custom product class that has a description and up to 8 can sizes (different products will have different available can sizes)

Using a classmethod function does not give me the access to the instance values so I assume that a function field is the way to go but the only examples I can see using a function field is to set a value from a predefined list.

Should I be going down the route of using One2Many, Many2one fields?

No idea if this makes sense or not :-)

If not then I will go forth back to the shadows from whence I came!!!!
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/0caebec1-d152-49f6-b5eb-5c1e72318ae4%40googlegroups.com.
Cédric Krier
2018-03-05 14:26:28 UTC
Permalink
Post by Steven Lightfoot
What is the easiest way of filling a selection field dynamically? I need to fill it based on a custom product class that has a description and up to 8 can sizes (different products will have different available can sizes)
Using a classmethod function does not give me the access to the instance values
So use an instance method decorated with fields.depends:
http://doc.tryton.org/4.6/trytond/doc/ref/models/fields.html#trytond.model.fields.Selection.selection
Post by Steven Lightfoot
so I assume that a function field is the way to go but the only examples I can see using a function field is to set a value from a predefined list.
Function field works the same way as standard field.
Post by Steven Lightfoot
Should I be going down the route of using One2Many, Many2one fields?
It is also an option, it depends of the schema.


But did you considered to use the product_attribute ? It seems to be
exactly the solution to your "product class".
--
Cédric Krier - B2CK SPRL
Email/Jabber: ***@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/20180305142628.GF4221%40kei.
Steven Lightfoot
2018-03-05 16:06:42 UTC
Permalink
Thank you cedric, I had not considered the product_attribute. I will have another look.

Much appreciated.
Post by Steven Lightfoot
Hi
What is the easiest way of filling a selection field dynamically? I need to fill it based on a custom product class that has a description and up to 8 can sizes (different products will have different available can sizes)
Using a classmethod function does not give me the access to the instance values so I assume that a function field is the way to go but the only examples I can see using a function field is to set a value from a predefined list.
Should I be going down the route of using One2Many, Many2one fields?
No idea if this makes sense or not :-)
If not then I will go forth back to the shadows from whence I came!!!!
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/36766c87-ba45-4240-96a7-cd39d1460df4%40googlegroups.com.
Loading...