forked from Yaltik/golem
[IMP]GOLEM Member Number generation better handling
This commit is contained in:
parent
c60feaf23a
commit
fb8ed0d211
@ -120,10 +120,10 @@ class GolemMember(models.Model):
|
||||
@api.one
|
||||
def _generate_number_global(self):
|
||||
""" Number generation in case of global configuration """
|
||||
for member in self:
|
||||
self.ensure_one()
|
||||
conf = self.env['ir.config_parameter']
|
||||
domain = ['&',
|
||||
('member_id', '=', member.id),
|
||||
('member_id', '=', self.id),
|
||||
('season_id', '=', None)]
|
||||
member_num = self.env['golem.member.number']
|
||||
mn = member_num.search(domain)
|
||||
@ -133,7 +133,7 @@ class GolemMember(models.Model):
|
||||
conf.set_param('golem_number_counter', str(last))
|
||||
pfx = conf.get_param('golem_numberconfig_prefix')
|
||||
number = pfx + str(last)
|
||||
data = {'member_id': member.id,
|
||||
data = {'member_id': self.id,
|
||||
'season_id': None,
|
||||
'number': number}
|
||||
mn = member_num.create(data)
|
||||
@ -143,17 +143,17 @@ class GolemMember(models.Model):
|
||||
def _generate_number(self):
|
||||
""" Computes number according to pre-existing number and chosen
|
||||
seasons """
|
||||
for member in self:
|
||||
self.ensure_one()
|
||||
conf = self.env['ir.config_parameter']
|
||||
if conf.get_param('golem_numberconfig_isautomatic') == '0':
|
||||
member.number = member.number_manual
|
||||
self.number = self.number_manual
|
||||
else:
|
||||
if conf.get_param('golem_numberconfig_isperseason') == '1':
|
||||
mn = member._generate_number_perseason()
|
||||
mn = self._generate_number_perseason()
|
||||
else:
|
||||
mn = member._generate_number_global()
|
||||
mn = self._generate_number_global()
|
||||
if mn:
|
||||
member.number = mn[0]
|
||||
self.number = mn[0]
|
||||
|
||||
@api.model
|
||||
@api.returns('self', lambda rec: rec.id)
|
||||
|
Loading…
Reference in New Issue
Block a user