~julie-w/unifield-wm/UTP-758

« back to all changes in this revision

Viewing changes to account_journal/account_journal.py

  • Committer: jf
  • Date: 2016-01-25 14:14:07 UTC
  • mfrom: (2703.20.59 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20160125141407-vgfz8lrdvvgq0zip
US-822 [IMP] Year End Closure functionnality
lp:~unifield-team/unifield-wm/us-822

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
                ('sale', 'Sale'),
77
77
                ('sale_refund','Sale Refund'),
78
78
                ('stock', 'Stock'),
 
79
                ('system', 'System'),
79
80
        ]
80
81
 
81
82
    def _get_has_entries(self, cr, uid, ids, field_name, arg, context=None):
313
314
        """
314
315
        if context is None:
315
316
            context = {}
 
317
 
 
318
        if not context.get('sync_update_execution', False):
 
319
            if vals.get('type', '') == 'system':
 
320
                # not from sync, user not allowed to update 'system' journal
 
321
                # (note: noteditable not usable on journal form)
 
322
                raise osv.except_osv(_('Warning'),
 
323
                    _('System journal not updatable'))
 
324
 
316
325
        res = super(account_journal, self).write(cr, uid, ids, vals, context=context)
317
326
        for j in self.browse(cr, uid, ids):
318
327
            if j.type == 'cur_adj' and j.default_debit_account_id.user_type_code != 'expense':
329
338
                        abs_obj.write(cr, uid, s_ids, {'name': vals['name']}, context=context)
330
339
        return res
331
340
 
 
341
    def unlink(self, cr, uid, ids, context=None):
 
342
        if not ids:
 
343
            return False
 
344
        if isinstance(ids, (int, long, )):
 
345
            ids = [ids]
 
346
 
 
347
        is_system = [ rec.type == 'system' \
 
348
            for rec in self.browse(cr, uid, ids, context=context) ]
 
349
        if any(is_system):
 
350
            raise osv.except_osv(_('Warning'),
 
351
                _('System journal not deletable'))
 
352
        return super(account_journal, self).unlink(cr, uid, ids,
 
353
            context=context)
 
354
 
332
355
    def button_delete_journal(self, cr, uid, ids, context=None):
333
356
        """
334
357
        Delete all linked register and this journal except: