[FIX] account: There is no sale_refund nor purchase_refund analytic journal
authorDenis Ledoux <dle@odoo.com>
Mon, 1 Dec 2014 14:28:00 +0000 (15:28 +0100)
committerDenis Ledoux <dle@odoo.com>
Mon, 1 Dec 2014 14:31:12 +0000 (15:31 +0100)
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.

addons/account/account_invoice.py

index 8195fd7..7b01459 100644 (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!'),