Tryton - Issues

 

Issue8478

Title migration error from 5.0 to 5.2: ir.msg_setter_function_missing
Priority bug Status resolved
Superseder Nosy List ced, reviewbot, roundup-bot, semarie
Type crash Components trytond
Assigned To semarie Keywords review
Reviews 251711002
View: 251711002

Created on 2019-07-07.10:26:23 by semarie, last changed by roundup-bot.

Messages
New changeset 9438b92ee708 by Sebastien Marie in branch '5.2':
Skip the Function field without setter in Data.sync()
https://hg.tryton.org/trytond/rev/9438b92ee708
New changeset c599ab843dfc by Cédric Krier in branch 'default':
Skip the Function field without setter in Data.sync()
https://hg.tryton.org/tryton-env/rev/c599ab843dfc
New changeset 30b549397664 by Sebastien Marie in branch 'default':
Skip the Function field without setter in Data.sync()
https://hg.tryton.org/trytond/rev/30b549397664
review251711002 updated at https://codereview.tryton.org/251711002/#ps253801002
review251711002 updated at https://codereview.tryton.org/251711002/#ps259821002
review251711002 updated at https://codereview.tryton.org/251711002/#ps287711002
review251711002 updated at https://codereview.tryton.org/251711002/#ps279671002
review251711002 updated at https://codereview.tryton.org/251711002/#ps277571002
msg50525 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-07-07.13:39:41
This is because the deferral field became a Function field without setter.
I guess the sync method should skip the Function field without setter.
msg50522 (view) Author: [hidden] (semarie) Date: 2019-07-07.10:26:22
I am testing a migration path between 5.0 and 5.2.

When tryting to synchronize out_fo_sync ir.model.data records, I have the following error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/model/modelview.py", line 692, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/ir/model.py", line 1265, in sync
    Model.write(*values_to_write)
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/model/modelsql.py", line 159, in wrapper
    return func(cls, *args, **kwargs)
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/model/modelsql.py", line 1007, in write
    field.set(cls, fname, *fargs)
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/model/fields/function.py", line 126, in set
    **Model.__names__(self.name)))
NotImplementedError: Fonction de définition manquante pour le champ « Report » sur « Modèle de compte ».

The exception message (in french here) is "ir.msg_setter_function_missing".

I tested it with empty database with only standard modules installed. The database has been initialized with a Party, a Company, and a Chart of Accounts (French plan).

Next, I started the following upgrade path:
- stopped my 5.0 server
- applying database conversion described on https://discuss.tryton.org/t/migration-from-5-0-to-5-2/995
- running trytond-admin -d test -m
- running trytond-admin -d test --all
  few warnings
- with trytond-console, I checked for out_of_sync records
  >>> Data = pool.get('ir.model.data')
  >>> ms = Data.search([('out_of_sync', '=', True)])
  >>> len(ms)
  87
  >>> set(map(lambda m: (m.module, m.model) , ms))
{('account', 'ir.model.button'), ('country', 'country.subdivision'), ('account_invoice', 'ir.model.button'), ('account_payment', 'ir.rule.group'), ('account_product', 'ir.rule.group'
), ('account_fr', 'account.account.type.template'), ('account_invoice', 'ir.rule.group'), ('account_statement', 'ir.model.button'), ('account_statement', 'ir.rule.group'), ('account_
asset', 'ir.model.button'), ('ir', 'ir.lang'), ('account_payment_sepa', 'ir.rule.group'), ('account_payment_sepa', 'ir.model.button'), ('analytic_account', 'ir.rule.group'), ('accoun
t', 'ir.rule.group'), ('res', 'ir.rule.group'), ('account_asset', 'ir.rule.group'), ('company', 'ir.rule.group'), ('account', 'account.account.type.template')}
  >>> Data.sync(ms)
  >>> Data.search([('out_of_sync', '=', True)])
  []
  >>> transaction.commit()

- rerun trytond-admin -d test --all
  no more warnings

- rerun trytond-console -d test
  >>> Data = pool.get('ir.model.data')
  >>> ms = Data.search([('out_of_sync', '=', True)])
  >>> len(ms)
  651
  >>> set(map(lambda m: (m.module, m.model) , ms))
  {('account', 'ir.action.act_window'), ('ir', 'ir.ui.menu'), ('account', 'ir.action.act_window.domain'), ('ir', 'ir.lang'), ('account_fr', 'account.tax.code.line.template'), ('account
_fr', 'account.account.template'), ('res', 'ir.cron'), ('account_asset', 'account.account.template'), ('account_fr', 'account.account.type.template'), ('account_payment_clearing', 'i
r.cron'), ('account_payment', 'ir.action.act_window'), ('account', 'account.account.type.template'), ('account', 'account.account.template')}
  >>> Data.sync(ms)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/model/modelview.py", line 692, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/ir/model.py", line 1265, in sync
    Model.write(*values_to_write)
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/model/modelsql.py", line 159, in wrapper
    return func(cls, *args, **kwargs)
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/model/modelsql.py", line 1007, in write
    field.set(cls, fname, *fargs)
  File "/home/semarie/tmp/tryton/tryton-5.2/lib/python3.7/site-packages/trytond/model/fields/function.py", line 126, in set
    **Model.__names__(self.name)))
NotImplementedError: Fonction de définition manquante pour le champ « Report » sur « Modèle de compte ».

If I ran Data.sync() individually on each record, I have errors only on a few set of records.

>>> def resync_one_by_one(ms):
...         for m in ms:
...           try:
...             Data.sync([m])
...           except:
...             pass
...
>>> resync_one_by_one(ms)
>>> ms = Data.search([('out_of_sync', '=', True)])
>>> len(ms)
93
>>> set(map(lambda m: (m.module, m.model) , ms))
{('account_fr', 'account.account.template'), ('account_asset', 'account.account.template')}

Example of values:
>>> ms[0].model
'account.account.template'
>>> ms[0].module
'account_asset'
>>> ms[0].values
'[["deferral",true],["kind","expense"],["name","Assets"],["parent",1],["reconcile",false],["type",6]]'
>>> ms[0].fs_values
'[["deferral",true],["kind","expense"],["name","Assets"],["parent",1],["reconcile",false],["type",297]]'

>>> ms[-1].model
'account.account.template'
>>> ms[-1].module
'account_fr'
>>> ms[-1].values
'[["code","8092"],["deferral",true],["kind","other"],["name","Contrepartie 802"],["parent",1315],["type",296]]'
>>> ms[-1].fs_values
'[["code","8092"],["deferral",true],["kind","other"],["name","Contrepartie 802"],["parent",1315],["type",314]]'
History
Date User Action Args
2019-07-22 21:48:19roundup-botsetmessages: + msg50788
keyword: - backport
2019-07-17 01:03:45cedsetkeyword: + backport
2019-07-17 01:03:08roundup-botsetmessages: + msg50683
2019-07-17 00:58:10roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg50681
2019-07-11 07:03:45reviewbotsetmessages: + msg50612
2019-07-10 16:45:53reviewbotsetmessages: + msg50605
2019-07-10 15:46:16reviewbotsetmessages: + msg50604
2019-07-09 23:43:21cedsetstatus: chatting -> testing
2019-07-08 10:33:52reviewbotsetmessages: + msg50535
2019-07-08 10:13:11reviewbotsetnosy: + reviewbot
messages: + msg50533

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