[FIX] account: There is no sale_refund nor purchase_refund analytic journal

During rev. cbe2dbb, type2journal was refactored, and set as a global variable in the top of the file, as it was use everywhere accross the file.
But, in this specific method _get_journal_analytic, this type2journal dict wasn't the same as everywhere else, as you can see at rev. d2ff95f for example. We must therefore set a specific type2journal dict for this specific method.
This commit is contained in:
Denis Ledoux 2014-12-01 15:28:00 +01:00
parent 1fe6e8172d
commit 64fd5288c8
1 changed files with 2 additions and 1 deletions

View File

@ -87,7 +87,8 @@ class account_invoice(models.Model):
@api.returns('account.analytic.journal', lambda r: r.id)
def _get_journal_analytic(self, inv_type):
""" Return the analytic journal corresponding to the given invoice type. """
journal_type = TYPE2JOURNAL.get(inv_type, 'sale')
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'}
journal_type = type2journal.get(inv_type, 'sale')
journal = self.env['account.analytic.journal'].search([('type', '=', journal_type)], limit=1)
if not journal:
raise except_orm(_('No Analytic Journal!'),