68
68
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
69
69
if object_ids and not rule_id:
71
fields = ['state', 'balance_end_real', 'closing_balance_frozen', 'closing_date', 'notes', 'name',
72
'open_advance_amount', 'user_id', 'closing_date', 'unrecorded_expenses_amount']
71
fields = ['state', 'balance_end_real', 'closing_balance_frozen', 'closing_date', 'notes', 'ending_details_ids', 'name',
72
'open_advance_amount', 'user_id']
74
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)
103
field_name = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.bank.statement.line'), ('name', '=', 'name')], context=context)
104
field_parent = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.bank.statement.line'), ('name', '=', 'statement_id')], context=context)
110
parent_id = field_parent[0]
112
name_id = field_name[0]
114
rule_id = self.create(cr, uid, {'name': name,
115
'object_id': object_ids[0],
119
'field_ids': [(6, 0, fields_ids)],
120
'parent_field_id': parent_id,
121
'name_get_field_id': name_id,
124
# Subscribe to the rule
125
self.subscribe(cr, uid, rule_id)
127
I will create a rule for Cash Box Lines of a Register
129
!python {model: audittrail.rule}: |
130
name = 'CashBox Line'
131
object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.cashbox.line')], context=context)
132
rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
133
if object_ids and not rule_id:
135
fields = ['pieces', 'number', 'subtotal']
137
fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.cashbox.line'), ('name', 'in', fields)], context=context)
138
field_name = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.cashbox.line'), ('name', '=', 'pieces')], context=context)
139
field_parent = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.cashbox.line'), ('name', '=', 'ending_id')], context=context)
145
parent_id = field_parent[0]
147
name_id = field_name[0]
149
rule_id = self.create(cr, uid, {'name': name,
150
'object_id': object_ids[0],
154
'field_ids': [(6, 0, fields_ids)],
155
'parent_field_id': parent_id,
156
'name_get_field_id': name_id,
157
'domain_filter': "[('ending_id', '!=', False)]",
76
rule_id = self.create(cr, uid, {'name': name,
77
'object_id': object_ids[0],
81
'field_ids': [(6, 0, fields_ids)],
160
84
# Subscribe to the rule
161
85
self.subscribe(cr, uid, rule_id)