openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #12303
[Bug 1010585] [NEW] Sequence in the environment multicompany
Public bug reported:
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
** Affects: openobject-addons
Importance: Undecided
Status: New
--
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/1010585
Title:
Sequence in the environment multicompany
Status in OpenERP Addons (modules):
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-addons/+bug/1010585/+subscriptions
Follow ups
References