Browse Source
[IMP] don't break on properties pointing to unknown models
pull/1507/head
Holger Brunn
6 years ago
No known key found for this signature in database
GPG Key ID: 1C9760FECA3AE18
1 changed files with
15 additions and
2 deletions
-
database_cleanup/models/purge_properties.py
|
|
@ -5,6 +5,7 @@ from odoo import api, models, fields |
|
|
|
REASON_DUPLICATE = 1 |
|
|
|
REASON_DEFAULT = 2 |
|
|
|
REASON_DEFAULT_FALSE = 3 |
|
|
|
REASON_UNKNOWN_MODEL = 4 |
|
|
|
|
|
|
|
|
|
|
|
class CleanupPurgeLineProperty(models.TransientModel): |
|
|
@ -44,10 +45,22 @@ class CleanupPurgeWizardProperty(models.TransientModel): |
|
|
|
]) |
|
|
|
handled_field_ids = [] |
|
|
|
for prop in default_properties: |
|
|
|
if not prop.get_by_record(): |
|
|
|
value = None |
|
|
|
try: |
|
|
|
value = prop.get_by_record() |
|
|
|
except KeyError: |
|
|
|
result.append({ |
|
|
|
'name': '%s@%s: %s' % ( |
|
|
|
prop.name, prop.res_id, prop.get_by_record() |
|
|
|
prop.name, prop.res_id, value, |
|
|
|
), |
|
|
|
'property_id': prop.id, |
|
|
|
'reason': REASON_UNKNOWN_MODEL, |
|
|
|
}) |
|
|
|
continue |
|
|
|
if not value: |
|
|
|
result.append({ |
|
|
|
'name': '%s@%s: %s' % ( |
|
|
|
prop.name, prop.res_id, value, |
|
|
|
), |
|
|
|
'property_id': prop.id, |
|
|
|
'reason': REASON_DEFAULT_FALSE, |
|
|
|