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