~yannick-buron/odoo-vertical-community/8.0

« back to all changes in this revision

Viewing changes to __unreviewed__/account_wallet/account_wallet.py

  • Committer: Yannick Buron
  • Date: 2014-12-04 14:16:21 UTC
  • mfrom: (102.1.17)
  • Revision ID: git-v1:f3eb9142acb1ac339528a1adeb1099b66b077182
Merge pull request #19 from YannickB/menufix

[unreviewed][IMP] Add alert to marketplace and transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
    _name = 'account.wallet.transaction'
116
116
    _description = 'Transaction'
117
117
    _inherit = ['mail.thread']
 
118
 
 
119
    _track = {
 
120
        'state': {
 
121
            'account_wallet.mt_transaction_state': lambda self, cr, uid, obj, ctx=None: obj.already_published == True,
 
122
        },
 
123
    }
 
124
 
118
125
    _columns = {
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'),
151
158
 
152
159
    }
153
160
 
204
211
        (_check_same_partner, 'You cannot make a transaction between the same partner.', ['sender_id']),
205
212
    ]
206
213
 
 
214
    def create(self, cr, uid, vals, context=None):
 
215
        res = super(AccountWalletTransaction, self).create(
 
216
            cr, uid, vals, context=context
 
217
        )
 
218
 
 
219
        #Ensure we don't create a new line when we call write
 
220
        if 'currency_ids' in vals:
 
221
            del vals['currency_ids']
 
222
            
 
223
        #Call write for the message_subscribe
 
224
        self.write(cr, uid, [res], vals, context=context)
 
225
        return res
 
226
 
 
227
    def write(self, cr, uid, ids, vals, context=None):
 
228
        res = super(AccountWalletTransaction, self).write(
 
229
            cr, uid, ids, vals, context=context
 
230
        )
 
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
 
236
                )
 
237
            if 'receiver_id' in vals:
 
238
                self.message_subscribe(
 
239
                    cr, uid, [transaction.id],
 
240
                    [vals['receiver_id']], context=context
 
241
                )
 
242
        return res
 
243
 
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')