forked from Yaltik/golem
[IMP]GOLEM : store is_default for members and activities
This commit is contained in:
parent
cd2afd3b22
commit
481ca0994d
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016-2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2016-2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
@ -19,7 +19,7 @@
|
||||
'name': 'GOLEM activities',
|
||||
'summary': 'Extends Odoo products for multi-activity',
|
||||
'description': 'Extends Odoo products for multi-activity',
|
||||
'version': '10.0.2.7.0',
|
||||
'version': '10.0.2.8.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Fabien Bourgeois, Michel Dessenne',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2016-2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
@ -15,4 +15,4 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import golem_activity
|
||||
from . import golem_activity, golem_season
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017-2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2017-2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
@ -105,8 +105,7 @@ class GolemActivity(models.Model):
|
||||
index=True, auto_join=True,
|
||||
ondelete='restrict')
|
||||
is_default = fields.Boolean('Default season?',
|
||||
compute='_compute_is_default',
|
||||
search='_search_is_default')
|
||||
compute='_compute_is_default', store=True)
|
||||
|
||||
@api.depends('season_id')
|
||||
def _compute_is_default(self):
|
||||
@ -115,18 +114,6 @@ class GolemActivity(models.Model):
|
||||
for activity in self:
|
||||
activity.is_default = (default_season == activity.season_id)
|
||||
|
||||
@api.multi
|
||||
def _search_is_default(self, operator, value):
|
||||
""" Search function for is default """
|
||||
if operator in ('in', '='):
|
||||
operator = '=' if value else '!='
|
||||
elif operator in ('not in', '!='):
|
||||
operator = '!=' if value else '='
|
||||
else:
|
||||
err = _('Unsupported operator for defautl season search')
|
||||
raise NotImplementedError(err)
|
||||
return [('season_id', operator, self.default_season().id)]
|
||||
|
||||
animator_id = fields.Many2one('res.partner', string='Animator',
|
||||
index=True, auto_join=True,
|
||||
domain=[('is_company', '=', False)])
|
||||
|
34
golem_activity/models/golem_season.py
Normal file
34
golem_activity/models/golem_season.py
Normal file
@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
""" GOLEM Season adaptations """
|
||||
|
||||
from odoo import models, api
|
||||
|
||||
|
||||
class GolemSeason(models.Model):
|
||||
""" GOLEM Season adaptations """
|
||||
_inherit = 'golem.season'
|
||||
|
||||
@api.multi
|
||||
def do_default_season(self):
|
||||
""" Regenerates is_default when season changes """
|
||||
self.ensure_one()
|
||||
res = super(GolemSeason, self).do_default_season()
|
||||
all_activities = self.env['golem.activity'].search([])
|
||||
all_activities._compute_is_default()
|
||||
return res
|
@ -21,7 +21,7 @@
|
||||
'name': 'GOLEM non-profit members',
|
||||
'summary': 'Extends Odoo contacts for MJC',
|
||||
'description': 'Extends Odoo contacts for MJC',
|
||||
'version': '10.0.2.7.3',
|
||||
'version': '10.0.2.8.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Fabien Bourgeois, Michel Dessenne',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -222,8 +222,7 @@ class GolemMember(models.Model):
|
||||
required=True, default=default_season,
|
||||
auto_join=True, ondelete='restrict')
|
||||
is_default = fields.Boolean('Default season?',
|
||||
compute='_compute_is_default',
|
||||
search='_search_is_default')
|
||||
compute='_compute_is_default', store=True)
|
||||
is_number_manual = fields.Boolean('Is number manual?', store=False,
|
||||
compute='_compute_is_number_manual')
|
||||
|
||||
@ -255,18 +254,6 @@ class GolemMember(models.Model):
|
||||
for member in self:
|
||||
member.is_default = default_s in member.season_ids
|
||||
|
||||
@api.multi
|
||||
def _search_is_default(self, operator, value):
|
||||
""" Search function for is default """
|
||||
if operator in ('in', '='):
|
||||
operator = '=' if value else '!='
|
||||
elif operator in ('not in', '!='):
|
||||
operator = '!=' if value else '='
|
||||
else:
|
||||
err = _('Unsupported operator for defautl season search')
|
||||
raise NotImplementedError(err)
|
||||
return [('season_ids', operator, self.default_season().id)]
|
||||
|
||||
@api.depends('number')
|
||||
def _compute_is_number_manual(self):
|
||||
conf = self.env['ir.config_parameter']
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2018-2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
@ -30,6 +30,9 @@ class GolemSeason(models.Model):
|
||||
self.ensure_one()
|
||||
res = super(GolemSeason, self).do_default_season()
|
||||
all_members = self.env['golem.member'].search([])
|
||||
# Recompute is_default
|
||||
all_members._compute_is_default()
|
||||
# Regenerate number
|
||||
conf = self.env['ir.config_parameter']
|
||||
if conf.get_param('golem_numberconfig_isautomatic') == '1' and \
|
||||
conf.get_param('golem_numberconfig_isperseason') == '1':
|
||||
|
Loading…
Reference in New Issue
Block a user