From f3260ca757afd00da2485ddab5eafdd120284fe6 Mon Sep 17 00:00:00 2001 From: michel Date: Tue, 13 Feb 2018 16:30:15 +0100 Subject: [PATCH] [Bug] Add fonction to Get default season --- golem_payment/models/golem_payment.py | 11 ++++++++++- golem_payment/views/golem_payment_views.xml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/golem_payment/models/golem_payment.py b/golem_payment/models/golem_payment.py index 987c88ef..6d96500a 100644 --- a/golem_payment/models/golem_payment.py +++ b/golem_payment/models/golem_payment.py @@ -41,10 +41,19 @@ class GolemPaymentSchedule(models.Model): _order = 'season_id desc' name = fields.Char(required=True) - season_id = fields.Many2one('golem.season', 'Season', required=True) day_ids = fields.Many2many('golem.payment.schedule.day', string='Days') occurences = fields.Integer(compute='_compute_occurences') + @api.model + def _default_season(self): + """ Get default season """ + domain = [('is_default', '=', True)] + return self.env['golem.season'].search(domain, limit=1) + + season_id = fields.Many2one('golem.season', string='Seasons', + readonly=True, default=_default_season) + + @api.depends('day_ids') def _compute_occurences(self): """ Computes number of occurences """ diff --git a/golem_payment/views/golem_payment_views.xml b/golem_payment/views/golem_payment_views.xml index 786901a0..9b3ccb46 100644 --- a/golem_payment/views/golem_payment_views.xml +++ b/golem_payment/views/golem_payment_views.xml @@ -29,7 +29,7 @@ along with this program. If not, see . - +