[FIX] delivery, stock_account: invoice on delivery with fiscal position

When creating an invoice on delivery, the right 'account_id' was not
set on the invoice line according to the fiscal position.

This commit is contained in:
Goffin Simon 2015-11-27 16:12:05 +01:00
parent b8dfa91613
commit 28463d0310
2 changed files with 6 additions and 5 deletions

View File

@ -107,9 +107,10 @@ class stock_picking(osv.osv):
taxes = picking.carrier_id.product_id.taxes_id
partner = picking.partner_id or False
fp = invoice.fiscal_position or partner.property_account_position
if partner:
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, partner.property_account_position, account_id)
taxes_ids = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner.property_account_position, taxes)
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fp, account_id)
taxes_ids = self.pool.get('account.fiscal.position').map_tax(cr, uid, fp, taxes)
taxes_ids = [x.id for x in taxes]

View File

@ -134,6 +134,7 @@ class stock_move(osv.osv):
def _get_invoice_line_vals(self, cr, uid, move, partner, inv_type, context=None):
fp_obj = self.pool.get('account.fiscal.position')
# Get account_id
fp = fp_obj.browse(cr, uid, context.get('fp_id')) if context.get('fp_id') else False
if inv_type in ('out_invoice', 'out_refund'):
account_id = move.product_id.property_account_income.id
if not account_id:
@ -142,7 +143,7 @@ class stock_move(osv.osv):
account_id = move.product_id.property_account_expense.id
if not account_id:
account_id = move.product_id.categ_id.property_account_expense_categ.id
fiscal_position = partner.property_account_position
fiscal_position = fp or partner.property_account_position
account_id = fp_obj.map_account(cr, uid, fiscal_position, account_id)
# set UoS if it's a sale and the picking doesn't have one
@ -320,8 +321,7 @@ class stock_picking(osv.osv):
merge_vals['name'] = ', '.join(invoice_name)
if merge_vals:
invoice_line_vals = move_obj._get_invoice_line_vals(cr, uid, move, partner, inv_type, context=context)
invoice_line_vals = move_obj._get_invoice_line_vals(cr, uid, move, partner, inv_type, context=dict(context, fp_id=invoice_vals.get('fiscal_position', False)))
invoice_line_vals['invoice_id'] = invoices[key]
invoice_line_vals['origin'] = origin
if not is_extra_move[move.id]: