diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index bdd8af1afd8..09cc4c301a4 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1310,6 +1310,7 @@ class procurement_order(osv.osv): if available_draft_po_ids: po_id = available_draft_po_ids[0] po_rec = po_obj.browse(cr, uid, po_id, context=context) + #if the product has to be ordered earlier those in the existing PO, we replace the purchase date on the order to avoid ordering it too late if datetime.strptime(po_rec.date_order, DEFAULT_SERVER_DATE_FORMAT) > purchase_date: po_obj.write(cr, uid, [po_id], {'date_order': purchase_date}, context=context) #look for any other PO line in the selected PO with same product and UoM to sum quantities instead of creating a new po line @@ -1369,8 +1370,11 @@ class product_template(osv.Model): _inherit = 'product.template' def _get_buy_route(self, cr, uid, context=None): - buy_route = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'purchase', 'route_warehouse0_buy')[1] - return [buy_route] + + buy_route = self.pool.get('ir.model.data').xmlid_to_res_id(cr, uid, 'purchase.route_warehouse0_buy') + if buy_route: + return [buy_route] + return [] def _purchase_count(self, cr, uid, ids, field_name, arg, context=None): res = dict.fromkeys(ids, 0) diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 40689551195..26d2ff1002f 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -79,9 +79,7 @@ class stock_move(osv.osv): if move.purchase_line_id: purchase_line = move.purchase_line_id res['invoice_line_tax_id'] = [(6, 0, [x.id for x in purchase_line.taxes_id])] - #res['account_analytic_id'] = purc_line.order_id.project_id and sale_line.order_id.project_id.id or False res['price_unit'] = purchase_line.price_unit - #res['discount'] = sale_line.discount return res class stock_picking(osv.osv): diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py index e9a4a46e3d0..7a835fb2f4d 100644 --- a/addons/stock/procurement.py +++ b/addons/stock/procurement.py @@ -346,10 +346,7 @@ class procurement_order(osv.osv): procurement_obj = self.pool.get('procurement.order') offset = 0 ids = [1] - if company_id: - dom = [('company_id', '=', company_id)] - else: - dom = [] + dom = company_id and [('company_id', '=', company_id)] or False while ids: ids = orderpoint_obj.search(cr, uid, dom, offset=offset, limit=100) for op in orderpoint_obj.browse(cr, uid, ids, context=context): diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 9c5310dcd6b..7e529b9047a 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -3823,7 +3823,7 @@ class stock_pack_operation(osv.osv): if pack_op.qty_done < pack_op.product_qty: # we split the operation in two op = self.copy(cr, uid, pack_op.id, {'product_qty': pack_op.qty_done, 'qty_done': pack_op.qty_done}, context=context) - self.write(cr, uid, pack_op.id, {'product_qty': pack_op.product_qty - pack_op.qty_done, 'qty_done': 0, 'lot_id': False}, context=context) + self.write(cr, uid, [pack_op.id], {'product_qty': pack_op.product_qty - pack_op.qty_done, 'qty_done': 0, 'lot_id': False}, context=context) processed_ids.append(op) self.write(cr, uid, processed_ids, {'processed': 'true'}, context=context)