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 Register Line object
89
!python {model: audittrail.rule}: |
90
name = 'Register Line'
91
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.bank.statement.line')], context=context)
92
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
93
if object_ids and not rule_id:
96
'name', 'document_date', 'date', 'sequence_for_reference',
97
'account_id', 'partner_type2',
98
'amount_in', 'amount_out',
99
'reconciled', 'state',
102
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.bank.statement.line'), ('name', 'in', fields)], context=context)
104
rule_id = self.create(cr, uid, {'name': name,
105
'object_id': object_ids[0],
109
'field_ids': [(6, 0, fields_ids)],
112
# Subscribe to the rule
113
self.subscribe(cr, uid, rule_id)
115
I will create a rule for Budget object
117
!python {model: audittrail.rule}: |
119
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'msf.budget')], context=context)
120
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
121
if object_ids and not rule_id:
123
fields = ['state', 'code', 'cost_center_id', 'name']
125
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'msf.budget'), ('name', 'in', fields)], context=context)
127
rule_id = self.create(cr, uid, {'name': name,
128
'object_id': object_ids[0],
132
'field_ids': [(6, 0, fields_ids)],
135
# Subscribe to the rule
136
self.subscribe(cr, uid, rule_id)
138
I will create a rule for Financing Contracts object
140
!python {model: audittrail.rule}: |
141
name = 'Financing Contract'
142
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'financing.contract.contract')], context=context)
143
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
144
if object_ids and not rule_id:
146
fields = ['state', 'code', 'currency_table_id', 'donor_id', 'grant_amount', 'hard_closed_date', 'hq_grant_reference',
147
'name', 'open_date', 'reporting_currency', 'soft_closed_date']
149
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'financing.contract.contract'), ('name', 'in', fields)], context=context)
151
rule_id = self.create(cr, uid, {'name': name,
152
'object_id': object_ids[0],
156
'field_ids': [(6, 0, fields_ids)],
159
# Subscribe to the rule
160
self.subscribe(cr, uid, rule_id)
162
I will create a rule for Analytic account object
164
!python {model: audittrail.rule}: |
165
name = 'Analytic Account'
166
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.analytic.account')], context=context)
167
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
168
if object_ids and not rule_id:
170
fields = ['state', 'category', 'code', 'complete_name', 'cost_center_ids', 'date', 'date_start', 'name', 'parent_id']
172
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.analytic.account'), ('name', 'in', fields)], context=context)
174
rule_id = self.create(cr, uid, {'name': name,
175
'object_id': object_ids[0],
179
'field_ids': [(6, 0, fields_ids)],
182
# Subscribe to the rule
183
self.subscribe(cr, uid, rule_id)
185
I will create a rule for Period object
187
!python {model: audittrail.rule}: |
189
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.period')], context=context)
190
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
191
if object_ids and not rule_id:
195
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.period'), ('name', 'in', fields)], context=context)
197
rule_id = self.create(cr, uid, {'name': name,
198
'object_id': object_ids[0],
202
'field_ids': [(6, 0, fields_ids)],
205
# Subscribe to the rule
206
self.subscribe(cr, uid, rule_id)