Tryton - Issues

 

Issue6869

Title party address formats are not auto-updated, thus missing the district -> subdivision rename
Priority bug Status resolved
Superseder Nosy List ced, pokoli, rhertzog
Type crash Components party
Assigned To Keywords
Reviews

Created on 2017-10-20.09:32:04 by rhertzog, last changed by pokoli.

Messages
msg36385 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2017-10-20.10:29:35
Added the query to the migration page:

https://discuss.tryton.org/t/migration-from-4-2-to-4-4/264
msg36382 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2017-10-20.10:09:26
address format should stay non-updatable to allow customization.
As we do not know if custom module did not add a district option, we should just add the query to the migration page.
msg36381 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2017-10-20.09:46:59
It can be fixed executing the following query on the database:

UPDATE party_address_format SET format_ = REPLACE(format_, '${district}', '${subdivision}');

I'm wondering if including this query in the migration page will be enough, or we should change something in the module. I see the following possible changes:

1. Add this query as migration from 4.2
2. Make the party_address updatable, which will help us for future changes.
msg36380 (view) Author: [hidden] (rhertzog) (Tryton committer) Date: 2017-10-20.09:32:04
In Tryton 4.4 I get an error similar to what got reported here: https://bugs.tryton.org/issue6111

The problem seems to be that address formats are not auto-updated:
http://hg.tryton.org/modules/party/file/1bb95be2e171/address.xml#l89 

So despite the above fix, when you upgrade from 4.2 to 4.4, you still have "${district}" in many address formats and you end up with traceback such as the one show below when trying to generate an invoice.

Either the address formats needs to be marked as auto-updatable, or you need to add migration code to replace "${district}" with "${subdivision}".

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 105, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 165, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/model/modelview.py", line 619, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/model/workflow.py", line 34, in wrapper
    result = func(cls, filtered, *args, **kwargs)
  File "/trytond/modules/account_invoice/invoice.py", line 1341, in post
    invoice.print_invoice()
  File "/trytond/modules/account_invoice/invoice.py", line 1250, in print_invoice
    InvoiceReport.execute([self.id], {})
  File "/trytond/modules/account_invoice/invoice.py", line 2366, in execute
    result = super(InvoiceReport, cls).execute(ids, data)
  File "/trytond/report/report.py", line 153, in execute
    cls.render(action_report, report_context))
  File "/trytond/report/report.py", line 238, 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 893, 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 617, 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 557, in _flatten
    for kind, data, pos in stream:
  File "/genshi/template/directives.py", line 359, 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 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "", line 1, in 
  File "/genshi/template/eval.py", line 318, in lookup_attr
    val = getattr(obj, key)
  File "/trytond/model/fields/field.py", line 282, in _get_
    return inst.__getattr__(self.name)
  File "/trytond/model/modelstorage.py", line 1369, in _getattr_
    read_data = self.read(list(ids), list(ffields.keys()))
  File "/trytond/model/modelsql.py", line 778, in read
    getter_results = field.get(ids, cls, field_list, values=result)
  File "/trytond/model/fields/function.py", line 102, in get
    return dict((name, call(name)) for name in names)
  File "/trytond/model/fields/function.py", line 102, in 
    return dict((name, call(name)) for name in names)
  File "/trytond/model/fields/function.py", line 96, in call
    return dict((r.id, method(r, name)) for r in records)
  File "/trytond/model/fields/function.py", line 96, in 
    return dict((r.id, method(r, name)) for r in records)
  File "/trytond/modules/party/address.py", line 126, in get_full_address
    **self._get_address_substitutions())
  File "/string.py", line 121, in substitute
    return self.pattern.sub(convert, self.template)
  File "/string.py", line 111, in convert
    val = mapping[named]
KeyError: 'district'
History
Date User Action Args
2017-10-20 10:29:36pokolisetstatus: chatting -> resolved
messages: + msg36385
2017-10-20 10:09:27cedsetnosy: + ced
messages: + msg36382
2017-10-20 09:46:59pokolisetstatus: unread -> chatting
nosy: + pokoli
messages: + msg36381
2017-10-20 09:32:04rhertzogcreate

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