Tryton - Issues



Title KeyError: u'district' on label report when address format contains ${district}
Priority bug Status resolved
Superseder Nosy List ced, nblock, reviewbot, roundup-bot
Type crash Components party
Assigned To ced Keywords review
Reviews 29801002, 29831002
View: 29801002, 29831002

Created on 2016-12-12.16:32:49 by nblock, last changed by roundup-bot.

New changeset e86ec0730f49 by Florian Preinstorfer in branch '4.2':
Add district and district_code as valid substitutions
New changeset b12a7e71c582 by C?dric Krier in branch 'default':
Add validation of address format
review29831002 updated at
msg30978 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2016-12-26.21:08:15
I take it back to finish the patch to be included in the next bug-fix release sets.
review29831002 updated at
review29801002 updated at
New review29831002 at
review29801002 updated at
msg30755 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2016-12-15.09:52:29
We also need a patch for trunk that replace district by subdivision in the XML.
New review29801002 at
msg30688 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2016-12-12.17:22:53
OK, it would have been better to put a comment when re-opening the issue otherwise people can not understand what you are doing.

We need to have a fix for 4.2 which adds district as valid substitution.
And for trunk, we need to correct the template to use subdivision instead and we need to have a validation on the format.
msg30686 (view) Author: [hidden] (nblock) Date: 2016-12-12.17:12:03 and several other locations too.
msg30685 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2016-12-12.17:09:45
I do not see what is in-progress. 'district' is not a available variable because it does not exist.
msg30684 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2016-12-12.16:44:31
district is not an available variable.
msg30683 (view) Author: [hidden] (nblock) Date: 2016-12-12.16:32:48
  Traceback (most recent call last):
    File "/trytond/", line 47, in dispatch_request
      return endpoint(request, **request.view_args)
    File "/trytond/protocols/", line 41, in rpc
      request, database_name, *request.rpc_params)
    File "/trytond/", line 39, in auth_required
      return wrapped(*args, **kwargs)
    File "/trytond/protocols/", line 107, in wrapper
      return func(request, pool, *args, **kwargs)
    File "/trytond/protocols/", line 160, in _dispatch
      result = rpc.result(meth(*c_args, **c_kwargs))
    File "/trytond/modules/company/", line 393, in execute
      return super(LetterReport, cls).execute(ids, data)
    File "/trytond/report/", line 152, in execute
      cls.render(action_report, report_context))
    File "/trytond/report/", line 237, in render
      data = rel_report(**report_context).render()
    File "/relatorio/templates/", line 34, in render
      return self.serializer(
    File "/relatorio/templates/", line 894, in __call__
      for kind, data, pos in stream:
    File "/genshi/", line 289, in _ensure
      for event in stream:
    File "/genshi/filters/", line 690, in __call__
      for kind, data, pos in stream:
    File "/genshi/template/", line 618, in _include
      for event in stream:
    File "/genshi/template/", line 326, in _match
      for event in stream:
    File "/genshi/template/", line 558, in _flatten
      for kind, data, pos in stream:
    File "/genshi/template/", line 360, in __call__
      iterable = _eval_expr(self.expr, ctxt, vars)
    File "/genshi/template/", line 289, in _eval_expr
      retval = expr.evaluate(ctxt)
    File "/genshi/template/", line 177, in evaluate
      return eval(self.code, _globals, {'__data__': data})
    File "<string>", line 1, in <Expression u"iter(party.addresses[0].full_address.split('\\n'))">
    File "/genshi/template/", line 317, in lookup_attr
      val = getattr(obj, key)
    File "/trytond/model/fields/", line 261, in __get__
      return inst.__getattr__(
    File "/trytond/model/", line 1364, in __getattr__
      read_data =, ffields.keys())
    File "/trytond/model/", line 773, in read
      getter_results = field.get(ids, cls, field_list, values=result)
    File "/trytond/model/fields/", line 91, in get
      return dict((name, call(name)) for name in names)
    File "/trytond/model/fields/", line 91, in <genexpr>
      return dict((name, call(name)) for name in names)
    File "/trytond/model/fields/", line 85, in call
      return dict((, method(r, name)) for r in records)
    File "/trytond/model/fields/", line 85, in <genexpr>
      return dict((, method(r, name)) for r in records)
    File "/trytond/modules/party/", line 123, in get_full_address
    File "/", line 172, in substitute
      return self.pattern.sub(convert, self.template)
    File "/", line 162, in convert
      val = mapping[named]
  KeyError: u'district'

 - Create a new party with e.g. country 'Pakistan' (or any other country where
   ${district} is used in the address format.
 - Report -> Label

Trytond: 4.2
Date User Action Args
2016-12-29 13:43:43roundup-botsetmessages: + msg31045
2016-12-29 13:42:29roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg31044
2016-12-26 21:35:41reviewbotsetmessages: + msg30979
2016-12-26 21:08:15cedsetstatus: in-progress -> testing
assignedto: nblock -> ced
messages: + msg30978
2016-12-19 14:27:44reviewbotsetmessages: + msg30821
2016-12-15 13:32:43reviewbotsetmessages: + msg30766
2016-12-15 11:33:54reviewbotsetmessages: + msg30759
2016-12-15 11:33:53reviewbotsetreviews: 29801002 -> 29801002, 29831002
2016-12-15 11:33:49reviewbotsetmessages: + msg30758
2016-12-15 09:52:29cedsetstatus: chatting -> in-progress
messages: + msg30755

Showing 10 items. Show all history (warning: this could be VERY long)