This slide will shows the Float Operations in Odoo 17.
Decimal accuracy is a measurement tool of Odoo to let the end-user specify the floating position of different categories like unit of measure, price. This feature helps the user to decide how many values to be displayed as decimals in each categ...
This slide will shows the Float Operations in Odoo 17.
Decimal accuracy is a measurement tool of Odoo to let the end-user specify the floating position of different categories like unit of measure, price. This feature helps the user to decide how many values to be displayed as decimals in each category.
Size: 345.44 KB
Language: en
Added: Jul 26, 2024
Slides: 12 pages
Slide Content
Float Operations in Odoo Odoo 17 Enterprise
Introduction Enterpr ise This slide will shows the Float Operations in Odoo 17. Decimal accuracy is a measurement tool of Odoo to let the end-user specify the floating position of different categories like unit of measure, price. This feature helps the user to decide how many values to be displayed as decimals in each category.
Enterprise Let’s check its usage by using an example . Go to the Settings > Technical > Decimal Accuracy. Here we have set decimal accuracy for ‘Product Unit of Measure’ as 2. It means that wherever Odoo shows unit of measure, it will show 2 decimal points as we see below.
Enterprise
Enterprise Here the decimal points for the quantity of the product is 2.
Enterprise Let’s go to the coding part. To specify decimal accuracies, we need to import the decimal_precision module. from odoo.addons import decimal_precision as dp We can also do by using the corresponding module . Precision = self.env['decimal.precision'].precision_get( 'Product Unit of Measure')
Enterprise We can use it anywhere like field declaration, functions etc product_qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True)
Enterprise Odoo provides some tools to check the decimal position of value. Here, we are checking those methods and functions used to check decimal point conditions. float_compare() This function determines whether the value is lower than or greater than another value by considering the given precision, precision rounding, etc.
Enterprise float_is_zero() This function returns true if the given value can be considered as zero with the given precision value and rounding digits . float_round() This function returns the given value by rounding it with the specified rounding criteria.
Enterprise float_repr() This function returns the string representation of the given value with the given decimal precision. This is used to get the string value of a float. float_split() This function used to get the integer values.
Enterprise float_split_str() This function will be used to split the integer value and fraction values from a float value. It exactly split the given value in its unitary and decimal parts. The float value is first rounded by using the function float_round(). Then the rounded value converts to string by using the function float_repr(). Then it will split the value and returns a tuple which contains both integer and fractional parts.
For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com