Add unit_digits and use it
This commit is contained in:
1 parent
26c5d4dd8c
commit
87a98018d5
3 files changed
+21
No files matched your search
BIN
Binary file not shown.
+18
@@ -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 = {}
|
||||
|
||||
@@ -199,6 +199,7 @@
|
||||
<field name="taxes"/>
|
||||
<field name="amount"/>
|
||||
<field name="sequence" tree_invisible="1"/>
|
||||
<field name="unit_digits" tree_invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group col="1" colspan="2">
|
||||
@@ -529,6 +530,7 @@
|
||||
<field name="amount"/>
|
||||
<separator name="taxes" colspan="4"/>
|
||||
<field name="taxes" colspan="4"/>
|
||||
<field name="unit_digits" invisible="1"/>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
@@ -549,6 +551,7 @@
|
||||
<field name="unit_price" select="2"/>
|
||||
<field name="taxes"/>
|
||||
<field name="amount"/>
|
||||
<field name="unit_digits" tree_invisible="1"/>
|
||||
</tree>
|
||||
]]>
|
||||
</field>
|
||||
|
||||
Reference in new issue
Block a user