Jignesh Rathod(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-1019267-jir into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #1019267 in OpenERP Addons: "account default journal not using defaults"
  https://bugs.launchpad.net/openobject-addons/+bug/1019267

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1019267-jir/+merge/115269

Hello ,

when you set a default journal in account invoice then journal not using 
as defaults and its solve by call _get_journal in onchange_company_id and set
val['journal_id'] = self._get_journal(cr, uid, context).

Thanks!
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1019267-jir/+merge/115269
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-1019267-jir.
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py	2012-07-14 23:18:43 +0000
+++ account/account_invoice.py	2012-07-17 05:20:29 +0000
@@ -55,6 +55,15 @@
         res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale')),
                                             ('company_id', '=', company_id)],
                                                 limit=1)
+        defaults = self.pool.get('ir.values').get_defaults(cr, uid, 'account.invoice',None)
+        import logging
+        _logger = logging.getLogger(__name__)
+        _logger.info('FGF context %s', context)
+        _logger.info('FGF res %s', res)
+        for val in defaults:
+            if val[1] == 'journal_id':
+                res = [(val[2])]
+            _logger.info('FGF res default %s', res)
         return res and res[0] or False
 
     def _get_currency(self, cr, uid, context=None):
@@ -590,13 +599,17 @@
             else:
                 journal_type = 'purchase'
             journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)])
-            if journal_ids:
-                val['journal_id'] = journal_ids[0]
-            ir_values_obj = self.pool.get('ir.values')
-            res_journal_default = ir_values_obj.get(cr, uid, 'default', 'type=%s' % (type), ['account.invoice'])
-            for r in res_journal_default:
-                if r[1] == 'journal_id' and r[2] in journal_ids:
-                    val['journal_id'] = r[2]
+            #if journal_ids:
+            #    val['journal_id'] = journal_ids[0]
+            #ir_values_obj = self.pool.get('ir.values')
+            #res_journal_default = ir_values_obj.get(cr, uid, 'default', 'type=%s' % (type), ['account.invoice'])
+            #for r in res_journal_default:
+            #    if r[1] == 'journal_id' and r[2] in journal_ids:
+            #        val['journal_id'] = r[2]
+            context = {}
+            context['type'] = type
+            context['company_id'] = company_id
+            val['journal_id'] = self._get_journal(cr, uid, context)
             if not val.get('journal_id', False):
                 raise osv.except_osv(_('Configuration Error !'), (_('Can\'t find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Financial Accounting\Accounts\Journals.') % (journal_type)))
             dom = {'journal_id':  [('id', 'in', journal_ids)]}

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to