From 49c5c7481af1fb5f04967047af3714e7fe46587a Mon Sep 17 00:00:00 2001 From: Fabien Bourgeois Date: Mon, 5 Jun 2017 10:02:38 +0200 Subject: [PATCH] [IMP]State id according to country id on GOLEM Member + [FIX]number_name field should be empty on creation --- golem_member/models/golem_member.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/golem_member/models/golem_member.py b/golem_member/models/golem_member.py index df499cd..8184f6a 100644 --- a/golem_member/models/golem_member.py +++ b/golem_member/models/golem_member.py @@ -94,11 +94,24 @@ class GolemMember(models.Model): is_number_manual = fields.Boolean('Is number manual?', store=False, compute='_compute_is_number_manual') + @api.onchange('country_id') + def _onchange_country_id(self): + member = self[0] + if member.country_id: + return { + 'domain': {'state_id': [('country_id', '=', member.country_id.id)]} + } + else: + return {'domain': {'state_id': []}} + @api.depends('number', 'name') def _compute_number_name(self): """ Computes a name composed with number and name """ for member in self: - member.number_name = u'{} - {}'.format(member.number, member.name) + if member.name: + member.number_name = u'{} - {}'.format(member.number, member.name) + else: + member.number_name = u'' @api.multi @api.depends('season_ids')