~openerp-commiter/openobject-addons/6.0-opw-4801-dhs

« back to all changes in this revision

Viewing changes to account/account.py

[IMP] account: Added account_cancel module and made changes in the view of account.journal

Show diffs side-by-side

added added

removed removed

Lines of Context:
557
557
    _name = "account.journal"
558
558
    _description = "Journal"
559
559
    _columns = {
560
 
        'name': fields.char('Journal Name', size=64, required=True, translate=True),
561
 
        'code': fields.char('Code', size=16),
562
 
        'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True,
 
560
        'name': fields.char('Journal Name', size=64, required=True, translate=True,help="Name of the journal"),
 
561
        'code': fields.char('Code', size=16,required=True,help="Code of the journal"),
 
562
        'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'),('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True,
563
563
                                 help="Select 'Sale' for Sale journal to be used at the time of making invoice."\
564
564
                                 " Select 'Purchase' for Purchase Journal to be used at the time of approving purchase order."\
565
565
                                 " Select 'Cash' to be used at the time of making payment."\
566
566
                                 " Select 'General' to be used at the time of stock input/output."\
567
567
                                 " Select 'Situation' to be used at the time of making vouchers."),
568
568
        'refund_journal': fields.boolean('Refund Journal', help='Fill this if the journal is to be used for refunds of invoices.'),
569
 
 
570
569
        'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]),
571
570
        'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]),
572
 
 
573
 
        'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the journal without removing it."),
574
 
        'view_id': fields.many2one('account.journal.view', 'View', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells Open ERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
575
 
        'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]"),
576
 
        'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]"),
 
571
        'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells Open ERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
 
572
        'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]",help="This will act as a default account for credit amount"),
 
573
        'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]",help="This will act as a default account for debit amount"),
577
574
        'centralisation': fields.boolean('Centralised counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."),
578
 
        'update_posted': fields.boolean('Allow Cancelling Entries'),
579
575
        'group_invoice_lines': fields.boolean('Group invoice lines', help="If this box is checked, the system will try to group the accounting lines when generating them from invoices."),
580
576
        'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=True),
581
577
        'user_id': fields.many2one('res.users', 'User', help="The user responsible for this journal"),
582
578
        'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'),
583
579
        'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
584
580
        'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want new account moves to pass through the \'draft\' state and instead goes directly to the \'posted state\' without any manual validation.'),
585
 
        'company_id': fields.many2one('res.company', 'Company', required=True,select=1),
 
581
        'company_id': fields.many2one('res.company', 'Company', required=True,select=1,help="Company related to a journal"),
586
582
        'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \
587
583
            help="The sequence used for invoice numbers in this journal."),
588
584
        'allow_date':fields.boolean('Check Date not in the Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'),
589
585
    }
590
586
 
591
587
    _defaults = {
592
 
        'active': lambda *a: 1,
593
588
        'user_id': lambda self,cr,uid,context: uid,
594
589
        'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
595
590
    }
617
612
        if not ids:
618
613
            ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
619
614
        return self.name_get(cr, user, ids, context=context)
 
615
    
 
616
    def onchange_type(self, cr, uid, ids, type):
 
617
        res={}
 
618
        for line in self.browse(cr, uid, ids):
 
619
            if type == 'situation':
 
620
                  res= {'value':{'centralisation': True}}
 
621
            else:
 
622
                  res= {'value':{'centralisation': False}}
 
623
        return res
 
624
       
620
625
 
621
626
account_journal()
622
627
 
990
995
    def button_validate(self, cursor, user, ids, context=None):
991
996
        return self.post(cursor, user, ids, context=context)
992
997
 
993
 
    def button_cancel(self, cr, uid, ids, context={}):
994
 
        for line in self.browse(cr, uid, ids, context):
995
 
            if not line.journal_id.update_posted:
996
 
                raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.'))
997
 
        if len(ids):
998
 
            cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,))
999
 
        return True
1000
 
 
1001
998
    def write(self, cr, uid, ids, vals, context={}):
1002
999
        c = context.copy()
1003
1000
        c['novalidate'] = True