115
115
_name = 'account.wallet.transaction'
116
116
_description = 'Transaction'
117
117
_inherit = ['mail.thread']
121
'account_wallet.mt_transaction_state': lambda self, cr, uid, obj, ctx=None: obj.already_published == True,
119
126
'sender_id': fields.many2one('res.partner', 'Sender', required=True, readonly=True,
120
127
states={'draft': [('readonly', False)]}, select=1),
147
154
('done', 'Closed'),
148
155
('confirm_refund', 'Confirm Refund'),
149
156
('cancel', 'Cancelled'),
150
], 'Status', readonly=True, required=True),
157
], 'Status', readonly=True, required=True, track_visibility='onchange'),
204
211
(_check_same_partner, 'You cannot make a transaction between the same partner.', ['sender_id']),
214
def create(self, cr, uid, vals, context=None):
215
res = super(AccountWalletTransaction, self).create(
216
cr, uid, vals, context=context
219
#Ensure we don't create a new line when we call write
220
if 'currency_ids' in vals:
221
del vals['currency_ids']
223
#Call write for the message_subscribe
224
self.write(cr, uid, [res], vals, context=context)
227
def write(self, cr, uid, ids, vals, context=None):
228
res = super(AccountWalletTransaction, self).write(
229
cr, uid, ids, vals, context=context
231
for transaction in self.browse(cr, uid, ids, context=context):
232
if 'sender_id' in vals:
233
self.message_subscribe(
234
cr, uid, [transaction.id],
235
[vals['sender_id']], context=context
237
if 'receiver_id' in vals:
238
self.message_subscribe(
239
cr, uid, [transaction.id],
240
[vals['receiver_id']], context=context
207
244
def unlink(self, cr, uid, ids, context=None):
208
245
# When we remove the transaction, we also remove all linked lines
209
246
currency_line_obj = self.pool.get('account.wallet.currency.line')