[ADD]GOLEM Activity Registration : dynamic domain for only subscribers

* Filter members according to activity ;
* Filter activities according to member.
This commit is contained in:
Fabien BOURGEOIS 2018-09-26 10:33:17 +02:00
parent 4d889a3eba
commit 87e7bccb57
5 changed files with 56 additions and 13 deletions

View File

@ -18,7 +18,7 @@
{
'name': 'GOLEM Activity Member Registrations',
'summary': 'GOLEM Activities Member Registrations management',
'version': '10.0.1.4.5',
'version': '10.0.1.5.0',
'category': 'GOLEM',
'author': 'Fabien Bourgeois, Michel Dessenne',
'license': 'AGPL-3',

View File

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-09 14:23+0000\n"
"PO-Revision-Date: 2018-08-09 16:38+0200\n"
"POT-Creation-Date: 2018-09-26 08:25+0000\n"
"PO-Revision-Date: 2018-09-26 10:28+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -204,6 +204,13 @@ msgstr "Le nombre de places ne peut pas être négatif"
msgid "On default season, there is no activity for this member."
msgstr "Sur la saison par défaut, il n'y a pas d'activité pour cet usager."
#. module: golem_activity_registration
#: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_only_for_subscriber
#: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_only_for_subscriber
#: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_search_inherit_registration
msgid "Only for subscriber"
msgstr "Réservé aux adhérents"
#. module: golem_activity_registration
#: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_places
msgid "Places"
@ -245,7 +252,7 @@ msgid "Service user"
msgstr "Usager"
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:70
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:71
#, python-format
msgid "Sorry, there is no more place !"
msgstr "Désolé, il n'y a plus de place disponible !"
@ -256,13 +263,19 @@ msgid "Subscription"
msgstr "Inscription"
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:100
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:130
#, python-format
msgid "Subscription can not be executed : the targeted activity is only for subscriber."
msgstr "L'inscription n'a pas pu être faite : l'activité choisie est réservée aux adhérents."
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:134
#, python-format
msgid "Subscription can not be executed : the targeted member is not on the same season as the activity."
msgstr "L'inscription n'a pas pu être enregistrée : l'usager visé n'est pas ahdérant pour la même saison que celle pendant laquelle se déroule l'activité."
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:92
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:104
#: sql_constraint:golem.activity.registration:0
#, python-format
msgid "This member has already been registered for this activity."

View File

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-09 14:23+0000\n"
"PO-Revision-Date: 2018-08-09 14:23+0000\n"
"POT-Creation-Date: 2018-09-26 08:25+0000\n"
"PO-Revision-Date: 2018-09-26 08:25+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -204,6 +204,13 @@ msgstr ""
msgid "On default season, there is no activity for this member."
msgstr ""
#. module: golem_activity_registration
#: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_only_for_subscriber
#: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_only_for_subscriber
#: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_search_inherit_registration
msgid "Only for subscriber"
msgstr ""
#. module: golem_activity_registration
#: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_places
msgid "Places"
@ -245,7 +252,7 @@ msgid "Service user"
msgstr ""
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:70
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:71
#, python-format
msgid "Sorry, there is no more place !"
msgstr ""
@ -256,13 +263,19 @@ msgid "Subscription"
msgstr ""
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:100
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:130
#, python-format
msgid "Subscription can not be executed : the targeted activity is only for subscriber."
msgstr ""
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:134
#, python-format
msgid "Subscription can not be executed : the targeted member is not on the same season as the activity."
msgstr ""
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:92
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:104
#: sql_constraint:golem.activity.registration:0
#, python-format
msgid "This member has already been registered for this activity."

View File

@ -76,7 +76,7 @@ class GolemActivityRegistration(models.Model):
""" GOLEM Activity Registration """
_name = 'golem.activity.registration'
_description = 'GOLEM Activity Registration'
_rec_name ='activity_id'
_rec_name = 'activity_id'
member_id = fields.Many2one('golem.member', string='Service user',
required=True, ondelete='cascade', index=True)
@ -92,6 +92,23 @@ class GolemActivityRegistration(models.Model):
('registration_uniq', 'UNIQUE (member_id, activity_id)',
_('This member has already been registered for this activity.'))]
@api.onchange('activity_id', 'activity_id.only_for_subscriber')
def onchange_activity_subcrib(self):
""" If activity only for subscribers : do not allow non subscribers """
domain = []
if self.activity_id.only_for_subscriber:
domain.append(('membership_state', 'not in', ('none', 'canceled', 'old')))
return {'domain': {'member_id': domain}}
@api.onchange('member_id')
def onchange_member_subcrib(self):
""" If not subscriber : do not show subscribers only activities """
domain = []
if self.member_id and self.member_id.membership_state in ('none', 'canceled', 'old'):
domain.append(('only_for_subscriber', '=', False))
return {'domain': {'activity_id': domain}}
@api.constrains('member_id', 'activity_id')
def _check_season_reliability(self):
""" Forbid registration when member season if not coherent with

View File

@ -38,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</group>
</page>
</page>
<field name="list_price" position="after">
<field name="audience_id" position="before">
<field name="only_for_subscriber"/>
</field>
</field>