← Back to team overview

openerp-india team mailing list archive

[Bug 1010585] Re: Sequence in the environment multicompany

 

*** This bug is a duplicate of bug 863221 ***
    https://bugs.launchpad.net/bugs/863221

** This bug has been marked a duplicate of bug 863221
   sequence might use a child company's sequence by error under certain circumstances

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

Title:
  Sequence in the environment multicompany

Status in OpenERP Server:
  New

Bug description:
  For environment multi-companies need to apply a patch in the sequence
  method that returns the appropriate document to use in order to take
  the sequence of the company and to have multiple companies working
  with the same code sequence, but with different numbers following
  because filtering for per company. It is a small patch to be applied
  in the select statement of ir.sequence for multi companies at the time
  of returning the stream to use:

  def get_id(self, cr, uid, sequence_id, test='id', context=None):
          assert test in ('code','id')
          company_id = self.pool.get('res.company')._company_default_get(cr, uid,'ir.sequence', context=context)
          cr.execute('''SELECT id, number_next, prefix, suffix, padding
                        FROM ir_sequence
                        WHERE %s='%s'
                         AND active=true
                         AND company_id=%d
                        ORDER BY company_id, id
                        FOR UPDATE NOWAIT''' % (test,sequence_id,company_id))
          res = cr.dictfetchone()
          
          if res:
              cr.execute('UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s AND active=true', (res['id'],))
              if res['number_next']:
                  return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix'])
              else:
                  return self._process(res['prefix']) + self._process(res['suffix'])
          return False

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


References