[IMP] Allow to delete attachment without res_model
But allow it only if a file pattern is set, to avoid deleting all orphan attachments are some are auto-generated by Odoopull/2766/head
parent
2109c15361
commit
4f42cf895d
|
@ -30,7 +30,7 @@ class IrAttachment(models.Model):
|
||||||
if rule.model_ids:
|
if rule.model_ids:
|
||||||
models = rule.model_ids.mapped("model")
|
models = rule.model_ids.mapped("model")
|
||||||
domains.append([("res_model", "in", models)])
|
domains.append([("res_model", "in", models)])
|
||||||
else:
|
elif not rule.empty_model or not rule.filename_pattern:
|
||||||
# Avoid deleting attachment without model, if there are, it is
|
# Avoid deleting attachment without model, if there are, it is
|
||||||
# probably some attachments created by Odoo
|
# probably some attachments created by Odoo
|
||||||
domains.append([("res_model", "!=", False)])
|
domains.append([("res_model", "!=", False)])
|
||||||
|
|
|
@ -61,6 +61,10 @@ class VacuumRule(models.Model):
|
||||||
)
|
)
|
||||||
model_filter_domain = fields.Text()
|
model_filter_domain = fields.Text()
|
||||||
model = fields.Char(readonly=True, compute="_compute_model_id", string="Model code")
|
model = fields.Char(readonly=True, compute="_compute_model_id", string="Model code")
|
||||||
|
empty_model = fields.Boolean(
|
||||||
|
help="Take into account attachment not linked to any model, but only if a "
|
||||||
|
"pattern is set, to avoid deleting attachments generated/needed by odoo"
|
||||||
|
)
|
||||||
message_type = fields.Selection(
|
message_type = fields.Selection(
|
||||||
[
|
[
|
||||||
("email", "Email"),
|
("email", "Email"),
|
||||||
|
|
|
@ -39,6 +39,10 @@
|
||||||
<group attrs="{'invisible': [('ttype', '!=', 'attachment')]}">
|
<group attrs="{'invisible': [('ttype', '!=', 'attachment')]}">
|
||||||
<field name="filename_pattern" />
|
<field name="filename_pattern" />
|
||||||
<field name="inheriting_model" />
|
<field name="inheriting_model" />
|
||||||
|
<field
|
||||||
|
name="empty_model"
|
||||||
|
attrs="{'invisible': ['|', ('model_ids', '!=', []), ('filename_pattern', '=', False)]}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group string="Models">
|
<group string="Models">
|
||||||
<field name="model_ids" nolabel="1" colspan="4" />
|
<field name="model_ids" nolabel="1" colspan="4" />
|
||||||
|
|
Loading…
Reference in New Issue