Small refactorings

This commit is contained in:
Youssef Elouahby 2018-10-22 21:24:57 +01:00
parent e5285ecebc
commit 473e3da65d
2 changed files with 11 additions and 11 deletions

View File

@ -30,13 +30,13 @@ class GolemFamily(models.Model):
@api.constrains('city', 'country_id', 'member_ids') @api.constrains('city', 'country_id', 'member_ids')
def save_family_history(self): def save_family_history(self):
""" save family history """ """ save family history """
default_season = self.env['golem.season'].search([('is_default', '=', True)]) default_season = self.env['golem.season'].search([('is_default', '=', True)], limit=1)
for family in self: for family in self:
history = self.env['golem.family.history'].search([ history = self.env['golem.family.history'].search([
('family_id', '=', family.id), ('family_id', '=', family.id),
('season_id', '=', default_season.id)]) ('season_id', '=', default_season.id)], limit=1)
if history: if history:
history[0].write({ history.write({
'city': family.city, 'city': family.city,
'country_id': family.country_id.id, 'country_id': family.country_id.id,
'member_ids':[(6, False, family.member_ids.ids)] 'member_ids':[(6, False, family.member_ids.ids)]

View File

@ -31,14 +31,14 @@ class GolemMember(models.Model):
'pcs_id', 'nationality_id', 'season_ids') 'pcs_id', 'nationality_id', 'season_ids')
def save_history(self): def save_history(self):
""" save member history """ """ save member history """
default_season = self.env['golem.season'].search([('is_default', '=', True)]) default_season = self.env['golem.season'].search([('is_default', '=', True)], limit=1)
for member in self: for member in self:
history = self.env['golem.member.history'].search([ history = self.env['golem.member.history'].search([
('member_id', '=', member.id), ('member_id', '=', member.id),
('season_id', '=', default_season.id)]) ('season_id', '=', default_season.id)], limit=1)
if history: if history:
history[0].write({'gender': member.gender, history.write({'gender': member.gender,
'nationality_id': member.nationality_id.id, 'nationality_id': member.nationality_id.id,
'city': member.city, 'city': member.city,
'family_quotient': member.family_quotient, 'family_quotient': member.family_quotient,