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).
This commit is contained in:
Pedro M. Baeza
2016-01-25 05:58:43 +01:00
committed by Carlos Roca
parent c73b278437
commit c8ec41aa95

View File

@@ -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)