[MEREG] Merge mtr branch for account joural changes and other changes

[IMP] improve

bzr revid: mra@mra-laptop-20100610085303-r8fx0b9vlakrd1oq
This commit is contained in:
Mustufa Rangwala 2010-06-10 14:23:03 +05:30
commit b986ab355c
6 changed files with 112 additions and 27 deletions

View File

@ -562,39 +562,35 @@ class account_journal(osv.osv):
_name = "account.journal"
_description = "Journal"
_columns = {
'name': fields.char('Journal Name', size=64, required=True, translate=True),
'code': fields.char('Code', size=16),
'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True,
'name': fields.char('Journal Name', size=64, required=True, translate=True,help="Name of the journal"),
'code': fields.char('Code', size=16,required=True,help="Code of the journal"),
'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,
help="Select 'Sale' for Sale journal to be used at the time of making invoice."\
" Select 'Purchase' for Purchase Journal to be used at the time of approving purchase order."\
" Select 'Cash' to be used at the time of making payment."\
" Select 'General' to be used at the time of stock input/output."\
" Select 'Situation' to be used at the time of making vouchers."),
'refund_journal': fields.boolean('Refund Journal', help='Fill this if the journal is to be used for refunds of invoices.'),
'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]),
'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the journal without removing it."),
'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."),
'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]"),
'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]"),
'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."),
'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"),
'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"),
'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."),
'update_posted': fields.boolean('Allow Cancelling Entries'),
'update_posted': fields.boolean('Allow Cancelling Entries',help="Check this box if you want to cancel the entries related to this journal or want to cancel the invoice related to this journal"),
'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."),
'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=True),
'user_id': fields.many2one('res.users', 'User', help="The user responsible for this journal"),
'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'),
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
'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.'),
'company_id': fields.many2one('res.company', 'Company', required=True,select=1),
'company_id': fields.many2one('res.company', 'Company', required=True,select=1,help="Company related to a journal"),
'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \
help="The sequence used for invoice numbers in this journal."),
'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'),
}
_defaults = {
'active': lambda *a: 1,
'user_id': lambda self,cr,uid,context: uid,
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
@ -604,7 +600,7 @@ class account_journal(osv.osv):
move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)])
if move_lines:
raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines'))
return super(account_period, self).write(cr, uid, ids, vals, context=context)
return super(account_journal, self).write(cr, uid, ids, vals, context=context)
def create(self, cr, uid, vals, context={}):
journal_id = super(account_journal, self).create(cr, uid, vals, context)
@ -631,6 +627,16 @@ class account_journal(osv.osv):
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
return self.name_get(cr, user, ids, context=context)
def onchange_type(self, cr, uid, ids, type):
res={}
for line in self.browse(cr, uid, ids):
if type == 'situation':
res= {'value':{'centralisation': True}}
else:
res= {'value':{'centralisation': False}}
return res
account_journal()
class account_fiscalyear(osv.osv):

View File

@ -272,22 +272,19 @@
<group colspan="4" col="6">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="active" select="1"/>
<field name="type"/>
<field name="type" on_change="onchange_type(type)"/>
<field name="refund_journal" attrs="{'readonly':[('type','=','general'),('type','=','cash'),('type','=','situation')]}"/>
</group>
<notebook colspan="4">
<notebook colspan="4">
<page string="General Information">
<group colspan="2" col="2">
<separator string="Journal View" colspan="4"/>
<field name="view_id"/>
<field name="view_id" widget="selection"/>
</group>
<group colspan="2" col="2">
<separator string="Sequence" colspan="4"/>
<field name="sequence_id"/>
<field name="invoice_sequence_id"/>
</group>
<group colspan="2" col="2">
@ -296,7 +293,7 @@
<field name="default_credit_account_id" attrs="{'required':[('type','=','cash')]}" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
</group>
<group colspan="2" col="2">
<group colspan="2" col="2">
<separator string="Validations" colspan="4"/>
<field name="allow_date" groups="base.group_extended"/>
</group>
@ -307,15 +304,19 @@
<field name="user_id" groups="base.group_extended"/>
<field name="currency"/>
</group>
<group colspan="2" col="2">
<separator string="Other Configuration" colspan="4"/>
<field name="centralisation"/>
<field name="group_invoice_lines"/>
<field name="update_posted"/>
<field name="centralisation" groups="base.group_extended"/>
<field name="entry_posted"/>
<group colspan="2" col="2">
<separator string="Invoicing Data" colspan="4"/>
<field name="invoice_sequence_id"/>
<field name="group_invoice_lines"/>
</group>
</group>
</page>
<page string="Entry Controls">
<page string="Entry Controls" groups="base.group_extended">
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>
<field colspan="4" name="type_control_ids" nolabel="1"/>
<separator colspan="4" string="Accounts Allowed (empty for no control)"/>
@ -957,7 +958,6 @@
<field name="state" select="1"/>
<group col="2" colspan="2">
<button name="button_validate" states="draft" string="Validate" type="object" icon="gtk-execute"/>
<button name="button_cancel" states="posted" string="Cancel" type="object" icon="gtk-cancel"/>
</group>
</page>
<page string="Other Information">

View File

@ -923,13 +923,13 @@ class account_invoice(osv.osv):
account_move_obj = self.pool.get('account.move')
invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
for i in invoices:
if i['move_id']:
if i['move_id']:
account_move_obj.button_cancel(cr, uid, [i['move_id'][0]])
# delete the move this invoice was pointing to
# Note that the corresponding move_lines and move_reconciles
# will be automatically deleted too
account_move_obj.unlink(cr, uid, [i['move_id'][0]])
if i['payment_ids']:
if i['payment_ids']:
account_move_line_obj = self.pool.get('account.move.line')
pay_ids = account_move_line_obj.browse(cr, uid , i['payment_ids'])
for move_line in pay_ids:

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name" : "Account Cancel",
"version" : "1.1",
"depends" : ["account"],
"author" : "Tiny",
"category": 'Generic Modules/Accounting',
"description": """
Module Add Allow cancelling entries field on form view of account journal if it set to true it allows user to cancel entries & invoices.
""",
'website': 'http://www.openerp.com',
'init_xml': [],
'update_xml': ['account_cancel_view.xml' ],
'demo_xml': [],
'installable': True,
'active': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="view_account_journal_form_inherit" model="ir.ui.view">
<field name="name">account.journal.form</field>
<field name="model">account.journal</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_account_journal_form"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[@string='General Information']/group/field[@name='centralisation']" position="after">
<field name="update_posted"/>
</xpath>
</field>
</record>
</data>
</openerp>