[FIX] stock_account, sale_stock: _get_partner_to_invoice
When getting the partner to invoice, the function _get_partner_to_invoice must check the type of the invoice to create. opw:658460
This commit is contained in:
parent
44dd7c5077
commit
47e7f5d9bd
|
@ -447,12 +447,13 @@ class stock_picking(osv.osv):
|
||||||
""" Inherit the original function of the 'stock' module
|
""" Inherit the original function of the 'stock' module
|
||||||
We select the partner of the sales order as the partner of the customer invoice
|
We select the partner of the sales order as the partner of the customer invoice
|
||||||
"""
|
"""
|
||||||
if picking.sale_id:
|
if context.get('inv_type') and context['inv_type'] in ('out_invoice', 'out_refund'):
|
||||||
saleorder_ids = self.pool['sale.order'].search(cr, uid, [('procurement_group_id' ,'=', picking.group_id.id)], context=context)
|
if picking.sale_id:
|
||||||
saleorders = self.pool['sale.order'].browse(cr, uid, saleorder_ids, context=context)
|
saleorder_ids = self.pool['sale.order'].search(cr, uid, [('procurement_group_id' ,'=', picking.group_id.id)], context=context)
|
||||||
if saleorders and saleorders[0] and saleorders[0].order_policy == 'picking':
|
saleorders = self.pool['sale.order'].browse(cr, uid, saleorder_ids, context=context)
|
||||||
saleorder = saleorders[0]
|
if saleorders and saleorders[0] and saleorders[0].order_policy == 'picking':
|
||||||
return saleorder.partner_invoice_id.id
|
saleorder = saleorders[0]
|
||||||
|
return saleorder.partner_invoice_id.id
|
||||||
return super(stock_picking, self)._get_partner_to_invoice(cr, uid, picking, context=context)
|
return super(stock_picking, self)._get_partner_to_invoice(cr, uid, picking, context=context)
|
||||||
|
|
||||||
def _get_sale_id(self, cr, uid, ids, name, args, context=None):
|
def _get_sale_id(self, cr, uid, ids, name, args, context=None):
|
||||||
|
|
|
@ -252,7 +252,7 @@ class stock_picking(osv.osv):
|
||||||
context = context or {}
|
context = context or {}
|
||||||
todo = {}
|
todo = {}
|
||||||
for picking in self.browse(cr, uid, ids, context=context):
|
for picking in self.browse(cr, uid, ids, context=context):
|
||||||
partner = self._get_partner_to_invoice(cr, uid, picking, context)
|
partner = self._get_partner_to_invoice(cr, uid, picking, dict(context, type=type))
|
||||||
#grouping is based on the invoiced partner
|
#grouping is based on the invoiced partner
|
||||||
if group:
|
if group:
|
||||||
key = partner
|
key = partner
|
||||||
|
|
Loading…
Reference in New Issue