← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/rpa-dev-addons2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons2

 

rpa (Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/rpa-dev-addons2 into lp:~openerp-dev/openobject-addons/trunk-dev-addons2.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  #511193 unit factor is limited to 5 zeros
  https://bugs.launchpad.net/bugs/511193
  #664344 Unclear help texts in product_expiry
  https://bugs.launchpad.net/bugs/664344
  #666781 useless list comprehension and browse in split_moves
  https://bugs.launchpad.net/bugs/666781
  #667558 product_visible_discount uses discount in changing UoM in sale order of OpenERP v6.0 rc1
  https://bugs.launchpad.net/bugs/667558


Bugs fixing for product, stock and purchase.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/rpa-dev-addons2/+merge/40086
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/rpa-dev-addons2.
=== modified file 'product/product.py'
--- product/product.py	2010-10-27 12:59:05 +0000
+++ product/product.py	2010-11-04 13:12:03 +0000
@@ -69,7 +69,7 @@
         'name': fields.char('Name', size=64, required=True, translate=True),
         'category_id': fields.many2one('product.uom.categ', 'UoM Category', required=True, ondelete='cascade',
             help="Quantity conversions may happen automatically between Units of Measure in the same category, according to their respective ratios."),
-        'factor': fields.float('Ratio', required=True,digits=(12, 6),
+        'factor': fields.float('Ratio', required=True,digits=(12, 12),
             help='How many times this UoM is smaller than the reference UoM in this category:\n'\
                     '1 * (reference unit) = ratio * (this unit)'),
         'factor_inv': fields.function(_factor_inv, digits_compute=dp.get_precision('Product UoM'),
@@ -342,7 +342,7 @@
 
     def _product_price(self, cr, uid, ids, name, arg, context={}):
         res = {}
-        quantity = context.get('quantity', 1)
+        quantity = context.get('quantity') or 1.0
         pricelist = context.get('pricelist', False)
         if pricelist:
             for id in ids:

=== modified file 'product_expiry/product_expiry.py'
--- product_expiry/product_expiry.py	2010-10-19 07:36:28 +0000
+++ product_expiry/product_expiry.py	2010-11-04 13:12:03 +0000
@@ -45,19 +45,19 @@
 
     _columns = {
         'life_date': fields.datetime('End of Life Date',
-            help='The date the lot may become dangerous and should not be consumed.'),
+            help='The date on which the lot may become dangerous and should not be consumed.'),
         'use_date': fields.datetime('Best before Date',
-            help='The date the lot starts deteriorating without becoming dangerous.'),
+            help='The date on which the lot starts deteriorating without becoming dangerous.'),
         'removal_date': fields.datetime('Removal Date',
-            help='The date the lot should be removed.'),
-        'alert_date': fields.datetime('Alert Date', help="The date signifying an alert to notify about the production lot."),
+            help='The date on which the lot should be removed.'),
+        'alert_date': fields.datetime('Alert Date', help="The date on which an alert should be notified about the production lot."),
     }
     # Assign dates according to products data
     def create(self, cr, uid, vals, context=None):
         newid = super(stock_production_lot, self).create(cr, uid, vals, context=context)
         obj = self.browse(cr, uid, newid, context=context)
         towrite = []
-        for f in ('life_date','use_date','removal_date','alert_date'):
+        for f in ('life_date', 'use_date', 'removal_date', 'alert_date'):
             if not getattr(obj, f):
                 towrite.append(f)
         context = context or {}
@@ -82,8 +82,7 @@
             help='The number of days before a production lot starts deteriorating without becoming dangerous.'),
         'removal_time': fields.integer('Product Removal Time',
             help='The number of days before a production lot should be removed.'),
-        'alert_time': fields.integer('Product Alert Time', help="The number of days after which, needs an alert to notify about the production lot."),
+        'alert_time': fields.integer('Product Alert Time', help="The number of days after which an alert should be notified about the production lot."),
     }
 product_product()
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-

=== modified file 'product_visible_discount/product_visible_discount.py'
--- product_visible_discount/product_visible_discount.py	2010-08-17 06:27:57 +0000
+++ product_visible_discount/product_visible_discount.py	2010-11-04 13:12:03 +0000
@@ -43,7 +43,7 @@
             uom=False, qty_uos=0, uos=False, name='', partner_id=False,
             lang=False, update_tax=True,date_order=False,packaging=False,fiscal_position=False, flag=False):
 
-        def get_real_price(res_dict, product_id, pricelist):
+        def get_real_price(res_dict, product_id, qty, uom, pricelist):
             item_obj = self.pool.get('product.pricelist.item')
             price_type_obj = self.pool.get('product.price.type')
             product_obj = self.pool.get('product.product')
@@ -56,10 +56,17 @@
                 if item_base > 0:
                     field_name = price_type_obj.browse(cr, uid, item_base).field
 
-            product_tmpl_id = product_obj.browse(cr, uid, product_id, context).product_tmpl_id.id
+            product = product_obj.browse(cr, uid, product_id, context)
+            product_tmpl_id = product.product_tmpl_id.id
 
             product_read = template_obj.read(cr, uid, product_tmpl_id, [field_name], context)
-            return product_read[field_name]
+            
+            factor = 1.0
+            if uom and uom != product.uom_id.id:
+                product_uom_obj = self.pool.get('product.uom')
+                uom_data = product_uom_obj.browse(cr, uid,  product.uom_id.id)
+                factor = uom_data.factor
+            return product_read[field_name] * factor
 
 
         res=super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty,
@@ -84,7 +91,7 @@
             pricelists = pricelist_obj.read(cr,uid,[pricelist],['visible_discount'])
 
             old_uom = product.uos_id or product.uom_id
-            new_list_price = get_real_price(list_price, product.id, pricelist)
+            new_list_price = get_real_price(list_price, product.id, qty, uom, pricelist)
             if(len(pricelists)>0 and pricelists[0]['visible_discount'] and list_price[pricelist] != 0):
                 discount = (new_list_price - price) / new_list_price * 100
                 result['price_unit'] = new_list_price
@@ -101,7 +108,7 @@
     def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context={}):
         res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context)
 
-        def get_real_price(res_dict, product_id, pricelist):
+        def get_real_price(res_dict, product_id, qty, uom, pricelist):
             item_obj = self.pool.get('product.pricelist.item')
             price_type_obj = self.pool.get('product.price.type')
             product_obj = self.pool.get('product.product')
@@ -114,10 +121,17 @@
                 if item_base > 0:
                     field_name = price_type_obj.browse(cr, uid, item_base).field
 
-            product_tmpl_id = product_obj.browse(cr, uid, product_id, context).product_tmpl_id.id
+            product = product_obj.browse(cr, uid, product_id, context)
+            product_tmpl_id = product.product_tmpl_id.id
 
             product_read = template_obj.read(cr, uid, product_tmpl_id, [field_name], context)
-            return product_read[field_name]
+
+            factor = 1.0
+            if uom and uom != product.uom_id.id:
+                product_uom_obj = self.pool.get('product.uom')
+                uom_data = product_uom_obj.browse(cr, uid,  product.uom_id.id)
+                factor = uom_data.factor
+            return product_read[field_name] * factor
 
         if product:
             pricelist_obj = self.pool.get('product.pricelist')
@@ -133,7 +147,7 @@
                         raise osv.except_osv(_('No Purchase Pricelist Found !'),_("You must first define a pricelist for Supplier !"))
                     price_unit_res = pricelist_obj.price_get(cr, uid, [pricelist], product.id, qty or 1.0, partner_id, {'uom': uom})[pricelist]
                     price_unit = price_unit_res[pricelist]
-                    real_price = get_real_price(price_unit_res, product.id, pricelist)
+                    real_price = get_real_price(price_unit_res, product.id, qty, uom, pricelist)
             else:
                 if partner_id:
                     pricelist = partner_obj.browse(cr, uid, partner_id).property_product_pricelist.id
@@ -142,7 +156,7 @@
                     price_unit_res = pricelist_obj.price_get(cr, uid, [pricelist], product.id, qty or 1.0, partner_id, {'uom': uom})
                     price_unit = price_unit_res[pricelist]
 
-                    real_price = get_real_price(price_unit_res, product.id, pricelist)
+                    real_price = get_real_price(price_unit_res, product.id, qty, uom, pricelist)
             if pricelist:
                 pricelists=pricelist_obj.read(cr,uid,[pricelist],['visible_discount'])
                 if(len(pricelists)>0 and pricelists[0]['visible_discount'] and real_price != 0):

=== modified file 'purchase/purchase.py'
--- purchase/purchase.py	2010-11-04 12:53:29 +0000
+++ purchase/purchase.py	2010-11-04 13:12:03 +0000
@@ -643,8 +643,8 @@
         if not  partner_id:
             raise osv.except_osv(_('No Partner!'), _('You have to select a partner in the purchase form !\nPlease set one partner before choosing a product.'))
         if not product:
-            return {'value': {'price_unit': price_unit or 0.0, 'name': name or '',
-                'notes': notes or'', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}}
+            return {'value': {'price_unit': 0.0, 'name': '', 'product_qty': 1.0, 'date_planned': False, 
+                'notes': '', 'product_uom' : False}, 'domain':{'product_uom':[]}}
         prod= self.pool.get('product.product').browse(cr, uid, product)
         lang=False
         if partner_id:
@@ -681,7 +681,7 @@
         res = {'value': {'price_unit': price, 'name': name or prod_name,
             'taxes_id':map(lambda x: x.id, prod.supplier_taxes_id),
             'date_planned': date_planned or dt,'notes': notes or prod.description_purchase,
-            'product_qty': qty,
+            'product_qty': qty or 1.0,
             'product_uom': uom}}
         domain = {}
 

=== modified file 'stock/wizard/stock_return_picking.py'
--- stock/wizard/stock_return_picking.py	2010-10-15 13:42:15 +0000
+++ stock/wizard/stock_return_picking.py	2010-11-04 13:12:03 +0000
@@ -149,10 +149,9 @@
         new_picking = None
         date_cur = time.strftime('%Y-%m-%d %H:%M:%S')
     
-        move_ids = [m.id for m in [line for line in pick.move_lines]]
         set_invoice_state_to_none = True
         returned_lines = 0
-        for move in move_obj.browse(cr, uid, move_ids):
+        for move in pick.move_lines:
             if not new_picking:
                 if pick.type=='out':
                     new_type = 'in'

=== modified file 'stock/wizard/stock_split_move.py'
--- stock/wizard/stock_split_move.py	2010-05-26 12:59:30 +0000
+++ stock/wizard/stock_split_move.py	2010-11-04 13:12:03 +0000
@@ -104,8 +104,7 @@
         pick_obj = self.pool.get('stock.picking')
         pick = pick_obj.browse(cr, uid, record_id, context=context)
         data = self.read(cr, uid, ids[0])
-        move_ids = [m.id for m in [line for line in pick.move_lines]]
-        for move in move_obj.browse(cr, uid, move_ids, context=context):
+        for move in pick.move_lines:
             quantity = data['move%s' % move.id]
             if 0 < quantity < move.product_qty:
                 new_qty = move.product_qty - quantity


Follow ups