Current check_bom_recursion [1] is not correct because it only recursively that the product is in the input but not to the ouput.
It does not contemplate a type possibility:
BOM: A
Input: X
Output: Y
BOM: B
Input: Y
Output Z
BOM: C
Input: Z
Output: X
2. Current check_bom_recursion is when validate a product.
In case the product cost is “average”, for each time do a check_bom_recursion. IMHO we do a validation in the ‘production.bom’ model instead of ‘product.product’.
Yes. This example crash about recursion method because don’t check the outputs are in other BOM:
File "/trytond/modules/production/product.py", line 54, in check_bom_recursion
input_.product.check_bom_recursion(product=product)):
File "/trytond/modules/production/product.py", line 54, in check_bom_recursion
input_.product.check_bom_recursion(product=product)):
File "/trytond/modules/production/product.py", line 54, in check_bom_recursion
input_.product.check_bom_recursion(product=product)):
… and as long as update the cost price (average) (or other product fields not related with the production) is not necessary to check product booms.
The example in the first post creates an infinte loop:
BOM: A
Input: X
Output: Y
BOM: B
Input: Y
Output Z
BOM: C
Input: Z
Output: X
Because current implementation only checks that the products of the input are different from the products of the output. But does not guarantee that the recursivity does not exist when the loop is created by three recursive BOMs.
We’ll create an issue to bugs.tryton.org and create a codereview.
Another discussion is if putting that check in the validate of product.product is a good idea given that, for example, a write() on product.product is done each time a product cost changes.