Tryton - Issues

 

Issue8843

Title FEC generation: 'ir.lang' Model has no attribute 'pm'
Priority bug Status chatting
Superseder Nosy List ced, reviewbot, semarie
Type crash Components account_fr
Assigned To semarie Keywords review
Reviews 282451002
View: 282451002

Created on 2019-11-20.15:37:03 by semarie, last changed by reviewbot.

Messages
review282451002 updated at https://codereview.tryton.org/282451002/#ps266391002
review282451002 updated at https://codereview.tryton.org/282451002/#ps258441002
review282451002 updated at https://codereview.tryton.org/282451002/#ps266371002
msg53364 (view) Author: [hidden] (semarie) Date: 2019-11-20.19:48:06
I created a review with reconciliation.create_date converted to date
msg53360 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-11-20.18:56:34
The test is not failing because pm is only required for datetime. And only reconciliation is datetime.
So I think the best is to convert the reconciliation create_date as date instead of fill pm on the language.
msg53359 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-11-20.18:52:20
Indeed FEC format force the configuration of the language so we use a fake one. But as we have defined new field on ir.lang that are used for formatting, we should fill them in the fake language.
msg53358 (view) Author: [hidden] (semarie) Date: 2019-11-20.15:37:02
Using tip (cbbf40368fcb exactly), when trying to generate FEC, I have the following exception:

Traceback (most recent call last):
  File "/trytond/model/model.py", line 277, in __getattr__
    return self._values[name]
KeyError: 'pm'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/trytond/wsgi.py", line 108, 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 76, 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 186, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/wizard/wizard.py", line 285, in execute
    return wizard._execute(state_name)
  File "/trytond/wizard/wizard.py", line 316, in _execute
    result = self._execute(transition())
  File "/trytond/modules/account_fr/account.py", line 117, in transition_generate
    row = self.get_row(line, format_date, format_number)
  File "/trytond/modules/account_fr/account.py", line 305, in get_row
    format_date(reconciliation.create_date) if reconciliation else '',
  File "/trytond/modules/account_fr/account.py", line 150, in <lambda>
    return lambda value: fr.strftime(value, '%Y%m%d')
  File "/trytond/ir/lang.py", line 504, in strftime
    p = self.pm or 'PM'
  File "/trytond/model/modelstorage.py", line 1403, in __getattr__
    return super(ModelStorage, self).__getattr__(name)
  File "/trytond/model/model.py", line 280, in __getattr__
    % (self.__name__, name, self._values))
AttributeError: 'ir.lang' Model has no attribute 'pm': {'code': 'fr_FR', 'date': '%d.%m.%Y'}

Fault: 'ir.lang' Model has no attribute 'pm': {'code': 'fr_FR', 'date': '%d.%m.%Y'}

I am able to reproduce it with trytond-console (it is the same way account_fr/account.fr function get_format_date() is doing):
>>> fr = Lang(code='fr_FR', date='%d.%m.%Y')
>>> fr.pm
Traceback (most recent call last):
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/trytond/model/model.py", line 277, in __getattr__
    return self._values[name]
KeyError: 'pm'
...

But I couldn't reproduce if I get a Lang from database:
>>> >>> fr, = Lang.search([('code', '=', 'fr')])
>>> fr.pm
''

I am unsure if the problem is in account_fr (Lang should be get from database) or in trytond itself (pm field should be infered to None as not defined).
History
Date User Action Args
2019-11-21 08:40:53reviewbotsetmessages: + msg53370
2019-11-21 07:08:51reviewbotsetmessages: + msg53369
2019-11-20 20:08:25reviewbotsetstatus: unread -> chatting
nosy: + reviewbot
messages: + msg53365
2019-11-20 19:48:06semariesetstatus: chatting -> unread
reviews: 282451002
messages: + msg53364
keyword: + review
assignedto: semarie
2019-11-20 18:56:34cedsetmessages: + msg53360
2019-11-20 18:52:20cedsetstatus: unread -> chatting
nosy: + ced
messages: + msg53359
2019-11-20 15:37:03semariecreate

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