bzr revid: fp@tinyerp.com-20090116193152-s4ukc9zvw2953u2o
This commit is contained in:
Fabien Pinckaers 2009-01-16 20:31:52 +01:00
commit 612b845b33
8 changed files with 224 additions and 158 deletions

View File

@ -162,13 +162,14 @@
<field name="type">tree</field>
<field name="field_parent">child_id</field>
<field name="arch" type="xml">
<tree string="Chart of accounts" toolbar="1">
<tree string="Chart of accounts" toolbar="1" colors="blue:type=='view'">
<field name="code"/>
<field name="name"/>
<field name="debit"/>
<field name="credit"/>
<field name="balance"/>
<field name="company_currency_id"/>
<field name="type" invisible="1"/>
</tree>
</field>
</record>
@ -272,6 +273,7 @@
<field name="group_invoice_lines"/>
<field name="update_posted"/>
<field name="entry_posted"/>
<field name="fy_seq_id" colspan="4" widget="one2many_list" >
<tree string="Invoice Sequences">
<field name="fiscalyear_id"/>
@ -282,7 +284,6 @@
<field name="sequence_id"/>
</form>
</field>
<field name="entry_posted"/>
</page>
<page string="Entry Controls">
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>
@ -670,8 +671,9 @@
<field name="type">tree</field>
<field eval="4" name="priority"/>
<field name="arch" type="xml">
<tree string="Account Entry Line">
<tree string="Account Entry Line" editable="top" on_write="_on_create_write">
<field name="date"/>
<field name="period_id"/>
<field name="move_id"/>
<field name="ref"/>
<field name="invoice"/>

View File

@ -7,9 +7,12 @@
<wizard id="wizard_invoice_pay" model="account.invoice" name="account.invoice.pay" string="Pay invoice"/>
<!-- close year, period, journal -->
<wizard id="wizard_fiscalyear_close" menu="False" model="account.fiscalyear" name="account.fiscalyear.close" string="Close a Fiscal Year"/>
<wizard id="wizard_fiscalyear_close" menu="False" model="account.fiscalyear" name="account.fiscalyear.close" string="Close a Fiscal Year (New entries)"/>
<menuitem id="menu_finance" name="Financial Management"/><menuitem action="wizard_fiscalyear_close" id="menu_wizard_fy_close" parent="menu_account_end_year_treatments" sequence="11" type="wizard"/>
<wizard id="wizard_fiscalyear_close_state" menu="False" model="account.fiscalyear" name="account.fiscalyear.close.state" string="Close a Fiscal Year (States)"/>
<menuitem action="wizard_fiscalyear_close_state" id="menu_wizard_fy_close_state" parent="menu_account_end_year_treatments" type="wizard"/>
<wizard id="wizard_open_closed_fiscalyear" menu="False" model="account.fiscalyear" name="account.open_closed_fiscalyear" string="Open a Closed Fiscal Year"/>
<menuitem action="wizard_open_closed_fiscalyear" id="menu_wizard_open_closed_fy" parent="account.menu_account_end_year_treatments" sequence="12" type="wizard"/>

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -41,6 +41,7 @@ import wizard_partner_balance_report
import wizard_period_close
import wizard_fiscalyear_close
import wizard_fiscalyear_close_state
import wizard_open_closed_fiscalyear
import wizard_vat

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -26,27 +26,24 @@ import pooler
from tools.translate import _
_transaction_form = '''<?xml version="1.0"?>
<form string="Close Fiscal Year">
<form string="Close Fiscal Year with new entries">
<field name="fy_id"/>
<field name="fy2_id"/>
<field name="report_new"/>
<field name="report_name" colspan="3"/>
<separator string="Are you sure ?" colspan="4"/>
<separator string="Are you sure you want to create entries?" colspan="4"/>
<field name="sure"/>
</form>'''
_transaction_fields = {
'fy_id': {'string':'Fiscal Year to close', 'type':'many2one', 'relation': 'account.fiscalyear','required':True, 'domain':[('state','=','draft')]},
'fy2_id': {'string':'New Fiscal Year', 'type':'many2one', 'relation': 'account.fiscalyear', 'domain':[('state','=','draft')], 'required':True},
'report_new': {'string':'Create new entries', 'type':'boolean', 'required':True, 'default': lambda *a:True},
'report_name': {'string':'Name of new entries', 'type':'char', 'size': 64, 'required':True},
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_load(self, cr, uid, data, context):
data['form']['report_new'] = True
data['form']['report_name'] = 'End of Fiscal Year Entry'
data['form']['report_name'] = _('End of Fiscal Year Entry')
return data['form']
def _data_save(self, cr, uid, data, context):
@ -58,120 +55,115 @@ def _data_save(self, cr, uid, data, context):
new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'])
start_jp = new_fyear.start_journal_period_id
if data['form']['report_new']:
periods_fy2 = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids
if not periods_fy2:
raise wizard.except_wizard(_('UserError'),
_('There are no periods defined on New Fiscal Year.'))
period=periods_fy2[0]
if not start_jp:
raise wizard.except_wizard(_('UserError'),
_('The new fiscal year should have a journal for new entries define on it'))
periods_fy2 = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids
if not periods_fy2:
raise wizard.except_wizard(_('UserError'),
_('There are no periods defined on New Fiscal Year.'))
period=periods_fy2[0]
if not start_jp:
raise wizard.except_wizard(_('UserError'),
_('The new fiscal year should have a journal for new entries define on it'))
new_journal = start_jp.journal_id
new_journal = start_jp.journal_id
if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
raise wizard.except_wizard(_('UserError'),
_('The journal must have default credit and debit account'))
if not new_journal.centralisation:
raise wizard.except_wizard(_('UserError'),
_('The journal must have centralised counterpart'))
if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
raise wizard.except_wizard(_('UserError'),
_('The journal must have default credit and debit account'))
if not new_journal.centralisation:
raise wizard.except_wizard(_('UserError'),
_('The journal must have centralised counterpart'))
query_line = pool.get('account.move.line')._query_get(cr, uid,
obj='account_move_line', context={'fiscalyear': fy_id})
cr.execute('select id from account_account WHERE active')
ids = map(lambda x: x[0], cr.fetchall())
for account in pool.get('account.account').browse(cr, uid, ids,
context={'fiscalyear': fy_id}):
accnt_type_data = account.user_type
if not accnt_type_data:
continue
if accnt_type_data.close_method=='none' or account.type == 'view':
continue
if accnt_type_data.close_method=='balance':
if abs(account.balance)>0.0001:
pool.get('account.move.line').create(cr, uid, {
'debit': account.balance>0 and account.balance,
'credit': account.balance<0 and -account.balance,
'name': data['form']['report_name'],
query_line = pool.get('account.move.line')._query_get(cr, uid,
obj='account_move_line', context={'fiscalyear': fy_id})
cr.execute('select id from account_account WHERE active')
ids = map(lambda x: x[0], cr.fetchall())
for account in pool.get('account.account').browse(cr, uid, ids,
context={'fiscalyear': fy_id}):
accnt_type_data = account.user_type
if not accnt_type_data:
continue
if accnt_type_data.close_method=='none' or account.type == 'view':
continue
if accnt_type_data.close_method=='balance':
if abs(account.balance)>0.0001:
pool.get('account.move.line').create(cr, uid, {
'debit': account.balance>0 and account.balance,
'credit': account.balance<0 and -account.balance,
'name': data['form']['report_name'],
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'account_id': account.id
}, {'journal_id': new_journal.id, 'period_id':period.id})
if accnt_type_data.close_method == 'unreconciled':
offset = 0
limit = 100
while True:
cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'AND reconcile_id is NULL ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
parent_id = move['id']
move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'account_id': account.id
}, {'journal_id': new_journal.id, 'period_id':period.id})
if accnt_type_data.close_method == 'unreconciled':
offset = 0
limit = 100
while True:
cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'AND reconcile_id is NULL ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
parent_id = move['id']
move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'parent_move_lines':[(6,0,[parent_id])]
'parent_move_lines':[(6,0,[parent_id])]
})
pool.get('account.move.line').create(cr, uid, move, {
'journal_id': new_journal.id,
'period_id': period.id,
})
pool.get('account.move.line').create(cr, uid, move, {
'journal_id': new_journal.id,
'period_id': period.id,
})
offset += limit
if accnt_type_data.close_method=='detail':
offset = 0
limit = 100
while True:
cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
parent_id = move['id']
move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'parent_move_lines':[(6,0,[parent_id])]
})
pool.get('account.move.line').create(cr, uid, move)
offset += limit
offset += limit
if accnt_type_data.close_method=='detail':
offset = 0
limit = 100
while True:
cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
parent_id = move['id']
move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'parent_move_lines':[(6,0,[parent_id])]
})
pool.get('account.move.line').create(cr, uid, move)
offset += limit
cr.execute('UPDATE account_journal_period ' \
'SET state = %s ' \
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
('done',fy_id))
cr.execute('UPDATE account_period SET state = %s ' \
'WHERE fiscalyear_id = %s', ('done',fy_id))
new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'])
start_jp = new_fyear.start_journal_period_id
cr.execute('UPDATE account_fiscalyear ' \
'SET state = %s, end_journal_period_id = %s ' \
'WHERE id = %s', ('done', start_jp and start_jp.id or None, fy_id))
'SET end_journal_period_id = %s ' \
'WHERE id = %s', (start_jp and start_jp.id or None, fy_id))
return {}
class wiz_journal_close(wizard.interface):
states = {
'init': {
'actions': [_data_load],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Fiscal Year')]}
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Create entries')]}
},
'close': {
'actions': [_data_save],

View File

@ -0,0 +1,72 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 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/>.
#
##############################################################################
import wizard
import osv
import pooler
from tools.translate import _
_transaction_form = '''<?xml version="1.0"?>
<form string=" Close states of Fiscal year and periods">
<field name="fy_id"/>
<separator string="Are you sure you want to close the states of fiscal year and its period?" colspan="4"/>
<field name="sure"/>
</form>'''
_transaction_fields = {
'fy_id': {'string':'Fiscal Year to close', 'type':'many2one', 'relation': 'account.fiscalyear','required':True, 'domain':[('state','=','draft')]},
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_save(self, cr, uid, data, context):
if not data['form']['sure']:
raise wizard.except_wizard(_('UserError'), _('Closing of states cancelled, please check the box !'))
pool = pooler.get_pool(cr.dbname)
fy_id = data['form']['fy_id']
cr.execute('UPDATE account_journal_period ' \
'SET state = %s ' \
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
('done',fy_id))
cr.execute('UPDATE account_period SET state = %s ' \
'WHERE fiscalyear_id = %s', ('done',fy_id))
cr.execute('UPDATE account_fiscalyear ' \
'SET state = %s WHERE id = %s', ('done', fy_id))
return {}
class wiz_journal_close_state(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close states')]}
},
'close': {
'actions': [_data_save],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_journal_close_state('account.fiscalyear.close.state')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -92,22 +92,25 @@ class accounting_report_indicator(report_sxw.rml_parse):
'getarray':self.getarray,
'gettree':self.gettree,
})
self.count=0
self.treecount=0
self.list=[]
self.header_name=self.header_val=[]
self.main_dict={}
self.count = 0
self.treecount = 0
self.list = []
self.header_name = []
self.header_val = []
self.main_dict = {}
def repeatIn(self, lst, name, nodes_parent=False,td=False,width=[],value=[],type=[]):
def repeatIn(self, lst, name, nodes_parent=False,td=False,width=[],value=[],type=[],data=''):
self._node.data = ''
node = self._find_parent(self._node, nodes_parent or parents)
ns = node.nextSibling
#start
if not name=='array':
return super(accounting_report_indicator,self).repeatIn(lst, name, nodes_parent=False)
value=['Data']
array_header = eval(data,{'year':'Fiscal Year','periods':'Periods'})
value = [array_header]
value.extend(self.header_name)
type=['string'].extend(['float']*len(self.header_name))
width=[40]*(len(self.header_name)+1)
@ -145,7 +148,6 @@ class accounting_report_indicator(report_sxw.rml_parse):
newnode=False
i+=1
check=1
return super(accounting_report_indicator,self).repeatIn(lst, name, nodes_parent=False)
def lines(self,data):
@ -173,18 +175,22 @@ class accounting_report_indicator(report_sxw.rml_parse):
'disp_tree':obj_ind.disp_tree,
'note':obj_ind.note,
'type':obj_ind.type,
'array_table' : False,
}
if len(obj_ind.expression)>=2:
res['array_table'] = True
result.append(res)
return result
def getarray(self,data,object):
def getarray(self,data,object,array_header=''):
res={}
result=[]
self.getgraph(data,object,intercall=True)
self.header_val=[str(x) for x in self.header_val]
temp_dict=zip(self.header_name,self.header_val)
res=dict(temp_dict)
res['Data']='Value'
array_header = eval(array_header,{'year':'Fiscal Year','periods':'Periods'})
res[array_header]='Value'
result.append(res)
return result

View File

@ -91,14 +91,11 @@
<font color="white"> </font>
</para>
<para style="P1">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<blockTable colWidths="362.0,166.0" style="Table4">
<blockTable colWidths="528.0" style="Table4">
<tr>
<td>
<para style="P6">Name</para>
</td>
<td>
<para style="P6">Code</para>
</td>
</tr>
</blockTable>
<para style="P3">
@ -107,42 +104,18 @@
<para style="P3"><seqReset/></para>
<section>
<para style="P1">[[ repeatIn(lines(data['form']),'o')]]</para>
<blockTable colWidths="362.0,166.0" style="Table3">
<blockTable colWidths="528.0" style="Table3">
<tr>
<td>
<para style="P11"><b>(<seq/>)</b> [[ o['type']=='view' and setTag('para','para',{'fontName':'Helvetica-Bold','fontSize':'10.5'}) ]]<u>[[ o['name'] ]]</u></para>
</td>
<td>
<para style="P11">[[ o['type']=='view' and setTag('para','para',{'fontName':'Helvetica-Bold','fontSize':'10.5'}) ]]<u>[[ o['code'] ]]</u></para>
<para style="P11"><b>(<seq/>)</b> [[ o['type']=='view' and setTag('para','para',{'fontName':'Helvetica-Bold','fontSize':'10.5'}) ]]<u>[[ o['name'] ]]</u> (<u>[[ o['code'] ]]</u>)</para>
</td>
</tr>
</blockTable>
<para style="P3">
<font color="white"> </font>
</para>
<para style="P1">[[ o['disp_tree'] and setTag('para','image',{'file':gettree(data['form'],o)}) or removeParentNode('para') ]]</para>
<para style="P1">[[ o['disp_graph'] and setTag('para','image',{'width':'450.00','height':'215.00','file':getgraph(data['form'],o)}) or removeParentNode('para') ]]</para>
<para style="P3">
<font color="white"> </font>
</para>
<section>
<para style="P13">[[ repeatIn(getarray(data['form'],o),'array',td=len(data['form']['base_selection'][0][2])) ]]</para>
<blockTable colWidths="0.0" style="Table5">
<tr>
<td>
<para style="P9"> </para>
</td>
</tr>
<tr>
<td>
<para style="P9"> </para>
</td>
</tr>
</blockTable>
</section>
<para style="P3">
<font color="white"> </font>
</para>
<blockTable colWidths="14.0,500.0,14.0" repeatRows="1" style="Table6">
<tr>
<td>
@ -165,7 +138,7 @@
<para style="P9"> </para>
</td>
<td>
<para style="P5"><b>Notes :</b> [[ o['note'] ]]</para>
<para style="P5"> [[ format(o['note']) or removeParentNode('blockTable') ]]</para>
</td>
<td>
<para style="P9"> </para>
@ -175,8 +148,24 @@
<para style="P3">
<font color="white"> </font>
</para>
<hr color="black" thickness="1.5"/>
</section>
<section>
<para style="P1">[[ repeatIn(lines(data['form']),'o')]]</para>
<para style="P13">[[ o['array_table'] and repeatIn(getarray(data['form'],o,array_header=data['form']['select_base']),'array',td=len(data['form']['base_selection'][0][2]),data=data['form']['select_base']) or removeParentNode('section') ]]</para>
<blockTable colWidths="0.0" style="Table5">
<tr>
<td>
<para style="P9"> </para>
</td>
</tr>
<tr>
<td>
<para style="P9"> </para>
</td>
</tr>
</blockTable>
</section>
<hr color="black" thickness="1.5"/>
</story>
</document>

View File

@ -90,8 +90,9 @@ class wizard_vat(wizard.interface):
for ads in obj_cmpny.partner_id.address:
if ads.type=='default':
if ads.zip_id:
zip_city=pooler.get_pool(cr.dbname).get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1]
zip_city = pooler.get_pool(cr.dbname).get('res.partner.address').get_city(cr,uid,ads.id)
if not zip_city:
zip_city = ''
if ads.street:
street=ads.street
if ads.street2:
@ -104,7 +105,7 @@ class wizard_vat(wizard.interface):
data_file='<?xml version="1.0"?>\n<VatList xmlns="http://www.minfin.fgov.be/VatList" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.minfin.fgov.be/VatList VatList.xml" RecipientId="VAT-ADMIN" SenderId="'+ str(company_vat) + '"'
data_file +=' ControlRef="'+ cref + '" MandataireId="'+ data['form']['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
if data['form']['test_xml']:
data_file += 'Test="0"'
data_file += ' Test="0"'
data_file += ' VersionTech="1.2">'
data_file +='\n<AgentRepr DecNumber="1">\n\t<CompanyInfo>\n\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t<Name>'+str(obj_cmpny.name)+'</Name>\n\t\t<Street>'+ str(street) +'</Street>\n\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>'
data_file +='\n\t\t<Country>'+ str(country) +'</Country>\n\t</CompanyInfo>\n</AgentRepr>'
@ -114,7 +115,7 @@ class wizard_vat(wizard.interface):
for p_id in p_id_list:
record=[] # this holds record per partner
obj_partner=pooler.get_pool(cr.dbname).get('res.partner').browse(cr,uid,p_id)
cr.execute('select b.code,sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in ('"'produit'"','"'tax'"') and l.partner_id=%%s and l.date between %s group by a.type' % (period,), (p_id,))
cr.execute('select b.code,sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in ('"'produit'"','"'tax'"') and l.partner_id=%%s and l.date between %s group by b.code' % (period,), (p_id,))
line_info=cr.fetchall()
if not line_info:
continue