Odoo Hilfe

1

3
1 Answer
0
Ludovic CHEVALIER
08.07.15, 06:39

For my second problem, here is the method of account.invoice object (from account module) that select the journal: 

     def _get_journal(self, cr, uid, context=None):
if context is None:
context = {}
type_inv = context.get('type', 'out_invoice')
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
company_id = context.get('company_id', user.company_id.id)
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale_refund', 'in_refund': 'purchase_refund'}
journal_obj = self.pool.get('account.journal')
domain = [('company_id', '=', company_id)]
if isinstance(type_inv, list):
domain.append(('type', 'in', [type2journal.get(type) for type in type_inv if type2journal.get(type)]))
else:
domain.append(('type', '=', type2journal.get(type_inv, 'sale')))
res = journal_obj.search(cr, uid, domain, limit=1)
self.search(cr, uid, [('state', '=', 'done')], context=context)
return res and res[0] or False

We can see that the journal is chosen arbitrary by selecting the first one of the request ("limit=1").

Is it normal that users can't choose the journal they want for invoices? Why OpenERP prefers choose it by chance?


Edit 2015-10-23:

In addons/account/account.py:763, we could see:

    _order = 'code'

So, just have to put a correct code for invoices default journal. :-)

 

Fragen Sie
Keep Informed
3 Verfolger
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now