forked from Yaltik/golem
[FIX]Season member number generation : avoid useless loop when default season is changed
This commit is contained in:
parent
13a7785fe5
commit
a6b65dfa53
@ -201,10 +201,9 @@ class GolemMember(models.Model):
|
||||
member.number = member.number_manual
|
||||
else:
|
||||
if isperseason:
|
||||
member_num = member.generate_number_perseason()
|
||||
member.number = member.generate_number_perseason()
|
||||
else:
|
||||
member_num = member.generate_number_global()
|
||||
member.number = member_num
|
||||
member.number = member.generate_number_global()
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
@ -281,9 +280,10 @@ class GolemNumberConfig(models.TransientModel):
|
||||
conf.set_param('golem_numberconfig_isperseason', self.is_per_season)
|
||||
conf.set_param('golem_numberconfig_prefix', self.prefix or '')
|
||||
if self.number_from:
|
||||
conf.set_param('golem_number_counter', self.number_from)
|
||||
_LOGGER.warning('New number_from %s', self.number_from)
|
||||
conf.set_param('golem_number_counter', unicode(self.number_from))
|
||||
self.env['golem.season'].search([]).write({
|
||||
'member_counter': int(self.number_from)
|
||||
'member_counter': self.number_from
|
||||
})
|
||||
@api.multi
|
||||
def apply_nocompute(self):
|
||||
@ -300,7 +300,6 @@ class GolemNumberConfig(models.TransientModel):
|
||||
self.apply_config()
|
||||
conf = self.env['ir.config_parameter']
|
||||
conf.set_param('golem_numberconfig_isfornewmembersonly', '0')
|
||||
conf.set_param('golem_number_counter', self.number_from)
|
||||
self.env['golem.member.number'].search([]).unlink()
|
||||
self.env['golem.season'].search([]).write({
|
||||
'member_counter': int(self.number_from)
|
||||
|
@ -26,7 +26,7 @@ class GolemMemberTestCase(TransactionCase):
|
||||
""" GOLEM member testing """
|
||||
|
||||
def setUp(self, *args, **kwargs):
|
||||
""" Bootstrap season and memebers """
|
||||
""" Bootstrap season and members """
|
||||
super(GolemMemberTestCase, self).setUp(*args, **kwargs)
|
||||
self.member_numberconfig_model = self.env['golem.member.numberconfig']
|
||||
season_mdl = self.env['golem.season'].sudo()
|
||||
@ -145,10 +145,10 @@ class GolemMemberTestCase(TransactionCase):
|
||||
conf.apply_nocompute()
|
||||
self.assertEqual(self.member1.number, u'M01')
|
||||
new_m = self.member_model.create({'lastname': 'NEW',
|
||||
'firstname': 'Buddy',
|
||||
'firstname': 'Dewie',
|
||||
'season_ids': [self.season_current]})
|
||||
new_m2 = self.member_model.create({'lastname': 'NEW',
|
||||
'firstname': 'Buddy',
|
||||
'firstname': 'Dowa',
|
||||
'season_ids': [self.season_current]})
|
||||
self.assertEqual(new_m.number, u'1')
|
||||
self.assertEqual(new_m2.number, u'2')
|
||||
@ -164,7 +164,7 @@ class GolemMemberTestCase(TransactionCase):
|
||||
'firstname': 'Buddy',
|
||||
'season_ids': [self.season_current]})
|
||||
new_m2 = self.member_model.create({'lastname': 'NEW',
|
||||
'firstname': 'Buddy',
|
||||
'firstname': 'Bobby',
|
||||
'season_ids': [self.season_current]})
|
||||
self.assertEqual(new_m.number, u'50')
|
||||
self.assertEqual(new_m2.number, u'51')
|
||||
@ -174,3 +174,7 @@ class GolemMemberTestCase(TransactionCase):
|
||||
self.assertEqual(new_m.number, u'50')
|
||||
self.member1.season_ids += self.season_next
|
||||
self.assertEqual(self.member1.number, u'M01')
|
||||
new_m3 = self.member_model.create({'lastname': 'NEW',
|
||||
'firstname': 'Barny',
|
||||
'season_ids': [self.season_current]})
|
||||
self.assertEqual(new_m3.number, u'52')
|
||||
|
@ -72,6 +72,9 @@ class GolemSeason(models.Model):
|
||||
if 'golem.member' in self.env.registry:
|
||||
all_members = self.env['golem.member'].search([])
|
||||
all_members.compute_is_current()
|
||||
conf = self.env['ir.config_parameter']
|
||||
if conf.get_param('golem_numberconfig_isautomatic') == '1' and \
|
||||
conf.get_param('golem_numberconfig_isperseason') == '1':
|
||||
all_members.generate_number()
|
||||
if 'golem.activity' in self.env.registry:
|
||||
self.env['golem.activity'].search([]).compute_is_current()
|
||||
|
Loading…
Reference in New Issue
Block a user