From cc3dfdd3c09077da966eeab913cfe71d25481050 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 3 Sep 2013 15:46:00 +0200 Subject: [PATCH] [IMP] Change warehouse to picking_type_id on purchase + put destination address after picking type + adapt packaging bzr revid: jco@openerp.com-20130903134600-7jraor07pqp8ijpo --- addons/purchase/board_purchase_view.xml | 1 - addons/purchase/purchase.py | 11 +++++------ addons/purchase/purchase_data.xml | 2 +- addons/purchase/purchase_view.xml | 14 +++++++------- addons/purchase/report/purchase_report.py | 6 +++--- addons/purchase/report/purchase_report_view.xml | 8 ++++---- addons/purchase/stock_view.xml | 3 --- addons/stock/stock.py | 2 +- 8 files changed, 21 insertions(+), 26 deletions(-) diff --git a/addons/purchase/board_purchase_view.xml b/addons/purchase/board_purchase_view.xml index d491985cf52..77d4e310b60 100644 --- a/addons/purchase/board_purchase_view.xml +++ b/addons/purchase/board_purchase_view.xml @@ -26,7 +26,6 @@ - diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index e2e4da3ba63..84c915bd130 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -188,7 +188,6 @@ class purchase_order(osv.osv): help="Put an address if you want to deliver directly from the supplier to the customer. " \ "Otherwise, keep empty to deliver to your own company." ), - 'warehouse_id': fields.many2one('stock.warehouse', 'Destination Warehouse'), 'location_id': fields.many2one('stock.location', 'Destination', required=True, domain=[('usage','<>','view')], states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]} ), 'pricelist_id':fields.many2one('product.pricelist', 'Pricelist', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}, help="The pricelist sets the currency used for this purchase order. It also computes the supplier price for the selected products/quantities."), 'currency_id': fields.many2one('res.currency','Currency', readonly=True, required=True,states={'draft': [('readonly', False)],'sent': [('readonly', False)]}), @@ -234,7 +233,8 @@ 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", required=True), + 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="This will determine picking type of incoming shipment", required=True, + states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}), 'related_location_id':fields.related('picking_type_id', 'default_location_dest_id', type='many2one', relation='stock.location', string="Related location", store=True), } _defaults = { @@ -302,7 +302,7 @@ class purchase_order(osv.osv): if not address_id: return {} address = self.pool.get('res.partner') - values = {'warehouse_id': False} + values = {} supplier = address.browse(cr, uid, address_id) if supplier: location_id = supplier.property_stock_customer.id @@ -861,7 +861,7 @@ class purchase_order(osv.osv): 'date_order': porder.date_order, 'partner_id': porder.partner_id.id, 'dest_address_id': porder.dest_address_id.id, - 'warehouse_id': porder.warehouse_id.id, + 'picking_type_id': porder.picking_type_id.id, 'location_id': porder.location_id.id, 'pricelist_id': porder.pricelist_id.id, 'state': 'draft', @@ -1247,7 +1247,6 @@ class procurement_order(osv.osv): partner_id = partner.id address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] pricelist_id = partner.property_product_pricelist_purchase.id - warehouse_id = warehouse_obj.search(cr, uid, [('company_id', '=', procurement.company_id.id or company.id)], context=context) uom_id = procurement.product_id.uom_po_id.id qty = uom_obj._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id) if seller_qty: @@ -1283,7 +1282,7 @@ class procurement_order(osv.osv): 'origin': procurement.origin, 'partner_id': partner_id, 'location_id': procurement.location_id.id, - 'warehouse_id': warehouse_id and warehouse_id[0] or False, + 'picking_type_id': procurement.rule_id.picking_type_id.id, 'pricelist_id': pricelist_id, 'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT), 'company_id': procurement.company_id.id, diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index afd9560e350..ed8e01634ac 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -44,7 +44,7 @@ diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 9bd65cc49e7..19cb68fe76a 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -196,9 +196,13 @@ - - + + + @@ -241,11 +245,7 @@ - - + diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index faf5b89df45..7c57f8e3c00 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -42,7 +42,7 @@ class purchase_report(osv.osv): ('done', 'Done'), ('cancel', 'Cancelled')],'Order Status', readonly=True), 'product_id':fields.many2one('product.product', 'Product', readonly=True), - 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', readonly=True), + 'picking_type_id': fields.many2one('stock.warehouse', 'Warehouse', readonly=True), 'location_id': fields.many2one('stock.location', 'Destination', readonly=True), 'partner_id':fields.many2one('res.partner', 'Supplier', readonly=True), 'pricelist_id':fields.many2one('product.pricelist', 'Pricelist', readonly=True), @@ -82,7 +82,7 @@ class purchase_report(osv.osv): s.dest_address_id, s.pricelist_id, s.validator, - s.warehouse_id as warehouse_id, + s.picking_type_id as picking_type_id, s.partner_id as partner_id, s.create_uid as user_id, s.company_id as company_id, @@ -128,7 +128,7 @@ class purchase_report(osv.osv): to_char(s.date_order, 'MM'), to_char(s.date_order, 'YYYY-MM-DD'), s.state, - s.warehouse_id, + s.picking_type_id, u.uom_type, u.category_id, t.uom_id, diff --git a/addons/purchase/report/purchase_report_view.xml b/addons/purchase/report/purchase_report_view.xml index 211f3e9a31a..60bf0885ed9 100644 --- a/addons/purchase/report/purchase_report_view.xml +++ b/addons/purchase/report/purchase_report_view.xml @@ -28,7 +28,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -72,9 +72,9 @@ - + - + diff --git a/addons/purchase/stock_view.xml b/addons/purchase/stock_view.xml index a924a5c341e..18ad626b84b 100644 --- a/addons/purchase/stock_view.xml +++ b/addons/purchase/stock_view.xml @@ -20,9 +20,6 @@ - - - diff --git a/addons/stock/stock.py b/addons/stock/stock.py index ffc1570b67f..0457676e249 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -774,7 +774,7 @@ class stock_picking(osv.osv): quant_obj.quants_reserve(cr, uid, quants, move, context=context) #In the end, move quants in correct package 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) + quant_obj.write(cr, uid, [x[0].id 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