Skip to content

Commit

Permalink
Merge pull request #36 from Yajo/fix-35
Browse files Browse the repository at this point in the history
Make no type count as a type.
  • Loading branch information
pedrobaeza committed Feb 18, 2016
2 parents a92139c + e2cd467 commit 3cf93ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ def test_cancel_multi_event_type(self):
self.wizard_model.with_context(
active_ids=self.registrations.ids).create(
{'reason_id': self.cancel_reason.id})

def test_cancel_one_event_without_type(self):
"""Registration cancel from 2 events (1 typed, 1 not) are aborted."""
self.event2.type = False
with self.assertRaises(exceptions.ValidationError):
self.wizard_model.with_context(
active_ids=self.registrations.ids).create(
{'reason_id': self.cancel_reason.id})
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ def default_get(self, var_fields):
var_fields)
registrations = self.env['event.registration'].browse(
self.env.context['active_ids'])
event_type = registrations.mapped("event_id.type")
if len(event_type) != 1:
raise exceptions.ValidationError(
_("You cannot cancel registrations from events of different "
"types at once."))
res['event_type_id'] = event_type.id
first_type = registrations[:1].event_id.type
for event in registrations.mapped("event_id"):
if event.type != first_type:
raise exceptions.ValidationError(
_("You cannot cancel registrations from events of "
"different types at once."))
res['event_type_id'] = first_type.id
return res

@api.multi
Expand Down

0 comments on commit 3cf93ba

Please sign in to comment.