Tryton - Issues



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

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

msg36385 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2017-10-20.10:29:35
Added the query to the migration page:
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:

The problem seems to be that address formats are not auto-updated: 

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/", 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 105, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/", line 165, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/model/", line 619, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/model/", line 34, in wrapper
    result = func(cls, filtered, *args, **kwargs)
  File "/trytond/modules/account_invoice/", line 1341, in post
  File "/trytond/modules/account_invoice/", line 1250, in print_invoice
    InvoiceReport.execute([], {})
  File "/trytond/modules/account_invoice/", line 2366, in execute
    result = super(InvoiceReport, cls).execute(ids, data)
  File "/trytond/report/", line 153, in execute
    cls.render(action_report, report_context))
  File "/trytond/report/", line 238, in render
    data = rel_report(**report_context).render()
  File "/relatorio/templates/", line 34, in render
    return self.serializer(
  File "/relatorio/templates/", line 893, 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 617, in _include
    for event in stream:
  File "/genshi/template/", line 326, in _match
    for event in stream:
  File "/genshi/template/", line 557, in _flatten
    for kind, data, pos in stream:
  File "/genshi/template/", line 359, 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 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "", line 1, in 
  File "/genshi/template/", line 318, in lookup_attr
    val = getattr(obj, key)
  File "/trytond/model/fields/", line 282, in _get_
    return inst.__getattr__(
  File "/trytond/model/", line 1369, in _getattr_
    read_data =, list(ffields.keys()))
  File "/trytond/model/", line 778, in read
    getter_results = field.get(ids, cls, field_list, values=result)
  File "/trytond/model/fields/", line 102, in get
    return dict((name, call(name)) for name in names)
  File "/trytond/model/fields/", line 102, in 
    return dict((name, call(name)) for name in names)
  File "/trytond/model/fields/", line 96, in call
    return dict((, method(r, name)) for r in records)
  File "/trytond/model/fields/", line 96, in 
    return dict((, method(r, name)) for r in records)
  File "/trytond/modules/party/", line 126, in get_full_address
  File "/", line 121, in substitute
    return self.pattern.sub(convert, self.template)
  File "/", line 111, in convert
    val = mapping[named]
KeyError: 'district'
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)