Tryton - Issues

 

Issue8058

Title Can't create productions from request because exceeds digits limit
Priority bug Status resolved
Superseder Nosy List ced, pokoli, resteve, reviewbot, roundup-bot
Type crash Components stock_supply_production
Assigned To ced Keywords review
Reviews 287151002
View: 287151002

Created on 2019-01-29.16:47:49 by resteve, last changed by roundup-bot.

Messages
New changeset ab0a62508de3 by Cédric Krier in branch '5.0':
Ceil quantity of production with the default UoM
https://hg.tryton.org/modules/stock_supply_production/rev/ab0a62508de3

New changeset 7a3b7f794c8c by Cédric Krier in branch '4.8':
Ceil quantity of production with the default UoM
https://hg.tryton.org/modules/stock_supply_production/rev/7a3b7f794c8c

New changeset 12200b73b22c by Cédric Krier in branch '4.6':
Ceil quantity of production with the default UoM
https://hg.tryton.org/modules/stock_supply_production/rev/12200b73b22c

New changeset 2818ea8a378f by Cédric Krier in branch '4.4':
Ceil quantity of production with the default UoM
https://hg.tryton.org/modules/stock_supply_production/rev/2818ea8a378f
New changeset 97baf66de928 by Cédric Krier in branch 'default':
Ceil quantity of production with the default UoM
https://hg.tryton.org/tryton-env/rev/97baf66de928
New changeset a084e8f44d6c by Cédric Krier in branch 'default':
Ceil quantity of production with the default UoM
https://hg.tryton.org/modules/stock_supply_production/rev/a084e8f44d6c
review287151002 updated at https://codereview.tryton.org/287151002/#ps273161002
msg47939 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-03-23.00:48:05
Here is review287151002 that should fix it.

On a side note, this could have been fixed faster if @resteve was more cooperative by providing more inputs on his case to let others understand. This is a behavior that must change.
msg47936 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-03-23.00:38:22
Indeed it is similar to issue6668 but issue6668 does not explain correctly the issue. It is not because products_by_location does not round the quantity it does. But it is because the shortages computation involve adding quantities day by day. Those quantities are float and so a small precision error is adding on each operation which could become significant for the resulted float.
e.g:
>>> 1.1 + 1.1 + 1.1
3.3000000000000003
msg46650 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-01-30.17:10:04
I do not see any patch on msg46573
A patch contains at least the file and the line number which is being modified.
msg46649 (view) Author: [hidden] (resteve) Date: 2019-01-30.16:52:48
> So if you have a patch why you don't propose it?

See msg46573 (...and I read how to contribute). Thanks
msg46647 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-01-30.16:18:09
So if you have a patch why you don't propose it?
msg46646 (view) Author: [hidden] (resteve) Date: 2019-01-30.16:16:45
> and how do you solve it?

convert decimals according to decimals uom?
msg46645 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-01-30.15:04:39
and how do you solve it?
msg46643 (view) Author: [hidden] (resteve) Date: 2019-01-30.15:01:47
> But to produce this limits excess you need to perform the division between two numbers. For example: 2.0 / 1.0 does not exceed the limit. 

Exact! You could do a scenario with these division to reproduce it.

> So please provide the values that you are using and a simple scenario to reproduce the issue.

Sorry ,we detected in production env and we solved it.
msg46642 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-01-30.14:58:41
But to produce this limits excess you need to perform the division between two numbers. For example: 2.0 / 1.0 does not exceed the limit. 

So please provide the values that you are using and a simple scenario to reproduce the issue.
msg46640 (view) Author: [hidden] (resteve) Date: 2019-01-30.14:24:29
You could reproduce when qty decimals exceeds the limit domain.
msg46634 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-01-30.13:10:25
I still do not see any simple step by step scenario to reproduce it.

How much quantities do you have on the inputs and outputs?
msg46633 (view) Author: [hidden] (resteve) Date: 2019-01-30.12:59:53
- Uom Product: grams
- Uom inputs: kilograms
- Uom outputs: grams

The problem is that qty decimals and uom production request [1] exceeds the limit domain [2].

[1] https://bitbucket.org/tryton/stock_supply_production/src/a3e099be638515203589e22ae8bd9298d17d7db5/production.py?at=default&fileviewer=file-view-default#production.py-146

[2] https://bitbucket.org/tryton/production/src/ff98aa7a5be23337aea356546b3ddd630ac63068/production.py?at=default&fileviewer=file-view-default#production.py-114
msg46574 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2019-01-29.18:23:46
Could you please explain the full scenario? 

There should be something between creating a product with grams and creating request products as by default tryton will not create any production for producible products. 

Do you use a BOM? How much quantity are you producing? 

It will be great if you can provide a simple step by step scenario to reproduce it.

Thank you!
msg46573 (view) Author: [hidden] (resteve) Date: 2019-01-29.16:47:48
Scenario:

1- Create a product with default uom: gram
2- Create Request Productions:


The number of digits "2" of field "Quantity" on "6328.44000000006" exceeds its limit.

Detected all versions in compute_request() method:

POC:

-            quantity=quantity,
+            quantity=float(Decimal(quantity).quantize(Decimal(str(10 ** -product.default_uom.digits)))),
History
Date User Action Args
2019-04-10 19:21:42roundup-botsetmessages: + msg48811
2019-03-27 23:19:08roundup-botsetmessages: + msg48065
2019-03-27 23:19:05roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg48064
2019-03-23 01:18:45reviewbotsetnosy: + reviewbot
messages: + msg47942
2019-03-23 00:48:06cedsetstatus: in-progress -> testing
reviews: 287151002
messages: + msg47939
keyword: + review
2019-03-23 00:38:23cedsetstatus: chatting -> in-progress
assignedto: ced
messages: + msg47936
nosy: + ced
2019-01-30 17:10:05pokolisetmessages: + msg46650
2019-01-30 16:52:48restevesetmessages: + msg46649
2019-01-30 16:18:10pokolisetmessages: + msg46647
2019-01-30 16:16:45restevesetmessages: + msg46646

Showing 10 items. Show all history (warning: this could be VERY long)