Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRT][11.0][database_cleanup] forward port features #1507

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions database_cleanup/models/purge_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,19 @@ class CleanupPurgeWizardModule(models.TransientModel):
@api.model
def find(self):
res = []
purge_lines = self.env['cleanup.purge.line.module']
for module in self.env['ir.module.module'].search([]):
if get_module_path(module.name):
continue
if module.state == 'uninstalled':
self.env['cleanup.purge.line.module'].create({
purge_lines += self.env['cleanup.purge.line.module'].create({
'name': module.name,
}).purge()
})
continue
res.append((0, 0, {'name': module.name}))

purge_lines.purge()

if not res:
raise UserError(_('No modules found to purge'))
return res
Expand Down
28 changes: 27 additions & 1 deletion database_cleanup/models/purge_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from odoo import api, models, fields
REASON_DUPLICATE = 1
REASON_DEFAULT = 2
REASON_DEFAULT_FALSE = 3
REASON_UNKNOWN_MODEL = 4


class CleanupPurgeLineProperty(models.TransientModel):
Expand All @@ -17,6 +19,8 @@ class CleanupPurgeLineProperty(models.TransientModel):
reason = fields.Selection([
(REASON_DUPLICATE, 'Duplicated property'),
(REASON_DEFAULT, 'Same value as default'),
(REASON_DEFAULT_FALSE, 'Empty default property'),
(REASON_UNKNOWN_MODEL, 'Unknown model'),
])

@api.multi
Expand All @@ -42,6 +46,27 @@ def find(self):
])
handled_field_ids = []
for prop in default_properties:
value = None
try:
value = prop.get_by_record()
except KeyError:
result.append({
'name': '%s@%s: %s' % (
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,
})
continue
if prop.fields_id.id in handled_field_ids:
continue
domain = [
Expand Down Expand Up @@ -76,7 +101,8 @@ def find(self):
for redundant_property in self.env['ir.property'].search(domain):
result.append({
'name': '%s@%s: %s' % (
prop.name, prop.res_id, prop.get_by_record()
prop.name, redundant_property.res_id,
prop.get_by_record()
),
'property_id': redundant_property.id,
'reason': REASON_DEFAULT,
Expand Down