Tryton - Issues

 

Issue6111

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.

Messages
New changeset e86ec0730f49 by Florian Preinstorfer in branch '4.2':
Add district and district_code as valid substitutions
http://hg.tryton.org/modules/party/rev/e86ec0730f49
New changeset b12a7e71c582 by C?dric Krier in branch 'default':
Add validation of address format
http://hg.tryton.org/modules/party/rev/b12a7e71c582
review29831002 updated at https://codereview.tryton.org/29831002/#ps40001
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 https://codereview.tryton.org/29831002/#ps20001
review29801002 updated at https://codereview.tryton.org/29801002/#ps40001
New review29831002 at https://codereview.tryton.org/29831002/#ps1
review29801002 updated at https://codereview.tryton.org/29801002/#ps20001
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 https://codereview.tryton.org/29801002/#ps1
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
http://hg.tryton.org/modules/party/file/tip/address.xml#l475 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:
  Traceback (most recent call last):
    File "/trytond/wsgi.py", line 47, in dispatch_request
      return endpoint(request, **request.view_args)
    File "/trytond/protocols/dispatcher.py", line 41, in rpc
      request, database_name, *request.rpc_params)
    File "/trytond/wsgi.py", line 39, in auth_required
      return wrapped(*args, **kwargs)
    File "/trytond/protocols/wrappers.py", line 107, in wrapper
      return func(request, pool, *args, **kwargs)
    File "/trytond/protocols/dispatcher.py", line 160, in _dispatch
      result = rpc.result(meth(*c_args, **c_kwargs))
    File "/trytond/modules/company/company.py", line 393, in execute
      return super(LetterReport, cls).execute(ids, data)
    File "/trytond/report/report.py", line 152, in execute
      cls.render(action_report, report_context))
    File "/trytond/report/report.py", line 237, in render
      data = rel_report(**report_context).render()
    File "/relatorio/templates/base.py", line 34, in render
      return self.serializer(self.events)
    File "/relatorio/templates/opendocument.py", line 894, in __call__
      for kind, data, pos in stream:
    File "/genshi/core.py", line 289, in _ensure
      for event in stream:
    File "/genshi/filters/i18n.py", line 690, in __call__
      for kind, data, pos in stream:
    File "/genshi/template/base.py", line 618, in _include
      for event in stream:
    File "/genshi/template/markup.py", line 326, in _match
      for event in stream:
    File "/genshi/template/base.py", line 558, in _flatten
      for kind, data, pos in stream:
    File "/genshi/template/directives.py", line 360, in __call__
      iterable = _eval_expr(self.expr, ctxt, vars)
    File "/genshi/template/base.py", line 289, in _eval_expr
      retval = expr.evaluate(ctxt)
    File "/genshi/template/eval.py", 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/eval.py", line 317, in lookup_attr
      val = getattr(obj, key)
    File "/trytond/model/fields/field.py", line 261, in __get__
      return inst.__getattr__(self.name)
    File "/trytond/model/modelstorage.py", line 1364, in __getattr__
      read_data = self.read(list(ids), ffields.keys())
    File "/trytond/model/modelsql.py", line 773, in read
      getter_results = field.get(ids, cls, field_list, values=result)
    File "/trytond/model/fields/function.py", line 91, in get
      return dict((name, call(name)) for name in names)
    File "/trytond/model/fields/function.py", line 91, in <genexpr>
      return dict((name, call(name)) for name in names)
    File "/trytond/model/fields/function.py", line 85, in call
      return dict((r.id, method(r, name)) for r in records)
    File "/trytond/model/fields/function.py", line 85, in <genexpr>
      return dict((r.id, method(r, name)) for r in records)
    File "/trytond/modules/party/address.py", line 123, in get_full_address
      **self._get_address_substitutions())
    File "/string.py", line 172, in substitute
      return self.pattern.sub(convert, self.template)
    File "/string.py", line 162, in convert
      val = mapping[named]
  KeyError: u'district'

Reproduce:
 - 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
History
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)