[ADD] auditlog: enable to track Unlink record
parent
cc42565123
commit
2ab065271d
|
@ -138,6 +138,9 @@ class AuditlogRule(models.Model):
|
||||||
string="Action",
|
string="Action",
|
||||||
states={"subscribed": [("readonly", True)]},
|
states={"subscribed": [("readonly", True)]},
|
||||||
)
|
)
|
||||||
|
capture_record = fields.Boolean(
|
||||||
|
"Capture Record", help="Select this if you want to keep track of Unlink Record",
|
||||||
|
)
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
(
|
(
|
||||||
|
@ -474,6 +477,10 @@ class AuditlogRule(models.Model):
|
||||||
for res_id in res_ids:
|
for res_id in res_ids:
|
||||||
model_model = self.env[res_model]
|
model_model = self.env[res_model]
|
||||||
name = model_model.browse(res_id).name_get()
|
name = model_model.browse(res_id).name_get()
|
||||||
|
model_id = self.pool._auditlog_model_cache[res_model]
|
||||||
|
auditlog_rule = self.env["auditlog.rule"].search(
|
||||||
|
[("model_id", "=", model_id)]
|
||||||
|
)
|
||||||
res_name = name and name[0] and name[0][1]
|
res_name = name and name[0] and name[0][1]
|
||||||
vals = {
|
vals = {
|
||||||
"name": res_name,
|
"name": res_name,
|
||||||
|
@ -499,6 +506,10 @@ class AuditlogRule(models.Model):
|
||||||
self._create_log_line_on_write(
|
self._create_log_line_on_write(
|
||||||
log, diff.changed(), old_values, new_values
|
log, diff.changed(), old_values, new_values
|
||||||
)
|
)
|
||||||
|
elif method == "unlink" and auditlog_rule.capture_record:
|
||||||
|
self._create_log_line_on_read(
|
||||||
|
log, list(old_values.get(res_id, EMPTY_DICT).keys()), old_values
|
||||||
|
)
|
||||||
|
|
||||||
def _get_field(self, model, field_name):
|
def _get_field(self, model, field_name):
|
||||||
cache = self.pool._auditlog_field_cache
|
cache = self.pool._auditlog_field_cache
|
||||||
|
|
|
@ -5,3 +5,5 @@
|
||||||
* Pieter Paulussen <pieter.paulussen@me.com>
|
* Pieter Paulussen <pieter.paulussen@me.com>
|
||||||
* Alan Ramos <alan.ramos@jarsa.com.mx>
|
* Alan Ramos <alan.ramos@jarsa.com.mx>
|
||||||
* Stefan Rijnhart <stefan@opener.amsterdam>
|
* Stefan Rijnhart <stefan@opener.amsterdam>
|
||||||
|
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
||||||
|
* Hardik Suthar <hsuthar@opensourceintegrators.com>
|
||||||
|
|
|
@ -40,6 +40,10 @@
|
||||||
readonly="1"
|
readonly="1"
|
||||||
groups="base.group_no_one"
|
groups="base.group_no_one"
|
||||||
/>
|
/>
|
||||||
|
<field
|
||||||
|
name="capture_record"
|
||||||
|
attrs="{'invisible':['|' ,('log_type','!=', 'full'), ('log_unlink','!=', True)]}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group colspan="1">
|
<group colspan="1">
|
||||||
<field name="log_read" />
|
<field name="log_read" />
|
||||||
|
|
Loading…
Reference in New Issue