diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py index a0bb133dd46..94b40dfd1c9 100644 --- a/addons/purchase/__openerp__.py +++ b/addons/purchase/__openerp__.py @@ -83,8 +83,8 @@ Dashboard / Reports for Purchase Management will include: 'test/average_price.yml', ], 'demo': [ - 'purchase_order_demo.yml', - 'purchase_demo.xml', + #'purchase_order_demo.yml', + #'purchase_demo.xml', ], 'installable': True, 'auto_install': False, diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index d0876df7ef1..e2e4da3ba63 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -235,6 +235,7 @@ class purchase_order(osv.osv): 'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"), 'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"), 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="This will determine picking type of incoming shipment", required=True), + 'related_location_id':fields.related('picking_type_id', 'default_location_dest_id', type='many2one', relation='stock.location', string="Related location", store=True), } _defaults = { 'date_order': fields.date.context_today, @@ -308,6 +309,16 @@ class purchase_order(osv.osv): values.update({'location_id': location_id}) return {'value':values} + def onchange_picking_type_id(self, cr, uid, ids, picking_type_id, context=None): + value = {} + if picking_type_id: + picktype = self.pool.get("stock.picking.type").browse(cr, uid, picking_type_id, context=context) + if picktype.default_location_dest_id: + value.update({'location_id': picktype.default_location_dest_id.id}) + value.update({'related_location_id': picktype.default_location_dest_id and picktype.default_location_dest_id.id or False}) + return {'value': value} + + def onchange_partner_id(self, cr, uid, ids, partner_id): partner = self.pool.get('res.partner') if not partner_id: diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index f152d5ba066..9bd65cc49e7 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -198,7 +198,7 @@ - + @@ -241,7 +241,11 @@ - + + diff --git a/addons/stock/stock.py b/addons/stock/stock.py index bfe1af7caa3..fea4a3286f9 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -773,8 +773,8 @@ class stock_picking(osv.osv): quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order=prefered_order, context=context) quant_obj.quants_reserve(cr, uid, quants, move, context=context) #In the end, move quants in correct package - if create and ops.result_package_id: - quant_obj.write(cr, uid, [x[0] for x in quants], {'package_id': ops.result_package_id.id}, context=context) + if create: + quant_obj.write(cr, uid, [x[0] for x in quants], {'package_id': ops.result_package_id and ops.result_package_id.id or False}, context=context) res2[move.id] -= qty res[ops.id] = {} res[ops.id][ops.product_id.id] = qty_to_do @@ -796,8 +796,8 @@ class stock_picking(osv.osv): res.setdefault(ops.id, {}).setdefault(quant.product_id.id, 0.0) res[ops.id][quant.product_id.id] += qty_to_do #Add parent package - if create and ops.result_package_id: - self.pool.get("stock.package").write(cr, uid, [ops.package_id.id], {'parent_id': ops.result_package_id.id}, context=context) + if create: + self.pool.get("stock.package").write(cr, uid, [ops.package_id.id], {'parent_id': ops.result_package_id and ops.result_package_id.id or False}, context=context) return (res, res2) diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py index bedf59baf1e..78e9ea694cc 100644 --- a/addons/stock_location/stock_location.py +++ b/addons/stock_location/stock_location.py @@ -168,13 +168,10 @@ class procurement_order(osv.osv): def _search_suitable_rule(self, cr, uid, procurement, domain, context=None): '''we try to first find a rule among the ones defined on the procurement order group and if none is found, we try on the routes defined for the product, and finally we fallback on the default behavior''' - route_ids = [x.id for x in procurement.route_ids] + route_ids = [x.id for x in procurement.route_ids] + [x.id for x in procurement.product_id.route_ids] res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], order = 'route_sequence, sequence', context=context) if not res: - route_ids = [x.id for x in procurement.product_id.route_ids] - res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], order = 'route_sequence, sequence', context=context) - if not res: - res = self.pool.get('procurement.rule').search(cr, uid, domain, order='sequence', context=context) + res = self.pool.get('procurement.rule').search(cr, uid, domain, order='sequence', context=context) return res