-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getTotalWeightVolume uses wrong scale #11861
Comments
By introducing the c_units table and class, we create big issues in weight_calculation Fetch methods of class core/class/cunits.class.php never fetch the scale field, but conversion functions still need this info Also there can be big migration problems because until dolibarr 9 you will have on a product weight = 100 weight_unit = -3 for a product of 100g How do you convert this in the new system ? |
On the proposal card, you have a computed volume based on product line volumes. This is the role of the getTotalWeightVolume function. I am sorry the copy paste of my git diff resulted in a crappy report... In short, this function will convert values with differing units (say liters of milliliters) to a reference unit (cubic meters). The problem is that it is not using the right parameter for the scaling (it uses the unit index, which may have previously been chosen to reflect this scale, but this is presently not the case and the dictionary defines a scale value which should be used). This has been reported in the forum as well : https://www.dolibarr.org/forum/5-bugs-on-cvs-or-demo-version/29558-severe-problem-with-calculated-weight-and-volume |
OK. The field is visible only when there is a weight > 0 |
Thank you, that was impressively fast ! |
Hi !
Tks for your help French forum : |
Bug
Function getTotalWeightVolume from core/class/commonobject.class.php uses unit index instead of dictionary 'scale' to convert values
Environment
Expected and actual behavior
Total weight and volume should be computed and converted from defined to reference unit.
Aberrant values are returned by the implemented function
Steps to reproduce the behavior
Add product with weight/volume and units defined to proposals => displayed total is aberrant.
Proposed resolution : modify lines in function
@@ -3684,24 +3691,24 @@ abstract class CommonObject
@@ -3709,7 +3716,7 @@ abstract class CommonObject
else
$totalWeight += $weight * $qty; // This may be wrong if we mix different units
}
The text was updated successfully, but these errors were encountered: