forked from Yaltik/golem
[Bug] Add fonction to Get default season
This commit is contained in:
parent
bf8fc34b6b
commit
f3260ca757
@ -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 """
|
||||
|
@ -29,7 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name" />
|
||||
<field name="season_id" readonly='1'/>
|
||||
<field name="season_id" />
|
||||
<field name="day_ids" widget="many2many_tags" />
|
||||
<field name="occurences" />
|
||||
</group>
|
||||
|
Loading…
Reference in New Issue
Block a user