From 6ea0cc41b93f27d4698993e63c9b3248c9de29fa Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 22 Dec 2014 17:28:51 +0100 Subject: [PATCH] [FIX] Drop shipping invoice correction When invoicing from dropshipping picking, choose the correct partner. Also, change the partner on the picking to be the partner of the purchase. Change the picking report to include the destination partner or the warehouse address on the right. [IMP] Only put partner_id on move from purchase when really necessary [FIX] Default value of partner on stock move should be False --- addons/purchase/purchase.py | 4 +- addons/sale_stock/sale_stock.py | 4 +- addons/stock/stock.py | 3 +- addons/stock/views/report_stockpicking.xml | 55 ++++++++++++++-------- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 8a39ce82e10..34b6fec6cca 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -725,7 +725,7 @@ class purchase_order(osv.osv): 'location_id': order.partner_id.property_stock_supplier.id, 'location_dest_id': order.location_id.id, 'picking_id': picking_id, - 'partner_id': order.dest_address_id.id or order.partner_id.id, + 'partner_id': order.dest_address_id.id, 'move_dest_id': False, 'state': 'draft', 'purchase_line_id': order_line.id, @@ -831,7 +831,7 @@ class purchase_order(osv.osv): for order in self.browse(cr, uid, ids): picking_vals = { 'picking_type_id': order.picking_type_id.id, - 'partner_id': order.dest_address_id.id or order.partner_id.id, + 'partner_id': order.partner_id.id, 'date': max([l.date_planned for l in order.order_line]), 'origin': order.name } diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index acad6b5d805..66e01cd99a5 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -371,7 +371,7 @@ class stock_move(osv.osv): return invoice_line_id def _get_master_data(self, cr, uid, move, company, context=None): - if move.procurement_id and move.procurement_id.sale_line_id: + if move.procurement_id and move.procurement_id.sale_line_id and move.procurement_id.sale_line_id.order_id.order_policy == 'picking': sale_order = move.procurement_id.sale_line_id.order_id return sale_order.partner_invoice_id, sale_order.user_id.id, sale_order.pricelist_id.currency_id.id return super(stock_move, self)._get_master_data(cr, uid, move, company, context=context) @@ -411,7 +411,7 @@ class stock_picking(osv.osv): """ saleorder_ids = self.pool['sale.order'].search(cr, uid, [('procurement_group_id' ,'=', picking.group_id.id)], context=context) saleorders = self.pool['sale.order'].browse(cr, uid, saleorder_ids, context=context) - if saleorders and saleorders[0]: + if saleorders and saleorders[0] and saleorders[0].order_policy == 'picking': saleorder = saleorders[0] return saleorder.partner_invoice_id.id return super(stock_picking, self)._get_partner_to_invoice(cr, uid, picking, context=context) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 581b8c5c78f..3939e621095 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1789,8 +1789,7 @@ class stock_move(osv.osv): return False def _default_destination_address(self, cr, uid, context=None): - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - return user.company_id.partner_id.id + return False _defaults = { 'location_id': _default_location_source, diff --git a/addons/stock/views/report_stockpicking.xml b/addons/stock/views/report_stockpicking.xml index 7d2bb125de2..f152e47a523 100644 --- a/addons/stock/views/report_stockpicking.xml +++ b/addons/stock/views/report_stockpicking.xml @@ -9,26 +9,41 @@
-
- Supplier Address: -
-
- Warehouse Address: -
-
- Customer Address: -
-
-
-

VAT:

-
- -

- : - -

- +
+
+
+ Supplier Address: +
+
+ Warehouse Address: +
+
+ Customer Address: +
+
+
+

VAT:

+
+
+
+
+ Delivery Address: +
+
+
+ Warehouse Address: +
+
+
+
+

+ : + +

+
Order (Origin)