UnboundLocalError if subscription recurrance weekday is illegal
In a subscription recurrance, when entering a wrong weekday, the exception below occurs:
Traceback (most recent call last):
File "/trytond/wsgi.py", line 111, in dispatch_request
return endpoint(request, **request.view_args)
File "/trytond/protocols/dispatcher.py", line 48, in rpc
request, database_name, *request.rpc_params)
File "/trytond/wsgi.py", line 78, in auth_required
return wrapped(*args, **kwargs)
File "/trytond/protocols/wrappers.py", line 131, in wrapper
return func(request, pool, *args, **kwargs)
File "/trytond/protocols/dispatcher.py", line 181, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/trytond/model/modelsql.py", line 159, in wrapper
return func(cls, *args, **kwargs)
File "/trytond/model/modelsql.py", line 1033, in write
field.set(cls, fname, *fargs)
File "/trytond/model/fields/one2many.py", line 258, in set
Target.write(*to_write)
File "/trytond/model/modelsql.py", line 159, in wrapper
return func(cls, *args, **kwargs)
File "/trytond/model/modelsql.py", line 1039, in write
cls._validate(sub_records, field_names=all_field_names)
File "/trytond/model/modelstorage.py", line 76, in wrapper
return func(*args, **kwargs)
File "/trytond/model/modelstorage.py", line 1342, in _validate
record.pre_validate()
File "/trytond/modules/sale_subscription/recurrence.py", line 215, in pre_validate
self.check_by(name)
File "/trytond/modules/sale_subscription/recurrence.py", line 219, in check_by
getattr(self, '_%s' % name)
File "/trytond/modules/sale_subscription/recurrence.py", line 170, in _byweekday
byweekday.append(cls)
UnboundLocalError: local variable 'cls' referenced before assignment
Fault: local variable 'cls' referenced before assignment
Expected bahavior
Show some error message like "Illegal weekday XXX given" (with XXX = the offending value
How to reproduce
- Go to article → Settings → Subscrition Recurence Rules
- Create a new subscription:
- Name "doe not matter"
- Frequeny: weekly
- per weekday: "TX"
- Save it → Error