account default journal not using defaults

Bug #1019267 reported by Ferdinand
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Low
OpenERP R&D Addons Team 3

Bug Description

account/account_invoice.py

this code selects an arbitrary (first) journal which matches the condition

    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')
        res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale')),
                                            ('company_id', '=', company_id)],
                                                limit=1)

the defaults are defined as

select id,name,key2,value from ir_values where model like '%invoi%' and name ='journal_id' ;
  id | name | key2 | value
------+------------+---------------+-------
 2283 | journal_id | | I2 +
      | | | .
 2284 | journal_id | partner_id=84 | I13 +
      | | | .
 2285 | journal_id | partner_id=85 | I13 +
      | | | .
 2286 | journal_id | partner_id=83 | I13 +
      | | | .
(4 rows)

the _get_journal function
must respect the existing defaults

patch follows soon

Related branches

Revision history for this message
Ferdinand (office-chricar) wrote :

this patch fixes the issue that the correct default value is returned.

nevertheless the returned value is not used

Revision history for this message
Ferdinand (office-chricar) wrote :

the journals

select id,name from account_journal where type='sale';
 id | name
----+--------------------------------------------------
  2 | Journal Verkauf
 10 | Journal Verkauf / Büro Hamburg (NICHT VERWENDEN)
 12 | Journal Verkauf / Intern (NICHT VERWENDEN)
 13 | Journal Verkauf Intern

the log

FGF context {'uid': 1, 'journal_type': 'sale', 'section_id': False, 'default_type': 'out_invoice', 'lang': 'de_DE', 'tz': 'Europe/Vienna', 'search_default_to_do': 1, 'project_id': False, 'type': 'out_invoice', 'department_id': False}
FGF res [13]
FGF res default [2]

13 is returned by the original _get_journal and 2 is the correct value returned by the patched version, but it is not used
see also
https://bugs.launchpad.net/openobject-server/+bug/1019503

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello Ferdinand ,

I have checked this issue with trunk.After some analysis I find out that problem
in addons account_invoice.py , Journal_id is overwrite in onchange_company_id at line 596-597.
if you used (line : 597) res_journal_default = ir_values_obj.get_defaults(cr, uid,'account.invoice')
and its working fine beacuse " res_journal_default = ir_values_obj.get(cr, uid, 'default', 'type=%s' % (type), ['account.invoice']) " this not return a correct value.

So I am assigning this issue to addons team.

Thank you!

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Ferdinand (office-chricar) wrote :

for simplicity of the code the computation of the journal_id this should be coded correctly only ONCE (_get_journal) and reused elsewhere.

see attached patch which works for me

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello Ferdinand,

I have attached branch for you .

This issue has been fixed at following branch , revision no and Id.

Branch : lp:~openerp-dev/openobject-addons/trunk-bug-1019267-jir
Revision No : 7059
Revision ID : jir@jir-desktop-20120717050733-zcicsywmimj92t04

Thanks for your contribution.

Changed in openobject-addons:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.