Display product_uom_qty as integer instead of float - view

I need to display the field product_uom_qty under sale.order.line (of Sale order) and quantity under account.invoice.line (of an invoice) as an integer instead of the current floating point.
How can I do it?
Please let me know.
Thanks.

Since you are asking for Odoo 10:
Go to Settings in Debug mode.
Under the Technical > Database Structure > Decimal Accuracy click the menu.
Find Product Unit of Measure and edit it to 0 digits.
This will change whenever product_uom_qty is accessed with Decimal Accuracy precision, not just Sales Orders.

If you want to do it in the model, you can set digits like this.
fields.float('Quantity', digits=(x,y))
If you want to do it in the view, you can set digits like this.
<field digits="(x,y)" name="product_uom_quantity"/>
where x is the digits before the decimal point, and y is the digits after the decimal point. So, if you set y to 0 it will have no decimal point seemingly an integer.

You can set the widget attribute to integer.
Example:
<field name="product_uom_qty" widget="integer"/>

Related

How to set the decimal to 2 in MariaDB

I use Laravel with vue/vuetify in frontend.
In a simple form, the user can set the settlement_factorwhich is a number with 2 decimals.
The field in the DB looks like
If I enter 1.68 the entry in the db is 1.68 but the system returns 1.68000000000002
Patch request value:
"settlement_factor": "1.68",
Response value
"settlement_factor": 1.6800000000000002,
But if I enter 1.67, the system returns 1.67 which is right:
Patch request value:
"settlement_factor": "1.67",
Response value
"settlement_factor": 1.67,
I use Laravel ressources to modify the response:
'settlement_factor' => $this->settlement_factor,
Why does the system change the value 1.68 to 1.68000000000002 but the other numbers are ok?
I have no Idea to find the error.
For a quick fix, I can add the round()function.
Don't use double for this. Double is a floating point number encoded
in 64 bits. The encoding of a decimal number in binary cannot always
be exact. 1.68 happens to be one of the numbers where the encoding is not exact so you see it displayed as 1.68000000000002.
Use Decimal (5,2) this would allow for 5 significant digits with 2 to the right of the decimal point. This would give you a range of 0 to 999.99. You can adjust these 2 number to fit the range you expect for the number. To match to the number you used, use Decimal (3,2) which gives you a range of 0.00 to 9.99.
Rounding will be managed by Decimal Type so you will not see the
encoding deviation like in Double.

In Google Sheets, how do we take a decimal feet value and turn it into properly formatted fractional Feet & Inches?

Been looking all over and nothing comes up as far as a Google Sheets formula.
Let's say we have a value of 3.6875 feet. We can use the number format # ??/??, but it will give us a fractional value in feet (in this case, 3 11/16 feet).
How do we "grab" the 11/16 and multiply it by 12 to get the inches value (8.25), and then the really tricky part, how do we display the whole enchilada as 3'8¹/⁴" (yes, including the superscript)?
A1= 3.6875
B1=INT(A1)&"'-"&TRIM(TEXT(ROUND(MOD(A1,1)*12*16,0)/16,"# ??/??")&"""")
Output: 3'-8 1/4 "
UPDATED:
You can have a table to search the superscript
The idea to get the superscript: with above output (3'-8 1/4"): is to extract the fraction (1/4), search for the equivalent superscript in the table (¹/⁴), then replace it (3'-8 ¹/⁴"):
So basically we will need:
REGEXEXTRACT
VLOOKUP
REGEXREPLACE
SPREADSHEET DEMO: HERE
=arrayformula(
if(len(A2:A),INT(A2:A)&"'-
"&REGEXREPLACE(TRIM(TEXT(ROUND(MOD(A2:A,1)*12*16,0)/16,"#??/??")&""""),
"\d{1}\/\d+",
VLOOKUP(IFNA(
REGEXEXTRACT(TRIM(TEXT(ROUND(MOD(A2:A,1)*12*16,0)/16,"# ??/??")&""""),
"\d{1}\/\d+"),
"0/0"),
TABLE!A:B,2,0)),""))

Crystal Reports Not Rounding Correctly

I have a formula which is simply 28742.92 / 100.
I have rounding which is set to 0.00001 however it outputs the value 284.
Is it possible to output decimal values as it appears in a standard calculation e.g. 28742.92 / 100 = 284.7289
Many Thanks.
Right click on your numeric field and choose the 4th option from the top Customize field.
Once done, choose the way you want to format your number

jFreeCharts large number label display

I am using jfreecharts to vreate a value-time chart.
Data is gathered dynamically from web services and some times there are large numbers in it. The chart is created without any problem but the value axis
labels are of this format: 2E10 etc. I would like to have 20000000000 displayed. I have not find any solution after 2 hours of rsearching. Can anyone suggest something?
This fixed the problem:
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
DecimalFormat newFormat = new DecimalFormat("0.0000");
rangeAxis.setNumberFormatOverride(newFormat);
It also works when you have a dataset with largest value a float with 0 as integer part and at least the first 3 decimal digits to be 0 in which case labels also appear in negative power of 10 by default.

Numeric Filter and missing values (Weka)

I'm using SMOTE to oversample my dataset (affected by class imbalance). Some of my attributes have integer values, others have only two decimals but SMOTE creates new instances with many decimals. So to solve this problems I thought to use NumericCleaner Filter and set the number of decimals I desire. This seems to work but I've got problems with missing values. Each missing values is replaced with a 0.0 value, I need to evaluate my model using missing values in dataset. So how can I use NumericCleaner (or other filters that permit to round values) and keep my missing values?
Very interesting question. Okay, here is the solution:
use SMOTE to oversample the minority group (this produces decimal points but the missing values remain missing values)
then select weka filter->unsupervised->attribute->NumericTransform
then click on this filter and set the attribute instances (where you are having decimal points features) and in the methodName instead of "abs", put "ceil".
I hope that solves the problem.

Resources