← Back to team overview

openerp-india team mailing list archive

[Bug 1019267] Re: account default journal not using defaults

 

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


** Patch added: "account_invoice.py.20120704.patch"
   https://bugs.launchpad.net/openobject-addons/+bug/1019267/+attachment/3213303/+files/account_invoice.py.20120704.patch

** Patch removed: "account_invoice.py.20120630.patch"
   https://bugs.launchpad.net/openobject-addons/+bug/1019267/+attachment/3208491/+files/account_invoice.py.20120630.patch

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1019267

Title:
  account default journal not using defaults

Status in OpenERP Addons (modules):
  Confirmed

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1019267/+subscriptions


References