Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
6271 Weergaven

Hello,
I am thinking of storing computed fields, qty_available and virtual_available, product.product fields. The objectif is to make faster searches based on this field.
Since each move will update this field I am wondering what would be the negative impact? Have some of you tried it ? 

Thanks

Avatar
Annuleer
Beste antwoord

Both negative and positive impacts are linked to stock moves. Positive or negative just depend on actual destination and source locations.

Simultaneously, storing the fields is hardly a good idea: 

  1. Although they depend mainly on stock moves, it would be extremely difficult to catch the changes (each state change, create, update, etc - simple api@depends probably would not be enough). There is a significant chance that certain triggers would be missed;

  2. Those fields are context-dependent. In a significant number of methods, no just product quantity is needed but quantity for a definite warehouse or stock lot. Moreover, quantities are calculated for any real date what is impossible if fields are stored. Finally, actual figures are access-dependent (different user and users different companies might have different final values). So, you would need to re-develop all of those methods. This is extremely complex and error-prone;

  3. There are issues with product template / variant inheritance. That Inheritance would a be an obstacle to store values.

There are critical reasons why fields are made non stored. Avoiding that would jeopardize procurement, user experience, etc.

If you anyway wanted to have some stored figures, it would be better to introduce own fields for that purposes. You may populate such fields both by compute methods (with own calculation logic) or regularly by cron jobs (e.g. just by copying non-stored values).

Avatar
Annuleer
Auteur

So it would not affect the performance with too much write, the only issue would be incorrect information stored if I miss some events.

Concerning the user experience, being able to quickly see if a product is available or not is very useful ! I think I might give it a shot but as you said in another fields ;)

Thank you very much for your detailed answer :)

Gerelateerde posts Antwoorden Weergaven Activiteit
1
okt. 21
6729
2
jul. 23
5080
2
mrt. 22
7851
0
aug. 17
4656
2
mrt. 15
12790