diff --git a/invoice.odt b/invoice.odt index d5f8c4c2c6..e7ff20cb22 100644 Binary files a/invoice.odt and b/invoice.odt differ diff --git a/invoice.py b/invoice.py index 066302c019..1f5a65be6d 100644 --- a/invoice.py +++ b/invoice.py @@ -1243,6 +1243,7 @@ class InvoiceLine(OSV): ('comment', 'Comment'), ], 'Type', select=1, required=True) quantity = fields.Float('Quantity', + digits="(16, unit_digits)", states={ 'invisible': "type != 'line'", 'required': "type == 'line'", @@ -1252,6 +1253,8 @@ class InvoiceLine(OSV): 'required': "product", 'invisible': "type != 'line'", }, domain="[('category', '=', (product, 'product'))]") + unit_digits = fields.Function('get_unit_digits', type='integer', + string='Unit Digits', on_change_with=['unit']) product = fields.Many2One('product.product', 'Product', states={ 'invisible': "type != 'line'", @@ -1329,6 +1332,21 @@ class InvoiceLine(OSV): (vals.get('unit_price') or Decimal('0.0'))) return Decimal('0.0') + def on_change_with_unit_digits(self, cursor, user, ids, vals, + context=None): + uom_obj = self.pool.get('product.uom') + if vals.get('unit'): + uom = uom_obj.browse(cursor, user, vals['unit'], + context=context) + return uom.digits + return 2 + + def get_unit_digits(self, cursor, user, ids, name, arg, context=None): + res = {} + for line in self.browse(cursor, user, ids, context=context): + res[line.id] = line.unit.digits + return res + def get_amount(self, cursor, user, ids, name, arg, context=None): currency_obj = self.pool.get('currency.currency') res = {} diff --git a/invoice.xml b/invoice.xml index c70f371b9d..505e0ef0cb 100644 --- a/invoice.xml +++ b/invoice.xml @@ -199,6 +199,7 @@ + @@ -529,6 +530,7 @@ + ]]> @@ -549,6 +551,7 @@ + ]]>