Browse Source

Merge pull request #1507 from hbrunn/11.0-database_cleanup-forward_port_features-2019-02-11

[PRT][11.0][database_cleanup] forward port features
pull/1424/head
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
2e7541afb3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      database_cleanup/models/purge_modules.py
  2. 28
      database_cleanup/models/purge_properties.py

7
database_cleanup/models/purge_modules.py

@ -63,16 +63,19 @@ class CleanupPurgeWizardModule(models.TransientModel):
@api.model @api.model
def find(self): def find(self):
res = [] res = []
purge_lines = self.env['cleanup.purge.line.module']
for module in self.env['ir.module.module'].search([]): for module in self.env['ir.module.module'].search([]):
if get_module_path(module.name): if get_module_path(module.name):
continue continue
if module.state == 'uninstalled': if module.state == 'uninstalled':
self.env['cleanup.purge.line.module'].create({
purge_lines += self.env['cleanup.purge.line.module'].create({
'name': module.name, 'name': module.name,
}).purge()
})
continue continue
res.append((0, 0, {'name': module.name})) res.append((0, 0, {'name': module.name}))
purge_lines.purge()
if not res: if not res:
raise UserError(_('No modules found to purge')) raise UserError(_('No modules found to purge'))
return res return res

28
database_cleanup/models/purge_properties.py

@ -4,6 +4,8 @@
from odoo import api, models, fields from odoo import api, models, fields
REASON_DUPLICATE = 1 REASON_DUPLICATE = 1
REASON_DEFAULT = 2 REASON_DEFAULT = 2
REASON_DEFAULT_FALSE = 3
REASON_UNKNOWN_MODEL = 4
class CleanupPurgeLineProperty(models.TransientModel): class CleanupPurgeLineProperty(models.TransientModel):
@ -17,6 +19,8 @@ class CleanupPurgeLineProperty(models.TransientModel):
reason = fields.Selection([ reason = fields.Selection([
(REASON_DUPLICATE, 'Duplicated property'), (REASON_DUPLICATE, 'Duplicated property'),
(REASON_DEFAULT, 'Same value as default'), (REASON_DEFAULT, 'Same value as default'),
(REASON_DEFAULT_FALSE, 'Empty default property'),
(REASON_UNKNOWN_MODEL, 'Unknown model'),
]) ])
@api.multi @api.multi
@ -42,6 +46,27 @@ class CleanupPurgeWizardProperty(models.TransientModel):
]) ])
handled_field_ids = [] handled_field_ids = []
for prop in default_properties: 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: if prop.fields_id.id in handled_field_ids:
continue continue
domain = [ domain = [
@ -76,7 +101,8 @@ class CleanupPurgeWizardProperty(models.TransientModel):
for redundant_property in self.env['ir.property'].search(domain): for redundant_property in self.env['ir.property'].search(domain):
result.append({ result.append({
'name': '%s@%s: %s' % ( '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, 'property_id': redundant_property.id,
'reason': REASON_DEFAULT, 'reason': REASON_DEFAULT,

Loading…
Cancel
Save