From bd08fcdfc3f7ab9ba5cb8cb7dc33764cb1ac9c35 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 25 Jan 2016 05:58:43 +0100 Subject: [PATCH] account_payment_*: Ensure work with dropshipping dual invoice When invoicing from dropshipping, the same picking serves for both invoicing sale and purchase orders. The OCA module stock_dropshipping_dual_invoice makes that this happens, but as the picking is the same, it contains both the sale and the purchase reference, making that the resulting invoices don't have the correct payment mode. This is harmless for the rest of operations, as the dictionary query is provided with the proper default value. On v9, dropshipping dual invoice has been merged into core, so this patch for sure will be welcome in that version (if the used method is the same). --- account_payment_purchase/models/stock_picking.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/account_payment_purchase/models/stock_picking.py b/account_payment_purchase/models/stock_picking.py index 2ab8c6073..28d30e057 100644 --- a/account_payment_purchase/models/stock_picking.py +++ b/account_payment_purchase/models/stock_picking.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Account Payment Purchase module for OpenERP @@ -28,11 +28,13 @@ class StockPicking(models.Model): @api.model def _create_invoice_from_picking(self, picking, vals): - if picking and picking.move_lines: + # This will assure that stock_dropshipping_dual_invoice will work + inv_type = self.env.context.get('inv_type', 'in_invoice') + if picking and picking.move_lines and inv_type == 'in_invoice': # Get purchase order from first move line if picking.move_lines[0].purchase_line_id: purchase = picking.move_lines[0].purchase_line_id.order_id vals['partner_bank_id'] = purchase.supplier_partner_bank_id.id vals['payment_mode_id'] = purchase.payment_mode_id.id - return super(StockPicking, self)._create_invoice_from_picking(picking, - vals) + return super(StockPicking, self)._create_invoice_from_picking( + picking, vals)