2
I will create a rule for Invoice object
4
!python {model: audittrail.rule}: |
6
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.invoice')], context=context)
7
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
8
if object_ids and not rule_id:
10
fields = ['date_invoice', 'state', 'account_id', 'address_invoice_id', 'amount_to_pay', 'analytic_distribution_id',
11
'check_total', 'comment', 'currency_id', 'fiscal_position', 'name', 'origin', 'partner_id',
12
'payment_ids', 'period_id', 'reference', 'reference_type', 'tax_line']
14
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.invoice'), ('name', 'in', fields)], context=context)
16
rule_id = self.create(cr, uid, {'name': name,
17
'object_id': object_ids[0],
21
'field_ids': [(6, 0, fields_ids)],
24
# Subscribe to the rule
25
self.subscribe(cr, uid, rule_id)
27
I will create a rule for Invoice lines
29
!python {model: audittrail.rule}: |
31
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.invoice.line')], context=context)
32
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
33
if object_ids and not rule_id:
35
fields = ['account_id', 'analytic_distribution_id', 'invoice_id', 'invoice_line_tax_id', 'name', 'origin', 'partner_id', 'price_unit',
36
'product_id', 'quantity', 'uos_id']
38
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.invoice.line'), ('name', 'in', fields)], context=context)
39
field_name = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.invoice.line'), ('name', '=', 'line_number')], context=context)
40
field_parent = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.invoice.line'), ('name', '=', 'invoice_id')], context=context)
46
parent_id = field_parent[0]
48
name_id = field_name[0]
50
rule_id = self.create(cr, uid, {'name': name,
51
'object_id': object_ids[0],
55
'field_ids': [(6, 0, fields_ids)],
56
'parent_field_id': parent_id,
57
'name_get_field_id': name_id,
60
# Subscribe to the rule
61
self.subscribe(cr, uid, rule_id)
63
I will create a rule for Register object
65
!python {model: audittrail.rule}: |
67
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.bank.statement')], context=context)
68
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
69
if object_ids and not rule_id:
71
fields = ['state', 'balance_end_real', 'closing_balance_frozen', 'closing_date', 'notes', 'ending_details_ids', 'name',
72
'open_advance_amount', 'user_id']
74
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.bank.statement'), ('name', 'in', fields)], context=context)
76
rule_id = self.create(cr, uid, {'name': name,
77
'object_id': object_ids[0],
81
'field_ids': [(6, 0, fields_ids)],
84
# Subscribe to the rule
85
self.subscribe(cr, uid, rule_id)
87
I will create a rule for Budget object
89
!python {model: audittrail.rule}: |
91
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'msf.budget')], context=context)
92
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
93
if object_ids and not rule_id:
95
fields = ['state', 'code', 'cost_center_id', 'name']
97
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'msf.budget'), ('name', 'in', fields)], context=context)
99
rule_id = self.create(cr, uid, {'name': name,
100
'object_id': object_ids[0],
104
'field_ids': [(6, 0, fields_ids)],
107
# Subscribe to the rule
108
self.subscribe(cr, uid, rule_id)
110
I will create a rule for Financing Contracts object
112
!python {model: audittrail.rule}: |
113
name = 'Financing Contract'
114
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'financing.contract.contract')], context=context)
115
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
116
if object_ids and not rule_id:
118
fields = ['state', 'code', 'currency_table_id', 'donor_id', 'grant_amount', 'hard_closed_date', 'hq_grant_reference',
119
'name', 'open_date', 'reporting_currency', 'soft_closed_date']
121
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'financing.contract.contract'), ('name', 'in', fields)], context=context)
123
rule_id = self.create(cr, uid, {'name': name,
124
'object_id': object_ids[0],
128
'field_ids': [(6, 0, fields_ids)],
131
# Subscribe to the rule
132
self.subscribe(cr, uid, rule_id)
134
I will create a rule for Analytic account object
136
!python {model: audittrail.rule}: |
137
name = 'Analytic Account'
138
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.analytic.account')], context=context)
139
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
140
if object_ids and not rule_id:
142
fields = ['state', 'category', 'code', 'complete_name', 'cost_center_ids', 'date', 'date_start', 'name', 'parent_id']
144
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.analytic.account'), ('name', 'in', fields)], context=context)
146
rule_id = self.create(cr, uid, {'name': name,
147
'object_id': object_ids[0],
151
'field_ids': [(6, 0, fields_ids)],
154
# Subscribe to the rule
155
self.subscribe(cr, uid, rule_id)
157
I will create a rule for Period object
159
!python {model: audittrail.rule}: |
161
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.period')], context=context)
162
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
163
if object_ids and not rule_id:
167
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.period'), ('name', 'in', fields)], context=context)
169
rule_id = self.create(cr, uid, {'name': name,
170
'object_id': object_ids[0],
174
'field_ids': [(6, 0, fields_ids)],
177
# Subscribe to the rule
178
self.subscribe(cr, uid, rule_id)