From 556c7f03f0e469e8d0702ba0baa30fd71cde7828 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 29 Nov 2013 15:35:22 +0100 Subject: [PATCH] [FIX] purchase: revert revision 7677 to set a default unit of measure to 'Unit' This allows to field a purchase.order without showing the units of measure if not product is selected Revision 7677 was integrated to fix lp:958897 (no change of uom when selecting a product whose uom is in the category 'Units'). This fix did not solve it properly (only for initial value) and introduced another problem. A better fix will be done on the onchange product. bzr revid: mat@openerp.com-20131129143522-i85e4hvf0p4h3ynn --- addons/purchase/purchase.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 10d8a34ba74..4aa59744a12 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -853,6 +853,14 @@ class purchase_order_line(osv.osv): res[line.id] = cur_obj.round(cr, uid, cur, taxes['total']) return res + def _get_uom_id(self, cr, uid, context=None): + try: + proxy = self.pool.get('ir.model.data') + result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit') + return result[1] + except Exception, ex: + return False + _columns = { 'name': fields.text('Description', required=True), 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True), @@ -879,6 +887,7 @@ class purchase_order_line(osv.osv): } _defaults = { + 'product_uom' : _get_uom_id, 'product_qty': lambda *a: 1.0, 'state': lambda *args: 'draft', 'invoiced': lambda *a: 0,