示例#1
0
 def _next(self):
     if self.sequence_id.implementation == 'standard':
         number_next = ir_sequence._select_nextval(self._cr, 'ir_sequence_%03d_%03d' % (self.sequence_id.id, self.id))
     else:
         number_next = ir_sequence._update_nogap(self, self.sequence_id.number_increment)
         
     return self.sequence_id.get_next_char(number_next, self.prefix, self.suffix)
示例#2
0
    def _next(self):

        force_company = self._context.get('force_company')
        if not force_company:
            force_company = self.env['res.users'].browse().company_id.id
        sequences = self.read(
                              ['name', 'company_id', 'implementation', 'number_next', 'prefix', 'suffix', 'padding',
                               'number_increment', 'auto_reset', 'reset_period', 'reset_time', 'reset_init_number'])
        preferred_sequences = [s for s in sequences if s['company_id'] and s['company_id'][0] == force_company]
        seq = preferred_sequences[0] if preferred_sequences else sequences[0]
        if seq['implementation'] == 'standard':
            current_time = ':'.join([seq['reset_period'], self._interpolation_dict().get(seq['reset_period'])])
            if seq['auto_reset'] and current_time != seq['reset_time']:
                self._cr.execute("UPDATE ir_sequence SET reset_time=%s WHERE id=%s ", (current_time, seq['id']))
                _alter_sequence(self._cr, 'ir_sequence_%03d' % self.id, seq['number_increment'], seq['reset_init_number'])
                self._cr.commit()
            number_next = _select_nextval(self._cr, 'ir_sequence_%03d' % self.id)
            # self._cr.execute("SELECT nextval('%s')" % seq['name'])
            seq['number_next'] = number_next
        else:
            self._cr.execute("SELECT number_next FROM ir_sequence WHERE id=%s FOR UPDATE NOWAIT", (seq['id'],))
            self._cr.execute("UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s ", (seq['id'],))
        d = self._interpolation_dict()
        try:
            interpolated_prefix = self._interpolate(seq['prefix'], d)
            interpolated_suffix = self._interpolate(seq['suffix'], d)
        except ValueError:
            raise osv.except_osv(_('Warning'), _('Invalid prefix or suffix for sequence \'%s\'') % (seq.get('name')))
        return interpolated_prefix + '%%0%sd' % seq['padding'] % seq['number_next'] + interpolated_suffix
示例#3
0
 def _next_do(self):
     if self.env.context.get('sequence_tuple', False):
         if self.implementation == 'standard':
             number_next = _select_nextval(self._cr,
                                           'ir_sequence_%03d' % self.id)[0]
         else:
             number_next = _update_nogap(self, self.number_increment)
         prefix, suffix = self._get_prefix_suffix()
         return (prefix, number_next, suffix,
                 self.get_next_char(number_next))
     return super()._next_do()
示例#4
0
 def _next_do(self):
     if self.env.context.get("sequence_tuple", False):
         if self.implementation == "standard":
             number_next = _select_nextval(self._cr,
                                           "ir_sequence_%03d" % self.id)[0]
         else:
             number_next = _update_nogap(self, self.number_increment)
         prefix, suffix = self._get_prefix_suffix()
         code = self.get_next_char(number_next)
         dc = ""
         formula = self.check_digit_formula
         if formula and formula != "none":
             dc = code[-1:]
         return (prefix, number_next, suffix, dc, code)
     return super()._next_do()
示例#5
0
 def _next(self):
     if self.env.context.get('sequence_tuple', False):
         if self.sequence_id.implementation == 'standard':
             number_next = _select_nextval(
                 self._cr, 'ir_sequence_%03d_%03d' % (
                     self.sequence_id.id, self.id))[0]
         else:
             number_next = _update_nogap(
                 self, self.sequence_id.number_increment)
         prefix, suffix = self.sequence_id._get_prefix_suffix()
         code = self.sequence_id.get_next_char(number_next)
         dc = ''
         formula = self.sequence_id.check_digit_formula
         if formula and formula != 'none':
             dc = code[-1:]
         return (
             prefix, number_next, suffix, dc, code)
     return super()._next()