Tryton - Issues

 

Issue7771

Title Users can not be deleted for logging purpose
Priority wish Status resolved
Superseder Nosy List ced, coogor, nicoe, pokoli, risto3
Type feature request Components
Assigned To ced Keywords
Reviews

Created on 2018-10-07.09:02:51 by risto3, last changed by ced.

Messages
msg51788 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-09-11.17:49:43
I added the queries on
https://discuss.tryton.org/t/migration-from-4-8-to-5-0/596
https://discuss.tryton.org/t/migration-from-5-0-to-5-2/995

Once run there are no more warnings.
msg51762 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-09-09.15:03:48
Indeed I think we should have wrote migration query that delete those users created by XML which are now gone (issue8201).
msg45352 (view) Author: [hidden] (nicoe) (Tryton committer) Date: 2018-12-17.17:19:26
Well since the error handling code will inactivate the record if it's possible to do so then we should warn that it has been deactivated, no?
msg45351 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-12-17.16:45:07
On 2018-12-17 16:16, Sergi Almacellas Abellana wrote:
> I see one improvement here: 
> 
> - If the model has an active field do not raise the deletion error but try to inactivate it. Only raise an error if it's not possible to inactivate it. 
> 
> Does it make sense for you?

For me, it is not right to silently ignore this case because the normal
state is to have the record deleted.
msg45349 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2018-12-17.16:16:44
Once this error is raised the code tries to inactivate the users. See:

http://hg.tryton.org/trytond/file/6571df5d8026/trytond/convert.py#l805

Your users should be inactive in the database. 

I see one improvement here: 

- If the model has an active field do not raise the deletion error but try to inactivate it. Only raise an error if it's not possible to inactivate it. 

Does it make sense for you?
msg45346 (view) Author: [hidden] (coogor) Date: 2018-12-17.14:39:41
Obviously there is the conversion routine trytond.convert that tries to delete a user from the database. 
First question is, why the user needs to be deleted.
Second, can the program trigger the inactivation?
If not, can that (what needs to be done) be included in a manual upgrade procedure?
msg45342 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-12-17.13:24:39
I have no idea how this could be improved so suggestion are welcomed.
msg45340 (view) Author: [hidden] (coogor) Date: 2018-12-17.13:11:04
I've seen that error as well, and thought I made a mistake...but it seems to be common.
@ced: A Python-Dump is expected behaviour?
msg44559 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-10-24.20:31:30
This is the expected behavior.
msg44351 (view) Author: [hidden] (risto3) Date: 2018-10-07.09:02:50
I'm seeing the following during update to V5:

21060 140057328604672 [2018-10-07 06:35:05,092] INFO trytond.convert Deleting 3@res.user from sale.user_process_sale
21060 140057328604672 [2018-10-07 06:35:05,124] ERROR trytond.convert Could not delete id: 3 of model res.user
There should be some relation that points to this resource
You should manually fix this and restart --update=module
Traceback (most recent call last):
  File "/opt/trytond/trytond/convert.py", line 797, in post_import
    Model.delete([Model(db_id)])
  File "/opt/trytond/trytond/res/user.py", line 414, in delete
    cls.raise_user_error('delete_forbidden')
  File "/opt/trytond/trytond/error.py", line 74, in raise_user_error
    raise UserError(error)
trytond.exceptions.UserError: ('UserError', ('Users can not be deleted for logging purpose.\nInstead you must inactivate them.', ''))
21060 140057328604672 [2018-10-07 06:35:05,164] INFO trytond.convert Deleting 3@ir.cron from purchase.cron_process_purchase
21060 140057328604672 [2018-10-07 06:35:05,194] INFO trytond.convert Deleting 38@res.user-res.group from purchase.user_process_purchase_group_purchase
21060 140057328604672 [2018-10-07 06:35:05,207] INFO trytond.convert Deleting 4@res.user from purchase.user_process_purchase
21060 140057328604672 [2018-10-07 06:35:05,211] ERROR trytond.convert Could not delete id: 4 of model res.user
There should be some relation that points to this resource
You should manually fix this and restart --update=module
Traceback (most recent call last):
  File "/opt/trytond/trytond/convert.py", line 797, in post_import
    Model.delete([Model(db_id)])
  File "/opt/trytond/trytond/res/user.py", line 414, in delete
    cls.raise_user_error('delete_forbidden')
  File "/opt/trytond/trytond/error.py", line 74, in raise_user_error
    raise UserError(error)
trytond.exceptions.UserError: ('UserError', ('Users can not be deleted for logging purpose.\nInstead you must inactivate them.', ''))


These are Cron processes:
$ psql foo -c '\copy res_user to stdout csv'
0,Root,f,root,,2018-09-14 21:09:46.784194,0,,,2,,,,,,,,,
2,Cron Trigger,f,user_cron_trigger,,2018-09-14 21:09:46.510312,0,,,2,,,,,,,,,
1,Administrator,t,admin,,2018-09-14 21:09:46.510312,0,admin,9,2,<sorry stina>,,,Administrator,2018-09-16 05:13:09.199355,1,1,,1
3,Cron Process Sale,f,user_cron_process_sale,,2018-09-14 21:14:19.878087,0,,,2,,,,"",2018-10-07 06:35:05.12769,0,,,
4,Cron Process Purchase,f,user_cron_process_purchase,,2018-09-14 21:14:30.215088,0,,,2,,,,"",2018-10-07 06:35:05.21346,0,,,
History
Date User Action Args
2019-09-11 17:49:43cedsetstatus: chatting -> resolved
assignedto: ced
messages: + msg51788
2019-09-09 15:03:49cedsetmessages: + msg51762
2018-12-17 17:19:27nicoesetnosy: + nicoe
messages: + msg45352
2018-12-17 16:45:07cedsetmessages: + msg45351
2018-12-17 16:16:44pokolisetnosy: + pokoli
messages: + msg45349
2018-12-17 14:39:41coogorsetmessages: + msg45346
2018-12-17 13:24:51cedsetpriority: feature -> wish
2018-12-17 13:24:39cedsetpriority: bug -> feature
type: feature request
messages: + msg45342
title: V5 update : Users can not be deleted for logging purpose -> Users can not be deleted for logging purpose
2018-12-17 13:11:05coogorsetstatus: invalid -> chatting
nosy: + coogor
messages: + msg45340
2018-10-24 20:31:30cedsetstatus: unread -> invalid
nosy: + ced
messages: + msg44559

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