[FIX] account: default domain on journal_id field for invoices
authorDenis Ledoux <dle@odoo.com>
Mon, 16 Jun 2014 14:55:58 +0000 (16:55 +0200)
committerDenis Ledoux <dle@odoo.com>
Mon, 16 Jun 2014 14:55:58 +0000 (16:55 +0200)
Prior to this fix, the domain was set in the onchange methods onchange_company_id. Therefore, if the onchange was not triggered, the domain wasnt apply (e.g. while editing an existing invoice).

addons/account/account_invoice.py

index 55ba105..afd0077 100644 (file)
@@ -298,7 +298,8 @@ class account_invoice(osv.osv):
             },
             multi='all'),
         'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}, track_visibility='always'),
-        'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
+        'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]},
+                                      domain="[('type', 'in', {'out_invoice': ['sale'], 'out_refund': ['sale_refund'], 'in_refund': ['purchase_refund'], 'in_invoice': ['purchase']}.get(type, [])), ('company_id', '=', company_id)]"),
         'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}),
         'check_total': fields.float('Verification Total', digits_compute=dp.get_precision('Account'), readonly=True, states={'draft':[('readonly',False)]}),
         'reconciled': fields.function(_reconciled, string='Paid/Reconciled', type='boolean',