From b9e31237647a98e344b392db4d2731e9e2bbf25b Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Thu, 29 Aug 2013 09:35:16 +0200 Subject: [PATCH] [IMP]purchase: add picking_type field and set it by default as picking in bzr revid: csn@openerp.com-20130829073516-48qqx63o897ins11 --- addons/purchase/purchase.py | 8 +++++++- addons/purchase/purchase_view.xml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 79df9f31103..660b70a488c 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -150,6 +150,10 @@ class purchase_order(osv.osv): limit=1) return res and res[0] or False + def _get_picking_in(self, cr, uid, context=None): + obj_data = self.pool.get('ir.model.data') + return obj_data.get_object_reference(cr, uid, 'stock','picking_type_in')[1] + STATE_SELECTION = [ ('draft', 'Draft PO'), ('sent', 'RFQ Sent'), @@ -230,6 +234,7 @@ class purchase_order(osv.osv): 'journal_id': fields.many2one('account.journal', 'Journal'), '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"), } _defaults = { 'date_order': fields.date.context_today, @@ -241,7 +246,8 @@ class purchase_order(osv.osv): 'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=c), 'journal_id': _get_journal, - 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id + 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id, + 'picking_type_id': _get_picking_in, } _sql_constraints = [ ('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'), diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index e3af7bd6243..973757770c4 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -198,6 +198,7 @@ +