qty = fields.Float(string='Quantity', required=True, digits=(16, 3), default=1)
1. 如上图, digits=(16,3) : 16位整数,3位小数
from odoo import api, fields, models
import odoo.addons.decimal_precision as dp
class MrpBomLine(models.Model):
_inherit = 'mrp.bom.line'
product_qty = fields.Float(
'Product Quantity', default=1.0,
digits=dp.get_precision('Mrp Bom Qty'), required=True)
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record forcecreate="True" id="mrp_bom_qty" model="decimal.precision">
<field name="name">Mrp Bom Qty</field>
<field name="digits" eval="3"/>
</record>
</data>
</odoo>
2. 如上图,进入: 设置-->技术-->数据库结构-->小数准确性,设置想要的精度