diff --git a/addons/delivery/stock.py b/addons/delivery/stock.py index 8e7b5836355..6f2d2a07ca0 100644 --- a/addons/delivery/stock.py +++ b/addons/delivery/stock.py @@ -147,10 +147,6 @@ class stock_move(osv.osv): weight = weight_net = 0.00 if move.product_id.weight > 0.00: converted_qty = move.product_qty - - if move.product_uom.id <> move.product_id.uom_id.id: - converted_qty = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, move.product_id.uom_id.id) - weight = (converted_qty * move.product_id.weight) if move.product_id.weight_net > 0.00: @@ -165,11 +161,11 @@ class stock_move(osv.osv): _columns = { 'weight': fields.function(_cal_move_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight', store={ - 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_qty', 'product_uom'], 20), + 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_uom_qty', 'product_uom'], 30), }), 'weight_net': fields.function(_cal_move_weight, type='float', string='Net weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight', store={ - 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_qty', 'product_uom'], 20), + 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_uom_qty', 'product_uom'], 30), }), 'weight_uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True,readonly="1",help="Unit of Measure (Unit of Measure) is the unit of measurement for Weight",), } diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 850f8c22eda..5add8703614 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1097,6 +1097,7 @@ class mrp_production(osv.osv): def _make_consume_line_from_data(self, cr, uid, production, product, uom_id, qty, uos_id, uos_qty, context=None): stock_move = self.pool.get('stock.move') + loc_obj = self.pool.get('stock.location') # Internal shipment is created for Stockable and Consumer Products if product.type not in ('product', 'consu'): return False @@ -1107,7 +1108,7 @@ class mrp_production(osv.osv): if production.bom_id.routing_id and production.bom_id.routing_id.location_id and production.bom_id.routing_id.location_id.id != source_location_id: source_location_id = production.bom_id.routing_id.location_id.id prev_move = True - + destination_location_id = production.product_id.property_stock_production.id move_id = stock_move.create(cr, uid, { 'name': production.name, @@ -1125,6 +1126,7 @@ class mrp_production(osv.osv): #this saves us a browse in create() 'price_unit': product.standard_price, 'origin': production.name, + 'warehouse_id': loc_obj.get_warehouse(cr, uid, production.location_src_id, context=context), }, context=context) if prev_move: diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 160bd2e0c3d..9240c369a0e 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -383,7 +383,6 @@ - diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 04f4ef8b4ef..2015b11d7c2 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -519,7 +519,7 @@ class ProductChangeMixin(object): partner = self.pool.get('res.partner').browse(cr, uid, partner_id) result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner.property_account_position, product_obj.taxes_id) - result['name'] = product_obj.partner_ref + result['name'] = product_obj.display_name result['product_uom'] = product_obj.uom_id and product_obj.uom_id.id or False if not pricelist: warning = { diff --git a/addons/product/product.py b/addons/product/product.py index cc8d1affb3a..c36fb278537 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -1007,9 +1007,10 @@ class product_product(osv.osv): sellers = filter(lambda x: x.name.id == partner_id, product.seller_ids) if sellers: for s in sellers: + seller_variant = s.product_name and "%s (%s)" % (s.product_name, variant) or False mydict = { 'id': product.id, - 'name': s.product_name or name, + 'name': seller_variant or name, 'default_code': s.product_code or product.default_code, } result.append(_name_get(mydict)) diff --git a/addons/product_extended/product_extended.py b/addons/product_extended/product_extended.py index 6ed71c6873a..14383704b34 100644 --- a/addons/product_extended/product_extended.py +++ b/addons/product_extended/product_extended.py @@ -36,15 +36,15 @@ class product_product(osv.osv): testdict = {} for prod_id in ids: bom_obj = self.pool.get('mrp.bom') - bom_ids = bom_obj.search(cr, uid, [('product_id','=', prod_id), ('bom_line_ids', '!=', False)], context=context) - if bom_ids: - bom_id = bom_ids[0] + bom_id = bom_obj._bom_find(cr, uid, False, product_id = prod_id, context=context) + if bom_id: # In recursive mode, it will first compute the prices of child boms if recursive: #Search the products that are components of this bom of prod_id - boms = bom_obj.search(cr, uid, [('bom_id', '=', bom_id)], context=context) + bom = bom_obj.browse(cr, uid, bom_id, context=context) + #Call compute_price on these subproducts - prod_set = set([x.product_id.id for x in bom_obj.browse(cr, uid, boms, context=context)]) + prod_set = set([x.product_id.id for x in bom.bom_line_ids]) res = self.compute_price(cr, uid, list(prod_set), recursive=recursive, test=test, real_time_accounting = real_time_accounting, context=context) if test: testdict.update(res) @@ -63,10 +63,10 @@ class product_product(osv.osv): context={} price = 0 uom_obj = self.pool.get("product.uom") - if bom.bom_line_ids: - for sbom in bom.bom_line_ids: - my_qty = sbom.bom_line_ids and 1.0 or sbom.product_qty - price += uom_obj._compute_price(cr, uid, sbom.product_id.uom_id.id, sbom.product_id.standard_price, sbom.product_uom.id) * my_qty + tmpl_obj = self.pool.get('product.template') + for sbom in bom.bom_line_ids: + my_qty = sbom.product_qty + price += uom_obj._compute_price(cr, uid, sbom.product_id.uom_id.id, sbom.product_id.standard_price, sbom.product_uom.id) * my_qty if bom.routing_id: for wline in bom.routing_id.workcenter_lines: @@ -79,15 +79,16 @@ class product_product(osv.osv): #Convert on product UoM quantities if price > 0: price = uom_obj._compute_price(cr, uid, bom.product_uom.id, price / bom.product_qty, bom.product_id.uom_id.id) - product = self.pool.get("product.product").browse(cr, uid, bom.product_id.id, context=context) + + product = tmpl_obj.browse(cr, uid, bom.product_tmpl_id.id, context=context) if not test: if (product.valuation != "real_time" or not real_time_accounting): - self.write(cr, uid, [bom.product_id.id], {'standard_price' : price}, context=context) + tmpl_obj.write(cr, uid, [product.id], {'standard_price' : price}, context=context) else: #Call wizard function here wizard_obj = self.pool.get("stock.change.standard.price") ctx = context.copy() - ctx.update({'active_id': bom.product_id.id}) + ctx.update({'active_id': product.id, 'active_model': 'product.template'}) wiz_id = wizard_obj.create(cr, uid, {'new_price': price}, context=ctx) wizard_obj.change_price(cr, uid, [wiz_id], context=ctx) return price diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index be2803261e7..97f0861ef31 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -679,12 +679,12 @@ class purchase_order(osv.osv): def action_cancel(self, cr, uid, ids, context=None): for purchase in self.browse(cr, uid, ids, context=context): for pick in purchase.picking_ids: - if pick.state not in ('draft', 'cancel'): - raise osv.except_osv( - _('Unable to cancel the purchase order %s.') % (purchase.name), - _('First cancel all receipts related to this purchase order.')) - self.pool.get('stock.picking') \ - .signal_workflow(cr, uid, map(attrgetter('id'), purchase.picking_ids), 'button_cancel') + for move in pick.move_lines: + if pick.state == 'done': + raise osv.except_osv( + _('Unable to cancel the purchase order %s.') % (purchase.name), + _('You have already received some goods for it. ')) + self.pool.get('stock.picking').action_cancel(cr, uid, [x.id for x in purchase.picking_ids if x.state != 'cancel'], context=context) for inv in purchase.invoice_ids: if inv and inv.state not in ('cancel', 'draft'): raise osv.except_osv( @@ -692,10 +692,6 @@ class purchase_order(osv.osv): _('You must first cancel all invoices related to this purchase order.')) self.pool.get('account.invoice') \ .signal_workflow(cr, uid, map(attrgetter('id'), purchase.invoice_ids), 'invoice_cancel') - self.pool['purchase.order.line'].write(cr, uid, [l.id for l in purchase.order_line], - {'state': 'cancel'}) - self.write(cr, uid, ids, {'state': 'cancel'}) - self.set_order_line_status(cr, uid, ids, 'cancel', context=context) self.signal_workflow(cr, uid, ids, 'purchase_cancel') return True @@ -1156,6 +1152,7 @@ class purchase_order_line(osv.osv): self.write(cr, uid, ids, {'state': 'confirmed'}, context=context) return True + class procurement_rule(osv.osv): _inherit = 'procurement.rule' @@ -1287,7 +1284,7 @@ class procurement_order(osv.osv): product = prod_obj.browse(cr, uid, procurement.product_id.id, context=new_context) taxes_ids = procurement.product_id.supplier_taxes_id taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids) - name = product.partner_ref + name = product.display_name if product.description_purchase: name += '\n' + product.description_purchase diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 239bc990ff2..1ccd8af6011 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -202,8 +202,7 @@