bzr revid: pso@tinyerp.com-20101103125959-scelvehgbrlhn2z8
This commit is contained in:
pso
2010-11-03 18:29:59 +05:30
10 changed files with 224 additions and 11 deletions
+13
View File
@@ -614,9 +614,22 @@ class account_journal(osv.osv):
'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,
}
_sql_constraints = [
('code_company_uniq', 'unique (code, company_id)', 'The code of the journal must be unique per company !'),
('name_company_uniq', 'unique (name, company_id)', 'The name of the journal must be unique per company !'),
]
_order = 'code'
def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False):
journal = self.browse(cr, uid, id, context=context)
if not default:
default = {}
default = default.copy()
default['code'] = (journal['code'] or '') + '(copy)'
default['name'] = (journal['name'] or '') + '(copy)'
return super(account_journal, self).copy(cr, uid, id, default, context=context)
def write(self, cr, uid, ids, vals, context=None):
if 'company_id' in vals:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)])
+12 -1
View File
@@ -528,10 +528,18 @@ class account_move_line(osv.osv):
return False
return True
def _check_partner_id(self, cr, uid, ids):
lines = self.browse(cr, uid, ids)
for l in lines:
if l.account_id.type in ('receivable', 'payable') and not l.partner_id:
return False
return True
_constraints = [
(_check_no_view, 'You can not create move line on view account.', ['account_id']),
(_check_no_closed, 'You can not create move line on closed account.', ['account_id']),
(_check_company_id,'Company must be same for its related account and period.',['company_id'] ),
(_check_company_id, 'Company must be same for its related account and period.',['company_id'] ),
(_check_partner_id, 'You can not create move line on receivable/payable account without partner', ['account_id'] )
]
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
@@ -929,6 +937,9 @@ class account_move_line(osv.osv):
elif field == 'date':
attrs.append('on_change="onchange_date(date)"')
elif field == 'analytic_account_id':
attrs.append('''groups="analytic.group_analytic_accounting"''') # Currently it is not working due to framework problem may be ..
if field in ('amount_currency', 'currency_id'):
attrs.append('on_change="onchange_currency(account_id, amount_currency, currency_id, date, journal_id)"')
attrs.append('''attrs="{'readonly': [('state', '=', 'valid')]}"''')
+7 -7
View File
@@ -342,7 +342,7 @@
<record id="sales_journal" model="account.journal">
<field name="name">Sales Journal - (test)</field>
<field name="code">SAJ</field>
<field name="code">SAJ - (test)</field>
<field name="type">sale</field>
<field name="view_id" ref="account_sp_journal_view"/>
<field name="sequence_id" ref="sequence_sale_journal"/>
@@ -353,7 +353,7 @@
</record>
<record id="refund_sales_journal" model="account.journal">
<field name="name">Sales Credit Note Journal - (test)</field>
<field name="code">SCNJ</field>
<field name="code">SCNJ- (test)</field>
<field name="type">sale_refund</field>
<field eval="True" name="refund_journal"/>
<field name="view_id" ref="account_sp_refund_journal_view"/>
@@ -366,7 +366,7 @@
<record id="expenses_journal" model="account.journal">
<field name="name">Expenses Journal - (test)</field>
<field name="code">EXJ</field>
<field name="code">EXJ- (test)</field>
<field name="type">purchase</field>
<field name="view_id" ref="account_sp_journal_view"/>
<field name="sequence_id" ref="sequence_purchase_journal"/>
@@ -377,7 +377,7 @@
</record>
<record id="refund_expenses_journal" model="account.journal">
<field name="name">Expenses Credit Notes Journal - (test)</field>
<field name="code">ECNJ</field>
<field name="code">ECNJ- (test)</field>
<field name="type">purchase_refund</field>
<field eval="True" name="refund_journal"/>
<field name="view_id" ref="account_sp_refund_journal_view"/>
@@ -390,7 +390,7 @@
<record id="bank_journal" model="account.journal">
<field name="name">Bank Journal - (test)</field>
<field name="code">BNK</field>
<field name="code">BNK- (test)</field>
<field name="type">bank</field>
<field name="view_id" ref="account_journal_bank_view"/>
<field name="sequence_id" ref="sequence_bank_journal"/>
@@ -401,7 +401,7 @@
</record>
<record id="check_journal" model="account.journal">
<field name="name">Checks Journal - (test)</field>
<field name="code">CHK</field>
<field name="code">CHK- (test)</field>
<field name="type">bank</field>
<field name="view_id" ref="account_journal_bank_view"/>
<field name="sequence_id" ref="sequence_check_journal"/>
@@ -412,7 +412,7 @@
</record>
<record id="cash_journal" model="account.journal">
<field name="name">Cash Journal - (test)</field>
<field name="code">CSH</field>
<field name="code">CSH- (test)</field>
<field name="type">cash</field>
<field name="view_id" ref="account_journal_bank_view"/>
<field name="sequence_id" ref="sequence_cash_journal"/>
+24
View File
@@ -0,0 +1,24 @@
# -*- 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/>.
#
##############################################################################
import account_sequence
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+39
View File
@@ -0,0 +1,39 @@
# -*- 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': 'Sequence Numbering',
'version': '1.1',
'category': 'Generic Modules/Accounting',
'description': """
This module maintains internal sequence number for accounting entries.
""",
'author': 'OpenERP SA',
'website': 'http://www.openerp.com',
'depends': ['account'],
'init_xml': [],
'update_xml': ['account_sequence_data.xml','account_sequence.xml'],
'demo_xml': ['account_sequence_minimal.xml'],
'installable': True,
'active': False,
'certificate': '',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
class account_move(osv.osv):
_inherit = 'account.move'
_columns = {
'internal_sequence_number': fields.char('Internal Sequence Number', size=64, readonly=True),
}
def post(self, cr, uid, ids, context=None):
obj_sequence = self.pool.get('ir.sequence')
res = super(account_move, self).post(cr, uid, ids, context)
for line in self.browse(cr, uid, ids):
if line.journal_id.internal_sequence:
c = {'fiscalyear_id': line.period_id.fiscalyear_id.id}
seq_no = obj_sequence.get_id(cr, uid, line.journal_id.internal_sequence.id, context=c)
if seq_no:
self.write(cr, uid, [line.id], {'internal_sequence_number':seq_no})
return res
account_move()
class account_journal(osv.osv):
_inherit = "account.journal"
_columns = {
'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence'),
}
account_journal()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_form_inherit" model="ir.ui.view">
<field name="name">account.move.form.inherit</field>
<field name="model">account.move</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<field name="to_check" position="after">
<field name="internal_sequence_number"/>
</field>
</field>
</record>
<record id="view_account_journal_form_inherit" model="ir.ui.view">
<field name="name">account.journal.form.inherit</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">
<field name="code" position="after">
<field name="internal_sequence"/>
</field>
</field>
</record>
</data>
</openerp>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--Account Journal Internal Sequences-->
<record id="internal_sequence_journal" model="ir.sequence">
<field name="name">Internal Sequence Journal</field>
<field name="code">account.journal</field>
<field name="number_next">1</field>
</record>
</data>
</openerp>
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="account.sales_journal" model="account.journal">
<field name="internal_sequence" ref="internal_sequence_journal"/>
</record>
<record id="account.refund_sales_journal" model="account.journal">
<field name="internal_sequence" ref="internal_sequence_journal"/>
</record>
<record id="account.expenses_journal" model="account.journal">
<field name="internal_sequence" ref="internal_sequence_journal"/>
</record>
<record id="account.refund_expenses_journal" model="account.journal">
<field name="internal_sequence" ref="internal_sequence_journal"/>
</record>
<record id="account.bank_journal" model="account.journal">
<field name="internal_sequence" ref="internal_sequence_journal"/>
</record>
<record id="account.check_journal" model="account.journal">
<field name="internal_sequence" ref="internal_sequence_journal"/>
</record>
<record id="account.cash_journal" model="account.journal">
<field name="internal_sequence" ref="internal_sequence_journal"/>
</record>
</data>
</openerp>
+3 -3
View File
@@ -206,9 +206,9 @@
<group col="13" colspan="4">
<field name="state"/>
<button name="invoice_recreate" states="invoice_except" string="Recreate Invoice" icon="gtk-go-forward"/>
<button name="invoice_corrected" states="invoice_except" string="Invoice Corrected" icon="gtk-apply"/>
<button name="ship_recreate" states="shipping_except" string="Recreate Procurement" icon="gtk-ok"/>
<button name="ship_corrected" states="shipping_except" string="Procurement Corrected" icon="gtk-apply"/>
<button name="invoice_corrected" states="invoice_except" string="Ignore Exception" icon="gtk-apply"/>
<button name="ship_recreate" states="shipping_except" string="Recreate Packing" icon="gtk-ok"/>
<button name="ship_corrected" states="shipping_except" string="Ignore Exception" icon="gtk-apply"/>
<button name="action_cancel" states="manual,progress" string="Cancel Order" type="object" icon="gtk-cancel"/>
<button name="manual_invoice" states="manual" string="Create Final Invoice" icon="gtk-go-forward" type="object"/>
<button name="ship_cancel" states="shipping_except" string="Cancel Order" icon="gtk-cancel"/>