bzr revid: ruchakpatel@gmail.com-20081003050559-pgefch6p59ccwprb
This commit is contained in:
Rucha Patel 2008-10-03 10:35:59 +05:30
commit 5a17384a56
151 changed files with 11188 additions and 2957 deletions

17
addons/.project.moved Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>new-report-apa</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>

6
addons/.pydevproject Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.4</pydev_property>
</pydev_project>

View File

@ -141,7 +141,9 @@ class account_account(osv.osv):
if context is None:
context = {}
pos = 0
while pos<len(args):
if args[pos][0]=='code' and args[pos][1] in ('like','ilike') and args[pos][2]:
args[pos] = ('code', '=like', str(args[pos][2].replace('%',''))+'%')
if args[pos][0]=='journal_id':
@ -157,17 +159,33 @@ class account_account(osv.osv):
ids1 += map(lambda x: x.id, jour.account_control_ids)
args[pos] = ('id','in',ids1)
pos+=1
return super(account_account,self).search(cr, uid, args, offset, limit,
order, context=context, count=count)
def _get_children_and_consol(self, cr, uid, ids, context={}):
#this function search for all the children and all consolidated children (recursively) of the given account ids
res = self.search(cr, uid, [('parent_id', 'child_of', ids)])
for id in res:
this = self.browse(cr, uid, id, context)
for child in this.child_consol_ids:
if child.id not in res:
res.append(child.id)
if len(res) != len(ids):
return self._get_children_and_consol(cr, uid, res, context)
return res
def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''):
#compute the balance/debit/credit accordingly to the value of field_name for the given account ids
mapping = {
'balance': "COALESCE(SUM(l.debit) - SUM(l.credit), 0) as balance ",
'debit': "COALESCE(SUM(l.debit), 0) as debit ",
'credit': "COALESCE(SUM(l.credit), 0) as credit "
}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
#get all the necessary accounts
ids2 = self._get_children_and_consol(cr, uid, ids, context)
acc_set = ",".join(map(str, ids2))
#compute for each account the balance/debit/credit from the move lines
accounts = {}
if ids2:
query = self.pool.get('account.move.line')._query_get(cr, uid,
@ -184,13 +202,29 @@ class account_account(osv.osv):
for res in cr.dictfetchall():
accounts[res['id']] = res
#for the asked accounts, get from the dictionnary 'accounts' the value of it
res = {}
for id in ids:
res[id] = {}.fromkeys(field_names, 0.0)
ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])])
res[id] = self._get_account_values(cr, uid, id, accounts, field_names, context)
return res
def _get_account_values(self, cr, uid, id, accounts, field_names, context={}):
res = {}.fromkeys(field_names, 0.0)
browse_rec = self.browse(cr, uid, id)
if browse_rec.type == 'consolidation':
ids2 = self.read(cr, uid, [browse_rec.id], ['child_consol_ids'], context)[0]['child_consol_ids']
for t in self.search(cr, uid, [('parent_id', 'child_of', [browse_rec.id])]):
if t not in ids2 and t != browse_rec.id:
ids2.append(t)
for i in ids2:
tmp = self._get_account_values(cr, uid, i, accounts, field_names, context)
for a in field_names:
res[a] += tmp[a]
else:
ids2 = self.search(cr, uid, [('parent_id', 'child_of', [browse_rec.id])])
for i in ids2:
for a in field_names:
res[id][a] += accounts.get(i, {}).get(a, 0.0)
res[a] += accounts.get(i, {}).get(a, 0.0)
return res
def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}):
@ -216,7 +250,7 @@ class account_account(osv.osv):
_columns = {
'name': fields.char('Name', size=128, required=True, select=True),
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Force all moves for this account to have this secondary currency."),
'code': fields.char('Code', size=64),
'code': fields.char('Code', size=64, required=True),
'type': fields.selection([
('receivable','Receivable'),
('payable','Payable'),
@ -229,7 +263,7 @@ class account_account(osv.osv):
'user_type': fields.many2one('account.account.type', 'Account Type', required=True),
'parent_id': fields.many2one('account.account','Parent', ondelete='cascade'),
'child_parent_ids':fields.one2many('account.account','parent_id','Children'),
'child_consol_ids':fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children',domain=[('type', '=', 'consolidation')]),
'child_consol_ids':fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children'),
'child_id': fields.function(_get_child_ids, method=True, type='many2many',relation="account.account",string="Children Accounts"),
'balance': fields.function(__compute, digits=(16,2), method=True, string='Balance', multi='balance'),
'credit': fields.function(__compute, digits=(16,2), method=True, string='Credit', multi='balance'),
@ -245,7 +279,7 @@ class account_account(osv.osv):
'parent_left': fields.integer('Parent Left', select=1),
'parent_right': fields.integer('Parent Right', select=1),
'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries otherwise it will print balance of this account")
'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries when printing the General Ledger, otherwise it will only print its balance.")
}
def _default_company(self, cr, uid, context={}):
@ -924,15 +958,21 @@ class account_move_reconcile(osv.osv):
{'reconcile_id': rec.id }
)
return True
def name_get(self, cr, uid, ids, context=None):
result = {}
if not len(ids):
return []
result = []
for r in self.browse(cr, uid, ids, context):
total = reduce(lambda y,t: (t.debit or 0.0) - (t.credit or 0.0) + y, r.line_partial_ids, 0.0)
if total:
result[r.id] = '%s (%.2f)' % (r.name, total)
name = '%s (%.2f)' % (r.name, total)
result.append((r.id,name))
else:
result[r.id] = r.name
result.append((r.id,r.name))
return result
account_move_reconcile()
#----------------------------------------------------------
@ -1478,13 +1518,15 @@ account_subscription_line()
class account_config_wizard(osv.osv_memory):
_name = 'account.config.wizard'
def _get_charts(self, cr, uid, context):
module_obj=self.pool.get('ir.module.module')
ids=module_obj.search(cr, uid, [('category_id', '=', 'Account charts'), ('state', '<>', 'installed')])
ids=module_obj.search(cr, uid, [('category_id', '=', 'Account Charts'), ('state', '<>', 'installed')])
res=[(m.id, m.shortdesc) for m in module_obj.browse(cr, uid, ids)]
res.append((-1, 'None'))
res.sort(lambda x,y: cmp(x[1],y[1]))
return res
_columns = {
'name':fields.char('Name', required=True, size=64, help="Name of the fiscal year as displayed on screens."),
'code':fields.char('Code', required=True, size=64, help="Name of the fiscal year as displayed in reports."),
@ -1498,19 +1540,20 @@ class account_config_wizard(osv.osv_memory):
'name': lambda *a: time.strftime('%Y'),
'date1': lambda *a: time.strftime('%Y-01-01'),
'date2': lambda *a: time.strftime('%Y-12-31'),
'period':lambda *a:'month'
'period':lambda *a:'month',
'charts': lambda *a: -1,
}
def action_cancel(self,cr,uid,ids,conect=None):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
def install_account_chart(self, cr, uid,ids, context=None):
for res in self.read(cr,uid,ids):
for res in self.read(cr,uid,ids):
id = res['charts']
def install(id):
mod_obj = self.pool.get('ir.module.module')
@ -1553,12 +1596,12 @@ class account_config_wizard(osv.osv_memory):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
account_config_wizard()
@ -2025,7 +2068,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
@ -2033,11 +2076,11 @@ class wizard_multi_charts_accounts(osv.osv_memory):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
}
wizard_multi_charts_accounts()

View File

@ -167,8 +167,8 @@ class account_bank_statement(osv.osv):
if not (abs(st.balance_end - st.balance_end_real) < 0.0001):
raise osv.except_osv(_('Error !'),
_('The statement balance is incorrect !\n'
'Check that the ending balance equals the computed one.'))
_('The statement balance is incorrect !\n') +
_('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end))
if (not st.journal_id.default_credit_account_id) \
or (not st.journal_id.default_debit_account_id):
raise osv.except_osv(_('Configration Error !'),
@ -177,7 +177,7 @@ class account_bank_statement(osv.osv):
for line in st.move_line_ids:
if line.state <> 'valid':
raise osv.except_osv(_('Error !'),
_('The account entries lines are not valid.'))
_('The account entries lines are not in valid state.'))
for move in st.line_ids:
move_id = account_move_obj.create(cr, uid, {

View File

@ -339,6 +339,17 @@
<field name="domain">[('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
<record id="action_invoice_tree1_view1" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="act_window_id" ref="action_invoice_tree1"/>
</record>
<record id="action_invoice_tree1_view2" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="invoice_form"/>
<field name="act_window_id" ref="action_invoice_tree1"/>
</record>
<menuitem action="action_invoice_tree1" id="menu_action_invoice_tree1" parent="account.menu_finance_invoice"/>
<record id="action_invoice_tree1_new" model="ir.actions.act_window">
<field name="name">New Customer Invoice</field>
@ -421,6 +432,7 @@
<field name="name">Draft Customer Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','=','draft'),('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
@ -442,6 +454,7 @@
<field name="name">PRO-FORMA Customer Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','=','proforma'),('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
@ -463,6 +476,7 @@
<field name="name">Unpaid Customer Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','!=','draft'),('reconciled','=',False),('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
@ -484,6 +498,7 @@
<field name="name">Draft Supplier Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','=','draft'),('type','=','in_invoice')]</field>
<field name="context">{'type':'in_invoice'}</field>
</record>
@ -505,6 +520,7 @@
<field name="name">Unpaid Supplier Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','!=','draft'),('reconciled','=',False),('type','=','in_invoice')]</field>
<field name="context">{'type':'in_invoice'}</field>
</record>
@ -526,6 +542,7 @@
<field name="name">Draft Customer Refunds</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','=','draft'),('type','=','out_refund')]</field>
<field name="context">{'type':'out_refund'}</field>
</record>
@ -547,6 +564,7 @@
<field name="name">Unpaid Customer Refunds</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','!=','draft'),('reconciled','=',False),('type','=','out_refund')]</field>
<field name="context">{'type':'out_refund'}</field>
</record>
@ -568,6 +586,7 @@
<field name="name">Draft Supplier Refunds</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','=','draft'),('type','=','in_refund')]</field>
<field name="context">{'type':'in_refund'}</field>
</record>
@ -589,6 +608,7 @@
<field name="name">Unpaid Supplier Refunds</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','!=','draft'),('reconciled','=',False),('type','=','in_refund')]</field>
<field name="context">{'type':'in_refund'}</field>
</record>

View File

@ -305,6 +305,8 @@ class account_move_line(osv.osv):
'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'),
#TODO: remove this
'amount_taxed':fields.float("Taxed Amount",digits=(16,2)),
'parent_move_lines':fields.many2many('account.move.line', 'account_move_line_rel', 'child_id', 'parent_id', 'Parent'),
'reconcile_implicit':fields.boolean('Implicit Reconciliaiton')
}
def _get_date(self, cr, uid, context):
@ -435,7 +437,11 @@ class account_move_line(osv.osv):
currency = 0.0
account_id = False
partner_id = False
implicit_lines = []
for line in unrec_lines:
if line.parent_move_lines:
for i in line.parent_move_lines:
implicit_lines.append(i.id)
if line.state <> 'valid':
raise osv.except_osv(_('Error'),
_('Entry "%s" is not valid !') % line.name)
@ -481,7 +487,7 @@ class account_move_line(osv.osv):
self_debit = -writeoff
# If comment exist in context, take it
if context['comment']:
if 'comment' in context and context['comment']:
libelle=context['comment']
else:
libelle='Write-Off'
@ -531,9 +537,13 @@ class account_move_line(osv.osv):
'line_id': map(lambda x: (4,x,False), ids),
'line_partial_ids': map(lambda x: (3,x,False), ids)
})
wf_service = netsvc.LocalService("workflow")
if implicit_lines:
self.write(cr, uid, implicit_lines, {'reconcile_implicit':True,'reconcile_id':r_id})
for id in implicit_lines:
wf_service.trg_trigger(uid, 'account.move.line', id, cr)
# the id of the move.reconcile is written in the move.line (self) by the create method above
# because of the way the line_id are defined: (4, x, False)
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'account.move.line', id, cr)
return r_id
@ -629,7 +639,7 @@ class account_move_line(osv.osv):
if raise_ex:
raise osv.except_osv(_('Wrong Accounting Entry!'), _('Both Credit and Debit cannot be zero!'))
account_obj = self.pool.get('account.account')
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!'))
if update_check:

View File

@ -116,19 +116,19 @@
<field name="type" select="1"/>
<field name="company_id" select="2"/>
<field name="parent_id"/>
<field name="active"/>
<field name="user_type" select="1"/>
</group>
<notebook colspan="4">
<page string="General Information">
<newline/>
<field name="user_type" select="1"/>
<field name="currency_id" select="2"/>
<field name="active" select="2"/>
<field name="reconcile"/>
<field name="check_history"/>
<newline/>
<newline/>
<field name="child_consol_ids" colspan="4"/>
<field colspan="4" name="tax_ids" domain="[('parent_id','=',False)]"/>
<field name="child_consol_ids" colspan="4" attrs="{'readonly':[('type','!=','consolidation')]}"/>/>
</page>
<page string="Notes">
<field colspan="4" name="note" nolabel="1"/>
@ -654,6 +654,7 @@
<field name="state"/>
<field name="reconcile_id"/>
<field name="reconcile_partial_id"/>
<field colspan="4" name="reconcile_implicit"/>
</tree>
</field>
</record>
@ -705,6 +706,10 @@
<page string="Analytic Lines">
<field colspan="4" name="analytic_lines" nolabel="1"/>
</page>
<page string="Move Lines">
<field colspan="4" name="reconcile_implicit"/>
<field colspan="4" name="parent_move_lines" nolabel="0"/>
</page>
</notebook>
</form>
</field>
@ -744,7 +749,7 @@
<newline/>
<field name="account_tax_id" domain="[('parent_id','=',False)]"/>
<field name="analytic_account_id"/>
<field colspan="4" name="reconcile_implicit"/>
<separator colspan="4" string="State"/>
<newline/>
<field name="reconcile_id"/>
@ -1285,6 +1290,7 @@
<field name="credit" sum="Total credit"/>
<field name="account_tax_id"/>
<field name="analytic_account_id"/>
<field colspan="4" name="reconcile_implicit"/>
<field name="state"/>
</tree>
</field>
@ -1354,21 +1360,21 @@
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</record>
<!-- register configuration wizard -->
<record id="config_fiscalyear" model="ir.module.module.configuration.step">
<record id="config_fiscalyear" model="ir.actions.todo">
<field name="name">Account Configure Wizard</field>
<field name="note">Define Fiscal Years and Select Charts of Account</field>
<field name="action_id" ref="action_account_config_wizard_form"/>
<field name="state">open</field>
</record>
</record>
<!-- Account Templates -->

View File

@ -150,7 +150,9 @@
<field name="view_type">form</field>
<field name="view_id" ref="view_account_analytic_line_tree"/>
</record>
<menuitem id="next_id_41" name="Analytic Entries" parent="account.menu_finance_entries"/><menuitem action="action_account_analytic_line_form" id="account_entries_analytic_entries" parent="next_id_41"/>
<wizard id="action_account_analytic_line" menu="False" model="account.analytic.line" name="account.analytic.line" string="Entries Encoding by Line"/>
<menuitem id="next_id_41" name="Analytic Entries" parent="account.menu_finance_entries"/>
<menuitem type="wizard" icon="STOCK_JUSTIFY_FILL" action="action_account_analytic_line" id="account_entries_analytic_entries" parent="next_id_41"/>
<record id="action_account_tree1" model="ir.actions.act_window">
@ -238,7 +240,7 @@
#
<record id="action_account_analytic_journal_open_form" model="ir.actions.act_window">
<field name="name">account.analytic.journal.open.form</field>
<field name="name">Entries of Open Analytic Journals</field>
<field name="res_model">account.analytic.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>

View File

@ -34,6 +34,7 @@ import wizard_account_analytic_inverted_balance_report
import wizard_account_analytic_cost_ledger_report
import wizard_account_analytic_cost_ledger_for_journal_report
import wizard_account_analytic_analytic_check
import wizard_account_analytic_line
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,86 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import pooler
import time
def _action_open_window(self, cr, uid, data, context):
domain=[]
from_date= data['form']['from_date']
to_date=data['form']['to_date']
if from_date and to_date:
domain=[('date','>=',from_date),('date','<=',to_date)]
elif from_date:
domain=[('date','>=',from_date)]
elif to_date:
domain=[('date','<=',to_date)]
return {
'name': 'Analytic Entries',
'view_type': 'form',
"view_mode": 'tree,form',
'res_model': 'account.analytic.line',
'type': 'ir.actions.act_window',
'domain': domain}
class account_analytic_line(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="View Account Analytic Lines">
<separator string="Account Analytic Lines Analysis" colspan="4"/>
<field name="from_date"/>
<newline/>
<field name="to_date"/>
<newline/>
<label string=""/>
<label string="(Keep empty to open the current situation)" align="0.0" colspan="3"/>
</form>'''
form1_fields = {
'from_date': {
'string': 'From',
'type': 'date',
},
'to_date': {
'string': 'To',
'type': 'date',
},
}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Entries','gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
account_analytic_line('account.analytic.line')

View File

@ -39,6 +39,7 @@ import invoice
import overdue
import aged_trial_balance
import tax_report
import general_ledger_landscape
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
@ -28,113 +27,194 @@
#
##############################################################################
import xml
import copy
from operator import itemgetter
import time
import datetime
from report import report_sxw
class account_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_balance, self).__init__(cr, uid, name, context)
self.sum_debit = 0.0
self.sum_credit = 0.0
self.localcontext.update({
'time': time,
'lines': self.lines,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'get_fiscalyear':self.get_fiscalyear,
'get_periods':self.get_periods,
})
self.context = context
def get_fiscalyear(self, form):
fisc_id = form['fiscalyear']
if fisc_id:
self.cr.execute("select name from account_fiscalyear where id = %d" %(int(fisc_id)))
else:
self.cr.execute("select name from account_fiscalyear where state='draft'")
res=self.cr.fetchall()
result=''
for r in res:
result+=r[0]+","
return str(result and result[:-1]) or ''
def get_periods(self, form):
periods=form['periods'][0][2]
if periods:
period_ids = ",".join([str(x) for x in form['periods'][0][2] if x])
self.cr.execute("select name from account_period where id in (%s)" % (period_ids))
else:
if form['fiscalyear']:
self.cr.execute("select name from account_period where fiscalyear_id = %d"%(int(form['fiscalyear'])))
_name = 'report.account.account.balance'
def __init__(self, cr, uid, name, context):
super(account_balance, self).__init__(cr, uid, name, context)
self.sum_debit = 0.00
self.sum_credit = 0.00
self.date_lst = []
self.date_lst_string = ''
self.localcontext.update({
'time': time,
'lines': self.lines,
'moveline':self.moveline,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'get_fiscalyear':self.get_fiscalyear,
'get_periods':self.get_periods,
})
self.context = context
def get_fiscalyear(self, form):
res=[]
if form.has_key('fiscalyear'):
fisc_id = form['fiscalyear']
if not (fisc_id):
return ''
self.cr.execute("select name from account_fiscalyear where id = %d" %(int(fisc_id)))
res=self.cr.fetchone()
return res and res[0] or ''
def get_periods(self, form):
result=''
if form.has_key('periods'):
period_ids = ",".join([str(x) for x in form['periods'][0][2] if x])
self.cr.execute("select name from account_period where id in (%s)" % (period_ids))
res=self.cr.fetchall()
for r in res:
result+=r[0]+", "
return str(result and result[:-1]) or ''
def lines(self, form, ids={}, done=None, level=1):
if not ids:
ids = self.ids
if not ids:
return []
if not done:
done={}
res={}
result_acc=[]
ctx = self.context.copy()
if form.has_key('fiscalyear'):
self.transform_period_into_date_array(form)
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
else:
self.cr.execute("select name from account_period")
res=self.cr.fetchall()
result=''
for r in res:
result+=r[0]+","
return str(result and result[:-1]) or ''
def lines(self, form, ids={}, done=None, level=1):
if not ids:
ids = self.ids
if not ids:
return []
if not done:
done={}
result = []
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
ctx['target_move'] = form['target_move']
ctx['state']=form['state']
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
def cmp_code(x, y):
return cmp(x.code, y.code)
accounts.sort(cmp_code)
for account in accounts:
if account.id in done:
continue
done[account.id] = 1
res = {
'code': account.code,
'name': account.name,
'level': level,
'debit': account.debit,
'credit': account.credit,
'balance': account.balance,
'leef': not bool(account.child_id)
}
self.sum_debit += account.debit
self.sum_credit += account.credit
if not (res['credit'] or res['debit']) and not account.child_id:
continue
if account.child_id:
def _check_rec(account):
if not account.child_id:
return bool(account.credit or account.debit)
for c in account.child_id:
if _check_rec(c):
return True
return False
if not _check_rec(account):
self.transform_date_into_date_array(form)
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
def cmp_code(x, y):
return cmp(x.code, y.code)
accounts.sort(cmp_code)
for account in accounts:
if account.id in done:
continue
result.append(res)
if account.child_id:
ids2 = [(x.code,x.id) for x in account.child_id]
ids2.sort()
result += self.lines(form, [x[1] for x in ids2], done, level+1)
return result
def _sum_credit(self):
return self.sum_credit
def _sum_debit(self):
return self.sum_debit
done[account.id] = 1
res = {
'lid' :'',
'date':'',
'jname':'',
'ref':'',
'lname':'',
'debit1':'',
'credit1':'',
'balance1' :'',
'id' : account.id,
'code': account.code,
'name': account.name,
'level': level,
'debit': account.debit,
'credit': account.credit,
'balance': account.balance,
'leef': not bool(account.child_id),
}
self.sum_debit += account.debit
self.sum_credit += account.credit
if not (res['credit'] or res['debit']) and not account.child_id:
continue
if account.child_id:
def _check_rec(account):
if not account.child_id:
return bool(account.credit or account.debit)
for c in account.child_id:
if _check_rec(c):
return True
return False
if not _check_rec(account):
continue
if form['display_account'] == 'bal_mouvement':
if res['credit'] <> 0 or res['debit'] <> 0 or res['balance'] <> 0:
result_acc.append(res)
elif form['display_account'] == 'bal_solde':
if res['balance'] <> 0:
result_acc.append(res)
else:
result_acc.append(res)
res1 = self.moveline(form, account.id,res['level'])
if res1:
for r in res1:
result_acc.append(r)
if account.code=='0':
result_acc.pop(-1)
if account.child_id:
ids2 = [(x.code,x.id) for x in account.child_id]
ids2.sort()
result_acc += self.lines(form, [x[1] for x in ids2], done, level+1)
return result_acc
def moveline(self,form,ids,level):
res={}
self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\''
self.cr.execute(
"SELECT l.id as lid,l.date,j.code as jname, l.ref, l.name as lname, l.debit as debit1, l.credit as credit1 " \
"FROM account_move_line l " \
"LEFT JOIN account_journal j " \
"ON (l.journal_id = j.id) " \
"WHERE l.account_id = '"+str(ids)+"' " \
"AND l.date IN (" + self.date_lst_string + ") " \
"ORDER BY l.id")
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
sum = r['debit1'] - r['credit1']
r['balance1'] = sum
r['id'] =''
r['code']= ''
r['name']=''
r['level']=level
r['debit']=''
r['credit']=''
r['balance']=''
r['leef']=''
return res or ''
def date_range(self,start,end):
start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d")))
end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d")))
full_str_date = []
#
r = (end+datetime.timedelta(days=1)-start).days
#
date_array = [start+datetime.timedelta(days=i) for i in range(r)]
for date in date_array:
full_str_date.append(str(date))
return full_str_date
#
def transform_period_into_date_array(self,form):
## Get All Period Date
if not form['periods'][0][2] :
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',form['fiscalyear'])])
else:
periods_id = form['periods'][0][2]
date_array = []
for period_id in periods_id:
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
self.date_lst = date_array
self.date_lst.sort()
def transform_date_into_date_array(self,form):
return_array = self.date_range(form['date_from'],form['date_to'])
self.date_lst = return_array
self.date_lst.sort()
def _sum_credit(self):
return self.sum_credit
def _sum_debit(self):
return self.sum_debit
report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header=2)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2,116 +2,91 @@
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="35.0" y1="35.0" width="525" height="772"/>
<frame id="first" x1="57.0" y1="57.0" width="481" height="700"/>
<pageGraphics>
<drawRightString x="297.5" y="0.7cm"><pageNumber/> / </drawRightString>
<drawString x="297.5" y="0.7cm"><pageCount/></drawString>
</pageGraphics>
<setFont name="Helvetica-Bold" size="9"/>
<!--COL 1-->
<drawString x="1.0cm" y="28.1cm">[[ company.name ]]</drawString>
<drawString x="16.2cm" y="28.1cm">Account Balance - [[ company.currency_id.name ]]</drawString>
<!--COL 2-->
<setFont name="Helvetica" size="9"/>
<drawString x="1.0cm" y="1cm"> [[ time.strftime("%m-%d-%y %H:%M", time.localtime()) ]]</drawString>
<drawString x="19.0cm" y="1cm">Page <pageNumber/></drawString>
<lineMode width="0.7"/>
<lines>1cm 27.7cm 20cm 27.7cm</lines>
<setFont name="Helvetica" size="8"/>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,-1"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,-1"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,-1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,-1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<blockLeftPadding length="0" start="0,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<blockValign value="TOP"/>
<blockAlignment value="RIGHT" start="2,1" stop="-1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,0"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockTableStyle id="Table3">
<blockLeftPadding length="0" start="0,0" stop="-1,0"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<blockAlignment value="RIGHT" start="2,1" stop="-1,-1"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Helvetica" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Helvetica" fontSize="2.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica" fontSize="8.0" leading="14" spaceBefore="0.0" spaceAfter="6.0" alignment="RIGHT"/>
<paraStyle name="P9" fontName="Helvetica-Bold" alignment="CENTER" fontSize="14.5" leftIndent="-5.0"/>
<paraStyle name="P9b" fontName="Helvetica" fontSize="8" leftIndent="-5.0" alignment="LEFT"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="8.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12a" fontName="Helvetica" fontSize="8.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" rightIndent="17.0" leftIndent="-0.0" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3a" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica" fontSize="9.0" leading="14" spaceBefore="0.0" spaceAfter="6.0" alignment="RIGHT"/>
<paraStyle name="P9" fontName="Helvetica-Bold" alignment="CENTER" fontSize="12" leftIndent="-5.0"/>
<paraStyle name="P9b" fontName="Helvetica" fontSize="9" leftIndent="0.0" alignment="LEFT"/>
<paraStyle name="P9a" fontName="Helvetica-Bold" fontSize="9" leftIndent="0.0" alignment="LEFT"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="9.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12a" fontName="Helvetica" fontSize="9.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<blockTableStyle id="TrLevel7">
<blockLeftPadding length="0" start="0,0" stop="-1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevel6">
<blockLeftPadding length="60" start="1,0" stop="1,0"/>
<blockLeftPadding length="0" start="0,0" stop="-1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevel5">
<blockLeftPadding length="40" start="1,0" stop="1,0"/>
<blockLeftPadding length="0" start="0,0" stop="-1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevel4">
<blockLeftPadding length="20" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="1,0" stop="1,0"/>
<blockLeftPadding length="0" start="0,0" stop="-1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevel3">
<blockLeftPadding length="0" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="1,0" stop="-1,0"/>
<blockLeftPadding length="0" start="0,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevel2">
<blockLeftPadding length="0" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="1,0" stop="1,0"/>
<blockTopPadding length="13" start="0,0" stop="-1,0"/>
<blockBottomPadding length="2" start="0,0" stop="-1,0"/>
<blockFont name="Times-Bold" start="0,0" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="TrLevel1">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<blockLeftPadding length="0" start="1,0" stop="1,0"/>
<blockTopPadding length="26" start="0,0" stop="-1,0"/>
<blockBottomPadding length="2" start="0,0" stop="-1,0"/>
<blockFont name="Times-Bold" start="0,0" stop="-1,-1"/>
<blockLeftPadding length="0" start="0,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevel1">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<blockLeftPadding length="0" start="0,0" stop="1,0"/>
</blockTableStyle>
<paraStyle
name="Level7"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Level6"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Level5"
fontName="Helvetica"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Level4"
@ -119,36 +94,35 @@
fontSize="8.0" />
<paraStyle
name="Level3"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Level2"
firstLineIndent="-0.03cm"
fontName="Helvetica-Bold"
fontSize="8.0" />
<paraStyle name="Level1"
<paraStyle name="Level2"
fontSize="8.0"
fontName="Helvetica-Bold"
/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Helvetica"/>
<paraStyle name="Level1"
fontSize="8.0"
fontName="Helvetica-Bold"
/>
</stylesheet>
<images/>
<story>
<para style="P2">
<font color="white"> </font>
</para>
<para style="P9"> Account Balance</para>
<blockTable colWidths="527.00" style="Table4" repeatRows="1">
<tr>
<td>
<para style="P9a">[[ get_fiscalyear(data['form']) or removeParentNode('tr') ]]:</para>
<para style="P9b"><i> [[ get_periods(data['form']) or removeParentNode('tr') ]]</i></para>
</td>
</tr>
</blockTable>
<para style="P2">
<font color="white"> </font>
</para>
<para style="P9b">[[ get_fiscalyear(data['form']) ]]: <i> [[ get_periods(data['form']) ]] </i></para>
<para style="P2">
<font color="white"> </font>
</para>
<blockTable colWidths="52,248.0,73.0,72.0,82.0" style="Table2" repeatRows="1">
<blockTable colWidths="50.0,248.0,73.0,72.0,87.0" style="Table1" repeatRows="1">
<tr>
<td>
<para style="P12a">Code</para>
@ -166,25 +140,45 @@
<para style="P10">Balance</para>
</td>
</tr>
<tr>
<td><para style="P14">[[ repeatIn(lines(data['form']), 'a') ]]<i>[[ a['code'] ]]</i></para></td>
<td>
<para style="P14">[[ setTag('tr','tr',{'style':'TrLevel'+str(a['level']), 'paraStyle':('Level'+str(a['level']))}) ]]<font></font>
[[ a['name'] ]]</para>
</td>
<td>
<para style="P3">[[ formatLang(a['debit'] or '') ]]</para>
</td>
<td>
<para style="P3">[[ formatLang(a['credit'] or '') ]]</para>
</td>
<td>
<para style="P3"><u>[[ (a['leef'] and removeParentNode('para')) or formatLang(a['balance'] or '') ]]</u></para>
<para style="P3">[[ ((not a['leef']) and removeParentNode('para')) or formatLang(a['balance'] or '') ]]</para>
</td>
</tr>
</blockTable>
</story>
<tr>
<td>
<blockTable colWidths="50.0,248.0,73.0,72.0,82.0" style="Table3">
<para style="P2">[[ repeatIn(lines(data['form']), 'a') ]]</para>
<tr>
<td><para style="P14">[[ setTag('para','para',{'style':('Level'+str(a['level']))}) ]]<i>[[ a['code'] or removeParentNode('tr') ]]</i></para></td>
<td>
<para style="P14">[[ setTag('para','para',{'style':('Level'+str(a['level']))}) ]]<font color="white">[[ (a['level']&lt;6 and removeParentNode('font') or '... '*(a['level']-4)) ]]</font>[[ setTag('blockTable','blockTable',{'style':'TrLevel'+str(a['level'])}) ]][[ a['name'] ]]</para>
</td>
<td>
<para style="P3">[[ formatLang(a['debit']) and '%.2f'%a['debit'] or '']]</para>
</td>
<td>
<para style="P3">[[ formatLang(a['credit']) and '%.2f'%a['credit'] or '']]</para>
</td>
<td>
<para style="P3">[[ (a['level']&lt;4) and setTag('para','para',{'style':'P3a'}) ]]<u>[[ (a['leef'] and removeParentNode('para')) or formatLang(a['balance']) and '%.2f'%a['balance'] or '' ]]</u></para>
<para style="P3">[[ ((not a['leef']) and removeParentNode('para')) or formatLang(a['balance']) and formatLang(a['balance']) or '' ]]</para>
</td>
</tr>
<tr>
<td><para style="P14">[[ a['jname'] or removeParentNode('tr') ]]</para></td>
<td>
<para style="P14"><font color="white">[[ '... '*(a['level']-3) ]]</font>[[ a['lname'] ]]</para>
</td>
<td>
<para style="P3">[[ formatLang(a['debit1']) and '%.2f'%a['debit1'] or '']]</para>
</td>
<td>
<para style="P3">[[ formatLang(a['credit1']) and '%.2f'%a['credit1'] or '']]</para>
</td>
<td>
<para style="P3">[[ formatLang(a['balance1']) and '%.2f'%a['balance1'] or '']]</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
</story>
</document>

311
addons/account/report/aged_trial_balance.py Normal file → Executable file
View File

@ -1,9 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@ -30,166 +27,172 @@
import time
import pooler
import rml_parse
from report import report_sxw
class aged_trial_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(aged_trial_report, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'get_lines': self._get_lines,
'get_total': self._get_total,
'get_before': self._get_before,
'get_for_period': self._get_for_period,
'get_company': self._get_company,
'get_currency': self._get_currency,
})
class aged_trial_report(rml_parse.rml_parse):
def __init__(self, cr, uid, name, context):
super(aged_trial_report, self).__init__(cr, uid, name, context)
self.line_query = ''
self.total_account = []
self.localcontext.update({
'time': time,
'get_lines': self._get_lines,
'get_total': self._get_total,
'get_direction': self._get_direction,
'get_for_period': self._get_for_period,
'get_company': self._get_company,
'get_currency': self._get_currency,
})
def _get_lines(self, form):
if (form['result_selection'] == 'customer' ):
self.ACCOUNT_TYPE = "('receivable')"
elif (form['result_selection'] == 'supplier'):
self.ACCOUNT_TYPE = "('payable')"
else:
self.ACCOUNT_TYPE = "('payable','receivable')"
def _add_header(self, node):
return True
res = []
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
self.line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
context={'fiscalyear': form['fiscalyear']})
self.cr.execute("SELECT DISTINCT res_partner.id AS id, " \
"res_partner.name AS name " \
"FROM res_partner,account_move_line AS line, account_account,account_move_reconcile AS recon " \
"WHERE (line.account_id=account_account.id) " \
"AND ((reconcile_id IS NULL) " \
"OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \
"AND (line.partner_id=res_partner.id) " \
"AND (account_account.company_id = %d) " \
"ORDER BY res_partner.name", (form['date1'],form['company_id']))
partners = self.cr.dictfetchall()
## mise a 0 du total
for i in range(7):
self.total_account.append(0)
#
for partner in partners:
values = {}
## If choise selection is in the future
if form['direction_selection'] == 'future':
self.cr.execute("SELECT SUM(debit-credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id=account_account.id) " \
"AND (account_account.type IN " + self.ACCOUNT_TYPE + ") " \
"AND (COALESCE(date_maturity,date) < %s) AND (partner_id=%d) " \
"AND ((reconcile_id IS NULL) " \
"OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(form['date1'], partner['id'],form['date1'], form['company_id']))
before = self.cr.fetchone()
self.total_account[6] = self.total_account[6] + (before and before[0] or 0.0)
def _get_lines(self, form):
self.form=form
res = []
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
context={'fiscalyear': form['fiscalyear'],'state':form['state']})
self.cr.execute("SELECT DISTINCT res_partner.id AS id, " \
"res_partner.name AS name, res_partner.ref AS code " \
"FROM res_partner, account_move_line AS line, account_account " \
"WHERE (line.account_id=account_account.id) " \
"AND (line.reconcile_id IS NULL) " \
"AND (line.partner_id=res_partner.id) " \
"AND " + line_query + " " \
"AND (account_account.company_id = %d) " \
"AND account_account.active " \
"ORDER BY res_partner.name", (form['company_id'],))
partners = self.cr.dictfetchall()
for partner in partners:
values = {}
self.cr.execute("SELECT SUM(debit-credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id=account_account.id) " \
"AND (account_account.type IN (" + form['computation'] +")) " \
"AND (date < %s) AND (partner_id=%d) " \
"AND (reconcile_id IS NULL) " \
"AND " + line_query + " " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(form['0']['start'], partner['id'], form['company_id']))
before = self.cr.fetchone()
values['before'] = before and before[0] or ""
for i in range(5):
self.cr.execute("SELECT SUM(debit-credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id=account_account.id) " \
"AND (account_account.type IN (" + form['computation'] + ")) " \
"AND (date >= %s) AND (date <= %s) " \
"AND (partner_id = %d) " \
"AND (reconcile_id IS NULL) " \
"AND " + line_query + " " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(form[str(i)]['start'], form[str(i)]['stop'],
partner['id'], form['company_id']))
during = self.cr.fetchone()
values[str(i)] = during and during[0] or ""
values['direction'] = before and before[0] or 0.0
else:
self.cr.execute("SELECT SUM(debit-credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id=account_account.id) " \
"AND (account_account.type IN " + self.ACCOUNT_TYPE + ") " \
"AND (COALESCE(date_maturity,date) > %s) AND (partner_id=%d) " \
"AND ((reconcile_id IS NULL) " \
"OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(form['date1'], partner['id'],form['date1'], form['company_id']))
after = self.cr.fetchone()
self.total_account[6] = self.total_account[6] + (after and after[0] or 0.0)
values['direction'] = after and after[0] or ""
#print str(values['direction'])
for i in range(5):
self.cr.execute("SELECT SUM(debit-credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id=account_account.id) " \
"AND (account_account.type IN " + self.ACCOUNT_TYPE + ") " \
"AND (COALESCE(date_maturity,date) BETWEEN %s AND %s) " \
"AND (partner_id = %d) " \
"AND ((reconcile_id IS NULL) " \
"OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(form[str(i)]['start'], form[str(i)]['stop'],partner['id'],form['date1'] ,form['company_id']))
during = self.cr.fetchone()
# Ajout du compteur
self.total_account[(i)] = self.total_account[(i)] + (during and during[0] or 0)
self.cr.execute("SELECT SUM(debit-credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id = account_account.id) " \
"AND (account_account.type IN (" + form['computation'] + ")) " \
"AND (partner_id = %d) " \
"AND (reconcile_id IS NULL) " \
"AND " + line_query + " " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(partner['id'], form['company_id']))
total = self.cr.fetchone()
values['total'] = total and total[0] or 0.0
values['name'] = partner['name']
values['ref'] = partner['code']
t = 0.0
for i in range(5)+['before']:
t+= float(values.get(str(i), 0.0) or 0.0)
if values['total']:
res.append(values)
total = 0.0
totals = {}
for r in res:
total += float(r['total'] or 0.0)
for i in range(5)+['before']:
totals.setdefault(str(i), 0.0)
totals[str(i)] += float(r[str(i)] or 0.0)
if form['sorting_on']=='amount':
res.sort(lambda x,y:cmp(y['total'],x['total']))
return res
#print str(during)
values[str(i)] = during and during[0] or ""
self.cr.execute("SELECT SUM(debit-credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id = account_account.id) " \
"AND (account_account.type IN " + self.ACCOUNT_TYPE + ") " \
"AND (partner_id = %d) " \
"AND ((reconcile_id IS NULL) " \
"OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(partner['id'],form['date1'],form['company_id']))
total = self.cr.fetchone()
values['total'] = total and total[0] or 0.0
## Add for total
self.total_account[(i+1)] = self.total_account[(i+1)] + (total and total[0] or 0.0)
print self.total_account,">>>>>>>>>>>>>Total>>>>>>>>>>>>>>>>"
values['name'] = partner['name']
#t = 0.0
#for i in range(5)+['direction']:
# t+= float(values.get(str(i), 0.0) or 0.0)
#values['total'] = t
if values['total']:
res.append(values)
total = 0.0
totals = {}
for r in res:
total += float(r['total'] or 0.0)
for i in range(5)+['direction']:
totals.setdefault(str(i), 0.0)
totals[str(i)] += float(r[str(i)] or 0.0)
return res
def _get_total(self, fiscalyear, company_id):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
context={'fiscalyear': fiscalyear,'state':self.datas['form']['state']})
self.cr.execute("SELECT SUM(debit - credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id = account_account.id) " \
"AND (account_account.type IN (" + self.form['computation'] + ")) "\
"AND reconcile_id IS NULL " \
"AND partner_id is NOT NULL " \
"AND " + line_query + " " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(company_id,))
total = self.cr.fetchone()
return total and total[0] or 0.0
def _get_total(self,pos):
print self.total_account,"========_get_total========"
period = self.total_account[int(pos)]
return period
def _get_before(self, date, fiscalyear, company_id):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
context={'fiscalyear': fiscalyear,'state':self.datas['form']['state']})
self.cr.execute("SELECT SUM(debit - credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id = account_account.id) " \
"AND (account_account.type IN (" + self.form['computation'] + ")) " \
"AND reconcile_id IS NULL " \
"AND (date < %s) " \
"AND partner_id IS NOT NULL " \
"AND " + line_query + " " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(date, company_id))
before = self.cr.fetchone()
return before and before[0] or 0.0
def _get_direction(self,pos):
period = self.total_account[int(pos)]
return period
def _get_for_period(self, period, fiscalyear, company_id):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
context={'fiscalyear': fiscalyear,'state':self.datas['form']['state']})
self.cr.execute("SELECT SUM(debit - credit) " \
"FROM account_move_line AS line, account_account " \
"WHERE (line.account_id = account_account.id) " \
"AND (account_account.type IN (" + self.form['computation'] + ")) " \
"AND reconcile_id IS NULL " \
"AND (date >= %s) " \
"AND (date <= %s) " \
"AND partner_id IS NOT NULL " \
"AND " + line_query + " " \
"AND (account_account.company_id = %d) " \
"AND account_account.active",
(period['start'], period['stop'], company_id))
period = self.cr.fetchone()
return period and period[0] or 0.0
def _get_for_period(self,pos):
period = self.total_account[int(pos)]
return period
def _get_company(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
def _get_company(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
def _get_currency(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
def _get_currency(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
report_sxw.report_sxw(
'report.account.aged.trial.balance',
'res.partner',
'addons/account/report/aged_trial_balance.rml',
parser=aged_trial_report, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner',
'addons/account/report/aged_trial_balance.rml',parser=aged_trial_report,header=False)

342
addons/account/report/aged_trial_balance.rml Normal file → Executable file
View File

@ -1,8 +1,35 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(842.0,595.0)" title="Test" author="Martin Simon" allowSplitting="20">
<template pageSize="(1120.0,770.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="728" height="481"/>
<frame id="first" x1="20.0" y1="35.0" width="1080" height="650"/>
<pageGraphics>
<!--logo-->
<!--<fill color="darkblue"/>-->
<!--<stroke color="darkblue"/>-->
<!--TITLE COMPANY-->
<!-- <drawString x="4.6cm" y="28.7cm">[[ company.partner_id.name ]]</drawString> -->
<setFont name="Helvetica-Bold" size="9"/>
<!--COL 1-->
<drawString x="1.5cm" y="25.00cm">[[ company.name ]]</drawString>
<drawString x="33.90cm" y="25.00cm">Age Partner Balance - [[ get_currency(data['form']) ]]</drawString>
<!--COL 2-->
<setFont name="Helvetica" size="9"/>
<drawString x="1.5cm" y="0.90cm"> [[ time.strftime('%Y-%m-%d %H:%M', time.localtime()) ]]</drawString>
<drawString x="36.90cm" y="0.90cm">Page <pageNumber/></drawString>
<!--<drawRightString x="19.8cm" y="28cm">[[ company.rml_header1 ]]</drawRightString>-->
<lineMode width="0.7"/>
<lines>1.5cm 24.70cm 38.00cm 24.70cm</lines>
<setFont name="Helvetica" size="8"/>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
@ -13,231 +40,158 @@
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,-1"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,-1"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,-1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,-1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,-1"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="4,0" stop="4,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="4,0" stop="4,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="5,0" stop="5,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="5,0" stop="5,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="6,0" stop="6,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="6,0" stop="6,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="6,-1" stop="6,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="7,0" stop="7,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="7,0" stop="7,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="7,-1" stop="7,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="8,0" stop="8,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="8,0" stop="8,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="8,0" stop="8,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="8,-1" stop="8,-1"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockTableStyle id="Table2">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,1" stop="-1,1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,2" stop="-1,-1"/>
<blockValign value="TOP"/>
<blockAlignment value="LEFT" start="2,1" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="4,0" stop="4,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="4,0" stop="4,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="5,0" stop="5,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="5,0" stop="5,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="6,0" stop="6,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="6,0" stop="6,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="6,-1" stop="6,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="7,0" stop="7,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="7,0" stop="7,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="7,0" stop="7,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="7,-1" stop="7,-1"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P11" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="P1" fontName="Helvetica" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Helvetica" fontSize="8.3" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2_content" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Total" fontName="Helvetica-Bold" fontSize="8.5" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Total_right" fontName="Helvetica-Bold" fontSize="8.5" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="15.0" leading="20" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="8.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Helvetica" fontSize="8.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Helvetica" fontSize="8.3" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="content" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica" fontSize="8.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Helvetica" fontSize="8.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P14" fontName="Helvetica" fontSize="8.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Helvetica"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="8.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="8.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Helvetica"/>
</stylesheet>
<images/>
<story>
<blockTable colWidths="198.0,313.0,217.0" repeatRows="1" style="Table1">
<blockTable colWidths="300.0,100.0,100.0,100.0,100.0,105.0,105.0,125.0" style="Table2" repeatRows="1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
<para style="P2">Partners</para>
</td>
<td>
<para style="P1">Aged Trial balance</para>
<para style="P8">[[ data['form']['direction_selection'] == 'future' and 'Due' or 'Not due' ]] [[data['form']['date1'] ]]</para>
</td>
<td>
<para style="P2">From the beginning</para>
<para style="P2">to [[ formatLang(data['form']['4']['stop'], date=True) ]]</para>
<para style="P8">[[ data['form']['4']['name'] ]]</para>
</td>
<td>
<para style="P8">[[ data['form']['3']['name'] ]]</para>
</td>
<td>
<para style="P8">[[ data['form']['2']['name'] ]]</para>
</td>
<td>
<para style="P8">[[ data['form']['1']['name'] ]]</para>
</td>
<td>
<para style="P8">[[ data['form']['0']['name'] ]]</para>
</td>
<td>
<para style="P8">Total</para>
</td>
</tr>
<tr>
<td>
<para style="P3"> <font color="white">[[ (get_lines(data['form']), 'partner') == False or removeParentNode('para') ]]</font></para>
<para style="P9"><font color="white"> </font></para>
<para style="Total">Account Total</para>
</td>
<td>
<para style="P9"><font color="white"> </font></para>
<para style="Total_right">[[ get_direction('6') ]] </para>
</td>
<td>
<para style="P9"><font color="white"> </font></para>
<para style="Total_right">[[ get_for_period('4') ]]</para>
</td>
<td>
<para style="P9"><font color="white"> </font></para>
<para style="Total_right">[[ get_for_period('3') ]]</para>
</td>
<td>
<para style="P9"><font color="white"> </font></para>
<para style="Total_right">[[ get_for_period('2') ]]</para>
</td>
<td>
<para style="P9"><font color="white"> </font></para>
<para style="Total_right">[[ get_for_period('1') ]]</para>
</td>
<td>
<para style="P9"><font color="white"> </font></para>
<para style="Total_right">[[ get_for_period('0') ]]</para>
</td>
<td>
<para style="P9"><font color="white"> </font></para>
<para style="Total_right">[[ get_total('5') ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ get_company(data['form']) ]]</para>
<para style="P3">[[ repeatIn(get_lines(data['form']), 'partner') ]]</para>
<para style="P2_content">[[ partner['name'] ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
<para style="content">[[ (partner['direction']) or 0.0 ]] </para>
</td>
<td>
<para style="P4">Currency: [[ get_currency(data['form']) ]]</para>
<para style="content">[[ (partner['4']) or 0.0 ]]</para>
</td>
<td>
<para style="content">[[ (partner['3']) or 0.0 ]]</para>
</td>
<td>
<para style="content">[[ (partner['2']) or 0.0 ]]</para>
</td>
<td>
<para style="content">[[ (partner['1']) or 0.0 ]]</para>
</td>
<td>
<para style="content">[[ (partner['0']) or 0.0 ]]</para>
</td>
<td>
<para style="content">[[ (partner['total']) or 0.0 ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P10">Printing date: [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P10">
<font color="white"> </font>
</para>
<blockTable colWidths="109.0,109.0,71.0,71.0,71.0,71.0,71.0,71.0,85.0" style="Tableau1">
<tr>
<td>
<para style="P5">Partners</para>
</td>
<td>
<para style="P5">Code</para>
</td>
<td>
<para style="P6">[[ data['form']['4']['name'] ]]</para>
</td>
<td>
<para style="P6">[[ data['form']['3']['name'] ]]</para>
</td>
<td>
<para style="P6">[[ data['form']['2']['name'] ]]</para>
</td>
<td>
<para style="P6">[[ data['form']['1']['name'] ]]</para>
</td>
<td>
<para style="P6">[[ data['form']['0']['name'] ]]</para>
</td>
<td>
<para style="P6">Before [[ formatLang(data['form']['0']['start'], date=True) ]]</para>
</td>
<td>
<para style="P5">Total</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="109.0,109.0,71.0,71.0,71.0,71.0,71.0,71.0,85.0" style="Tableau2">
<tr>
<td>
<para style="P9">[[ repeatIn(get_lines(data['form']), 'partner') ]]</para>
<para style="P9">[[ partner['name'] ]]</para>
</td>
<td>
<para style="P3">[[ partner['ref'] or ' ' ]]</para>
</td>
<td>
<para style="P8">[[ formatLang((partner['4'] or 0.0)) ]]</para>
</td>
<td>
<para style="P8">[[ formatLang((partner['3'] or 0.0)) ]]</para>
</td>
<td>
<para style="P8">[[ formatLang((partner['2'] or 0.0)) ]]</para>
</td>
<td>
<para style="P8">[[ formatLang((partner['1'] or 0.0)) ]]</para>
</td>
<td>
<para style="P8">[[ formatLang((partner['0'] or 0.0)) ]]</para>
</td>
<td>
<para style="P8">[[ formatLang((partner['before'] or 0.0)) ]]</para>
</td>
<td>
<para style="P8">[[ formatLang((partner['total'] or 0.0)) ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="218.0,71.0,71.0,71.0,71.0,71.0,71.0,85.0" style="Tableau3">
<tr>
<td>
<para style="P5">Account total</para>
</td>
<td>
<para style="P7">[[ formatLang(get_for_period(data['form']['4'], data['form']['fiscalyear'], data['form']['company_id'])) ]]</para>
</td>
<td>
<para style="P7">[[ formatLang(get_for_period(data['form']['3'], data['form']['fiscalyear'], data['form']['company_id'])) ]]</para>
</td>
<td>
<para style="P7">[[ formatLang(get_for_period(data['form']['2'], data['form']['fiscalyear'], data['form']['company_id'])) ]]</para>
</td>
<td>
<para style="P7">[[ formatLang( get_for_period(data['form']['1'], data['form']['fiscalyear'], data['form']['company_id'])) ]]</para>
</td>
<td>
<para style="P7">[[ formatLang(get_for_period(data['form']['0'], data['form']['fiscalyear'], data['form']['company_id'])) ]]</para>
</td>
<td>
<para style="P7">[[ formatLang(get_before(data['form']['0']['start'], data['form']['fiscalyear'], data['form']['company_id'])) ]]</para>
</td>
<td>
<para style="P11">[[ formatLang(get_total( data['form']['fiscalyear'], data['form']['company_id'])) ]]</para>
</td>
</tr>
</blockTable>
<para style="P10">
<para style="P9">
<font color="white"> </font>
</para>
</story>

475
addons/account/report/general_ledger.py Normal file → Executable file
View File

@ -1,9 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2005-2006 CamptoCamp
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@ -29,160 +27,339 @@
##############################################################################
import time
from mx.DateTime import *
from report import report_sxw
import xml
import rml_parse
import pooler
class general_ledger(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(general_ledger, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit_account': self._sum_debit_account,
'sum_credit_account': self._sum_credit_account,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'check_lines': self.check_lines,
class general_ledger(rml_parse.rml_parse):
_name = 'report.account.general.ledger'
def preprocess(self, objects, data, ids):
##
self.borne_date = self.get_min_date(data['form'])
##
new_ids = []
if (data['model'] == 'account.account'):
new_ids = ids
else:
new_ids.append(data['form']['Account_list'])
objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
super(general_ledger, self).preprocess(objects, data, new_ids)
def __init__(self, cr, uid, name, context):
super(general_ledger, self).__init__(cr, uid, name, context)
self.query = ""
self.child_ids = ""
self.tot_currency = 0.0
self.period_sql = ""
self.sold_accounts = {}
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit_account': self._sum_debit_account,
'sum_credit_account': self._sum_credit_account,
'sum_solde_account': self._sum_solde_account,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'sum_solde': self._sum_solde,
'get_children_accounts': self.get_children_accounts,
'sum_currency_amount_account': self._sum_currency_amount_account
})
self.context = context
def _calc_contrepartie(self,cr,uid,ids, context={}):
result = {}
#for id in ids:
# result.setdefault(id, False)
for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context):
# For avoid long text in the field we will limit it to 5 lines
#
#
#
result[account_line.id] = ' '
num_id_move = str(account_line.move_id.id)
num_id_line = str(account_line.id)
account_id = str(account_line.account_id.id)
# search the basic account
# We have the account ID we will search all account move line from now until this time
# We are in the case of we are on the top of the account move Line
cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\
where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id )
res_mv = cr.dictfetchall()
# we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line
if (len(res_mv) >=1):
concat = ''
rup_id = 0
for move_rest in res_mv:
concat = concat + move_rest['code_rest'] + '|'
result[account_line.id] = concat
if rup_id >5:
# we need to stop the computing and to escape but before we will add "..."
result[account_line.id] = concat + '...'
break
rup_id+=1
})
self.context = context
self.tmp_list2=[]
self.final_list=[]
#print str(result)
return result
def get_children_accounts(self, account, form):
self.child_ids = self.pool.get('account.account').search(self.cr, self.uid,
[('parent_id', 'child_of', self.ids)])
res = []
ctx = self.context.copy()
## We will make the test for period or date
## We will now make the test
#
if form.has_key('fiscalyear'):
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
else:
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
##
#
self.query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
for child_id in self.pool.get('account.account').search(self.cr, self.uid,
[('parent_id', 'child_of', [account.id])]):
child_account = self.pool.get('account.account').browse(self.cr, self.uid, child_id)
sold_account = self._sum_solde_account(child_account,form)
self.sold_accounts[child_account.id] = sold_account
if form['display_account'] == 'bal_mouvement':
if child_account.type != 'view' \
and len(self.pool.get('account.move.line').search(self.cr, self.uid,
[('account_id','=',child_account.id)],
context=ctx)) <> 0 :
res.append(child_account)
#print "Type de vue :" + form['display_account']
elif form['display_account'] == 'bal_solde':
if child_account.type != 'view' \
and len(self.pool.get('account.move.line').search(self.cr, self.uid,
[('account_id','=',child_account.id)],
context=ctx)) <> 0 :
if ( sold_account <> 0.0):
res.append(child_account)
else:
if child_account.type != 'view' \
and len(self.pool.get('account.move.line').search(self.cr, self.uid,
[('account_id','=',child_account.id)],
context=ctx)) <> 0 :
res.append(child_account)
##
if form['soldeinit']:
## We will now compute solde initiaux
for move in res:
SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'"
self.cr.execute(SOLDEINIT)
resultat = self.cr.dictfetchall()
if resultat[0] :
if resultat[0]['sum_debit'] == None:
sum_debit = 0
else:
sum_debit = resultat[0]['sum_debit']
if resultat[0]['sum_credit'] == None:
sum_credit = 0
else:
sum_credit = resultat[0]['sum_credit']
move.init_credit = sum_credit
move.init_debit = sum_debit
else:
move.init_credit = 0
move.init_debit = 0
##
return res
def get_min_date(self,form):
## Get max born from account_fiscal year
#
sql = """ select min(fy.date_start) from account_fiscalyear
As fy where fy.state <> 'close'
"""
self.cr.execute(sql)
res = self.cr.dictfetchall()
borne_min = res[0]['min']
#
##
if form.has_key('fiscalyear'):
## This function will return the most aged date
periods = form['periods'][0][2]
if not periods:
sql = """
Select min(p.date_start) from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """
"""
else:
periods_id = ','.join(map(str, periods))
sql = """
Select min(p.date_start) from account_period as p where p.id in ( """ + periods_id + """)
"""
self.cr.execute(sql)
res = self.cr.dictfetchall()
borne_max = res[0]['min']
else:
borne_max = form['date_from']
date_borne = {
'min_date': borne_min,
'max_date': borne_max,
}
return date_borne
def lines(self, account, form):
inv_types = {
'out_invoice': 'CI: ',
'in_invoice': 'SI: ',
'out_refund': 'OR: ',
'in_refund': 'SR: ',
}
### We will now compute solde initaux
if form['sortbydate'] == 'sort_date':
sorttag = 'l.date'
else:
sorttag = 'j.code'
sql = """
SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name , l.debit, l.credit, l.period_id
FROM account_move_line l LEFT JOIN res_currency c on (l.currency_id=c.id) JOIN account_journal j on (l.journal_id=j.id)
AND account_id = %d AND %s
ORDER by %s"""%(account.id,self.query,sorttag)
self.cr.execute(sql)
res = self.cr.dictfetchall()
sum = 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
for l in res:
line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id'])
l['move'] = line.move_id.name
self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id))
tmpres = self.cr.dictfetchall()
if len(tmpres) > 0 :
inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id'])
l['ref'] = inv_types[inv.type] + ': '+str(inv.number)
if line.partner_id :
l['partner'] = line.partner_id.name
else :
l['partner'] = ''
sum += l['debit'] - l ['credit']
c = time.strptime(l['date'],"%Y-%m-%d")
l['date'] = time.strftime("%d-%m-%Y",c)
l['progress'] = sum
l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']]
# Modification du amount Currency
if (l['credit'] > 0):
if l['amount_currency'] != None:
l['amount_currency'] = abs(l['amount_currency']) * -1
#
if l['amount_currency'] != None:
self.tot_currency = self.tot_currency + l['amount_currency']
return res
def _sum_debit_account(self, account, form):
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
## Add solde init to the result
#
sum_debit = self.cr.fetchone()[0] or 0.0
if form['soldeinit']:
sum_debit += account.init_debit
#
##
return sum_debit
def _sum_credit_account(self, account, form):
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id,self.query))
## Add solde init to the result
#
sum_credit = self.cr.fetchone()[0] or 0.0
if form['soldeinit']:
sum_credit += account.init_credit
#
##
return sum_credit
def _sum_solde_account(self, account, form):
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s"%(account.id,self.query))
sum_solde = self.cr.fetchone()[0] or 0.0
if form['soldeinit']:
sum_solde += account.init_debit - account.init_credit
return sum_solde
def recur(self,list1):
tmp_list3 =list1
self.tmp_list2 =list1
# print "self list",self.tmp_list2
for i in range(0,len(list1)):
if list1[i] in self.final_list:
continue
self.final_list.append(list1[i])
# print "finallly",self.final_list
if list1[i].child_id:
def _sum_debit(self, form):
if not self.ids:
return 0.0
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
sum_debit = self.cr.fetchone()[0] or 0.0
return sum_debit
tmp_list4=(hasattr(list1[i],'child_id') and list(list1[i].child_id) or [])
self.tmp_list2 +=tmp_list4
def _sum_credit(self, form):
if not self.ids:
return 0.0
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
## Add solde init to the result
#
sum_credit = self.cr.fetchone()[0] or 0.0
return sum_credit
self.tmp_list2+=self.recur(tmp_list4)
return self.final_list
def repeatIn(self, lst, name,nodes_parent=False):
if name=='o':
list_final=[]
if not lst:
return super(general_ledger,self).repeatIn(lst, name,nodes_parent)
try:
tmp_list = list(lst)
if tmp_list:
tmp_list = self.recur(tmp_list)
else:
return super(general_ledger,self).repeatIn(lst, name,nodes_parent)
lst = list(set([x for x in tmp_list]))
final={}
# for x in lst:
# final[x]=x.id
# final1=sorted(final.items(), lambda x, y: cmp(x[1], y[1]))
#
# for a in final1:
# list_final.append(a[0])
list_final=tmp_list
except:
pass
else:
list_final=lst
ret_data = super(general_ledger,self).repeatIn(list_final, name,nodes_parent)
return ret_data
def check_lines(self, account, form):
result = self.lines(account, form, history=True)
res = [{'code':account.code,'name':account.name}]
if not result:
res = []
return res
def lines(self, account, form, history=False):
self.ids +=[account.id]
if not account.check_history and not history:
return []
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
ctx['state']=form['state']
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
self.cr.execute("SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit "\
"FROM account_move_line l, account_journal j "\
"WHERE l.journal_id = j.id "\
"AND account_id = %d AND "+query+" "\
"ORDER by l.id", (account.id,))
res = self.cr.dictfetchall()
sum = 0.0
for l in res:
sum += l['debit'] - l ['credit']
l['progress'] = sum
return res
def _sum_debit_account(self, account, form):
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
ctx['state']=form['state']
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %d AND "+query, (account.id,))
return self.cr.fetchone()[0] or 0.0
def _sum_credit_account(self, account, form):
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
ctx['state']=form['state']
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %d AND "+query, (account.id,))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self, form):
if not self.ids:
return 0.0
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
ctx['state']=form['state']
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.ids))+") AND "+query)
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, form):
if not self.ids:
return 0.0
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
ctx['state']=form['state']
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.ids))+") AND "+query)
return self.cr.fetchone()[0] or 0.0
def _sum_solde(self, form):
if not self.ids:
return 0.0
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
# print ("SELECT (sum(debit) - sum(credit)) as Test "\
# "FROM account_move_line l "\
# "WHERE l.account_id in ("+','.join(map(str, child_ids))+") AND "+query+period_sql)
sum_solde = self.cr.fetchone()[0] or 0.0
return sum_solde
def _set_get_account_currency_code(self, account_id):
self.cr.execute("SELECT c.code as code "\
"FROM res_currency c,account_account as ac "\
"WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id))
result = self.cr.fetchone()
if result:
self.account_currency = result[0]
else:
self.account_currency = False
def _sum_currency_amount_account(self, account, form):
self._set_get_account_currency_code(account.id)
self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %d "%account.id)
total = self.cr.fetchone()
if self.account_currency:
return_field = str(total[0]) + self.account_currency
return return_field
else:
currency_total = self.tot_currency = 0.0
return currency_total
report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

539
addons/account/report/general_ledger.rml Normal file → Executable file
View File

@ -3,236 +3,331 @@
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
<pageGraphics>
<!--logo-->
<!--<fill color="darkblue"/>-->
<!--<stroke color="darkblue"/>-->
<!--TITLE COMPANY-->
<!-- <drawString x="4.6cm" y="28.7cm">[[ company.partner_id.name ]]</drawString> -->
<setFont name="Helvetica-Bold" size="9"/>
<!--COL 1-->
<drawString x="1.0cm" y="28.1cm">[[ company.name ]]</drawString>
<drawString x="17.7cm" y="28.1cm">General Ledger</drawString>
<!--COL 2-->
<setFont name="Helvetica" size="9"/>
<drawString x="1.0cm" y="1cm"> [[ time.strftime("%d-%m-%Y %H:%M", time.localtime()) ]]</drawString>
<drawString x="19.0cm" y="1cm">Page <pageNumber/></drawString>
<!--<drawRightString x="19.8cm" y="28cm">[[ company.rml_header1 ]]</drawRightString>-->
<lineMode width="0.7"/>
<lines>1cm 27.7cm 20cm 27.7cm</lines>
<setFont name="Helvetica" size="8"/>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<stylesheet>
<blockTableStyle id="tbl_header">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<blockValign value="TOP"/>
<blockAlignment value="RIGHT" start="2,1" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="tbl_content">
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,-1"/>
<blockValign value="TOP"/>
<blockAlignment value="RIGHT" start="2,1" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="0,0" stop="0,0"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table8">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="14.0" leading="17"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" rightIndent="0.0" leftIndent="0.0" fontName="Times-Bold" fontSize="10.0" leading="13"/>
<paraStyle name="P16" rightIndent="0.0" leftIndent="0.0" fontName="Times-Roman" fontSize="8.0" leading="10"/>
<paraStyle name="P17" rightIndent="0.0" leftIndent="0.0" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P18" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P20" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P21" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P22" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P23" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="P1" fontName="Helvetica" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Helvetica" fontSize="8.3" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="date" fontName="Helvetica" fontSize="8.3" leading="10" spaceBefore="0.0" spaceAfter="6.0" alignment="CENTER"/>
<paraStyle name="P2_content" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="8.3" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3_centre" fontName="Helvetica" fontSize="8.3" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3_content" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Helvetica" fontSize="8.3" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4_content" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Helvetica" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Helvetica" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9b" fontName="Helvetica-Bold" fontSize="8.5" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica" alignment="CENTER"/>
<paraStyle name="P11" fontName="Helvetica" fontSize="11.0" leading="14"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="14.0" leading="17"/>
<paraStyle name="P13" fontName="Helvetica-Bold" fontSize="10.0" leading="8" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Helvetica-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Helvetica" alignment="LEFT" fontSize="12.0" spaceAfter="0.0"/>
<paraStyle name="Standard" fontName="Helvetica-Bold" fontSize="8.5"/>
<paraStyle name="Account" fontName="Helvetica"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Helvetica"/>
</stylesheet>
<story>
<blockTable colWidths="126.0,217.0,138.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">General ledger</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P6">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P7">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P10">Printing date: [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P11">
<font color="white"> </font>
</para>
<blockTable colWidths="48.0,34.0,50.0,145.0,69.0,72.0,64.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P13">Date</para>
</td>
<td>
<para style="P13">Code</para>
</td>
<td>
<para style="P13">Ref.</para>
</td>
<td>
<para style="P13">Entry label</para>
</td>
<td>
<para style="P13">Debit</para>
</td>
<td>
<para style="P13">Credit</para>
</td>
<td>
<para style="P13">Progressive balance</para>
</td>
</tr>
</blockTable>
<para style="Text body">
<font color="white"> </font>
</para>
<blockTable colWidths="482.0" style="Table7">
<tr>
<td>
<para style="P17">[[ repeatIn(objects, 'o') ]] </para>
<para style="P17">[[ repeatIn(check_lines(o,data['form']), 'acc') ]]</para>
<para style="P17">
<font face="Times-Bold" size="10.0">[[ acc and acc['code'] or removeParentNode('para') ]] [[ acc and acc['name'] or removeParentNode('para') ]]</font>
</para>
<blockTable colWidths="44.0,38.0,50.0,144.0,69.0,72.0,64.0" style="Table8">
<tr>
<td>
<para style="P14"><font face="Times-Roman">[[ repeatIn(lines(o, data['form']), 'line') ]]</font>[[ line['date'] ]]</para>
</td>
<td>
<para style="P2">[[ line['code'] ]]</para>
</td>
<td>
<para style="P2">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P3">[[ line['name'] ]]</para>
</td>
<td>
<para style="P4">[[ formatLang(line['debit']) ]]</para>
</td>
<td>
<para style="P4">[[ formatLang(line['credit']) ]]</para>
</td>
<td>
<para style="P4">[[ formatLang(line['progress']) ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P14">
<font color="white"> </font>
</para>
<para style="P14">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P8">TOTAL (<font face="Times-Roman" size="10.0">[[ acc and acc['code'] or removeParentNode('para') ]]):</font></para>
</td>
<td>
<para style="P9">[[ formatLang(sum_debit_account(o, data['form'])) ]]</para>
</td>
<td>
<para style="P9">[[ formatLang(sum_credit_account(o, data['form'])) ]]</para>
</td>
<td>
<para style="P4">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<blockTable colWidths="277.0,69.0,72.0,63.0" style="Table4">
<tr>
<td>
<para style="P8">TOTAL:</para>
</td>
<td>
<para style="P9">[[ formatLang(sum_debit(data['form'])) ]]</para>
</td>
<td>
<para style="P9">[[ formatLang(sum_credit(data['form'])) ]]</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P10">
<font color="white"> </font>
</para>
</story>
</document>
<blockTable colWidths="54.0,155.0,70.0,20.0,80.0,59.0,52.0,54.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td>
<para style="P3_centre">Date</para>
</td>
<td>
<para style="P3">Partner</para>
</td>
<td>
<para style="P3">Ref</para>
</td>
<td>
<para style="P3">Mvt</para>
</td>
<td>
<para style="P3">Entry Label</para>
</td>
<td>
<para style="P4">Debit</para>
</td>
<td>
<para style="P4">Crebit</para>
</td>
<td>
<para style="P9">Balance</para>
</td>
</tr>
<tr>
<para>[[ repeatIn(objects, 'a') ]]</para>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<td>
<blockTable colWidths="48.0,155.0,70.0,20.0,80.0,59.0,52.0,54.0" style="tbl_content">
<tr>
<td>
<blockTable colWidths="273.00,100.0,52.5,52.5,52.5" style="Table5">
<tr>
<td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
<td><para style="Standard"></para></td>
<td alignment="right">
<para style="P9b"><u>[[ sum_debit_account(o, data['form']) or '0.0' ]]</u></para>
</td>
<td alignment="right">
<para style="P9b"><u>[[sum_credit_account(o, data['form']) or '0.0' ]]</u></para>
</td>
<td>
<para style="P9b"><u>[[sum_solde_account(o, data['form']) or '0.0' ]]</u></para>
</td>
</tr>
</blockTable>
</td>
</tr>
<tr>
[[ data['form']['soldeinit'] == True or removeParentNode('tr') ]]
<td>
<para style="P16"></para>
</td>
<td>
<para style="P3">Balance Initial</para>
</td>
<td>
<para style="P3"></para>
</td>
<td>
<para style="P3"></para>
</td>
<td>
<para style="P3"></para>
</td>
<td>
<para style="P4">[[ o.init_debit or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ o.init_credit or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ (o.init_debit - o.init_credit) or '0.0' ]]</para>
</td>
</tr>
<tr>[[ repeatIn(lines(o, data['form']), 'line') ]]
<td>
<para style="P3">[[ line['date'] ]]</para>
</td>
<td>
<para style="P3">[[ line['partner'] ]]</para>
</td>
<td>
<para style="P3">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P3">[[ line['move'] ]]</para>
</td>
<td>
<para style="P3">[[ line['name'] ]]</para>
</td>
<td>
<para style="P4">[[ line['debit'] and line['debit'] or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ line['credit'] and line['credit'] or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ line['progress'] and line['progress'] or '0.0' ]]</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<blockTable colWidths="59.0,125.0,66.0,20.0,100.0,50.0,50.0,50.0,40.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<tr>
<td>
<para style="P3_centre">Date</para>
</td>
<td>
<para style="P3">Partner</para>
</td>
<td>
<para style="P3">Ref</para>
</td>
<td>
<para style="P3">Mvt</para>
</td>
<td>
<para style="P3">Entry Label</para>
</td>
<td>
<para style="P4">Debit</para>
</td>
<td>
<para style="P4">Crebit</para>
</td>
<td>
<para style="P4">Balance</para>
</td>
<td>
<para style="P4">Currency</para>
</td>
</tr>
<tr>
<para>[[ repeatIn(objects, 'a') ]]</para>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<td>
<blockTable colWidths="54.0,125.0,66.0,20.0,100.0,50.0,50.0,50.0,40.0" style="tbl_content" >
<tr>
<td>
<blockTable colWidths="259.00,100.0,50.0,50.0,49.0" style="Table5">
<tr>
<td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
<td><para style="Standard"></para></td>
<td alignment="right">
<para style="P9b"><u>[[ sum_debit_account(o, data['form']) or '0.0' ]]</u></para>
</td>
<td alignment="right">
<para style="P9b"><u>[[sum_credit_account(o, data['form']) or '0.0' ]]</u></para>
</td>
<td>
<para style="P9b"><u>[[sum_solde_account(o, data['form']) or '0.0' ]]</u></para>
</td>
</tr>
</blockTable>
</td>
</tr>
<tr>[[ data['form']['soldeinit'] == True or removeParentNode('tr') ]]
<td>
<para style="P16"></para>
</td>
<td>
<para style="P3">Balance Initial</para>
</td>
<td>
<para style="P3"></para>
</td>
<td>
<para style="P3"></para>
</td>
<td>
<para style="P3"></para>
</td>
<td>
<para style="P4">[[ o.init_debit or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ o.init_credit or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ (o.init_debit - o.init_credit) or '0.0' ]]</para>
</td>
<td>
<para style="P4"> </para>
</td>
</tr>
<tr>[[ repeatIn(lines(o, data['form']), 'line') ]]
<td>
<para style="P3">[[ line['date'] ]]</para>
</td>
<td>
<para style="P3">[[ line['partner'] ]]</para>
</td>
<td>
<para style="P3">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P3">[[ line['move'] ]]</para>
</td>
<td>
<para style="P3">[[ line['name'] ]]</para>
</td>
<td>
<para style="P4">[[ line['debit'] and line['debit'] or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ line['credit'] and line['credit'] or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ line['progress'] and line['progress'] or '0.0' ]]</para>
</td>
<td>
<para style="P4">[[ line['amount_currency'] or '0.0' ]] [[ line['currency_code'] ]]</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
</story>
</document>

View File

@ -0,0 +1,365 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005-2006 CamptoCamp
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from mx.DateTime import *
from report import report_sxw
import xml
import rml_parse
import pooler
class general_ledger_landscape(rml_parse.rml_parse):
_name = 'report.account.general.ledger_landscape'
def preprocess(self, objects, data, ids):
##
self.borne_date = self.get_min_date(data['form'])
##
new_ids = []
if (data['model'] == 'account.account'):
new_ids = ids
else:
new_ids.append(data['form']['Account_list'])
objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
super(general_ledger_landscape, self).preprocess(objects, data, new_ids)
def __init__(self, cr, uid, name, context):
super(general_ledger_landscape, self).__init__(cr, uid, name, context)
self.query = ""
self.child_ids = ""
self.tot_currency = 0.0
self.period_sql = ""
self.sold_accounts = {}
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit_account': self._sum_debit_account,
'sum_credit_account': self._sum_credit_account,
'sum_solde_account': self._sum_solde_account,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'sum_solde': self._sum_solde,
'get_children_accounts': self.get_children_accounts,
'sum_currency_amount_account': self._sum_currency_amount_account
})
self.context = context
def _calc_contrepartie(self,cr,uid,ids, context={}):
result = {}
#for id in ids:
# result.setdefault(id, False)
for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context):
# For avoid long text in the field we will limit it to 5 lines
#
#
#
result[account_line.id] = ' '
num_id_move = str(account_line.move_id.id)
num_id_line = str(account_line.id)
account_id = str(account_line.account_id.id)
# search the basic account
# We have the account ID we will search all account move line from now until this time
# We are in the case of we are on the top of the account move Line
cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\
where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id )
res_mv = cr.dictfetchall()
# we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line
if (len(res_mv) >=1):
concat = ''
rup_id = 0
for move_rest in res_mv:
concat = concat + move_rest['code_rest'] + '|'
result[account_line.id] = concat
if rup_id >5:
# we need to stop the computing and to escape but before we will add "..."
result[account_line.id] = concat + '...'
break
rup_id+=1
#print str(result)
return result
def get_min_date(self,form):
## Get max born from account_fiscal year
#
sql = """ select min(fy.date_start) from account_fiscalyear
As fy where fy.state <> 'close'
"""
self.cr.execute(sql)
res = self.cr.dictfetchall()
borne_min = res[0]['min']
#
##
if form.has_key('fiscalyear'):
## This function will return the most aged date
periods = form['periods'][0][2]
if not periods:
sql = """
Select min(p.date_start) from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """
"""
else:
periods_id = ','.join(map(str, periods))
sql = """
Select min(p.date_start) from account_period as p where p.id in ( """ + periods_id + """)
"""
self.cr.execute(sql)
res = self.cr.dictfetchall()
borne_max = res[0]['min']
else:
borne_max = form['date_from']
date_borne = {
'min_date': borne_min,
'max_date': borne_max,
}
return date_borne
def get_children_accounts(self, account, form):
self.child_ids = self.pool.get('account.account').search(self.cr, self.uid,
[('parent_id', 'child_of', self.ids)])
#
res = []
ctx = self.context.copy()
## We will make the test for period or date
## We will now make the test
#
if form.has_key('fiscalyear'):
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
else:
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
##
#
self.query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
for child_id in self.pool.get('account.account').search(self.cr, self.uid,[('parent_id', 'child_of', [account.id])]):
child_account = self.pool.get('account.account').browse(self.cr, self.uid, child_id)
sold_account = self._sum_solde_account(child_account,form)
self.sold_accounts[child_account.id] = sold_account
if form['display_account'] == 'bal_mouvement':
if child_account.type != 'view' \
and len(self.pool.get('account.move.line').search(self.cr, self.uid,
[('account_id','=',child_account.id)],
context=ctx)) <> 0 :
res.append(child_account)
#print "Type de vue :" + form['display_account']
elif form['display_account'] == 'bal_solde':
if child_account.type != 'view' \
and len(self.pool.get('account.move.line').search(self.cr, self.uid,
[('account_id','=',child_account.id)],
context=ctx)) <> 0 :
if ( sold_account <> 0.0):
res.append(child_account)
else:
if child_account.type != 'view' \
and len(self.pool.get('account.move.line').search(self.cr, self.uid,
[('account_id','=',child_account.id)],
context=ctx)) <> 0 :
res.append(child_account)
##
if form['soldeinit']:
## We will now compute solde initiaux
for move in res:
SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'"
self.cr.execute(SOLDEINIT)
resultat = self.cr.dictfetchall()
if resultat[0] :
if resultat[0]['sum_debit'] == None:
sum_debit = 0
else:
sum_debit = resultat[0]['sum_debit']
if resultat[0]['sum_credit'] == None:
sum_credit = 0
else:
sum_credit = resultat[0]['sum_credit']
move.init_credit = sum_credit
move.init_debit = sum_debit
else:
move.init_credit = 0
move.init_debit = 0
##
return res
def lines(self, account, form):
inv_types = {
'out_invoice': 'CI: ',
'in_invoice': 'SI: ',
'out_refund': 'OR: ',
'in_refund': 'SR: ',
}
if form['sortbydate'] == 'sort_date':
sorttag = 'l.date'
else:
sorttag = 'j.code'
sql = """
SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name, l.debit, l.credit, l.period_id
FROM account_move_line l LEFT JOIN res_currency c on (l.currency_id=c.id) JOIN account_journal j on (l.journal_id=j.id)
AND account_id = %d AND %s
ORDER by %s"""%(account.id,self.query,sorttag)
self.cr.execute(sql)
res = self.cr.dictfetchall()
sum = 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
for l in res:
line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id'])
l['move'] = line.move_id.name
self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id))
tmpres = self.cr.dictfetchall()
if len(tmpres) > 0 :
inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id'])
l['ref'] = inv_types[inv.type] + ': '+str(inv.number)
if line.partner_id :
l['partner'] = line.partner_id.name
else :
l['partner'] = ''
sum += l['debit'] - l ['credit']
c = time.strptime(l['date'],"%Y-%m-%d")
l['date'] = time.strftime("%d-%m-%Y",c)
l['progress'] = sum
l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']]
# Modification du amount Currency
if (l['credit'] > 0):
if l['amount_currency'] != None:
l['amount_currency'] = abs(l['amount_currency']) * -1
#
if l['amount_currency'] != None:
self.tot_currency = self.tot_currency + l['amount_currency']
return res
def _sum_debit_account(self, account, form):
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
## Add solde init to the result
#
sum_debit = self.cr.fetchone()[0] or 0.0
if form['soldeinit']:
sum_debit += account.init_debit
#
##
return sum_debit
def _sum_credit_account(self, account, form):
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id,self.query))
## Add solde init to the result
#
sum_credit = self.cr.fetchone()[0] or 0.0
if form['soldeinit']:
sum_credit += account.init_credit
#
##
return sum_credit
def _sum_solde_account(self, account, form):
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s"%(account.id,self.query))
sum_solde = self.cr.fetchone()[0] or 0.0
if form['soldeinit']:
sum_solde += account.init_debit - account.init_credit
return sum_solde
def _sum_debit(self, form):
if not self.ids:
return 0.0
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
sum_debit = self.cr.fetchone()[0] or 0.0
return sum_debit
def _sum_credit(self, form):
if not self.ids:
return 0.0
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
## Add solde init to the result
#
sum_credit = self.cr.fetchone()[0] or 0.0
return sum_credit
def _sum_solde(self, form):
if not self.ids:
return 0.0
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
# print ("SELECT (sum(debit) - sum(credit)) as Test "\
# "FROM account_move_line l "\
# "WHERE l.account_id in ("+','.join(map(str, child_ids))+") AND "+query+period_sql)
sum_solde = self.cr.fetchone()[0] or 0.0
return sum_solde
def _set_get_account_currency_code(self, account_id):
print"====account_id=====",account_id
self.cr.execute("SELECT c.code as code "\
"FROM res_currency c,account_account as ac "\
"WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id))
result = self.cr.fetchone()
print"====result====",result
if result:
self.account_currency = result[0]
else:
self.account_currency = False
def _sum_currency_amount_account(self, account, form):
self._set_get_account_currency_code(account.id)
self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %d "%account.id)
total = self.cr.fetchone()
if self.account_currency:
return_field = str(total[0]) + self.account_currency
return return_field
else:
currency_total = self.tot_currency = 0.0
return currency_total
report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger_landscape, header=False)

View File

@ -0,0 +1,426 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(1120.0,770.0)" title="Test" author="Martin Simon" allowSplitting="20" >
<pageTemplate id="first">
<frame id="first" x1="22.0" y1="35.0" width="1080" height="680"/>
<pageGraphics>
<!--logo-->
<!--<fill color="darkblue"/>-->
<!--<stroke color="darkblue"/>-->
<!--TITLE COMPANY-->
<!-- <drawString x="4.6cm" y="28.7cm">[[ company.partner_id.name ]]</drawString> -->
<setFont name="Helvetica-Bold" size="9"/>
<!--COL 1-->
<drawString x="1.3cm" y="25.50cm">[[ company.name ]]</drawString>
<drawString x="36.00cm" y="25.50cm">General Ledger</drawString>
<!--COL 2-->
<setFont name="Helvetica" size="9"/>
<drawString x="1.3cm" y="0.90cm"> [[ time.strftime("%d-%m-%Y %H:%M", time.localtime()) ]]</drawString>
<drawString x="37.20cm" y="0.90cm">Page <pageNumber/></drawString>
<!--<drawRightString x="19.8cm" y="28cm">[[ company.rml_header1 ]]</drawRightString>-->
<lineMode width="0.7"/>
<lines>1.3cm 24.9cm 38.3cm 24.9cm</lines>
<setFont name="Helvetica" size="8"/>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="tbl_header">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<blockValign value="TOP"/>
<blockAlignment value="RIGHT" start="2,1" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="tbl_content">
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,-1"/>
<blockValign value="TOP"/>
<blockAlignment value="RIGHT" start="2,1" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="0,0" stop="0,0"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Helvetica" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Helvetica" fontSize="8.3" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="date" fontName="Helvetica" fontSize="8.3" leading="10" spaceBefore="0.0" spaceAfter="6.0" alignment="CENTER"/>
<paraStyle name="P2_content" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="8.3" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3_content" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Helvetica" fontSize="8.3" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4_content" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Helvetica" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Helvetica" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9b" fontName="Helvetica-Bold" fontSize="8.5" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica" alignment="CENTER"/>
<paraStyle name="P11" fontName="Helvetica" fontSize="11.0" leading="14"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="14.0" leading="17"/>
<paraStyle name="P13" fontName="Helvetica-Bold" fontSize="10.0" leading="8" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Helvetica-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Helvetica" alignment="LEFT" fontSize="12.0" spaceAfter="0.0"/>
<paraStyle name="Standard" fontName="Helvetica-Bold" fontSize="8.5"/>
<paraStyle name="Account" fontName="Helvetica"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Helvetica"/>
</stylesheet>
<story>
<blockTable colWidths="55.0,35.0,180.0, 90.0,30.0,345.0,50.0,69.0,72.0,64.0,58.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<tr>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="date">Date</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="date">JNRL</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="P2">Partner</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="P2">Ref</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="P2">Mvt</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="P3">Entry Label</para>
</td>
<td>
<para style="P12"><font color="white"> </font> </para>
<para style="P3">Counterpart</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="P4">Debit</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="P4">Credit</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="P4">Balance</para>
</td>
<td>
<para style="P12"><font color="white"> </font></para>
<para style="P4">Currency</para>
</td>
</tr>
<tr>
<para>[[ repeatIn(objects, 'a') ]]</para>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<td>
<blockTable colWidths="50.0,35.0,180.0, 90.0,30.0,345.0,50.0,69.0,72.0,64.0,58.0" style="tbl_content" >
<tr>
<td>
<blockTable colWidths="400.0,374.0,69.0,72.0,64.0,59.00" style="Table5">
<tr>
<td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
<td><para style="Standard"></para></td>
<td alignment="right">
<para style="P9b"><u>[[ sum_debit_account(o, data['form']) or '0.0' ]]</u></para>
</td>
<td alignment="right">
<para style="P9b"><u>[[ sum_credit_account(o, data['form']) or '0.0' ]]</u></para>
</td>
<td>
<para style="P9b"><u>[[ sum_solde_account(o, data['form']) or '0.0' ]]</u></para>
</td>
<td>
<para style="P9b"><u> [[ sum_currency_amount_account(o, data['form']) or '0.0' ]]</u></para>
</td>
</tr>
</blockTable>
</td>
</tr>
<tr>[[ data['form']['soldeinit'] == True or removeParentNode('tr') ]]
<td>
<para style="P3_content">Balance Initial</para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P4_content">[[ o.init_debit or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ o.init_credit or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ (o.init_debit - o.init_credit) or '0.0' ]]</para>
</td>
<td>
<para style="P4_content"> </para>
</td>
</tr>
<tr>
[[ repeatIn(lines(o, data['form']), 'line') ]]
<td>
<para style="P2_content">[[ line['date'] ]]</para>
</td>
<td>
<para style="P2_content">[[ line['code'] ]]</para>
</td>
<td>
<para style="P2_content">[[ line['partner'] ]]</para>
</td>
<td>
<para style="P2_content">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P2_content">[[ line['move'] ]]</para>
</td>
<td>
<para style="P3_content">[[ line['name'] ]]</para>
</td>
<td>
<para style="P3_content">[[ strip_name(line['line_corresp'],55) ]]</para>
</td>
<td>
<para style="P4_content">[[ line['debit'] and line['debit'] or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ line['credit'] and line['credit'] or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ line['progress'] and line['progress'] or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ line['amount_currency'] or '0.0' ]] [[ line['currency_code'] ]]</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<blockTable colWidths="55.0,35.0,196.0,90.0,30.0,390.0,50.0,69.0,72.0,64.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="date">Date</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="date">JNRL</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P2">Partner</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P2">Ref</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P2">Mvt</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P3">Entry Label</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P3">Counterpart</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P4">Debit</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P4">Credit</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P4">Balance</para>
</td>
</tr>
<tr>
<td>
<para>[[ repeatIn(objects, 'a') ]]</para>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<blockTable colWidths="50.0,35.0,196.0, 90.0,30.0,390.0,50.0,69.0,72.0,64.0" style="tbl_content" >[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td>
<blockTable colWidths="400.0,435.0,69.0,72.0,64.0" style="Table5">
<tr>
<td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
<td><para style="Standard"></para></td>
<td alignment="right">
<para style="P9b"><u>[[ sum_debit_account(o, data['form']) or '0.0']]</u></para>
</td>
<td alignment="right">
<para style="P9b"><u>[[sum_credit_account(o, data['form']) or '0.0']]</u></para>
</td>
<td>
<para style="P9b"><u>[[sum_solde_account(o, data['form']) or '0.0' ]]</u></para>
</td>
</tr>
</blockTable>
</td>
</tr>
<tr>[[ data['form']['soldeinit'] == True or removeParentNode('tr') ]]
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content">Solde Initial</para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P3_content"></para>
</td>
<td>
<para style="P4_content">[[ o.init_debit or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ o.init_credit or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ o.init_debit - o.init_credit or '0.0' ]]</para>
</td>
</tr>
<tr>[[ repeatIn(lines(o, data['form']), 'line') ]]
<td>
<para style="P2_content">[[ line['date'] ]]</para>
</td>
<td>
<para style="P2_content">[[ line['code'] ]]</para>
</td>
<td>
<para style="P2_content">[[ line['partner'] ]]</para>
</td>
<td>
<para style="P2_content">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P2_content">[[ line['move'] ]]</para>
</td>
<td>
<para style="P3_content">[[ line['name'] ]]</para>
</td>
<td>
<para style="P3_content">[[ strip_name(line['line_corresp'],55) ]]</para>
</td>
<td>
<para style="P4_content">[[ line['debit'] and line['debit'] or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ line['credit'] and line['credit'] or '0.0' ]]</para>
</td>
<td>
<para style="P4_content">[[ line['progress'] and line['progress'] or '0.0' ]]</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<para style="P12">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -127,7 +127,7 @@
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Table_Tax_Content_Table">
<blockTableStyle id="Table_Main_Table">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="0,0" stop="0,-1"/>
@ -137,8 +137,6 @@
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="4,0" stop="4,0"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
@ -148,24 +146,16 @@
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="5,2" stop="5,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="5,2" stop="5,2"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="6,2" stop="6,-1"/>
<lineStyle kind="LINEAFTER" colorName="#ffffff" start="6,2" stop="6,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="6,2" stop="6,2"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="6,-1" stop="6,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="0,4" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,4" stop="0,4"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="1,4" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#ffffff" start="1,4" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="1,4" stop="1,4"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="2,-1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_Tax_Header">
<blockAlignment value="LEFT"/>
@ -181,32 +171,22 @@
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_Format_Border">
<blockTableStyle id="Table_Table_Border_White">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#ffffff" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="2,-1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_Border_Color_Formating">
<blockTableStyle id="Table_Final_Border">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#ffffff" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#ffffff" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="1,-1" stop="1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_Coment_Payment_Term">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/>
</blockTableStyle>
<blockTableStyle id="Table_Payment_Terms">
<blockAlignment value="LEFT"/>
@ -296,7 +276,7 @@
<para style="terp_tblheader_General_Centre">Invoice Date</para>
</td>
<td>
<para style="terp_tblheader_General_Centre">Partner Code</para>
<para style="terp_tblheader_General_Centre">Partner Ref.</para>
</td>
</tr>
</blockTable>
@ -316,7 +296,7 @@
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="211.0,62.0,63.0,63.0,51.0,74.0" style="Table_Header_Invoice_Line">
<blockTable colWidths="211.0,62.0,63.0,63.0,36.0,89.0" style="Table_Header_Invoice_Line">
<tr>
<td>
<para style="terp_tblheader_Details">Description</para>
@ -334,13 +314,13 @@
<para style="terp_tblheader_Details_Right">Disc. (%)</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Price</para>
<para style="terp_tblheader_Details_Centre">Price</para>
</td>
</tr>
</blockTable>
<section>
<para style="terp_default_8">[[ repeatIn(o.invoice_line,'l') ]]</para>
<blockTable colWidths="211.0,62.0,36.0,27.0,63.0,51.0,46.0,26.0" style="Table_Invoice_Line_Content">
<blockTable colWidths="211.0,62.0,36.0,27.0,63.0,36.0,62.0,26.0" style="Table_Invoice_Line_Content">
<tr>
<td>
<para style="terp_default_9">[[ l.name ]]</para>
@ -369,41 +349,40 @@
</tr>
<tr>
<td>
<para style="terp_default_Note">[[ repeatIn((l.note and l.note.splitlines()) or [], 'note') ]]</para>
<para style="terp_default_Note">[[ note or removeParentNode('para') ]]</para>
<para style="terp_default_Note">[[ format(l.note or removeParentNode('tr')) ]]</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_Note">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_Note">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_Note">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_Note">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_Note">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_Note">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_Note">
<font color="white"> </font>
</para>
</td>
@ -477,37 +456,29 @@
</td>
</tr>
</blockTable>
<blockTable colWidths="196.0,334.0" style="Table_Tax_Content_Table">
<blockTable colWidths="530.0" style="Table_Main_Table">
<tr>
<td>
<para style="terp_default_8">[[ format(o.amount_tax or removeParentNode('blockTable')) ]]</para>
<blockTable colWidths="65.0,62.0,68.0" style="Table_Tax_Header">
<blockTable colWidths="54.0,58.0,67.0" style="Table_Tax_Header">
<tr>
<td>
<para style="terp_tblheader_Details_Centre">Tax</para>
<para style="terp_tblheader_General_Centre">Tax</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Base</para>
<para style="terp_tblheader_General_Right">Base</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Amount</para>
<para style="terp_tblheader_General_Right">Amount</para>
</td>
</tr>
</blockTable>
<para style="terp_default_2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="terp_default_8">[[ repeatIn(o.tax_line,'t') ]]</para>
<blockTable colWidths="64.0,63.0,69.0" style="Table_Tax_Content">
<blockTable colWidths="53.0,60.0,65.0" style="Table_Tax_Content">
<tr>
<td>
<para style="terp_default_Centre_8">[[ t.name ]]</para>
@ -521,16 +492,23 @@
</tr>
</blockTable>
</td>
</tr>
<tr>
<td>
<blockTable colWidths="167.0,167.0" style="Table_Format_Border">
<blockTable colWidths="53.0,60.0,65.0" style="Table_Table_Border_White">
<tr>
<td>
<para style="terp_default_8">
<para style="terp_default_2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_2">
<font color="white"> </font>
</para>
</td>
@ -539,15 +517,15 @@
</td>
</tr>
</blockTable>
<blockTable colWidths="196.0,334.0" style="Table_Border_Color_Formating">
<blockTable colWidths="180.0,350.0" style="Table_Final_Border">
<tr>
<td>
<para style="terp_default_8">
<para style="terp_default_2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">
<para style="terp_default_2">
<font color="white"> </font>
</para>
</td>
@ -573,8 +551,5 @@
<para style="terp_default_2">
<font color="white"> </font>
</para>
<para style="terp_default_2">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -42,6 +42,7 @@ class Overdue(report_sxw.rml_parse):
'time' : time,
'adr_get' : self._adr_get,
'getLines' : self._lines_get,
'tel_get' : self._tel_get,
})
def _adr_get(self, partner, type):
@ -51,6 +52,20 @@ class Overdue(report_sxw.rml_parse):
adr_id = addresses and addresses[type] or False
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
def _tel_get(self,partner):
if not partner:
return False
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], ['invoice'])
adr_id = addresses and addresses['invoice'] or False
if adr_id:
adr=res_partner_address.read(self.cr, self.uid, [adr_id])[0]
return adr['phone']
else:
return partner.address and partner.address[0].phone or False
return False
def _lines_get(self, partner):
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
movelines = moveline_obj.search(self.cr, self.uid,

View File

@ -110,7 +110,7 @@
<para style="P16">
<font color="white"> </font>
</para>
<para style="P16">Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at +32 81 81 37 00.</para>
<para style="P16">Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at [[ tel_get(company.partner_id) ]].</para>
<para style="P16">
<font color="white"> </font>
</para>

View File

@ -0,0 +1,157 @@
from report import report_sxw
import xml.dom.minidom
import os, time
import osv
import re
import tools
import pooler
import re
import sys
class rml_parse(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(rml_parse, self).__init__(cr, uid, name, context=None)
self.localcontext.update({
'comma_me': self.comma_me,
'format_date': self._get_and_change_date_format_for_swiss,
'strip_name' : self._strip_name,
'explode_name' : self._explode_name,
})
def comma_me(self,amount):
#print "#" + str(amount) + "#"
if not amount:
amount = 0.0
if type(amount) is float :
amount = str('%.2f'%amount)
else :
amount = str(amount)
if (amount == '0'):
return ' '
orig = amount
new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
if orig == new:
return new
else:
return self.comma_me(new)
def _ellipsis(self, string, maxlen=100, ellipsis = '...'):
ellipsis = ellipsis or ''
try:
return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen]
except Exception, e:
return False
def _strip_name(self, name, maxlen=50):
return self._ellipsis(name, maxlen, '...')
def _get_and_change_date_format_for_swiss (self,date_to_format):
date_formatted=''
if date_to_format:
date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
return date_formatted
def _explode_name(self,chaine,length):
# We will test if the size is less then account
full_string = ''
if (len(str(chaine)) <= length):
return chaine
#
else:
chaine = unicode(chaine,'utf8').encode('iso-8859-1')
rup = 0
for carac in chaine:
rup = rup + 1
if rup == length:
full_string = full_string + '\n'
full_string = full_string + carac
rup = 0
else:
full_string = full_string + carac
return full_string
def makeAscii(self,str):
try:
Stringer = str.encode("utf-8")
except UnicodeDecodeError:
try:
Stringer = str.encode("utf-16")
except UnicodeDecodeError:
print "UTF_16 Error"
Stringer = str
else:
return Stringer
else:
return Stringer
return Stringer
def explode_this(self,chaine,length):
#chaine = self.repair_string(chaine)
chaine = rstrip(chaine)
ast = list(chaine)
i = length
while i <= len(ast):
ast.insert(i,'\n')
i = i + length
chaine = str("".join(ast))
return chaine
def repair_string(self,chaine):
ast = list(chaine)
UnicodeAst = []
_previouslyfound = False
i = 0
#print str(ast)
while i < len(ast):
elem = ast[i]
try:
Stringer = elem.encode("utf-8")
except UnicodeDecodeError:
to_reencode = elem + ast[i+1]
print str(to_reencode)
Good_char = to_reencode.decode('utf-8')
UnicodeAst.append(Good_char)
i += i +2
else:
UnicodeAst.append(elem)
i += i + 1
return "".join(UnicodeAst)
def ReencodeAscii(self,str):
print sys.stdin.encoding
try:
Stringer = str.decode("ascii")
except UnicodeEncodeError:
print "REENCODING ERROR"
return str.encode("ascii")
except UnicodeDecodeError:
print "DECODING ERROR"
return str.encode("ascii")
else:
print Stringer
return Stringer
# def _add_header(self, node):
# rml_head = tools.file_open('specific_param/report/header/corporate_rml_header_ch.rml').read()
# head_dom = xml.dom.minidom.parseString(rml_head)
# #for frame in head_dom.getElementsByTagName('frame'):
# # frame.parentNode.removeChild(frame)
# node2 = head_dom.documentElement
# for tag in node2.childNodes:
# if tag.nodeType==tag.ELEMENT_NODE:
# found = self._find_node(node, tag.localName)
# # rml_frames = found.getElementsByTagName('frame')
# if found:
# if tag.hasAttribute('position') and (tag.getAttribute('position')=='inside'):
# found.appendChild(tag)
# else:
# found.parentNode.replaceChild(tag, found)
# # for frame in rml_frames:
# # tag.appendChild(frame)
# return True

273
addons/account/report/tax_report.py Normal file → Executable file
View File

@ -1,9 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@ -30,92 +27,206 @@
import time
import pooler
import rml_parse
import copy
from report import report_sxw
import pdb
import re
class tax_report(report_sxw.rml_parse):
class tax_report(rml_parse.rml_parse):
_name = 'report.account.vat.declaration'
def __init__(self, cr, uid, name, context):
super(tax_report, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'get_period': self._get_period,
'get_codes': self._get_codes,
'get_general': self._get_general,
'get_company': self._get_company,
'get_currency': self._get_currency,
'get_lines' : self._get_lines,
})
def __init__(self, cr, uid, name, context):
super(tax_report, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'get_period': self._get_period,
'get_codes': self._get_codes,
'get_general': self._get_general,
'get_company': self._get_company,
'get_currency': self._get_currency,
})
def comma_me(self,amount):
if type(amount) is float :
amount = str('%.2f'%amount)
else :
amount = str(amount)
if (amount == '0'):
return ' '
orig = amount
new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
if orig == new:
return new
else:
return self.comma_me(new)
def _get_lines(self, based_on,period_list,company_id=False, parent=False, level=0):
res = self._get_codes(based_on,parent,level,period_list)
res = self._add_codes(based_on,res,period_list)
i = 0
top_result = []
while i < len(res):
res_dict = { 'code' : res[i][1].code,
'name' : res[i][1].name,
'debit' : 0,
'credit' : 0,
'tax_amount' : res[i][1].sum_period,
'type' : 1,
'level' : res[i][0],
'pos' : 0
}
top_result.append(res_dict)
res_general = self._get_general(res[i][1].id,period_list,company_id,based_on)
ind_general = 0
while ind_general < len(res_general) :
res_general[ind_general]['type'] = 2
res_general[ind_general]['pos'] = 0
res_general[ind_general]['level'] = res_dict['level'] + ' '
top_result.append(res_general[ind_general])
ind_general+=1
i+=1
#array_result = self.sort_result(top_result)
return top_result
#return array_result
def _add_header(self, node):
return True
def _get_period(self, period_id):
return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
def _get_period(self, period_id):
return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
def _get_general(self, tax_code_id,period_list ,company_id, based_on):
res=[]
period_sql_list = ','.join(map(str, period_list[0][2]))
if based_on == 'payments':
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
SUM(line.debit) AS debit, \
SUM(line.credit) AS credit, \
COUNT(*) AS count, \
account.id AS account_id, \
account.name AS name, \
account.code AS code \
FROM account_move_line AS line, \
account_account AS account, \
account_move AS move \
LEFT JOIN account_invoice invoice ON \
(invoice.move_id = move.id) \
WHERE line.state<>%s \
AND line.tax_code_id = %d \
AND line.account_id = account.id \
AND account.company_id = %d \
AND move.id = line.move_id \
AND ((invoice.state = %s) \
OR (invoice.id IS NULL)) \
GROUP BY account.id,account.name,account.code', ('draft',tax_code_id,
company_id, 'paid'))
def _get_general(self, tax_code_id, period_id, company_id, based_on):
res=[]
if based_on == 'payments':
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
SUM(line.debit) AS debit, \
SUM(line.credit) AS credit, \
COUNT(*) AS count, \
account.id AS account_id \
FROM account_move_line AS line, \
account_account AS account, \
account_move AS move \
LEFT JOIN account_invoice invoice ON \
(invoice.move_id = move.id) \
WHERE line.state<>%s \
AND line.period_id = %d \
AND line.tax_code_id = %d \
AND line.account_id = account.id \
AND account.company_id = %d \
AND move.id = line.move_id \
AND ((invoice.state = %s) \
OR (invoice.id IS NULL)) \
GROUP BY account.id', ('draft', period_id, tax_code_id,
company_id, 'paid'))
else :
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
SUM(line.debit) AS debit, \
SUM(line.credit) AS credit, \
COUNT(*) AS count, \
account.id AS account_id \
FROM account_move_line AS line, \
account_account AS account \
WHERE line.state <> %s \
AND line.period_id = %d \
AND line.tax_code_id = %d \
AND line.account_id = account.id \
AND account.company_id = %d \
AND account.active \
GROUP BY account.id', ('draft', period_id, tax_code_id,
company_id))
res = self.cr.dictfetchall()
i = 0
while i<len(res):
res[i]['account'] = self.pool.get('account.account').browse(self.cr, self.uid, res[i]['account_id'])
i+=1
return res
else :
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
SUM(line.debit) AS debit, \
SUM(line.credit) AS credit, \
COUNT(*) AS count, \
account.id AS account_id, \
account.name AS name, \
account.code AS code \
FROM account_move_line AS line, \
account_account AS account \
WHERE line.state <> %s \
AND line.tax_code_id = %d \
AND line.account_id = account.id \
AND account.company_id = %d \
AND account.active \
GROUP BY account.id,account.name,account.code', ('draft',tax_code_id,
company_id))
res = self.cr.dictfetchall()
#AND line.period_id IN ('+ period_sql_list +') \
i = 0
while i<len(res):
res[i]['account'] = self.pool.get('account.account').browse(self.cr, self.uid, res[i]['account_id'])
i+=1
return res
def _get_codes(self, period_id, based_on, parent=False, level=0):
tc = self.pool.get('account.tax.code')
ids = tc.search(self.cr, self.uid, [('parent_id','=',parent)])
res = []
for code in tc.browse(self.cr, self.uid, ids, {'period_id': period_id,
'based_on': based_on}):
res.append((' - '*level*2, code))
res += self._get_codes(period_id, based_on, code.id, level+1)
return res
def _get_codes(self, based_on, parent=False, level=0,period_list=[]):
tc = self.pool.get('account.tax.code')
ids = tc.search(self.cr, self.uid, [('parent_id','=',parent)])
res = []
for code in tc.browse(self.cr, self.uid, ids, {'based_on': based_on}):
res.append(('a'*2*level,code))
print"=====res=====",res
res += self._get_codes(based_on, code.id, level+1)
return res
def _add_codes(self,based_on, account_list=[],period_list=[]):
res = []
for account in account_list:
tc = self.pool.get('account.tax.code')
ids = tc.search(self.cr, self.uid, [('id','=',account[1].id)])
sum_tax_add = 0
for period_ind in period_list[0][2]:
for code in tc.browse(self.cr, self.uid, ids, {'period_id':period_ind,'based_on': based_on}):
sum_tax_add = sum_tax_add + code.sum_period
code.sum_period = sum_tax_add
res.append((account[0],code))
return res
def _get_company(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
def _get_company(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
def _get_currency(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
def _get_currency(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
def sort_result(self,accounts):
# On boucle sur notre rapport
result_accounts = []
ind=0
old_level=0
while ind<len(accounts):
#
account_elem = accounts[ind]
#
#
# we will now check if the level is lower than the previous level, in this case we will make a subtotal
if (account_elem['level'] < old_level):
bcl_current_level = old_level
bcl_rup_ind = ind - 1
while (bcl_current_level >= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0 ):
tot_elem = copy.copy(accounts[bcl_rup_ind])
res_tot = { 'code' : accounts[bcl_rup_ind]['code'],
'name' : '',
'debit' : 0,
'credit' : 0,
'tax_amount' : accounts[bcl_rup_ind]['tax_amount'],
'type' : accounts[bcl_rup_ind]['type'],
'level' : 0,
'pos' : 0
}
if res_tot['type'] == 1:
# on change le type pour afficher le total
res_tot['type'] = 2
result_accounts.append(res_tot)
bcl_current_level = accounts[bcl_rup_ind]['level']
bcl_rup_ind -= 1
old_level = account_elem['level']
result_accounts.append(account_elem)
ind+=1
return result_accounts
report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code',
'addons/account/report/tax_report.rml', parser=tax_report, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
'addons/account/report/tax_report.rml', parser=tax_report, header=False)

288
addons/account/report/tax_report.rml Normal file → Executable file
View File

@ -2,7 +2,34 @@
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="42.0" y1="42.0" width="511" height="758"/>
<frame id="first" x1="42.0" y1="62.0" width="511" height="728"/>
<pageGraphics>
<!--logo-->
<!--<fill color="darkblue"/>-->
<!--<stroke color="darkblue"/>-->
<!--TITLE COMPANY-->
<!-- <drawString x="4.6cm" y="28.7cm">[[ company.partner_id.name ]]</drawString> -->
<setFont name="Helvetica-Bold" size="9"/>
<!--COL 1-->
<drawString x="1.0cm" y="28.1cm">[[ company.name ]]</drawString>
<drawRightString x="20cm" y="28.1cm">Tax Report</drawRightString>
<setFont name="Helvetica" size="9"/>
<drawString x="1.0cm" y="1cm"> [[ time.strftime("%Y-%m-%d %H:%M", time.localtime()) ]]</drawString>
<drawString x="19.0cm" y="1cm">Page <pageNumber/></drawString>
<!--<drawRightString x="19.8cm" y="28cm">[[ company.rml_header1 ]]</drawRightString>-->
<lineMode width="0.7"/>
<lines>1cm 27.7cm 20cm 27.7cm</lines>
<setFont name="Helvetica" size="8"/>
</pageGraphics>
</pageTemplate>
</template>
<stylesheet>
@ -20,10 +47,21 @@
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockTableStyle id="Table2">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="0,1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,1" stop="1,1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,1" stop="2,1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,1" stop="3,1"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockAlignment value="RIGHT" start="2,1" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
@ -36,131 +74,145 @@
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="11.0" leading="14" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P8" fontName="Times-Roman" alignment="LEFT"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="6.0" leading="8"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="7.0" leading="9" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="P1" fontName="Helvetica-Bold" alignment="CENTER" fontSize="14.5" leftIndent="-5.0"/>
<paraStyle name="P2" fontName="Helvetica" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Helvetica" fontSize="8.0" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Helvetica" fontSize="8.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9a" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9c" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9b" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica" alignment="CENTER"/>
<paraStyle name="P11" fontName="Helvetica" fontSize="8.0" leading="14"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12a" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Helvetica-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" rightIndent="17.0" leftIndent="-0.0" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Helvetica-Bold" fontSize="8.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Helvetica"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="1.0" leading="1" spaceBefore="0" spaceAfter="0"/>
<paraStyle name="Index" fontName="Helvetica"/>
<blockTableStyle id="TrLevelaaaaaaa">
<blockLeftPadding length="80" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevelaaaaaa">
<blockLeftPadding length="60" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevelaaaaa">
<blockLeftPadding length="40" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevelaaaa">
<blockLeftPadding length="20" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevelaaa">
<blockLeftPadding length="0" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="TrLevelaa">
<blockLeftPadding length="0" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="1,0" stop="-1,-1"/>
<blockTopPadding length="13" start="0,0" stop="-1,0"/>
<blockBottomPadding length="2" start="0,0" stop="-1,0"/>
<blockFont name="Times-Bold" start="0,0" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="TrLevel">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<blockLeftPadding length="0" start="1,0" stop="1,0"/>
<blockTopPadding length="26" start="0,0" stop="-1,0"/>
<blockBottomPadding length="2" start="0,0" stop="-1,0"/>
<blockFont name="Times-Bold" start="0,0" stop="-1,-1"/>
</blockTableStyle>
<paraStyle
name="Levelaaaaaaa"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Levelaaaaaa"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Levelaaaaa"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Levelaaaa"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Levelaaa"
fontName="Helvetica"
fontSize="8.0" />
<paraStyle
name="Levelaa"
firstLineIndent="-0.03cm"
fontName="Helvetica-Bold"
fontSize="8.0" />
<paraStyle name="Level"
fontSize="8.0"
fontName="Helvetica-Bold"
/>
</stylesheet>
<story>
<blockTable colWidths="139.0,220.0,152.0" repeatRows="1" style="Table1">
<para style="P2">
<font color="white"> </font>
</para>
<blockTable colWidths="347.0,64.0,59.0,71.0" style="Table2" repeatRows="1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
<para style="P12">Code</para>
</td>
<td>
<para style="P1">Tax Report</para>
<para style="P12a">Débit</para>
</td>
<td>
<para style="P2">Period: [[ get_period(data['form']['period_id']) ]]</para>
<para style="P12a">Crédit</para>
</td>
<td>
<para style="P12a">Solde</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ get_company(data['form']) ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4">Currency: [[ get_currency(data['form']) ]]</para>
</td>
<para style="Caption">[[ repeatIn(get_lines(data['form']['based_on'],data['form']['periods'],data['form']['company_id']), 'o') ]]</para>
<td>
<para style="P5"><font color="white">[[ o['level'] ]]</font>
[[o['type']==1 and ( setTag('para','para',{'fontName':'Helvetica'}))]]<font></font>
[[ setTag('tr','tr',{'style':'TrLevel'+str(o['level']), 'paraStyle':('Level'+str(o['level']))}) ]]<font></font>
[[ o['code'] ]] [[ o['name'] ]]<font></font>
</para>
</td>
<td>
<para style="P6">[[o['type']==2 and (o['debit']) ]]</para>
</td>
<td>
<para style="P6"> [[o['type']==2 and (o['credit']) ]] </para>
</td>
<td>
<para style="P6">[[ o['tax_amount'] ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P7"><font face="Times-Roman">Printing date: </font>[[ time.strftime('%Y-%m-%d') ]] <font face="Times-Roman">at</font> [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P8">
<font color="white"> </font>
</para>
<blockTable colWidths="148.0,168.0,64.0,59.0,71.0" repeatRows="1" style="Tableau3">
<tr>
<td>
<para style="Table Heading">Tax Code / Account</para>
</td>
<td>
<para style="Table Heading">General Account</para>
</td>
<td>
<para style="Table Heading">Debit</para>
</td>
<td>
<para style="Table Heading">Credit</para>
</td>
<td>
<para style="Table Heading">Tax Amount</para>
</td>
</tr>
</blockTable>
<para style="P9">
<font color="white"> </font>
</para>
<section>
<para style="P9">[[ repeatIn(get_codes(data['form']['period_id'], data['form']['based_on']), 'o') ]]</para>
<blockTable colWidths="316.0,64.0,59.0,71.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="P5">[[ o[0] ]] [[ o[1].code ]] - [[ o[1].name ]]</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P6">[[ o[1].sum_period and ('%.2f' % o[1].sum_period) or '' ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="44.0,273.0,62.0,60.0,72.0" repeatRows="1" style="Tableau2">
<tr>
<td>
<para style="P11">[[repeatIn(get_general(o[1], data['form']['period_id'], data['form']['company_id'], data['form']['based_on']), 'g') ]]</para>
</td>
<td>
<para style="P12">[[ g['account'].code ]] - [[ g['account'].name ]]</para>
</td>
<td>
<para style="P13">[[ g['debit'] and '%.2f' % g['debit'] or '' ]]</para>
</td>
<td>
<para style="P13">[[ g['credit'] and '%.2f' % g['credit'] or '' ]]</para>
</td>
<td>
<para style="P13">[[ g['tax_amount'] and '%.2f' % g['tax_amount'] or '' ]]</para>
</td>
</tr>
</blockTable>
<para style="P10">
<font color="white"> </font>
</para>
</section>
</blockTable>
</story>
</document>

496
addons/account/report/third_party_ledger.py Normal file → Executable file
View File

@ -1,9 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@ -30,153 +27,364 @@
import pooler
import time
import re
import rml_parse
import datetime
from report import report_sxw
class third_party_ledger(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(third_party_ledger, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit_partner': self._sum_debit_partner,
'sum_credit_partner': self._sum_credit_partner,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'get_company': self._get_company,
'get_currency': self._get_currency,
})
class third_party_ledger(rml_parse.rml_parse):
def __init__(self, cr, uid, name, context):
self.date_lst = []
self.date_lst_string = ''
super(third_party_ledger, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit_partner': self._sum_debit_partner,
'sum_credit_partner': self._sum_credit_partner,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'get_company': self._get_company,
'get_currency': self._get_currency,
'comma_me' : self.comma_me,
})
def date_range(self,start,end):
start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d")))
end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d")))
full_str_date = []
#
r = (end+datetime.timedelta(days=1)-start).days
#
date_array = [start+datetime.timedelta(days=i) for i in range(r)]
for date in date_array:
full_str_date.append(str(date))
return full_str_date
#
def transform_period_into_date_array(self,data):
## Get All Period Date
if not data['form']['periods'][0][2] :
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
else:
periods_id = data['form']['periods'][0][2]
date_array = []
for period_id in periods_id:
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
self.date_lst = date_array
self.date_lst.sort()
def transform_date_into_date_array(self,data):
return_array = self.date_range(data['form']['date1'],data['form']['date2'])
self.date_lst = return_array
self.date_lst.sort()
def preprocess(self, objects, data, ids):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
context={'fiscalyear': data['form']['fiscalyear'],'state':data['form']['state']})
self.cr.execute(
"SELECT DISTINCT line.partner_id " \
"FROM account_move_line AS line, account_account AS account " \
"WHERE line.partner_id IS NOT NULL " \
"AND line.date >= %s " \
"AND line.date <= %s " \
"AND " + line_query + " " \
"AND line.account_id = account.id " \
"AND account.company_id = %d " \
"AND account.active",
(data['form']['date1'], data['form']['date2'],
data['form']['company_id']))
new_ids = [id for (id,) in self.cr.fetchall()]
self.cr.execute(
"SELECT a.id " \
"FROM account_account a " \
"LEFT JOIN account_account_type t " \
"ON (a.type=t.code) " \
"WHERE t.partner_account=TRUE " \
"AND a.company_id = %d " \
"AND a.active", (data['form']['company_id'],))
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
self.partner_ids = ','.join(map(str, new_ids))
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
super(third_party_ledger, self).preprocess(objects, data, new_ids)
def comma_me(self,amount):
if type(amount) is float :
amount = str('%.2f'%amount)
else :
amount = str(amount)
if (amount == '0'):
return ' '
orig = amount
new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
if orig == new:
return new
else:
return self.comma_me(new)
def special_map(self):
string_map = ''
for date_string in self.date_lst:
string_map = date_string + ','
return string_map
def preprocess(self, objects, data, ids):
PARTNER_REQUEST = ''
if (data['model'] == 'res.partner'):
print"data['model']",data['model']
## Si on imprime depuis les partenaires
if ids:
PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")"
# Transformation des date
#
#
if data['form'].has_key('fiscalyear'):
self.transform_period_into_date_array(data)
else:
self.transform_date_into_date_array(data)
##
self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\''
#
#new_ids = [id for (id,) in self.cr.fetchall()]
if data['form']['result_selection'] == 'supplier':
ACCOUNT_TYPE = "AND a.type='payable' "
elif data['form']['result_selection'] == 'customer':
ACCOUNT_TYPE = "AND a.type='receivable' "
elif data['form']['result_selection'] == 'all':
ACCOUNT_TYPE = "AND (a.type='receivable' OR a.type='payable') "
def lines(self, partner):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l',
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
self.cr.execute(
"SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit " \
"FROM account_move_line l " \
"LEFT JOIN account_journal j " \
"ON (l.journal_id = j.id) " \
"WHERE l.partner_id = %d " \
"AND l.account_id IN (" + self.account_ids + ") " \
"AND l.date >= %s " \
"AND l.date <= %s "
"AND " + line_query + " " \
"ORDER BY l.id",
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
sum += r['debit'] - r['credit']
r['progress'] = sum
return res
self.cr.execute(
"SELECT a.id " \
"FROM account_account a " \
"LEFT JOIN account_account_type t " \
"ON (a.type=t.code) " \
"WHERE t.partner_account=TRUE " \
"AND a.company_id = %d " \
" " + ACCOUNT_TYPE + " " \
"AND a.active", (data['form']['company_id'],))
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
partner_to_use = []
if data['form']['soldeinit'] :
self.cr.execute(
"SELECT DISTINCT line.partner_id " \
"FROM account_move_line AS line, account_account AS account " \
"WHERE line.partner_id IS NOT NULL " \
"AND line.account_id = account.id " \
"AND line.date < %s " \
"AND line.reconcile_id IS NULL " \
# "AND line.account_id IN (" + self.account_ids + ") " \
" " + PARTNER_REQUEST + " " \
"AND account.company_id = %d " \
"AND account.active " ,
(self.date_lst[len(self.date_lst)-1],data['form']['company_id']))
else:
self.cr.execute(
"SELECT DISTINCT line.partner_id " \
"FROM account_move_line AS line, account_account AS account " \
"WHERE line.partner_id IS NOT NULL " \
"AND line.account_id = account.id " \
"AND line.date IN (" + self.date_lst_string + ") " \
# "AND line.account_id IN (" + self.account_ids + ") " \
" " + PARTNER_REQUEST + " " \
"AND account.company_id = %d " \
"AND account.active " ,
(data['form']['company_id']))
res = self.cr.dictfetchall()
for res_line in res:
partner_to_use.append(res_line['partner_id'])
res = self.cr.dictfetchall()
for res_line in res:
partner_to_use.append(res_line['partner_id'])
new_ids = partner_to_use
self.partner_ids = ','.join(map(str, new_ids))
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
super(third_party_ledger, self).preprocess(objects, data, new_ids)
def _sum_debit_partner(self, partner):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid,
obj='account_move_line',
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id = %d " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date >= %s " \
"AND date <= %s " \
"AND " + line_query,
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit_partner(self, partner):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid,
obj='account_move_line',
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id=%d " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date >= %s " \
"AND date <= %s " \
"AND " + line_query,
(partner.id, self.datas["form"]["date1"], self.datas["form"]["date2"]))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid,
obj='account_move_line',
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date >= %s " \
"AND date <= %s " \
"AND " + line_query,
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
line_query = account_move_line_obj._query_get(self.cr, self.uid,
obj='account_move_line',
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date >= %s " \
"AND date <= %s " \
"AND " + line_query,
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def lines(self, partner,data):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
full_account = []
if data['form']['reconcil'] :
RECONCILE_TAG = " "
else:
RECONCILE_TAG = "AND l.reconcile_id IS NULL"
if data['form']['soldeinit'] :
self.cr.execute(
"SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \
"FROM account_move_line l " \
"LEFT JOIN account_journal j " \
"ON (l.journal_id = j.id) " \
"WHERE l.partner_id = %d " \
# "AND l.account_id IN (" + self.account_ids + ") " \
"AND l.date < %s " \
"AND l.reconcile_id IS NULL "
"ORDER BY l.id",
(partner.id, self.date_lst[0]))
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
sum = r['debit'] - r['credit']
r['progress'] = sum
full_account.append(r)
self.cr.execute(
"SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \
"FROM account_move_line l " \
"LEFT JOIN account_journal j " \
"ON (l.journal_id = j.id) " \
"WHERE l.partner_id = %d " \
# "AND l.account_id IN (" + self.account_ids + ") " \
"AND l.date IN (" + self.date_lst_string + ") " \
" " + RECONCILE_TAG + " "\
"ORDER BY l.id",
(partner.id,))
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
sum = r['debit'] - r['credit']
r['progress'] = sum
full_account.append(r)
return full_account
def _get_company(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
def _sum_debit_partner(self, partner,data):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
if data['form']['reconcil'] :
RECONCILE_TAG = " "
else:
RECONCILE_TAG = "AND reconcile_id IS NULL"
if data['form']['soldeinit'] :
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id = %d " \
# "AND account_id IN (" + self.account_ids + ") " \
"AND reconcile_id IS NULL " \
"AND date < %s " ,
(partner.id, self.date_lst[0],))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
else:
result_tmp = result_tmp + 0.0
def _get_currency(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id = %d " \
# "AND account_id IN (" + self.account_ids + ") " \
" " + RECONCILE_TAG + " " \
"AND date IN (" + self.date_lst_string + ") " ,
(partner.id,))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
else:
result_tmp = result_tmp + 0.0
return result_tmp
def _sum_credit_partner(self, partner,data):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
if data['form']['reconcil'] :
RECONCILE_TAG = " "
else:
RECONCILE_TAG = "AND reconcile_id IS NULL"
if data['form']['soldeinit'] :
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id=%d " \
# "AND account_id IN (" + self.account_ids + ") " \
"AND reconcile_id IS NULL " \
"AND date < %s " ,
(partner.id,self.date_lst[0],))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
else:
result_tmp = result_tmp + 0.0
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id=%d " \
# "AND account_id IN (" + self.account_ids + ") " \
" " + RECONCILE_TAG + " " \
"AND date IN (" + self.date_lst_string + ") " ,
(partner.id,))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
else:
result_tmp = result_tmp + 0.0
return result_tmp
def _sum_debit(self,data):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
if data['form']['reconcil'] :
RECONCILE_TAG = " "
else:
RECONCILE_TAG = "AND reconcile_id IS NULL"
if data['form']['soldeinit'] :
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
# "AND account_id IN (" + self.account_ids + ") " \
"AND reconcile_id IS NULL " \
"AND date < %s " ,
(self.date_lst[0],))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
else:
result_tmp = result_tmp + 0.0
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
# "AND account_id IN (" + self.account_ids + ") " \
" " + RECONCILE_TAG + " " \
"AND date IN (" + self.date_lst_string + ") "
)
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
else:
result_tmp = result_tmp + 0.0
return result_tmp
def _sum_credit(self,data):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
if data['form']['reconcil'] :
RECONCILE_TAG = " "
else:
RECONCILE_TAG = "AND reconcile_id IS NULL"
if data['form']['soldeinit'] :
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
# "AND account_id IN (" + self.account_ids + ") " \
"AND reconcile_id IS NULL " \
"AND date < %s " ,
(self.date_lst[0],))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
else:
result_tmp = result_tmp + 0.0
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
# "AND account_id IN (" + self.account_ids + ") " \
" " + RECONCILE_TAG + " " \
"AND date IN (" + self.date_lst_string + ") "
)
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
else:
result_tmp = result_tmp + 0.0
return result_tmp
def _get_company(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
def _get_currency(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner',
'addons/account/report/third_party_ledger.rml',parser=third_party_ledger,
header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
'addons/account/report/third_party_ledger.rml',parser=third_party_ledger,
header=False)

406
addons/account/report/third_party_ledger.rml Normal file → Executable file
View File

@ -2,8 +2,41 @@
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
<header>
<pageGraphics>
<!--logo-->
<!--<fill color="darkblue"/>-->
<!--<stroke color="darkblue"/>-->
<!--TITLE COMPANY-->
<!-- <drawString x="4.6cm" y="28.7cm">[[ company.partner_id.name ]]</drawString> -->
<setFont name="Helvetica-Bold" size="9"/>
<!--COL 1-->
<drawString x="1.0cm" y="28.1cm">[[ company.name ]]</drawString>
<drawRightString x="20cm" y="28.1cm">Third Party Ledger [[ data['form']['result_selection'] == 'customer' and '/ Débiteur' ]] [[ data['form']['result_selection'] == 'supplier' and '/ Créancier' ]] [[ data['form']['result_selection'] == 'all' and '/ Créancier et Débiteur' ]]</drawRightString>
<!-- Header -->
<setFont name="Helvetica" size="9"/>
<drawString x="1.0cm" y="1cm"> [[ time.strftime("%Y-%m-%d %H:%M", time.localtime()) ]]</drawString>
<drawString x="19.0cm" y="1cm">Page <pageNumber/></drawString>
<!--<drawRightString x="19.8cm" y="28cm">[[ company.rml_header1 ]]</drawRightString>-->
<lineMode width="0.7"/>
<lines>1cm 27.7cm 20cm 27.7cm</lines>
<setFont name="Helvetica" size="8"/>
</pageGraphics>
</header>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
@ -13,227 +46,194 @@
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,-1"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,-1"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,-1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,-1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,-1"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockTableStyle id="tbl_heading">
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="4,0" stop="4,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="4,0" stop="4,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="5,0" stop="5,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="5,0" stop="5,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="6,0" stop="6,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="6,0" stop="6,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="6,0" stop="6,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="6,-1" stop="6,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="LEFT"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockLeftPadding length="0" start="1,0" stop="1,0"/>
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockValign value="LEFT"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockValign value="LEFT"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="0,0" stop="0,-1"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<blockValign value="LEFT"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,-1"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="P1" fontName="Helvetica" fontSize="2.0" leading="1" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P2" fontName="Helvetica-Bold" fontSize="14.5" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="7.5" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Helvetica" fontSize="7.5" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="7.5" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Helvetica" fontSize="8.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Helvetica-Bold" fontSize="8.5" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Balance" fontName="Helvetica-Bold" fontSize="8.5" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Helvetica-Bold" alignment="CENTER" fontSize="14.5" leftIndent="-5.0"/>
<paraStyle name="P9a" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9c" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9b" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="total" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica" alignment="CENTER"/>
<paraStyle name="P11" fontName="Helvetica" fontSize="8.0" leading="14"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="8.0" leading="9" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="date" fontName="Helvetica" fontSize="8.0" leading="9" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Helvetica-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" rightIndent="17.0" leftIndent="-0.0" fontName="Helvetica" fontSize="7.5" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Helvetica" fontSize="8.0" leading="12" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Helvetica"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Helvetica"/>
</stylesheet>
<images/>
<story>
<blockTable colWidths="145.0,187.0,149.0" repeatRows="1" style="Table1">
<tr>
<para style="P2"><font color="white"></font></para>
<para>
<font color="white">[[ data['form']['page_split'] == True or removeParentNode('para') ]] </font>
<font color="white">[[ repeatIn(objects, 'p') ]] [[ setLang(p.partner_id.lang) ]]</font>
</para>
<blockTable colWidths="50.0,37.0,120.0,135.0,69.0,72.0,63.0" repeatRows="1" style="tbl_heading">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Third party ledger</para>
</td>
<td>
<para style="P2"><font face="Times-Roman">From</font> [[ formatLang(data['form']['date1'], date=True) ]]</para>
<para style="P2"><font face="Times-Roman">to</font> [[ formatLang(data['form']['date2'], date=True) ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ get_company(data['form']) ]]</para>
</td>
<td>
<para style="P6">Complete</para>
</td>
<td>
<para style="P7"><font face="Times-Roman">Currency:</font> [[ get_currency(data['form']) ]]</para>
</td>
</tr>
<para style="date">Date</para>
</td>
<td>
<para style="P12">JNRL</para>
</td>
<td>
<para style="P12">Ref.</para>
</td>
<td>
<para style="P12">Entry label</para>
</td>
<td>
<para style="P16">Debit</para>
</td>
<td>
<para style="P16">Credit</para>
</td>
<td>
<para style="P16">Balance</para>
</td>
</tr>
<tr>
</tr>
<tr>
<td>
<blockTable colWidths="337.0,69.0,72.0,63.0" style="Table3">
<tr>
<td>
<para style="Balance">Balance brought forward</para>
</td>
<td>
<para style="P8"><u>[[ (sum_debit(data)) ]]</u></para>
</td>
<td>
<para style="P8"><u>[[ (sum_credit(data)) ]]</u></para>
</td>
<td>
<para style="P8"><u>[[ (sum_debit(data) - sum_credit(data)) ]]</u></para>
</td>
</tr>
</blockTable>
</td>
</tr>
<tr>
<td>
<para style="P1">
<font color="white">[[ data['form']['page_split'] == False or removeParentNode('para') ]] </font>
<font color="white">[[ repeatIn(objects, 'p') ]]</font>
</para>
<blockTable colWidths="200.0,137.0,69.0,72.0,63.0" style="Table5">
<tr>
<td>
<para style="total">[[ p.ref ]] - [[ p.name ]]</para>
</td>
<td>
<para style="total"></para>
</td>
<td>
<para style="P9b"><u>[[ (sum_debit_partner(p,data)) ]]</u></para>
</td>
<td>
<para style="P9b"><u>[[ (sum_credit_partner(p,data)) ]]</u></para>
</td>
<td>
<para style="P9b"><u>[[ (sum_debit_partner(p,data) - sum_credit_partner(p,data)) ]]</u></para>
</td>
</tr>
</blockTable>
<blockTable colWidths="45.0,37.0,120.0,135.0,69.0,72.0,63.0" style="Table2">
<tr>
<td>
<para style="P15"><font face="Helvetica">[[ repeatIn(lines(p,data), 'line') ]]</font>[[ line['date'] ]]</para>
</td>
<td>
<para style="P3">[[ line['code'] ]]</para>
</td>
<td>
<para style="P3">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P4">[[ line['name'] ]]</para>
</td>
<td>
<para style="P5">[[ (line['debit']) or '' ]]</para>
</td>
<td>
<para style="P5">[[ (line['credit']) or '' ]]</para>
</td>
<td>
<para style="P5">[[ (line['progress']) or '' ]]</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P10"><font face="Times-Roman">Printing date:</font> [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] <font face="Times-Roman">at</font> [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P11">
<font color="white"> </font>
</para>
<blockTable colWidths="45.0,36.0,50.0,145.0,69.0,72.0,64.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P12">Date</para>
</td>
<td>
<para style="P12">J. code</para>
</td>
<td>
<para style="P12">Voucher Nb</para>
</td>
<td>
<para style="P12">Entry label</para>
</td>
<td>
<para style="P12">Debit</para>
</td>
<td>
<para style="P12">Credit</para>
</td>
<td>
<para style="P12">Progressive balance</para>
</td>
</tr>
</blockTable>
<para style="Text body">
<font color="white"> </font>
</para>
<section>
<para style="P13">[[ repeatIn(objects, 'p') ]]</para>
<para style="P14">[[ p.ref ]] [[ p.name ]]</para>
<blockTable colWidths="45.0,37.0,50.0,145.0,69.0,72.0,63.0" style="Table3">
<tr>
<td>
<para style="P15"><font face="Times-Roman">[[ repeatIn(lines(p), 'line') ]]</font>[[ formatLang(line['date'], date=True) ]]</para>
</td>
<td>
<para style="P3">[[ line['code'] ]]</para>
</td>
<td>
<para style="P3">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P4">[[ line['name'] ]]</para>
</td>
<td>
<para style="P5">[[ formatLang(line['debit']) ]]</para>
</td>
<td>
<para style="P5">[[ formatLang(line['credit']) ]]</para>
</td>
<td>
<para style="P5">[[ formatLang(line['progress']) ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="277.0,69.0,72.0,63.0" style="Table5">
<tr>
<td>
<para style="P8">Total for [[ p.ref ]] </para>
<para style="P8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">[[ formatLang(sum_debit_partner(p)) ]]</para>
</td>
<td>
<para style="P9">[[ formatLang(sum_credit_partner(p)) ]]</para>
</td>
<td>
<para style="P9">[[ formatLang((sum_debit_partner(p) - sum_credit_partner(p))) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</section>
<para style="Text body">
<font color="white"> </font>
</para>
<blockTable colWidths="277.0,69.0,72.0,63.0" style="Table4">
<tr>
<td>
<para style="P8">Balance brought forward</para>
</td>
<td>
<para style="P9">[[ formatLang(sum_debit()) ]]</para>
</td>
<td>
<para style="P9">[[ formatLang(sum_credit()) ]]</para>
</td>
<td>
<para style="P9">[[ formatLang((sum_debit() - sum_credit())) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -1,9 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@ -30,37 +28,117 @@
import wizard
import pooler
import time
report_type = '''<?xml version="1.0"?>
<form string="Select Report Type">
</form>'''
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="fiscalyear" colspan="4"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal year)"/>
<field name="periods" colspan="4"/>
<field name="state" colspan="4"/>
<field name="date_from" colspan="4"/>
<field name="date_to" colspan="4"/>
<field name="display_account" colspan="4"/>
</form>'''
dates_fields = {
'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'display_account':{'string':"Display accounts",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]}
}
period_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="fiscalyear" colspan="4"/>
<field name="periods" colspan="4"/>
<field name="display_account" colspan="4"/>
</form>'''
period_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]}
}
account_form = '''<?xml version="1.0"?>
<form string="Select parent account">
<field name="Account_list" colspan="4"/>
</form>'''
account_fields = {
'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
}
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
periods_obj=pooler.get_pool(cr.dbname).get('account.period')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['target_move'] = False
data['form']['state']='all'
if context.has_key('target_move'):
data['form']['target_move'] = context['target_move']
data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
data['form']['display_account']='bal_all'
return data['form']
def _get_defaults_fordate(self, cr, uid, data, context):
data['form']['display_account']='bal_all'
return data['form']
def _check_path(self, cr, uid, data, context):
if data['model'] == 'account.account':
return 'checktype'
else:
return 'account_selection'
def _check_date(self, cr, uid, data, context):
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
else:
return 'report'
else:
raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
'actions': [],
'result': {'type':'choice','next_state':_check_path}
},
'account_selection': {
'actions': [],
'result': {'type':'form', 'arch':account_form,'fields':account_fields, 'state':[('end','Cancel'),('checktype','Print')]}
},
'checktype': {
'actions': [],
'result': {'type':'form', 'arch':report_type,'fields':{}, 'state':[('with_period','Use with Period'),('with_date','Use with Date')]}
},
'with_period': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'with_date': {
'actions': [_get_defaults_fordate],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]}
},
'checkdate': {
'actions': [],
'result': {'type':'choice','next_state':_check_date}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.account.balance', 'state':'end'}
@ -69,6 +147,3 @@ class wizard_report(wizard.interface):
wizard_report('account.account.balance.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

127
addons/account/wizard/wizard_aged_trial_balance.py Normal file → Executable file
View File

@ -1,9 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@ -34,78 +32,79 @@ import datetime
import pooler
from mx.DateTime import *
from tools.translate import _
_aged_trial_form = """<?xml version="1.0"?>
<form string="Aged Trial Balance">
<field name="company_id"/>
<newline/>
<field name="fiscalyear"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal year)"/>
<newline/>
<field name="period_length"/>
<newline/>
<field name="sorting_on"/>
<newline/>
<field name="computation"/>
<newline/>
<field name="state"/>
<field name="company_id"/>
<newline/>
<field name="date1"/>
<field name="period_length"/>
<newline/>
<field name="result_selection"/>
<newline/>
<field name="direction_selection"/>
</form>"""
_aged_trial_fields = {
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
'sorting_on':{'string': 'Sorting On', 'type': 'selection', 'selection': [('partner','By Partner Name (asc)'), ('amount','By Amount (desc)')],'required': True, 'default': lambda *a:'partner'},
'computation':{'string': 'Computational Method', 'type': 'selection', 'selection': [("\'receivable\'",'On Receivables Only'), ("\'payable\'",'On Payables Only'), ("\'receivable\',\'payable\'",'On Receivables & Payables')], 'required': True, 'default': lambda *a:"\'receivable\'"},
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
}
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'result_selection':{'string':"Display partner",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]},
'direction_selection':{'string':"Display aged balance of",'type':'selection','selection':[('past','Due amount'),('future','Not due amount')]},
}
def _calc_dates(self, cr, uid, data, context):
res = {}
period_length = data['form']['period_length']
if period_length<=0:
raise wizard.except_wizard(_('UserError'), _('You must enter a period length that cannot be 0 or below !'))
start = now()
for i in range(5)[::-1]:
stop = start-RelativeDateTime(days=period_length)
res[str(i)] = {
'name' : str((5-i)*period_length)+' days',
'stop': start.strftime('%Y-%m-%d'),
'start' : stop.strftime('%Y-%m-%d'),
}
start = stop - RelativeDateTime(days=1)
return res
res = {}
period_length = data['form']['period_length']
if period_length<=0:
raise wizard.except_wizard('UserError', 'You must enter a period length that cannot be 0 or below !')
start = datetime.date.fromtimestamp(time.mktime(time.strptime(data['form']['date1'],"%Y-%m-%d")))
start = DateTime(int(start.year),int(start.month),int(start.day))
if data['form']['direction_selection'] == 'past':
for i in range(5)[::-1]:
stop = start - RelativeDateTime(days=period_length)
res[str(i)] = {
'name' : str((5-(i+1))*period_length) + '-' + str((5-i)*period_length),
'stop': start.strftime('%Y-%m-%d'),
'start' : stop.strftime('%Y-%m-%d'),
}
start = stop - RelativeDateTime(days=1)
else:
for i in range(5):
stop = start + RelativeDateTime(days=period_length)
res[str(5-(i+1))] = {
'name' : str((i)*period_length)+'-'+str((i+1)*period_length),
'start': start.strftime('%Y-%m-%d'),
'stop' : stop.strftime('%Y-%m-%d'),
}
start = stop + RelativeDateTime(days=1)
return res
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
data['form']['state']='all'
return data['form']
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
return data['form']
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Partner Balance')]},
},
'print': {
'actions': [_calc_dates],
'result': {'type':'print', 'report':'account.aged.trial.balance', 'state':'end'},
},
}
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Trial Balance')]},
},
'print': {
'actions': [_calc_dates],
'result': {'type':'print', 'report':'account.aged_trial_balance', 'state':'end'},
},
}
wizard_report('account.aged.trial.balance')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -110,7 +110,7 @@ def _data_save(self, cr, uid, data, context):
offset = 0
limit = 100
while True:
cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \
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 ' \
@ -123,10 +123,13 @@ def _data_save(self, cr, uid, data, context):
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, {
'journal_id': new_journal.id,
@ -137,7 +140,7 @@ def _data_save(self, cr, uid, data, context):
offset = 0
limit = 100
while True:
cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \
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 ' \
@ -149,10 +152,13 @@ def _data_save(self, cr, uid, data, context):
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

View File

@ -1,10 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
@ -30,33 +26,144 @@
import wizard
import pooler
import locale
import time
report_type = '''<?xml version="1.0"?>
<form string="Select Report Type">
</form>'''
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="fiscalyear" colspan="4"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal year)"/>
<field name="periods" colspan="4"/>
<field name="state" colspan="4"/>
<form string="Select period ">
<field name="date_from" colspan="4"/>
<field name="date_to" colspan="4"/>
<field name="sortbydate" colspan="4"/>
<field name="display_account" colspan="4"/>
<field name="landscape" colspan="4"/>
<field name="soldeinit"/>
<field name="amount_currency" colspan="4"/>
</form>'''
dates_fields = {
'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'sortbydate':{'string':"Sort by",'type':'selection','selection':[('sort_date','Date'),('sort_mvt','Mouvement')]},
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]},
'landscape':{'string':"Print in Landscape Mode",'type':'boolean'},
'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
'amount_currency':{'string':"with amount in currency",'type':'boolean'}
}
account_form = '''<?xml version="1.0"?>
<form string="Select parent account">
<field name="Account_list" colspan="4"/>
</form>'''
account_fields = {
'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
}
period_form = '''<?xml version="1.0"?>
<form string="Select period ">
<field name="fiscalyear" colspan="4"/>
<field name="periods" colspan="4"/>
<field name="sortbydate" colspan="4"/>
<field name="display_account" colspan="4"/>
<field name="landscape" colspan="4"/>
<field name="soldeinit"/>
<field name="amount_currency" colspan="4"/>
</form>'''
period_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
'sortbydate':{'string':"Sort by:",'type':'selection','selection':[('sort_date','Date'),('sort_mvt','Mouvement')]},
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]},
'landscape':{'string':"Print in Landscape Mode",'type':'boolean'},
'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
'amount_currency':{'string':"with amount in currency",'type':'boolean'}
}
def _check_path(self, cr, uid, data, context):
if data['model'] == 'account.account':
return 'checktype'
else:
return 'account_selection'
def _check(self, cr, uid, data, context):
if data['form']['landscape']==True:
return 'report_landscape'
else:
return 'report'
def _check_date(self, cr, uid, data, context):
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
else:
return 'checkreport'
else:
raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['state']='all'
data['form']['sortbydate'] = 'sort_date'
data['form']['display_account']='bal_all'
data['form']['landscape']=True
data['form']['amount_currency'] = True
return data['form']
def _get_defaults_fordate(self, cr, uid, data, context):
data['form']['sortbydate'] = 'sort_date'
data['form']['display_account']='bal_all'
data['form']['landscape']=True
data['form']['amount_currency'] = True
return data['form']
states = {
'init': {
'actions': [],
'result': {'type':'choice','next_state':_check_path}
},
'account_selection': {
'actions': [],
'result': {'type':'form', 'arch':account_form,'fields':account_fields, 'state':[('end','Cancel'),('checktype','Print')]}
},
'checktype': {
'actions': [],
'result': {'type':'form', 'arch':report_type,'fields':{}, 'state':[('with_period','Use with Period'),('with_date','Use with Date')]}
},
'with_period': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('checkreport','Print')]}
},
'with_date': {
'actions': [_get_defaults_fordate],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]}
},
'checkdate': {
'actions': [],
'result': {'type':'choice','next_state':_check_date}
},
'checkreport': {
'actions': [],
'result': {'type':'choice','next_state':_check}
},
'report_landscape': {
'actions': [],
'result': {'type':'print', 'report':'account.general.ledger_landscape', 'state':'end'}
},
'report': {
'actions': [],
@ -64,7 +171,3 @@ class wizard_report(wizard.interface):
}
}
wizard_report('account.general.ledger.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -124,7 +124,7 @@ def _get_period(self, cr, uid, data, context={}):
raise wizard.except_wizard(_('Error !'), _('Can not pay draft invoice.'))
return {
'period_id': period_id,
'amount': invoice.amount_total,
'amount': invoice.residual,
'date': time.strftime('%Y-%m-%d')
}

160
addons/account/wizard/wizard_third_party_ledger.py Normal file → Executable file
View File

@ -1,9 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@ -32,54 +29,133 @@ import time
import wizard
import pooler
report_type = '''<?xml version="1.0"?>
<form string="Select Report Type">
</form>'''
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="company_id" colspan="4"/>
<field name="fiscalyear" colspan="4"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal year)"/>
<newline/>
<field name="date1"/>
<field name="date2"/>
<newline/>
<field name="state" colspan="4"/>
<field name="company_id" colspan="4"/>
<newline/>
<field name="date1"/>
<field name="date2"/>
<newline/>
<field name="result_selection"/>
<field name="soldeinit"/>
<field name="reconcil"/>
<newline/>
<field name="page_split"/>
</form>'''
dates_fields = {
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
'date1': {'string':'Start date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'result_selection':{'string':"Display partners",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]},
'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
'reconcil':{'string':"Inclure les ecritures reconsiliees",'type':'boolean'},
'page_split':{'string':"Un partenaire par page",'type':'boolean'},
}
period_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="company_id" colspan="4"/>
<newline/>
<field name="fiscalyear" colspan="4"/>
<field name="periods" colspan="4"/>
<newline/>
<field name="result_selection"/>
<field name="soldeinit"/>
<field name="reconcil"/>
<newline/>
<field name="page_split"/>
</form>'''
period_fields = {
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'result_selection':{'string':"Display partners",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]},
'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
'reconcil':{'string':"Inclure les ecritures reconsiliees",'type':'boolean'},
'page_split':{'string':"Un partenaire par page",'type':'boolean'},
}
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
def _get_defaults(self, cr, uid, data, context):
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
data['form']['state']='all'
return data['form']
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['display_account']='bal_all'
data['form']['result_selection'] = 'all'
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
data['form']['page_split'] = False
data['form']['reconcil'] = False
data['form']['soldeinit'] = True
return data['form']
def _get_defaults_fordate(self, cr, uid, data, context):
data['form']['result_selection'] = 'all'
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
data['form']['page_split'] = False
data['form']['reconcil'] = False
data['form']['soldeinit'] = True
return data['form']
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
}
}
def _check_date(self, cr, uid, data, context):
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
else:
return 'report'
else:
raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':report_type,'fields':{}, 'state':[('with_period','Use with Period'),('with_date','Use with Date')]}
},
'with_period': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'with_date': {
'actions': [_get_defaults_fordate],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]}
},
'checkdate': {
'actions': [],
'result': {'type':'choice','next_state':_check_date}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
}
}
wizard_report('account.third_party_ledger.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

102
addons/account/wizard/wizard_vat.py Normal file → Executable file
View File

@ -1,9 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@ -34,68 +31,65 @@ import pooler
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="company_id"/>
<newline/>
<field name="period_id"/>
<newline/>
<field name="based_on"/>
<field name="company_id"/>
<newline/>
<field name="based_on"/>
<field name="periods" colspan="4"/>
</form>'''
dates_fields = {
'company_id': {'string': 'Company', 'type': 'many2one',
'relation': 'res.company', 'required': True},
'period_id': {'string':'Period', 'type':'many2one',
'relation': 'account.period', 'required':True},
'based_on':{'string':'Base on', 'type':'selection', 'selection':[
('invoices','Invoices'),
('payments','Payments'),
], 'required':True, 'default': lambda *a: 'invoices'},
'company_id': {'string': 'Company', 'type': 'many2one',
'relation': 'res.company', 'required': True},
'based_on':{'string':'Base on', 'type':'selection', 'selection':[
('invoices','Invoices'),
('payments','Payments'),
], 'required':True, 'default': lambda *a: 'invoices'},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
}
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
period_obj = pool.get('account.period')
data['form']['period_id'] = period_obj.find(cr, uid)[0]
def _get_defaults(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
period_obj = pool.get('account.period')
user = pool.get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pool.get('res.company').search(cr, uid,
[('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
user = pool.get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pool.get('res.company').search(cr, uid,
[('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
return data['form']
return data['form']
states = {
'init': {
'actions': [_get_defaults],
'result': {
'type': 'form',
'arch': dates_form,
'fields': dates_fields,
'state': [
('end', 'Cancel'),
('report', 'Print VAT Decl.')
]
}
},
'report': {
'actions': [],
'result': {
'type': 'print',
'report': 'account.vat.declaration',
'state':'end'
}
}
}
states = {
'init': {
'actions': [_get_defaults],
'result': {
'type': 'form',
'arch': dates_form,
'fields': dates_fields,
'state': [
('end', 'Cancel'),
('report', 'Print VAT Decl.')
]
}
},
'report': {
'actions': [],
'result': {
'type': 'print',
'report': 'account.vat.declaration',
'state':'end'
}
}
}
wizard_report('account.vat.declaration')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,13 +1,13 @@
# -*- encoding: utf-8 -*-
{
"name" : "Crossovered Budget Management",
"name" : "Budget Management",
"version" : "1.0",
"author" : "Tiny",
"website" : "http://tinyerp.com/module_crossovered_budget.html",
"category" : "Generic Modules/Accounting",
"description": """This module allow accountants to manage analytic and crossovered budgets.
Once the Master Budgets and the Budgets defined (in Financial Management/Configuration/Budgets/), the Project Managers can set the planned amount on each Analytic Account.
Once the Master Budgets and the Budgets defined (in Financial Management/Budgets/), the Project Managers can set the planned amount on each Analytic Account.
The accountant has the possibility to see the total of amount planned for each Budget and Master Budget in order to ensure the total planned is not greater/lower than what he planned for this Budget/Master Budget. Each list of record can also be switched to a graphical view of it.

View File

@ -138,7 +138,7 @@ crossovered_budget()
class crossovered_budget_lines(osv.osv):
def _pra_amt(self, cr, uid, ids,name,args,context):
def _prac_amt(self, cr, uid, ids,context={}):
res = {}
for line in self.browse(cr, uid, ids):
acc_ids = ','.join([str(x.id) for x in line.general_budget_id.account_ids])
@ -157,7 +157,14 @@ class crossovered_budget_lines(osv.osv):
res[line.id]=result
return res
def _theo_amt(self, cr, uid, ids,name,args,context):
def _prac(self, cr, uid, ids,name,args,context):
res={}
for line in self.browse(cr, uid, ids):
res[line.id]=self._prac_amt(cr,uid,[line.id],context=context)[line.id]
return res
def _theo_amt(self, cr, uid, ids,context={}):
res = {}
for line in self.browse(cr, uid, ids):
today=datetime.datetime.today()
@ -184,6 +191,13 @@ class crossovered_budget_lines(osv.osv):
res[line.id]=theo_amt
return res
def _theo(self, cr, uid, ids,name,args,context):
res={}
for line in self.browse(cr, uid, ids):
res[line.id]=self._theo_amt(cr,uid,[line.id],context=context)[line.id]
return res
def _perc(self, cr, uid, ids,name,args,context):
res = {}
for line in self.browse(cr, uid, ids):
@ -201,58 +215,13 @@ class crossovered_budget_lines(osv.osv):
'date_from': fields.date('Start Date',required=True),
'date_to': fields.date('End Date',required=True),
'paid_date': fields.date('Paid Date'),
'planned_amount':fields.float('Planned Amount',required=True),
'practical_amount':fields.function(_pra_amt,method=True, string='Practical Amount',type='float'),
'theoritical_amount':fields.function(_theo_amt,method=True, string='Theoritical Amount',type='float'),
'planned_amount':fields.float('Planned Amount',required=True,digits=(16,2)),
'practical_amount':fields.function(_prac,method=True, string='Practical Amount',type='float',digits=(16,2)),
'theoritical_amount':fields.function(_theo,method=True, string='Theoritical Amount',type='float',digits=(16,2)),
'percentage':fields.function(_perc,method=True, string='Percentage',type='float'),
}
crossovered_budget_lines()
#class account_budget_post(osv.osv): #old code
# _name = 'account.budget.post'
# _inherit = 'account.budget.post'
# _columns = {
# 'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'general_budget_id', 'Budget Lines'),
# }
#account_budget_post()
#
#class account_budget_post_dotation(osv.osv):
# _name = 'account.budget.post.dotation'
# _inherit = 'account.budget.post.dotation'
#
# def _tot_planned(self, cr, uid, ids,name,args,context):
# res={}
# for line in self.browse(cr, uid, ids):
# if line.period_id:
# obj_period=self.pool.get('account.period').browse(cr, uid,line.period_id.id)
#
# total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start)
# budget_id=line.post_id and line.post_id.id or False
# query="select id from crossovered_budget_lines where general_budget_id= '"+ str(budget_id) + "' AND (date_from >='" +obj_period.date_start +"' and date_from <= '"+obj_period.date_stop + "') OR (date_to >='" +obj_period.date_start +"' and date_to <= '"+obj_period.date_stop + "') OR (date_from <'" +obj_period.date_start +"' and date_to > '"+obj_period.date_stop + "')"
# cr.execute(query)
# res1=cr.fetchall()
#
# tot_planned=0.00
# for record in res1:
# obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid,record[0])
# count_days = min(strToDate(obj_period.date_stop),strToDate(obj_lines.date_to)) - max(strToDate(obj_period.date_start), strToDate(obj_lines.date_from))
# days_in_period = count_days.days +1
# count_days = strToDate(obj_lines.date_to) - strToDate(obj_lines.date_from)
# total_days_of_rec = count_days.days +1
# tot_planned += obj_lines.planned_amount/total_days_of_rec* days_in_period
# res[line.id]=tot_planned
# else:
# res[line.id]=0.00
# return res
#
# _columns = {
# 'tot_planned':fields.function(_tot_planned,method=True, string='Total Planned Amount',type='float',store=True),
# }
#
#account_budget_post_dotation()
class account_analytic_account(osv.osv):
_name = 'account.analytic.account'
_inherit = 'account.analytic.account'
@ -266,7 +235,7 @@ account_analytic_account()
#--------------------------------------------------------------
# moved from account/project/project.py
# ---------------------------------------------------------
# Budgets
# Budgets.
# ---------------------------------------------------------
#class account_analytic_budget_post(osv.osv):

View File

@ -76,7 +76,7 @@
<field name="view_type">form</field>
<field name="view_id" ref="view_budget_post_tree"/>
</record>
<menuitem id="next_id_31" name="Budgets" parent="account.menu_finance_accounting"/><menuitem action="open_budget_post_form" id="menu_budget_post_form" parent="next_id_31"/>
<menuitem id="next_id_31" name="Budgets" parent="account.menu_finance"/><menuitem action="open_budget_post_form" id="menu_budget_post_form" parent="next_id_31"/>
<!-- ******************************************************************************************************** -->
<!--<record model="ir.ui.view" id="view_budget_post_dotation_form_inherit">

View File

@ -1,310 +0,0 @@
# Translation of OpenERP Server.
# This file containt the translation of the following modules:
# * account_budget_crossover
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 4.3.0"
"Report-Msgid-Bugs-To: support@openerp.com"
"POT-Creation-Date: 2008-09-10 12:47:16+0000"
"PO-Revision-Date: 2008-09-10 12:47:16+0000"
"Last-Translator: <>"
"Language-Team: "
"MIME-Version: 1.0"
"Content-Type: text/plain; charset=UTF-8"
"Content-Transfer-Encoding: "
"Plural-Forms: "
#. module: account_budget_crossover
#: field:crossovered.budget,creating_user_id:0
msgid "Responsible User"
msgstr ""
#. module: account_budget_crossover
#: selection:crossovered.budget,state:0
msgid "Confirmed"
msgstr ""
#. module: account_budget_crossover
#: constraint:ir.model:0
msgid "The Object name must start with x_ and not contain any special character !"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "Printed at:"
msgstr ""
#. module: account_budget_crossover
#: view:crossovered.budget:0
msgid "Confirm"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget,validating_user_id:0
msgid "Validate User"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget.lines,analytic_account_id:0
msgid "Analytic Account Ref"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "Currency:"
msgstr ""
#. module: account_budget_crossover
#: selection:crossovered.budget,state:0
msgid "Draft"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "at"
msgstr ""
#. module: account_budget_crossover
#: model:ir.actions.report.xml,name:account_budget_crossover.account_analytic_account_budget
#: model:ir.actions.report.xml,name:account_budget_crossover.report_crossovered_budget
#: model:ir.actions.wizard,name:account_budget_crossover.account_analytic_account_budget_report
#: model:ir.actions.wizard,name:account_budget_crossover.wizard_crossovered_budget_menu
msgid "Print Budgets"
msgstr ""
#. module: account_budget_crossover
#: wizard_button:wizard.analytic.account.budget.report,init,report:0
#: wizard_button:wizard.crossovered.budget,init,report:0
#: wizard_button:wizard.crossovered.budget.summary,init,report:0
msgid "Print"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget.lines,percentage:0
msgid "Percentage"
msgstr ""
#. module: account_budget_crossover
#: selection:crossovered.budget,state:0
msgid "Validated"
msgstr ""
#. module: account_budget_crossover
#: model:ir.model,name:account_budget_crossover.model_crossovered_budget_lines
msgid "Crossovered Budget Lines"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget,name:0
msgid "Name"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget,state:0
msgid "Status"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "%"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "Description"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
msgid "Analytic Account :"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget.lines,crossovered_budget_id:0
msgid "Budget Ref"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "to"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
#: field:crossovered.budget.lines,planned_amount:0
msgid "Planned Amount"
msgstr ""
#. module: account_budget_crossover
#: model:ir.ui.menu,name:account_budget_crossover.menu_financial_reporting_budget_budget_entries
msgid "Entries"
msgstr ""
#. module: account_budget_crossover
#: view:crossovered.budget:0
msgid "Validate"
msgstr ""
#. module: account_budget_crossover
#: wizard_view:wizard.crossovered.budget,init:0
#: wizard_view:wizard.crossovered.budget.summary,init:0
msgid "Select Options"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
#: field:crossovered.budget.lines,practical_amount:0
msgid "Practical Amount"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget,date_to:0
#: field:crossovered.budget.lines,date_to:0
msgid "End Date"
msgstr ""
#. module: account_budget_crossover
#: constraint:ir.ui.view:0
msgid "Invalid XML for View Architecture!"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget.lines,theoritical_amount:0
msgid "Theoritical Amount"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "Total:"
msgstr ""
#. module: account_budget_crossover
#: selection:crossovered.budget,state:0
msgid "Cancelled"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget.lines,general_budget_id:0
msgid "Master Budget Ref"
msgstr ""
#. module: account_budget_crossover
#: view:account.analytic.account:0
msgid "Lines"
msgstr ""
#. module: account_budget_crossover
#: model:ir.actions.act_window,name:account_budget_crossover.act_crossovered_budget_view
#: model:ir.ui.menu,name:account_budget_crossover.menu_act_crossovered_budget_view
#: view:crossovered.budget:0
msgid "Budget"
msgstr ""
#. module: account_budget_crossover
#: wizard_view:wizard.analytic.account.budget.report,init:0
msgid "Select Dates Period"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget.lines,paid_date:0
msgid "Paid Date"
msgstr ""
#. module: account_budget_crossover
#: model:ir.ui.menu,name:account_budget_crossover.menu_financial_reporting_budget_budget
msgid "Budgets"
msgstr ""
#. module: account_budget_crossover
#: wizard_field:wizard.analytic.account.budget.report,init,date_to:0
#: wizard_field:wizard.crossovered.budget,init,date_to:0
#: wizard_field:wizard.crossovered.budget.summary,init,date_to:0
msgid "End of period"
msgstr ""
#. module: account_budget_crossover
#: model:ir.model,name:account_budget_crossover.model_crossovered_budget
msgid "Crossovered Budget"
msgstr ""
#. module: account_budget_crossover
#: wizard_field:wizard.analytic.account.budget.report,init,date_from:0
#: wizard_field:wizard.crossovered.budget,init,date_from:0
#: wizard_field:wizard.crossovered.budget.summary,init,date_from:0
msgid "Start of period"
msgstr ""
#. module: account_budget_crossover
#: model:ir.actions.wizard,name:account_budget_crossover.wizard_crossovered_budget_menu_1
msgid "Print Summary of Budgets"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget,code:0
msgid "Code"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "Theoretical Amount"
msgstr ""
#. module: account_budget_crossover
#: rml:crossovered.budget.report:0
msgid "Budget :"
msgstr ""
#. module: account_budget_crossover
#: selection:crossovered.budget,state:0
#: view:crossovered.budget:0
msgid "Done"
msgstr ""
#. module: account_budget_crossover
#: model:ir.actions.act_window,name:account_budget_crossover.act_crossovered_budget_lines_view
#: field:account.analytic.account,crossovered_budget_line:0
#: field:account.budget.post,crossovered_budget_line:0
#: field:crossovered.budget,crossovered_budget_line:0
#: model:ir.ui.menu,name:account_budget_crossover.menu_act_crossovered_budget_lines_view
#: view:crossovered.budget:0
#: view:account.analytic.account:0
#: view:crossovered.budget.lines:0
msgid "Budget Lines"
msgstr ""
#. module: account_budget_crossover
#: wizard_button:wizard.analytic.account.budget.report,init,end:0
#: wizard_button:wizard.crossovered.budget,init,end:0
#: wizard_button:wizard.crossovered.budget.summary,init,end:0
#: view:crossovered.budget:0
msgid "Cancel"
msgstr ""
#. module: account_budget_crossover
#: field:account.budget.post.dotation,tot_planned:0
msgid "Total Planned Amount"
msgstr ""
#. module: account_budget_crossover
#: field:crossovered.budget,date_from:0
#: field:crossovered.budget.lines,date_from:0
msgid "Start Date"
msgstr ""
#. module: account_budget_crossover
#: rml:account.analytic.account.budget:0
#: rml:crossovered.budget.report:0
msgid "Analysis from"
msgstr ""

View File

@ -34,34 +34,27 @@ class analytic_account_budget_report(report_sxw.rml_parse):
result=[]
accounts = self.pool.get('account.analytic.account').browse(self.cr, self.uid, [object.id], self.context.copy())
c_b_lines_obj=self.pool.get('crossovered.budget.lines')
for account_id in accounts:
res={}
budget_lines=[]
b_line_ids=[]
for line in account_id.crossovered_budget_line:
b_line_ids.append(line.id)
if not b_line_ids:
return []
bd_lines_ids = ','.join([str(x) for x in b_line_ids])
d_from=form['date_from']
d_to=form['date_to']
query="select id from crossovered_budget_lines where id in ("+ str(bd_lines_ids) + ")"# AND '"+ str(d_from) +"'<=date_from AND date_from<date_to AND date_to<= '"+ str(d_to) +"'"
self.cr.execute(query)
budget_line_ids=self.cr.fetchall()
if not budget_line_ids:
return []
budget_lines=[x[0] for x in budget_line_ids]
bd_ids = ','.join([str(x) for x in budget_lines])
# bd_ids = ','.join([str(x) for x in budget_lines])
self.cr.execute('select distinct(crossovered_budget_id) from crossovered_budget_lines where id in (%s)'%(bd_lines_ids))
budget_ids=self.cr.fetchall()
context={'wizard_date_from':d_from,'wizard_date_to':d_to}
for i in range(0,len(budget_ids)):
budget_name=self.pool.get('crossovered.budget').browse(self.cr, self.uid,[budget_ids[i][0]])
@ -77,17 +70,17 @@ class analytic_account_budget_report(report_sxw.rml_parse):
}
result.append(res)
line_ids = self.pool.get('crossovered.budget.lines').search(self.cr, self.uid, [('id', 'in', b_line_ids),('crossovered_budget_id','=',budget_ids[i][0])])
line_id = self.pool.get('crossovered.budget.lines').browse(self.cr,self.uid,line_ids)
line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', b_line_ids),('crossovered_budget_id','=',budget_ids[i][0])])
line_id =c_b_lines_obj.browse(self.cr,self.uid,line_ids)
tot_theo=tot_pln=tot_prac=tot_perc=0
done_budget=[]
for line in line_id:
if line.id in budget_lines:
if line.id in b_line_ids:
theo=pract=0.00
theo=line._theo_amt(self.cr, self.uid, [line.id],"theoritical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
pract=line._pra_amt(self.cr, self.uid, [line.id],"practical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
theo=c_b_lines_obj._theo_amt(self.cr, self.uid, [line.id],context)[line.id]
pract=c_b_lines_obj._prac_amt(self.cr, self.uid, [line.id],context)[line.id]
if line.general_budget_id.id in done_budget:

View File

@ -54,7 +54,10 @@ class budget_report(report_sxw.rml_parse):
i = interval(d.period_id.date_start, d.period_id.date_stop)
total_days = reduce(lambda x,d: x+interval(d.period_id.date_start, d.period_id.date_stop), post_obj.dotation_ids, 0)
achievements = reduce(lambda x,l: x+l['achievements'], self.lines(post_obj, date1, date2), 0.0)
return [{'prev': prev, 'prev_period': prev * period_days / total_days, 'achievements': achievements}]
prev_1=1.00
if total_days<>0.00:
prev_1=prev * period_days / total_days
return [{'prev': prev, 'prev_period': prev_1, 'achievements': achievements}]
def budget_total(self, post_objs, date1, date2):
res = {'prev': 0.0, 'prev_period': 0.0, 'achievements': 0.0}

View File

@ -63,6 +63,7 @@ class budget_report(report_sxw.rml_parse):
budgets = self.pool.get('crossovered.budget').browse(self.cr, self.uid, [object.id], self.context.copy())
c_b_lines_obj=self.pool.get('crossovered.budget.lines')
for budget_id in budgets:
res={}
@ -74,22 +75,16 @@ class budget_report(report_sxw.rml_parse):
for line in budget_id.crossovered_budget_line:
budget_ids.append(line.id)
b_line_ids=','.join([str(x) for x in budget_ids])
query="select id from crossovered_budget_lines where crossovered_budget_id = '"+ str(budget_id.id) + "'"# AND '"+ str(d_from) +"'<=date_from AND date_from<date_to AND date_to<= '"+ str(d_to) +"'"
self.cr.execute(query)
budget_line_ids=self.cr.fetchall()
if not budget_line_ids:
if not budget_ids:
return []
budget_lines=[x[0] for x in budget_line_ids]
bd_ids = ','.join([str(x) for x in budget_lines])
b_line_ids=','.join([str(x) for x in budget_ids])
# bd_ids = ','.join([str(x) for x in budget_lines])
self.cr.execute('select distinct(analytic_account_id) from crossovered_budget_lines where id in (%s)'%(b_line_ids))
an_ids=self.cr.fetchall()
context={'wizard_date_from':d_from,'wizard_date_to':d_to}
for i in range(0,len(an_ids)):
analytic_name=self.pool.get('account.analytic.account').browse(self.cr, self.uid,[an_ids[i][0]])
@ -106,18 +101,18 @@ class budget_report(report_sxw.rml_parse):
}
result.append(res)
line_ids = self.pool.get('crossovered.budget.lines').search(self.cr, self.uid, [('id', 'in', budget_ids),('analytic_account_id','=',an_ids[i][0])])
line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', budget_ids),('analytic_account_id','=',an_ids[i][0])])
line_id = self.pool.get('crossovered.budget.lines').browse(self.cr,self.uid,line_ids)
line_id = c_b_lines_obj.browse(self.cr,self.uid,line_ids)
tot_theo=tot_pln=tot_prac=tot_perc=0.00
done_budget=[]
for line in line_id:
if line.id in budget_lines:
if line.id in budget_ids:
theo=pract=0.00
theo=line._theo_amt(self.cr, self.uid, [line.id],"theoritical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
pract=line._pra_amt(self.cr, self.uid, [line.id],"practical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
theo=c_b_lines_obj._theo_amt(self.cr, self.uid, [line.id],context)[line.id]
pract=c_b_lines_obj._prac_amt(self.cr, self.uid, [line.id],context)[line.id]
if line.general_budget_id.id in done_budget:

View File

@ -30,6 +30,8 @@
import time
import wizard
import datetime
import pooler
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
@ -43,9 +45,16 @@ dates_fields = {
}
class wizard_report(wizard.interface):
def _default(self, cr, uid, data, context):
pool_obj = pooler.get_pool(cr.dbname)
data_model = pool_obj.get(data['model']).browse(cr,uid,data['id'])
if not data_model.dotation_ids:
raise wizard.except_wizard('Insufficient Data!',"No Dotations or Master Budget Expenses Found on Budget '"+ data_model.name +"'!")
return data['form']
states = {
'init': {
'actions': [],
'actions': [_default],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {

View File

@ -212,7 +212,7 @@ class followup_all_print(wizard.interface):
def _get_partners(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
cr.execute(
"SELECT l.partner_id, l.followup_line_id, l.date, l.id "\
"SELECT l.partner_id, l.followup_line_id,l.date_maturity, l.date, l.id "\
"FROM account_move_line AS l "\
"LEFT JOIN account_account AS a "\
"ON (l.account_id=a.id) "\
@ -251,14 +251,17 @@ class followup_all_print(wizard.interface):
partner_list = []
to_update = {}
for partner_id, followup_line_id, date, id in move_lines:
for partner_id, followup_line_id, date_maturity,date, id in move_lines:
if not partner_id:
continue
if partner_id in partner_list:
to_update[str(id)] = fups[followup_line_id][1]
if followup_line_id not in fups:
continue
if date <= fups[followup_line_id][0].strftime('%Y-%m-%d'):
if date_maturity and date_maturity <= fups[followup_line_id][0].strftime('%Y-%m-%d'):
partner_list.append(partner_id)
to_update[str(id)] = fups[followup_line_id][1]
elif date and date <= fups[followup_line_id][0].strftime('%Y-%m-%d'):
partner_list.append(partner_id)
to_update[str(id)] = fups[followup_line_id][1]
return {'partner_ids': partner_list, 'to_update': to_update}

View File

@ -82,7 +82,7 @@ payment_mode()
class payment_order(osv.osv):
_name = 'payment.order'
_description = 'Payment Order'
_rec_name = 'date'
_rec_name = 'reference'
def get_wizard(self,type):
logger = netsvc.Logger()

View File

@ -13,15 +13,16 @@
*contacts working at several adresses (possibly for different partners),
*contacts with possibly different functions for each of its job's addresses
It also add a new menuitem located in
It also add new menuitems located in
Partners \ Contacts
Partners \ Functions
Pay attention that this module converts the existing addresses into "addresses + contacts". It means that some fields of the addresses will be missing (like the contact name), since these are supposed to be defined in an other object.
""",
"depends" : ["base"],
"init_xml" : [],
"demo_xml" : [],
"demo_xml" : ["base_contact_demo.xml"],
"update_xml" : [
"security/ir.model.access.csv",
'base_contact_view.xml'

View File

@ -0,0 +1,326 @@
<?xml version="1.0" ?>
<terp>
<data>
<!-- Create the functions -->
<record id="res_partner_function_privateaddress0" model="res.partner.function">
<field eval="&quot;&quot;&quot;Private Address&quot;&quot;&quot;" name="name"/>
</record>
<!-- Create the contacts -->
<record id="res_partner_contact_mortier0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Benoit&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Mortier&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_jacot0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Laurent&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Jacot&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_passot0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Thomas&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Passot&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_lacarte0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Etienne&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Lacarte&quot;&quot;&quot;" name="name"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_tang0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Tang&quot;&quot;&quot;" name="name"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_wong0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Wong&quot;&quot;&quot;" name="name"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_lavente0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Jean-Guy&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Lavente&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_lelitre0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Sylvie&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Lelitre&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;Mss&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_grosbonnet0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Arthur&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Grosbonnet&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_lesbrouffe0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Karine&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Lesbrouffe&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;Ms.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_zen0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Zen&quot;&quot;&quot;" name="name"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_pinckears0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;http://fptiny.blogspot.com/&quot;&quot;&quot;" name="website"/>
<field eval="&quot;&quot;&quot;Fabien&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Pinckears&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_debois0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Cécile&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Debois&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;Mss&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_luu0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Phuong&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Luu&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;Ms.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_elkhayat0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Najlaâ&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;El Khayat&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;Ms.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_depaoli0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Quentin&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;De Paoli&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_semal0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Fabian&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Semal&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_vandewerve0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Alain&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;van de Werve&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_lambotte0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Frédéric&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Lambotte&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_laurent0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Olivier&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Laurent&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_simonis0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Christophe&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Simonis&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_wirtel0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Stéphane&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Wirtel&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_contact_mignon0" model="res.partner.contact">
<field eval="&quot;&quot;&quot;Philippe&quot;&quot;&quot;" name="first_name"/>
<field eval="&quot;&quot;&quot;Mignon&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;M.&quot;&quot;&quot;" name="title"/>
<field eval="1" name="active"/>
</record>
<!-- Create the addresses -->
<record id="base.main_address" model="res.partner.address">
<field eval="&quot;&quot;&quot;Grand-Rosière&quot;&quot;&quot;" name="city"/>
<field eval="&quot;&quot;&quot;+32.81.73.35.01&quot;&quot;&quot;" name="fax"/>
<field eval="&quot;&quot;&quot;1367&quot;&quot;&quot;" name="zip"/>
<field name="country_id" ref="base.be"/>
<field eval="&quot;&quot;&quot;+32.81.81.37.00&quot;&quot;&quot;" name="phone"/>
<field eval="&quot;&quot;&quot;Chaussée de Namur, 40&quot;&quot;&quot;" name="street"/>
</record>
<record id="res_partner_address_0" model="res.partner.address">
<field eval="&quot;&quot;&quot;Louvain-La-Neuve&quot;&quot;&quot;" name="city"/>
<field eval="&quot;&quot;&quot;1348&quot;&quot;&quot;" name="zip"/>
<field eval="&quot;&quot;&quot;contact&quot;&quot;&quot;" name="type"/>
<field name="country_id" ref="base.be"/>
<field eval="&quot;&quot;&quot;rue du pré, 115&quot;&quot;&quot;" name="street"/>
<field eval="1" name="active"/>
</record>
<record id="res_partner_address_1" model="res.partner.address">
<field eval="&quot;&quot;&quot;Charleroi&quot;&quot;&quot;" name="city"/>
<field eval="&quot;&quot;&quot;6000&quot;&quot;&quot;" name="zip"/>
<field eval="&quot;&quot;&quot;contact&quot;&quot;&quot;" name="type"/>
<field name="country_id" ref="base.be"/>
<field eval="&quot;&quot;&quot;Boulevars Tirou, 32&quot;&quot;&quot;" name="street"/>
<field eval="1" name="active"/>
</record>
<!-- Create the jobs -->
<record id="res_partner_job_0" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_1"/>
<field name="function_id" ref="base.function_sale"/>
<field name="contact_id" ref="res_partner_contact_mortier0"/>
<field name="sequence_partner">2</field>
</record>
<record id="res_partner_job_1" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_2"/>
<field name="function_id" ref="base.function_sale"/>
<field eval="&quot;&quot;&quot;contact@tecsas.fr&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_jacot0"/>
</record>
<record id="res_partner_job_2" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_3"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;info@mediapole.net&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_passot0"/>
</record>
<record id="res_partner_job_3" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_tang"/>
<field name="function_id" ref="base.function_sale"/>
<field name="contact_id" ref="res_partner_contact_tang0"/>
</record>
<record id="res_partner_job_4" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_wong"/>
<field name="function_id" ref="base.function_sale"/>
<field name="contact_id" ref="res_partner_contact_wong0"/>
</record>
<record id="res_partner_job_5" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_6"/>
<field name="function_id" ref="base.function_director"/>
<field name="contact_id" ref="res_partner_contact_lacarte0"/>
<field name="sequence_contact">1</field>
<field name="sequence_partner">0</field>
</record>
<record id="res_partner_job_6" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_7"/>
<field name="function_id" ref="base.function_sale"/>
<field name="contact_id" ref="res_partner_contact_lavente0"/>
</record>
<record id="res_partner_job_7" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_8"/>
<field name="function_id" ref="base.function_it"/>
<field name="contact_id" ref="res_partner_contact_lelitre0"/>
</record>
<record id="res_partner_job_8" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_9"/>
<field name="function_id" ref="base.function_director"/>
<field name="contact_id" ref="res_partner_contact_grosbonnet0"/>
</record>
<record id="res_partner_job_9" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_10"/>
<field name="function_id" ref="base.function_sale"/>
<field name="contact_id" ref="res_partner_contact_lesbrouffe0"/>
</record>
<record id="res_partner_job_10" model="res.partner.job">
<field name="address_id" ref="base.res_partner_address_zen"/>
<field name="function_id" ref="base.function_it"/>
<field name="contact_id" ref="res_partner_contact_zen0"/>
</record>
<record id="res_partner_job_11" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_sale"/>
<field eval="&quot;&quot;&quot;pmi@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_mignon0"/>
</record>
<record id="res_partner_job_12" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;stw@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_wirtel0"/>
</record>
<record id="res_partner_job_13" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;chs@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_simonis0"/>
</record>
<record id="res_partner_job_14" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;olt@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_laurent0"/>
</record>
<record id="res_partner_job_15" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;fla@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_lambotte0"/>
</record>
<record id="res_partner_job_16" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_sale"/>
<field eval="&quot;&quot;&quot;avw@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_vandewerve0"/>
</record>
<record id="res_partner_job_17" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;fbs@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_semal0"/>
</record>
<record id="res_partner_job_18" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;qdp@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_depaoli0"/>
</record>
<record id="res_partner_job_19" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;nel@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_elkhayat0"/>
</record>
<record id="res_partner_job_20" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_it"/>
<field eval="&quot;&quot;&quot;phu@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_luu0"/>
</record>
<record id="res_partner_job_21" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_director"/>
<field eval="&quot;&quot;&quot;fp@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_pinckears0"/>
<field name="sequence_partner">-1</field>
</record>
<record id="res_partner_job_22" model="res.partner.job">
<field name="address_id" ref="base.main_address"/>
<field name="function_id" ref="base.function_sale"/>
<field eval="&quot;&quot;&quot;cde@tinyerp.com&quot;&quot;&quot;" name="email"/>
<field name="contact_id" ref="res_partner_contact_debois0"/>
</record>
<record id="res_partner_job_23" model="res.partner.job">
<field name="address_id" ref="res_partner_address_0"/>
<field name="contact_id" ref="res_partner_contact_mortier0"/>
<field name="function_id" ref="res_partner_function_privateaddress0"/>
<field name="sequence_contact">5</field>
</record>
<record id="res_partner_job_24" model="res.partner.job">
<field eval="1" name="sequence_contact"/>
<field name="address_id" ref="res_partner_address_1"/>
<field name="contact_id" ref="res_partner_contact_lacarte0"/>
<field name="function_id" ref="res_partner_function_privateaddress0"/>
<field name="sequence_contact">5</field>
</record>
<record id="res_partner_job_25" model="res.partner.job">
<field eval="2" name="sequence_contact"/>
<field name="address_id" ref="base.res_partner_address_1"/>
<field name="contact_id" ref="res_partner_contact_lacarte0"/>
<field name="function_id" ref="base.function_director"/>
<field name="sequence_contact">1</field>
</record>
</data>
</terp>

View File

@ -31,11 +31,52 @@
import netsvc
from osv import fields, osv
def _format_iban(string):
'''
This function removes all characters from given 'string' that isn't a alpha numeric and converts it to lower case.
'''
res = ""
for char in string:
if char.isalnum():
res += char.lower()
return res
class res_partner_bank(osv.osv):
_inherit = "res.partner.bank"
_columns = {
'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"),
}
def create(self, cr, uid, vals, context={}):
#overwrite to format the iban number correctly
if vals.has_key('iban'):
vals['iban'] = _format_iban(vals['iban'])
return super(res_partner_bank, self).create(cr, uid, vals, context)
def write(self, cr, uid, ids, vals, context={}):
#overwrite to format the iban number correctly
if vals.has_key('iban'):
vals['iban'] = _format_iban(vals['iban'])
return super(res_partner_bank, self).write(cr, uid, ids, vals, context)
def check_iban(self, cr, uid, ids):
'''
Check the IBAN number
'''
for bank_acc in self.browse(cr, uid, ids):
if not bank_acc.iban:
continue
iban =_format_iban(bank_acc.iban)
#the four first digits have to be shifted to the end
iban = iban[4:] + iban[:4]
#letters have to be transformed into numbers (a = 10, b = 11, ...)
iban2 = ""
for char in iban:
if char.isalpha():
iban2 += str(ord(char)-87)
else:
iban2 += char
#iban is correct if modulo 97 == 1
if not int(iban2) % 97 == 1:
return False
return True
def name_get(self, cr, uid, ids, context=None):
res = []
@ -48,6 +89,50 @@ class res_partner_bank(osv.osv):
res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context)
return res
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
#overwrite the search method in order to search not only on bank type == basic account number but also on type == iban
res = super(res_partner_bank,self).search(cr, uid, args, offset, limit, order, context=context, count=count)
if filter(lambda x:x[0]=='acc_number' ,args):
#get the value of the search
iban_value = filter(lambda x:x[0]=='acc_number' ,args)[0][2]
#get the other arguments of the search
args1 = filter(lambda x:x[0]!='acc_number' ,args)
#add the new criterion
args1 += [('iban','ilike',iban_value)]
#append the results to the older search
res += super(res_partner_bank,self).search(cr, uid, args1, offset, limit,
order, context=context, count=count)
return res
def get_bban_from_iban(self, cr, uid, ids, context=None):
'''
This function returns the bank account number computed from the iban account number, thanks to the mapping_list dictionary that contains the rules associated to its country.
'''
res = {}
mapping_list = {
#TODO add rules for others countries
'be': lambda x: x[4:],
'fr': lambda x: x[14:],
'ch': lambda x: x[9:],
'gb': lambda x: x[14:],
}
for record in self.browse(cr, uid, ids, context):
if not record.iban:
res[record.id] = False
continue
res[record.id] = False
for code, function in mapping_list.items():
if record.iban.lower().startswith(code):
res[record.id] = function(record.iban)
break
return res
_columns = {
'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"),
}
_constraints = [(check_iban, "The IBAN number doesn't seem to be correct.", ["iban"])]
res_partner_bank()

View File

@ -264,7 +264,7 @@ class wizard_base_setup(wizard.interface):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'context':{'menu':True},
'target':'new',

View File

@ -4,7 +4,7 @@
"version":"1.0",
"author":"Tiny",
"category":"Board/Document",
"depends":["board","document2", "report_document"],
"depends":["board","document", "report_document"],
"demo_xml":["board_document_demo.xml"],
"update_xml":["board_document_view.xml"],
"description": """ This module implements a dashboard for Document """,

View File

@ -106,11 +106,11 @@ class crm_menu_config_wizard(osv.osv_memory):
tools.convert_xml_import(cr, 'crm_configuration', tools.file_open(os.path.join('crm_configuration',file_name )), {}, 'init', *args)
except Exception, e:
raise osv.except_osv('Error !', e)
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
@ -118,11 +118,11 @@ class crm_menu_config_wizard(osv.osv_memory):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
crm_menu_config_wizard()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- configartion view -->
<record id="view_config_crm_menu" model="ir.ui.view">
@ -38,7 +38,7 @@
</record>
<!-- register configuration wizard -->
<record id="config_wizard_step_case_section_menu" model="ir.module.module.configuration.step">
<record id="config_wizard_step_case_section_menu" model="ir.actions.todo">
<field name="name">Create Menu for CRM Case Section</field>
<field name="note">This Configuration step use to create Menu for Case Sections</field>
<field name="action_id" ref="action_view_config_crm_menu"/>

View File

@ -82,6 +82,25 @@ class stock_picking(osv.osv):
if not account_id:
account_id = picking.carrier_id.product_id.categ_id\
.property_account_income_categ.id
taxes = self.pool.get('account.tax').browse(cursor, user,
[x.id for x in picking.carrier_id.product_id.taxes_id])
taxep = None
partner_id=picking.address_id.partner_id and picking.address_id.partner_id.id or False
if partner_id:
taxep_id = self.pool.get('res.partner').property_get(cursor, user,partner_id,property_pref=['property_account_tax']).get('property_account_tax',False)
if taxep_id:
taxep=self.pool.get('account.tax').browse(cursor, user,taxep_id)
if not taxep or not taxep.id:
taxes_ids = [x.id for x in picking.carrier_id.product_id.taxes_id]
else:
res5 = [taxep.id]
for t in taxes:
if not t.tax_group==taxep.tax_group:
res5.append(t.id)
taxes_ids = res5
invoice_line_obj.create(cursor, user, {
'name': picking.carrier_id.name,
'invoice_id': invoice.id,
@ -90,9 +109,7 @@ class stock_picking(osv.osv):
'account_id': account_id,
'price_unit': price,
'quantity': 1,
'invoice_line_tax_id': [(6, 0,
[x.id for x in (picking.carrier_id.product_id.taxes_id
or [])])],
'invoice_line_tax_id': [(6, 0,taxes_ids)],
})
return result

View File

@ -65,16 +65,34 @@ def _delivery_set(self, cr, uid, data, context):
grid_id = pooler.get_pool(cr.dbname).get('delivery.carrier').grid_get(cr, uid, [data['form']['carrier_id']],order.partner_shipping_id.id)
if not grid_id:
raise wizard.except_wizard(_('No grid avaible !'), _('No grid matching for this carrier !'))
grid = pooler.get_pool(cr.dbname).get('delivery.grid').browse(cr, uid, [grid_id])[0]
grid_obj=pooler.get_pool(cr.dbname).get('delivery.grid')
grid = grid_obj.browse(cr, uid, [grid_id])[0]
taxes = pooler.get_pool(cr.dbname).get('account.tax').browse(cr, uid,
[x.id for x in grid.carrier_id.product_id.taxes_id])
taxep = None
partner_id=order.partner_id and order.partner_id.id or False
if partner_id:
taxep_id = pooler.get_pool(cr.dbname).get('res.partner').property_get(cr, uid,partner_id,property_pref=['property_account_tax']).get('property_account_tax',False)
if taxep_id:
taxep=pooler.get_pool(cr.dbname).get('account.tax').browse(cr, uid,taxep_id)
if not taxep or not taxep.id:
taxes_ids = [x.id for x in grid.carrier_id.product_id.taxes_id]
else:
res5 = [taxep.id]
for t in taxes:
if not t.tax_group==taxep.tax_group:
res5.append(t.id)
taxes_ids = res5
line_obj.create(cr, uid, {
'order_id': order.id,
'name': grid.carrier_id.name,
'product_uom_qty': 1,
'product_uom': grid.carrier_id.product_id.uom_id.id,
'product_id': grid.carrier_id.product_id.id,
'price_unit': grid.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
'tax_id': [(6,0,[ x.id for x in grid.carrier_id.product_id.taxes_id])],
'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
'tax_id': [(6,0,taxes_ids)],
'type': 'make_to_stock'
})

View File

@ -0,0 +1,8 @@
To be done:
-----------
* Test to not create several times the same file / directory
-> May be put a sql_constraints uniq on several files
-> test through remove or put
* Retest everything

View File

@ -0,0 +1,30 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import document
import ftpserver

View File

@ -0,0 +1,21 @@
#
# Use the custom module to put your specific code in a separate module.
#
{
"name" : "Integrated Document Management System",
"version" : "1.0",
"author" : "Tiny",
"category" : "Generic Modules/Others",
"website": "http://www.tinyerp.com",
"description": """This is a complete document management system:
* FTP Interface
* User Authentification
* Document Indexation
""",
"depends" : ["base", "process"],
"init_xml" : ["document_data.xml"],
"update_xml" : ["document_view.xml"],
"demo_xml" : ["document_demo.xml"],
"active": False,
"installable": True
}

View File

@ -0,0 +1,34 @@
import time
import os
import StringIO
import odt2txt
#
# This should be the indexer
#
def content_index(content, filename=None, content_type=None):
fname,ext = os.path.splitext(filename)
result = ''
if ext in ('.doc'): #or content_type ?
(stdin,stdout) = os.popen2('antiword -', 'b')
stdin.write(content)
stdin.close()
result = stdout.read().decode('latin1','replace').encode('utf-8','replace')
elif ext == '.pdf':
fname = os.tempnam(filename)+'.pdf'
fp = file(fname,'wb')
fp.write(content)
fp.close()
fp = os.popen('pdftotext -enc UTF-8 -nopgbrk '+fname+' -', 'r')
result = fp.read()
fp.close()
elif ext in ('.xls','.ods','.odt','.odp'):
s = StringIO.StringIO(content)
o = odt2txt.OpenDocumentTextFile(s)
result = o.toString().encode('ascii','replace')
s.close()
elif ext in ('.txt','.py','.patch','.html','.csv','.xml'):
result = content
else:
result = content
return result

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<terp>
<data>
</data>
</terp>

View File

@ -0,0 +1,12 @@
<terp>
<data>
<record model="res.groups" id="group_compta_user">
<field name="name">grcompta</field>
</record>
<record model="res.groups" id="group_compta_admin">
<field name="name">grcomptaadmin</field>
</record>
<menuitem name="Administration" groups="admin,grcomptaadmin" icon="terp-stock" id="menu_admin_compta"/>
</data>
</terp>

594
addons/document/document.py Normal file
View File

@ -0,0 +1,594 @@
#############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import base64
from osv import osv, fields
from osv.orm import except_orm
import urlparse
import os
import pooler
from content_index import content_index
# Unsupported WebDAV Commands:
# label
# search
# checkin
# checkout
# propget
# propset
#
# An object that represent an uri
# path: the uri of the object
# content: the Content it belongs to (_print.pdf)
# type: content or collection
# content: objct = res.partner
# collection: object = directory, object2 = res.partner
# file: objct = ir.attachement
# root: if we are at the first directory of a ressource
#
INVALID_CHARS={'*':str(hash('*')), '|':str(hash('|')) , "\\":str(hash("\\")), '/':'__', ':':str(hash(':')), '"':str(hash('"')), '<':str(hash('<')) , '>':str(hash('>')) , '?':str(hash('?'))}
class node_class(object):
def __init__(self, cr, uid, path,object,object2=False, context={}, content=False, type='collection', root=False):
self.cr = cr
self.uid = uid
self.path = path
self.object = object
self.object2 = object2
self.context = context
self.content = content
self.type=type
self.root=root
def _file_get(self, nodename=False):
if not self.object:
return []
pool = pooler.get_pool(self.cr.dbname)
fobj = pool.get('ir.attachment')
res2 = []
where = []
if self.object2:
where.append( ('res_model','=',self.object2._name) )
where.append( ('res_id','=',self.object2.id) )
for content in self.object.content_ids:
test_nodename = self.object2.name + (content.suffix or '') + (content.extension or '')
if test_nodename.find('/'):
test_nodename=test_nodename.replace('/', '_')
path = self.path+'/'+test_nodename
#path = self.path+'/'+self.object2.name + (content.suffix or '') + (content.extension or '')
if not nodename:
n = node_class(self.cr, self.uid,path, self.object2, False, content=content, type='content', root=False)
res2.append( n)
else:
if nodename == test_nodename:
n = node_class(self.cr, self.uid, path, self.object2, False, content=content, type='content', root=False)
res2.append(n)
else:
where.append( ('parent_id','=',self.object.id) )
where.append( ('res_id','=',False) )
if nodename:
where.append( (fobj._rec_name,'=',nodename) )
ids = fobj.search(self.cr, self.uid, where+[ ('parent_id','=',self.object and self.object.id or False) ], context=self.context)
if self.object and self.root and (self.object.type=='ressource'):
ids += fobj.search(self.cr, self.uid, where+[ ('parent_id','=',False) ], context=self.context)
res = fobj.browse(self.cr, self.uid, ids, context=self.context)
return map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name, x, False, type='file', root=False), res) + res2
def directory_list_for_child(self,nodename,parent=False):
pool = pooler.get_pool(self.cr.dbname)
where = []
if nodename:
where.append(('name','=',nodename))
if (self.object and self.object.type=='directory') or not self.object2:
where.append(('parent_id','=',self.object and self.object.id or False))
else:
where.append(('parent_id','=',False))
if self.object:
where.append(('ressource_parent_type_id','=',self.object.ressource_type_id.id))
else:
where.append(('ressource_parent_type_id','=',False))
ids = pool.get('document.directory').search(self.cr, self.uid, where+[('ressource_id','=',0)], self.context)
if self.object2:
ids += pool.get('document.directory').search(self.cr, self.uid, where+[('ressource_id','=',self.object2.id)], self.context)
res = pool.get('document.directory').browse(self.cr, self.uid, ids,self.context)
return res
def _child_get(self, nodename=False):
if self.type not in ('collection','database'):
return []
res = self.directory_list_for_child(nodename)
result= map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name, x, x.type=='directory' and self.object2 or False, root=self.root), res)
if self.type=='database':
pool = pooler.get_pool(self.cr.dbname)
fobj = pool.get('ir.attachment')
vargs = [('parent_id','=',False),('res_id','=',False)]
if nodename:
vargs.append(('name','=',nodename))
file_ids=fobj.search(self.cr,self.uid,vargs)
res = fobj.browse(self.cr, self.uid, file_ids, context=self.context)
result +=map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name, x, False, type='file', root=self.root), res)
if self.type=='collection' and self.object.type=="ressource":
where = self.object.domain and eval(self.object.domain, {'active_id':self.root}) or []
pool = pooler.get_pool(self.cr.dbname)
obj = pool.get(self.object.ressource_type_id.model)
if self.object.ressource_tree:
if obj._parent_name in obj.fields_get(self.cr,self.uid):
where.append((obj._parent_name,'=',self.object2 and self.object2.id or False))
else :
if self.object2:
return result
else:
if self.object2:
return result
name_for = obj._name.split('.')[-1]
if nodename and nodename.find(name_for) == 0 :
id = int(nodename.replace(name_for,''))
where.append(('id','=',id))
elif nodename:
if nodename.find('__') :
nodename=nodename.replace('__','/')
for invalid in INVALID_CHARS:
if nodename.find(INVALID_CHARS[invalid]) :
nodename=nodename.replace(INVALID_CHARS[invalid],invalid)
where.append(('name','=',nodename))
ids = obj.search(self.cr, self.uid, where, self.context)
res = obj.browse(self.cr, self.uid, ids,self.context)
for r in res:
if not r.name:
r.name = name_for+'%d'%r.id
for invalid in INVALID_CHARS:
if r.name.find(invalid) :
r.name=r.name.replace(invalid,INVALID_CHARS[invalid])
result2 = map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name.replace('/','__'), self.object, x, root=r.id), res)
if result2:
result = result2
return result
def children(self):
return self._child_get() + self._file_get()
def child(self, name):
res = self._child_get(name)
if res:
return res[0]
res = self._file_get(name)
if res:
return res[0]
return None
def path_get(self):
path = self.path
if self.path[0]=='/':
path = self.path[1:]
return path
class document_directory(osv.osv):
_name = 'document.directory'
_description = 'Document directory'
_columns = {
'name': fields.char('Name', size=64, required=True, select=1),
'write_date': fields.datetime('Date Modified', readonly=True),
'write_uid': fields.many2one('res.users', 'Last Modification User', readonly=True),
'create_date': fields.datetime('Date Created', readonly=True),
'create_uid': fields.many2one('res.users', 'Creator', readonly=True),
'file_type': fields.char('Content Type', size=32),
'domain': fields.char('Domain', size=128),
'user_id': fields.many2one('res.users', 'Owner'),
'group_ids': fields.many2many('res.groups', 'document_directory_group_rel', 'item_id', 'group_id', 'Groups'),
'parent_id': fields.many2one('document.directory', 'Parent Item'),
'child_ids': fields.one2many('document.directory', 'parent_id', 'Childs'),
'file_ids': fields.one2many('ir.attachment', 'parent_id', 'Files'),
'content_ids': fields.one2many('document.directory.content', 'directory_id', 'Virtual Files'),
'type': fields.selection([('directory','Static Directory'),('ressource','Other Ressources')], 'Type', required=True),
'ressource_type_id': fields.many2one('ir.model', 'Childs Model'),
'ressource_parent_type_id': fields.many2one('ir.model', 'Linked Model'),
'ressource_id': fields.integer('Ressource ID'),
'ressource_tree': fields.boolean('Tree Structure'),
}
_defaults = {
'user_id': lambda self,cr,uid,ctx: uid,
'domain': lambda self,cr,uid,ctx: '[]',
'type': lambda *args: 'directory',
}
_sql_constraints = [
('dirname_uniq', 'unique (name,parent_id,ressource_id,ressource_parent_type_id)', 'The directory name must be unique !')
]
def get_resource_path(self,cr,uid,res_model,res_id):
# to be need test
path=[]
def _parent(dir_id):
parent=self.browse(cr,uid,dir_id)
if parent.parent_id:
_parent(parent.parent_id.id)
else:
path.append(parent.name)
return path
model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)])
directory_ids=self.search(cr,uid,[('ressource_type_id','=',model_ids[0]),('ressource_id','=',res_id)])
if len(directory_ids):
path=parent(directory_ids[0])
direc=self.browse(cr,uid,directory_ids)[0]
path.append(direc.name)
path.append(self.pool.get(direc.ressource_type_id.model).browse(cr,uid,res_id).name)
return "ftp://localhost:8021/"+cr.dbname+'/'.join(path)
return False
def _check_duplication(self, cr, uid,vals):
if 'name' in vals:
where=" name='%s'"% (vals['name'])
if not 'parent_id' in vals or not vals['parent_id']:
where+=' and parent_id is null'
else:
where+=' and parent_id=%d'%(vals['parent_id'])
if not 'ressource_parent_type_id' in vals or not vals['ressource_parent_type_id']:
where+= ' and ressource_parent_type_id is null'
else:
where+=" and ressource_parent_type_id='%s'"%(vals['ressource_parent_type_id'])
# if not 'ressource_id' in vals or not vals['ressource_id']:
# where+= ' and ressource_id is null'
# else:
# where+=" and ressource_id=%d"%(vals['ressource_id'])
cr.execute("select id from document_directory where" + where)
res = cr.fetchall()
if len(res):
return False
return True
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
cr.execute('select distinct parent_id from document_directory where id in ('+','.join(map(str,ids))+')')
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
level -= 1
return True
_constraints = [
(_check_recursion, 'Error! You can not create recursive Directories.', ['parent_id'])
]
def __init__(self, *args, **kwargs):
res = super(document_directory, self).__init__(*args, **kwargs)
self._cache = {}
return res
def onchange_content_id(self, cr, uid, ids, ressource_type_id):
return {}
def _get_childs(self, cr, uid, node, nodename=False, context={}):
where = []
if nodename:
where.append(('name','=',nodename))
if object:
where.append(('parent_id','=',object.id))
ids = self.search(cr, uid, where, context)
return self.browse(cr, uid, ids, context), False
"""
PRE:
uri: of the form "Sales Order/SO001"
PORT:
uri
object: the object.directory or object.directory.content
object2: the other object linked (if object.directory.content)
"""
def get_object(self, cr, uid, uri, context={}):
if not uri:
return node_class(cr, uid, '', False, type='database')
turi = tuple(uri)
if False and (turi in self._cache):
(path, oo, oo2, content,type,root) = self._cache[turi]
if oo:
object = self.pool.get(oo[0]).browse(cr, uid, oo[1], context)
else:
object = False
if oo2:
object2 = self.pool.get(oo2[0]).browse(cr, uid, oo2[1], context)
else:
object2 = False
node = node_class(cr, uid, path, object,object2, context, content, type, root)
return node
node = node_class(cr, uid, '/', False, type='database')
for path in uri[:]:
if path:
node = node.child(path)
if not node:
return False
oo = node.object and (node.object._name, node.object.id) or False
oo2 = node.object2 and (node.object2._name, node.object2.id) or False
self._cache[turi] = (node.path, oo, oo2, node.content,node.type,node.root)
return node
def get_childs(self, cr, uid, uri, context={}):
node = self.get_object(cr, uid, uri, context)
if uri:
children = node.children()
else:
children= [node]
result = map(lambda node: node.path_get(), children)
#childs,object2 = self._get_childs(cr, uid, object, False, context)
#result = map(lambda x: urlparse.urljoin(path+'/',x.name), childs)
return result
def write(self, cr, uid, ids, vals, context=None):
if not self._check_duplication(cr,uid,vals):
raise except_orm('ValidateError', 'Directory name must be unique!')
return super(document_directory,self).write(cr,uid,ids,vals,context=context)
def copy(self, cr, uid, id, default=None, context=None):
if not default:
default ={}
name = self.read(cr, uid, [id])[0]['name']
default.update({'name': name+ " (copy)"})
return super(document_directory,self).copy(cr,uid,id,default,context)
def create(self, cr, uid, vals, context=None):
if not self._check_duplication(cr,uid,vals):
raise except_orm('ValidateError', 'Directory name must be unique!')
if vals.get('name',False) and (vals.get('name').find('/')+1 or vals.get('name').find('@')+1 or vals.get('name').find('$')+1 or vals.get('name').find('#')+1) :
raise 'Error'
return super(document_directory,self).create(cr, uid, vals, context)
document_directory()
class document_directory_node(osv.osv):
_inherit = 'process.node'
_columns = {
'directory_id': fields.many2one('document.directory', 'Document directory', ondelete="set null"),
}
document_directory_node()
class document_directory_content(osv.osv):
_name = 'document.directory.content'
_description = 'Directory Content'
_order = "sequence"
_columns = {
'name': fields.char('Content Name', size=64, required=True),
'sequence': fields.integer('Sequence', size=16),
'suffix': fields.char('Suffix', size=16),
'versioning': fields.boolean('Versioning'),
'report_id': fields.many2one('ir.actions.report.xml', 'Report', required=True),
'extension': fields.selection([('.pdf','.pdf'),('','None')], 'Extension', required=True),
'directory_id': fields.many2one('document.directory', 'Directory')
}
_defaults = {
'extension': lambda *args: '',
'sequence': lambda *args: 1
}
document_directory_content()
class ir_action_report_xml(osv.osv):
_name="ir.actions.report.xml"
_inherit ="ir.actions.report.xml"
def _model_get(self, cr, uid, ids, name, arg, context):
res = {}
model_pool = self.pool.get('ir.model')
for data in self.read(cr,uid,ids,['model']):
model = data.get('model',False)
if model:
model_id =model_pool.search(cr,uid,[('model','=',model)])
if model_id:
res[data.get('id')] = model_id[0]
else:
res[data.get('id')] = False
return res
def _model_search(self, cr, uid, obj, name, args):
if not len(args):
return []
model_id= args[0][2]
if not model_id:
return []
model = self.pool.get('ir.model').read(cr,uid,[model_id])[0]['model']
report_id = self.search(cr,uid,[('model','=',model)])
if not report_id:
return [('id','=','0')]
return [('id','in',report_id)]
_columns={
'model_id' : fields.function(_model_get,fnct_search=_model_search,method=True,string='Model Id'),
}
ir_action_report_xml()
import random
import string
def random_name():
random.seed()
d = [random.choice(string.letters) for x in xrange(10) ]
name = "".join(d)
return name
def create_directory(path):
dir_name = random_name()
path = os.path.join(path,dir_name)
os.mkdir(path)
return dir_name
class document_file(osv.osv):
_inherit = 'ir.attachment'
def _data_get(self, cr, uid, ids, name, arg, context):
result = {}
cr.execute('select id,store_method,datas,store_fname,link from ir_attachment where id in ('+','.join(map(str,ids))+')')
for id,m,d,r,l in cr.fetchall():
if m=='db':
result[id] = d
elif m=='fs':
try:
path = os.path.join(os.getcwd(),'filestore')
value = file(os.path.join(path,r), 'rb').read()
result[id] = base64.encodestring(value)
except:
result[id]=''
else:
result[id] = ''
return result
#
# This code can be improved
#
def _data_set(self, cr, obj, id, name, value, uid=None, context={}):
if not value:
return True
if (not context) or context.get('store_method','fs')=='fs':
path = os.path.join(os.getcwd(), "filestore")
if not os.path.isdir(path):
os.mkdir(path)
flag = None
# This can be improved
for dirs in os.listdir(path):
if os.path.isdir(os.path.join(path,dirs)) and len(os.listdir(os.path.join(path,dirs)))<4000:
flag = dirs
break
flag = flag or create_directory(path)
filename = random_name()
fname = os.path.join(path, flag, filename)
fp = file(fname,'wb')
v = base64.decodestring(value)
fp.write(v)
filesize = os.stat(fname).st_size
cr.execute('update ir_attachment set store_fname=%s,store_method=%s,file_size=%d where id=%d', (os.path.join(flag,filename),'fs',len(v),id))
else:
cr.execute('update ir_attachment set datas=%s,store_method=%s where id=%d', (psycopg.Binary(value),'db',id))
return True
_columns = {
'user_id': fields.many2one('res.users', 'Owner', select=1),
'group_ids': fields.many2many('res.groups', 'document_directory_group_rel', 'item_id', 'group_id', 'Groups'),
'parent_id': fields.many2one('document.directory', 'Directory', select=1),
'file_size': fields.integer('File Size', required=True),
'file_type': fields.char('Content Type', size=32),
'index_content': fields.text('Indexed Content'),
'write_date': fields.datetime('Date Modified', readonly=True),
'write_uid': fields.many2one('res.users', 'Last Modification User', readonly=True),
'create_date': fields.datetime('Date Created', readonly=True),
'create_uid': fields.many2one('res.users', 'Creator', readonly=True),
'store_method': fields.selection([('db','Database'),('fs','Filesystem'),('link','Link')], "Storing Method"),
'datas': fields.function(_data_get,method=True,store=True,fnct_inv=_data_set,string='File Content',type="binary"),
'store_fname': fields.char('Stored Filename', size=200),
'res_model': fields.char('Attached Model', size=64), #res_model
'res_id': fields.integer('Attached ID'), #res_id
'partner_id':fields.many2one('res.partner', 'Partner', select=1),
'title': fields.char('Resource Title',size=64),
}
_defaults = {
'user_id': lambda self,cr,uid,ctx:uid,
'file_size': lambda self,cr,uid,ctx:0,
'store_method': lambda *args: 'db'
}
_sql_constraints = [
('filename_uniq', 'unique (name,parent_id,res_id,res_model)', 'The file name must be unique !')
]
def _check_duplication(self, cr, uid,vals):
if 'name' in vals:
res=self.search(cr,uid,[('name','=',vals['name']),('parent_id','=','parent_id' in vals and vals['parent_id'] or False),('res_id','=','res_id' in vals and vals['res_id'] or False),('res_model','=','res_model' in vals and vals['res_model']) or False])
if len(res):
return False
return True
def write(self, cr, uid, ids, vals, context=None):
if not self._check_duplication(cr,uid,vals):
raise except_orm('ValidateError', 'File name must be unique!')
result = super(document_file,self).write(cr,uid,ids,vals,context=context)
try:
for f in self.browse(cr, uid, ids, context=context):
if 'datas' not in vals:
vals['datas']=f.datas
res = content_index(base64.decodestring(vals['datas']), f.datas_fname, f.file_type or None)
super(document_file,self).write(cr, uid, ids, {
'index_content': res
})
except:
pass
return result
def create(self, cr, uid, vals, context={}):
vals['title']=vals['name']
if vals.get('res_id', False) and vals.get('res_model',False):
obj_model=self.pool.get(vals['res_model'])
result = obj_model.read(cr, uid, [vals['res_id']], context=context)
if len(result):
obj=result[0]
vals['title'] = (obj['name'] or '')[:60]
if obj_model._name=='res.partner':
vals['partner_id']=obj['id']
elif 'address_id' in obj:
address=self.pool.get('res.partner.address').read(cr,uid,[obj['address_id']],context=context)
if len(address):
vals['partner_id']=address[0]['partner_id'] or False
elif 'partner_id' in obj:
if isinstance(obj['partner_id'],tuple) or isinstance(obj['partner_id'],list):
vals['partner_id']=obj['partner_id'][0]
else:
vals['partner_id']=obj['partner_id']
datas=None
if 'datas' not in vals:
import urllib
datas=base64.encodestring(urllib.urlopen(vals['link']).read())
else:
datas=vals['datas']
vals['file_size']= len(datas)
if not self._check_duplication(cr,uid,vals):
raise except_orm('ValidateError', 'File name must be unique!')
result = super(document_file,self).create(cr, uid, vals, context)
cr.commit()
try:
res = content_index(base64.decodestring(datas), vals['datas_fname'], vals.get('content_type', None))
super(document_file,self).write(cr, uid, [result], {
'index_content': res,
})
cr.commit()
except:
pass
return result
def unlink(self,cr, uid, ids, context={}):
for f in self.browse(cr, uid, ids, context):
if f.store_method=='fs':
try:
path = os.path.join(os.getcwd(),'filestore',f.store_fname)
os.unlink(path)
except:
pass
return super(document_file, self).unlink(cr, uid, ids, context)
document_file()

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<terp>
<data noupdate="1">
</data>
</terp>

View File

@ -0,0 +1,93 @@
<?xml version="1.0"?>
<terp>
<data noupdate="1">
<record model="document.directory" id="dir_root">
<field name="name">Main Repository</field>
<field name="user_id" ref="base.user_admin"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_my_folder">
<field name="name">My Folder</field>
<field name="parent_id" ref="dir_root"/>
<field name="user_id" ref="base.user_admin"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_partner_category">
<field name="name">Partner Category</field>
<field name="parent_id" ref="dir_root"/>
<field name="type">ressource</field>
<field name="ressource_tree">1</field>
<field name="ressource_type_id" search="[('model','=','res.partner.category')]" />
<field name="user_id" ref="base.user_admin"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_partner">
<field name="name">Partner</field>
<field name="type">ressource</field>
<field name="domain">[('category_id','in',[active_id])]</field>
<field name="ressource_type_id" search="[('model','=','res.partner')]" />
<field name="ressource_parent_type_id" search="[('model','=','res.partner.category')]" />
<field name="user_id" ref="base.user_admin"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_partner_contacts">
<field name="name">Contacts</field>
<field name="type">ressource</field>
<field name="domain">[('partner_id','=',active_id)]</field>
<field name="ressource_type_id" search="[('model','=','res.partner.address')]" />
<field name="ressource_parent_type_id" search="[('model','=','res.partner')]" />
<field name="user_id" ref="base.user_admin"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_my_partner">
<field name="name">My Folder</field>
<field name="user_id" ref="base.user_admin"/>
<field name="ressource_parent_type_id" search="[('model','=','res.partner')]" />
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_personnal_folder">
<field name="name">Personnal Folders</field>
<field name="parent_id" ref="dir_root"/>
<field name="user_id" ref="base.user_admin"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_sale_order">
<field name="name">Sales Order</field>
<field name="user_id" ref="base.user_admin"/>
<field name="parent_id" ref="dir_root"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_sale_order_all">
<field name="name">All Sales Order</field>
<field name="user_id" ref="base.user_admin"/>
<field name="parent_id" ref="dir_sale_order"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_sale_order_salesman">
<field name="name">Sales by Salesman</field>
<field name="user_id" ref="base.user_admin"/>
<field name="parent_id" ref="dir_sale_order"/>
<field name="ressource_id" eval="0"/>
</record>
<record model="document.directory" id="dir_project">
<field name="name">Projects</field>
<field name="user_id" ref="base.user_admin"/>
<field name="parent_id" ref="dir_root"/>
<field name="ressource_id" eval="0"/>
</record>
</data>
</terp>

View File

@ -0,0 +1,203 @@
<terp>
<data>
<menuitem name="Document Management" icon="terp-stock" id="menu_document"/>
<record model="ir.ui.view" id="view_document_directory_form">
<field name="name">document.directory</field>
<field name="model">document.directory</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Directories">
<notebook>
<page string="Definition">
<field name="name" select="1" colspan="4"/>
<field name="user_id"/>
<field name="parent_id"/>
<separator string="Directory Type" colspan="4"/>
<field name="type"/>
<field name="ressource_type_id" on_change="onchange_content_id(ressource_type_id)"/>
<newline/>
<field name="domain"/>
<field name="ressource_tree"/>
<field name="ressource_id" select="2"/>
<field name="ressource_parent_type_id"/>
<separator string="Contents" colspan="4"/>
<field name="content_ids" nolabel="1" colspan="4">
<form string="Contents">
<field name="name"/>
<field name="sequence"/>
<field name="suffix"/>
<field name="extension"/>
<field name="report_id" domain="[('model_id','=',parent.ressource_type_id)]"/>
</form>
<tree string="Contents">
<field name="sequence"/>
<field name="name"/>
<field name="suffix"/>
<field name="extension"/>
<field name="report_id"/>
</tree>
</field>
</page><page string="Security">
<field name="group_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_document_directory_tree">
<field name="name">document.directory</field>
<field name="model">document.directory</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Directories">
<field name="name"/>
<field name="type"/>
<field name="user_id"/>
<field name="create_date"/>
<field name="write_date"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_document_directory_form">
<field name="type">ir.actions.act_window</field>
<field name="res_model">document.directory</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
name="Document Management/Configuration/Directories"
action="action_document_directory_form"
id="menu_document_directories"/>
<record model="ir.actions.act_window" id="action_document_directory_tree">
<field name="type">ir.actions.act_window</field>
<field name="res_model">document.directory</field>
<field name="view_type">tree</field>
<field name="domain">[('ressource_parent_type_id','=',False),('parent_id','=',False)]</field>
</record>
<menuitem
name="Document Management/Directorie's Structure"
action="action_document_directory_tree"
id="menu_document_directories_tree"/>
<record model="ir.ui.view" id="view_document_file_form">
<field name="name">ir.attachment</field>
<field name="model">ir.attachment</field>
<field name="priority" eval="1"/>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Files">
<notebook>
<page string="Definition">
<field name="name" select="1" colspan="4"/>
<field name="title" select="1" colspan="4"/>
<newline/>
<field name="datas"/>
<field name="file_size"/>
<newline/>
<field name="parent_id"/>
<newline/>
<field name="user_id"/>
<field name="partner_id"/>
<newline/>
<field name="create_date"/>
<field name="create_uid"/>
<field name="write_date"/>
<field name="write_uid"/>
</page><page string="Indexed Content">
<field name="index_content" nolabel="1" colspan="4" select="1"/>
</page><page string="Security">
<field name="group_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_document_file_tree">
<field name="name">ir.attachment</field>
<field name="model">ir.attachment</field>
<field name="type">tree</field>
<field name="priority" eval="1"/>
<field name="arch" type="xml">
<tree string="Files">
<field name="name"/>
<field name="title" />
<field name="partner_id"/>
<field name="file_size"/>
<field name="user_id"/>
<field name="write_date"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_document_file_form">
<field name="type">ir.actions.act_window</field>
<field name="res_model">ir.attachment</field>
<field name="view_type">form</field>
</record>
<menuitem
name="Document Management/Search a File"
action="action_document_file_form"
id="menu_document_files"/>
<record model="ir.actions.act_window" id="action_document_file_directory_form">
<field name="type">ir.actions.act_window</field>
<field name="res_model">ir.attachment</field>
<field name="view_type">form</field>
<field name="domain">[('parent_id','=',active_id)]</field>
</record>
<record model="ir.values" id="ir_action_document_file_directory_form">
<field name="key2" eval="'tree_but_open'"/>
<field name="model" eval="'document.directory'"/>
<field name="name">Browse Files</field>
<field name="value" eval="'ir.actions.act_window,%d'%action_document_file_directory_form"/>
<field name="object" eval="True"/>
</record>
<record model="ir.ui.view" id="view_attachment_form_inherit">
<field name="name">ir.attachment.view.inherit</field>
<field name="model">ir.attachment</field>
<field name="inherit_id" ref="base.view_attachment_form"/>
<field name="arch" type="xml">
<field name="datas_fname" position = "replace" >
</field>
</field>
</record>
<record model="ir.ui.view" id="view_process_node_form_inherit1">
<field name="name">process.node.form</field>
<field name="model">process.node</field>
<field name="type">form</field>
<field name="inherit_id" ref="process.view_process_node_form"/>
<field name="priority" eval="1"/>
<field name="arch" type="xml">
<field name="subflow_id" position="after">
<field name="directory_id"/>
<newline/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_process_form_inherit1">
<field name="name">process.process.form</field>
<field name="model">process.process</field>
<field name="type">form</field>
<field name="inherit_id" ref="process.view_process_form"/>
<field name="priority" eval="1"/>
<field name="arch" type="xml">
<field name="subflow_id" position="after">
<field name="directory_id"/>
<newline/>
</field>
</field>
</record>
</data>
</terp>

View File

@ -0,0 +1,22 @@
import threading
import ftpserver
import authorizer
import abstracted_fs
PORT = 8021
HOST = ''
class ftp_server(threading.Thread):
def run(self):
autho = authorizer.authorizer()
ftpserver.FTPHandler.authorizer = autho
ftpserver.max_cons = 300
ftpserver.max_cons_per_ip = 50
ftpserver.FTPHandler.abstracted_fs = abstracted_fs.abstracted_fs
address = (HOST, PORT)
ftpd = ftpserver.FTPServer(address, ftpserver.FTPHandler)
ftpd.serve_forever()
ds = ftp_server()
ds.start()

View File

@ -0,0 +1,751 @@
import os
import time
from tarfile import filemode
import StringIO
import base64
import glob
import fnmatch
import pooler
import netsvc
import posix
from service import security
class abstracted_fs:
"""A class used to interact with the file system, providing a high
level, cross-platform interface compatible with both Windows and
UNIX style filesystems.
It provides some utility methods and some wraps around operations
involved in file creation and file system operations like moving
files or removing directories.
Instance attributes:
- (str) root: the user home directory.
- (str) cwd: the current working directory.
- (str) rnfr: source file to be renamed.
"""
# Ok
def db_list(self):
s = netsvc.LocalService('db')
result = s.list()
self.db_name_list=[]
for db_name in result:
db = pooler.get_db_only(db_name)
cr = db.cursor()
cr.execute("select id from ir_module_module where name like 'document%' and state='installed' ")
res=cr.fetchone()
if res and len(res):
self.db_name_list.append(db_name)
cr.close()
return self.db_name_list
# Ok
def __init__(self):
self.root = None
self.cwd = '/'
self.rnfr = None
# --- Pathname / conversion utilities
# Ok
def ftpnorm(self, ftppath):
"""Normalize a "virtual" ftp pathname (tipically the raw string
coming from client) depending on the current working directory.
Example (having "/foo" as current working directory):
'x' -> '/foo/x'
Note: directory separators are system independent ("/").
Pathname returned is always absolutized.
"""
if os.path.isabs(ftppath):
p = os.path.normpath(ftppath)
else:
p = os.path.normpath(os.path.join(self.cwd, ftppath))
# normalize string in a standard web-path notation having '/'
# as separator.
p = p.replace("\\", "/")
# os.path.normpath supports UNC paths (e.g. "//a/b/c") but we
# don't need them. In case we get an UNC path we collapse
# redundant separators appearing at the beginning of the string
while p[:2] == '//':
p = p[1:]
# Anti path traversal: don't trust user input, in the event
# that self.cwd is not absolute, return "/" as a safety measure.
# This is for extra protection, maybe not really necessary.
if not os.path.isabs(p):
p = "/"
return p
# Ok
def ftp2fs(self, path_orig, data):
path = self.ftpnorm(path_orig)
if path and path=='/':
return None
path2 = filter(None,path.split('/'))[1:]
(cr, uid, pool) = data
res = pool.get('document.directory').get_object(cr, uid, path2[:])
if not res:
raise OSError(2, 'Not such file or directory.')
return res
# Ok
def fs2ftp(self, node):
res = node and ('/' + node.cr.dbname + '/' + node.path) or '/'
return res
# Ok
def validpath(self, path):
"""Check whether the path belongs to user's home directory.
Expected argument is a "real" filesystem pathname.
If path is a symbolic link it is resolved to check its real
destination.
Pathnames escaping from user's root directory are considered
not valid.
"""
return path and True or False
# --- Wrapper methods around open() and tempfile.mkstemp
# Ok
def create(self, node, objname, mode):
try:
class file_wrapper(StringIO.StringIO):
def __init__(self, sstr='', ressource_id=False, dbname=None, uid=1, name=''):
StringIO.StringIO.__init__(self, sstr)
self.ressource_id = ressource_id
self.name = name
self.dbname = dbname
self.uid = uid
def close(self, *args, **kwargs):
db,pool = pooler.get_db_and_pool(self.dbname)
cr = db.cursor()
uid =self.uid
val = self.getvalue()
val2 = {
'datas': base64.encodestring(val),
'file_size': len(val),
}
pool.get('ir.attachment').write(cr, uid, [self.ressource_id], val2)
cr.commit()
StringIO.StringIO.close(self, *args, **kwargs)
cr = node.cr
uid = node.uid
pool = pooler.get_pool(cr.dbname)
fobj = pool.get('ir.attachment')
ext = objname.find('.') >0 and objname.split('.')[1] or False
# TODO: test if already exist and modify in this case if node.type=file
### checked already exits
object2=node and node.object2 or False
object=node and node.object or False
cid=False
where=[('name','=',objname)]
if object and (object.type in ('directory','ressource')) or object2:
where.append(('parent_id','=',object.id))
else:
where.append(('parent_id','=',False))
if object2:
where +=[('res_id','=',object2.id),('res_model','=',object2._name)]
cids = fobj.search(cr, uid,where)
if len(cids):
cid=cids[0]
if not cid:
val = {
'name': objname,
'datas_fname': objname,
'datas': '',
'file_size': 0L,
'file_type': ext,
}
if object and (object.type in ('directory','ressource')) or not object2:
val['parent_id']= object and object.id or False
partner = False
if object2:
if 'partner_id' in object2 and object2.partner_id.id:
partner = object2.partner_id.id
if object2._name == 'res.partner':
partner = object2.id
val.update( {
'res_model': object2._name,
'partner_id': partner,
'res_id': object2.id
})
cid = fobj.create(cr, uid, val, context={})
cr.commit()
s = file_wrapper('', cid, cr.dbname, uid, )
return s
except Exception,e:
print e
raise OSError(1, 'Operation not permited.')
# Ok
def open(self, node, mode):
if not node:
raise OSError(1, 'Operation not permited.')
# Reading operation
if node.type=='file':
if not self.isfile(node):
raise OSError(1, 'Operation not permited.')
s = StringIO.StringIO(base64.decodestring(node.object.datas or ''))
s.name = node
return s
elif node.type=='content':
cr = node.cr
uid = node.uid
pool = pooler.get_pool(cr.dbname)
report = pool.get('ir.actions.report.xml').browse(cr, uid, node.content['report_id']['id'])
srv = netsvc.LocalService('report.'+report.report_name)
pdf,pdftype = srv.create(cr, uid, [node.object.id], {}, {})
s = StringIO.StringIO(pdf)
s.name = node
return s
else:
raise OSError(1, 'Operation not permited.')
# ok, but need test more
def mkstemp(self, suffix='', prefix='', dir=None, mode='wb'):
"""A wrap around tempfile.mkstemp creating a file with a unique
name. Unlike mkstemp it returns an object with a file-like
interface.
"""
raise 'Not Yet Implemented'
# class FileWrapper:
# def __init__(self, fd, name):
# self.file = fd
# self.name = name
# def __getattr__(self, attr):
# return getattr(self.file, attr)
#
# text = not 'b' in mode
# # max number of tries to find out a unique file name
# tempfile.TMP_MAX = 50
# fd, name = tempfile.mkstemp(suffix, prefix, dir, text=text)
# file = os.fdopen(fd, mode)
# return FileWrapper(file, name)
text = not 'b' in mode
# for unique file , maintain version if duplicate file
if dir:
cr = dir.cr
uid = dir.uid
pool = pooler.get_pool(cr.dbname)
object=dir and dir.object or False
object2=dir and dir.object2 or False
res=pool.get('ir.attachment').search(cr,uid,[('name','like',prefix),('parent_id','=',object and object.type in ('directory','ressource') and object.id or False),('res_id','=',object2 and object2.id or False),('res_model','=',object2 and object2._name or False)])
if len(res):
pre = prefix.split('.')
prefix=pre[0] + '.v'+str(len(res))+'.'+pre[1]
#prefix = prefix + '.'
return self.create(dir,suffix+prefix,text)
# Ok
def chdir(self, path):
if not path:
self.cwd='/'
return None
if path.type in ('collection','database'):
self.cwd = self.fs2ftp(path)
else:
raise OSError(1, 'Operation not permited.')
# Ok
def mkdir(self, node, basename):
"""Create the specified directory."""
if not node:
raise OSError(1, 'Operation not permited.')
try:
object2=node and node.object2 or False
object=node and node.object or False
cr = node.cr
uid = node.uid
pool = pooler.get_pool(cr.dbname)
if node.object and (node.object.type=='ressource') and not node.object2:
raise OSError(1, 'Operation not permited.')
val = {
'name': basename,
'ressource_parent_type_id': object and object.ressource_type_id.id or False,
'ressource_id': object2 and object2.id or False
}
if (object and (object.type in ('directory'))) or not object2:
val['parent_id'] = object and object.id or False
# Check if it alreayd exists !
pool.get('document.directory').create(cr, uid, val)
cr.commit()
except Exception,e:
print e
raise OSError(1, 'Operation not permited.')
# Ok
def close_cr(self, data):
if data:
data[0].close()
return True
def get_cr(self, path):
path = self.ftpnorm(path)
if path=='/':
return None
dbname = path.split('/')[1]
try:
db,pool = pooler.get_db_and_pool(dbname)
except:
raise OSError(1, 'Operation not permited.')
cr = db.cursor()
uid = security.login(dbname, self.username, self.password)
if not uid:
raise OSError(1, 'Operation not permited.')
return cr, uid, pool
# Ok
def listdir(self, path):
"""List the content of a directory."""
class false_node:
object = None
type = 'database'
def __init__(self, db):
self.path = '/'+db
if path is None:
result = []
for db in self.db_list():
result.append(false_node(db))
return result
return path.children()
# Ok
def rmdir(self, node):
"""Remove the specified directory."""
cr = node.cr
uid = node.uid
pool = pooler.get_pool(cr.dbname)
object2=node and node.object2 or False
object=node and node.object or False
if object._table_name=='document.directory':
if node.children():
raise OSError(39, 'Directory not empty.')
res = pool.get('document.directory').unlink(cr, uid, [object.id])
else:
raise OSError(39, 'Directory not empty.')
cr.commit()
# Ok
def remove(self, node):
"""Remove the specified file."""
cr = node.cr
uid = node.uid
pool = pooler.get_pool(cr.dbname)
object2=node and node.object2 or False
object=node and node.object or False
if not object:
raise OSError(2, 'Not such file or directory.')
if object._table_name=='ir.attachment':
res = pool.get('ir.attachment').unlink(cr, uid, [object.id])
else:
raise OSError(1, 'Operation not permited.')
cr.commit()
# Ok
def rename(self, src, dst_basedir,dst_basename):
"""
Renaming operation, the effect depends on the src:
* A file: read, create and remove
* A directory: change the parent and reassign childs to ressource
"""
try:
if src.type=='collection':
if src.object._table_name <> 'document.directory':
raise OSError(1, 'Operation not permited.')
result = {
'directory': [],
'attachment': []
}
# Compute all childs to set the new ressource ID
child_ids = [src]
while len(child_ids):
node = child_ids.pop(0)
child_ids += node.children()
if node.type =='collection':
result['directory'].append(node.object.id)
if (not node.object.ressource_id) and node.object2:
raise OSError(1, 'Operation not permited.')
elif node.type =='file':
result['attachment'].append(node.object.id)
cr = src.cr
uid = src.uid
pool = pooler.get_pool(cr.dbname)
object2=src and src.object2 or False
object=src and src.object or False
if object2 and not object.ressource_id:
raise OSError(1, 'Operation not permited.')
val = {
'name':dst_basename,
}
if (dst_basedir.object and (dst_basedir.object.type in ('directory'))) or not dst_basedir.object2:
val['parent_id'] = dst_basedir.object and dst_basedir.object.id or False
else:
val['parent_id'] = False
res = pool.get('document.directory').write(cr, uid, [object.id],val)
if dst_basedir.object2:
ressource_type_id = pool.get('ir.model').search(cr,uid,[('model','=',dst_basedir.object2._name)])[0]
ressource_id = dst_basedir.object2.id
title = dst_basedir.object2.name
ressource_model = dst_basedir.object2._name
if dst_basedir.object2._name=='res.partner':
partner_id=dst_basedir.object2.id
else:
partner_id= dst_basedir.object2.partner_id and dst_basedir.object2.partner_id.id or False
else:
ressource_type_id = False
ressource_id=False
ressource_model = False
partner_id = False
title = False
pool.get('document.directory').write(cr, uid, result['directory'], {
'ressource_id': ressource_id,
'ressource_parent_type_id': ressource_type_id
})
val = {
'res_id': ressource_id,
'res_model': ressource_model,
'title': title,
'partner_id': partner_id
}
pool.get('ir.attachment').write(cr, uid, result['attachment'], val)
if (not val['res_id']) and result['attachment']:
dst_basedir.cr.execute('update ir_attachment set res_id=NULL where id in ('+','.join(map(str,result['attachment']))+')')
cr.commit()
elif src.type=='file':
pool = pooler.get_pool(src.cr.dbname)
val = {
'partner_id':False,
#'res_id': False,
'res_model': False,
'name': dst_basename,
'datas_fname': dst_basename,
'title': dst_basename,
}
if (dst_basedir.object and (dst_basedir.object.type in ('directory','ressource'))) or not dst_basedir.object2:
val['parent_id'] = dst_basedir.object and dst_basedir.object.id or False
else:
val['parent_id'] = False
if dst_basedir.object2:
val['res_model'] = dst_basedir.object2._name
val['res_id'] = dst_basedir.object2.id
val['title'] = dst_basedir.object2.name
if dst_basedir.object2._name=='res.partner':
val['partner_id']=dst_basedir.object2.id
else:
val['partner_id']= dst_basedir.object2.partner_id and dst_basedir.object2.partner_id.id or False
elif src.object.res_id:
# I had to do that because writing False to an integer writes 0 instead of NULL
# change if one day we decide to improve osv/fields.py
dst_basedir.cr.execute('update ir_attachment set res_id=NULL where id=%d', (src.object.id,))
pool.get('ir.attachment').write(src.cr, src.uid, [src.object.id], val)
src.cr.commit()
elif src.type=='content':
src_file=self.open(src,'r')
dst_file=self.create(dst_basedir,dst_basename,'w')
dst_file.write(src_file.getvalue())
dst_file.close()
src_file.close()
src.cr.commit()
else:
raise OSError(1, 'Operation not permited.')
except Exception,err:
print err
raise OSError(1,'Operation not permited.')
# Nearly Ok
def stat(self, node):
r = list(os.stat('/'))
if self.isfile(node):
r[0] = 33188
r[6] = self.getsize(node)
r[7] = self.getmtime(node)
r[8] = self.getmtime(node)
r[9] = self.getmtime(node)
return posix.stat_result(r)
lstat = stat
# --- Wrapper methods around os.path.*
# Ok
def isfile(self, node):
if node and (node.type not in ('collection','database')):
return True
return False
# Ok
def islink(self, path):
"""Return True if path is a symbolic link."""
return False
# Ok
def isdir(self, node):
"""Return True if path is a directory."""
if node is None:
return True
if node and (node.type in ('collection','database')):
return True
return False
# Ok
def getsize(self, node):
"""Return the size of the specified file in bytes."""
result = 0L
if node.type=='file':
result = node.object.file_size or 0L
return result
# Ok
def getmtime(self, node):
"""Return the last modified time as a number of seconds since
the epoch."""
if node.object and node.type<>'content':
dt = (node.object.write_date or node.object.create_date)[:19]
result = time.mktime(time.strptime(dt, '%Y-%m-%d %H:%M:%S'))
else:
result = time.mktime(time.localtime())
return result
# Ok
def realpath(self, path):
"""Return the canonical version of path eliminating any
symbolic links encountered in the path (if they are
supported by the operating system).
"""
return path
# Ok
def lexists(self, path):
"""Return True if path refers to an existing path, including
a broken or circular symbolic link.
"""
return path and True or False
exists = lexists
# Ok, can be improved
def glob1(self, dirname, pattern):
"""Return a list of files matching a dirname pattern
non-recursively.
Unlike glob.glob1 raises exception if os.listdir() fails.
"""
names = self.listdir(dirname)
if pattern[0] != '.':
names = filter(lambda x: x.path[0] != '.', names)
return fnmatch.filter(names, pattern)
# --- Listing utilities
# note: the following operations are no more blocking
# Ok
def get_list_dir(self, path):
""""Return an iterator object that yields a directory listing
in a form suitable for LIST command.
"""
if self.isdir(path):
listing = self.listdir(path)
#listing.sort()
return self.format_list(path and path.path or '/', listing)
# if path is a file or a symlink we return information about it
elif self.isfile(path):
basedir, filename = os.path.split(path.path)
self.lstat(path) # raise exc in case of problems
return self.format_list(basedir, [filename])
# Ok
def get_stat_dir(self, rawline, datacr):
"""Return an iterator object that yields a list of files
matching a dirname pattern non-recursively in a form
suitable for STAT command.
- (str) rawline: the raw string passed by client as command
argument.
"""
ftppath = self.ftpnorm(rawline)
if not glob.has_magic(ftppath):
return self.get_list_dir(self.ftp2fs(rawline, datacr))
else:
basedir, basename = os.path.split(ftppath)
if glob.has_magic(basedir):
return iter(['Directory recursion not supported.\r\n'])
else:
basedir = self.ftp2fs(basedir, datacr)
listing = self.glob1(basedir, basename)
if listing:
listing.sort()
return self.format_list(basedir, listing)
# Ok
def format_list(self, basedir, listing, ignore_err=True):
"""Return an iterator object that yields the entries of given
directory emulating the "/bin/ls -lA" UNIX command output.
- (str) basedir: the absolute dirname.
- (list) listing: the names of the entries in basedir
- (bool) ignore_err: when False raise exception if os.lstat()
call fails.
On platforms which do not support the pwd and grp modules (such
as Windows), ownership is printed as "owner" and "group" as a
default, and number of hard links is always "1". On UNIX
systems, the actual owner, group, and number of links are
printed.
This is how output appears to client:
-rw-rw-rw- 1 owner group 7045120 Sep 02 3:47 music.mp3
drwxrwxrwx 1 owner group 0 Aug 31 18:50 e-books
-rw-rw-rw- 1 owner group 380 Sep 02 3:40 module.py
"""
for file in listing:
try:
st = self.lstat(file)
except os.error:
if ignore_err:
continue
raise
perms = filemode(st.st_mode) # permissions
nlinks = st.st_nlink # number of links to inode
if not nlinks: # non-posix system, let's use a bogus value
nlinks = 1
size = st.st_size # file size
uname = "owner"
gname = "group"
# stat.st_mtime could fail (-1) if last mtime is too old
# in which case we return the local time as last mtime
try:
mtime = time.strftime("%b %d %H:%M", time.localtime(st.st_mtime))
except ValueError:
mtime = time.strftime("%b %d %H:%M")
# formatting is matched with proftpd ls output
yield "%s %3s %-8s %-8s %8s %s %s\r\n" %(perms, nlinks, uname, gname,
size, mtime, file.path.split('/')[-1])
# Ok
def format_mlsx(self, basedir, listing, perms, facts, ignore_err=True):
"""Return an iterator object that yields the entries of a given
directory or of a single file in a form suitable with MLSD and
MLST commands.
Every entry includes a list of "facts" referring the listed
element. See RFC-3659, chapter 7, to see what every single
fact stands for.
- (str) basedir: the absolute dirname.
- (list) listing: the names of the entries in basedir
- (str) perms: the string referencing the user permissions.
- (str) facts: the list of "facts" to be returned.
- (bool) ignore_err: when False raise exception if os.stat()
call fails.
Note that "facts" returned may change depending on the platform
and on what user specified by using the OPTS command.
This is how output could appear to the client issuing
a MLSD request:
type=file;size=156;perm=r;modify=20071029155301;unique=801cd2; music.mp3
type=dir;size=0;perm=el;modify=20071127230206;unique=801e33; ebooks
type=file;size=211;perm=r;modify=20071103093626;unique=801e32; module.py
"""
permdir = ''.join([x for x in perms if x not in 'arw'])
permfile = ''.join([x for x in perms if x not in 'celmp'])
if ('w' in perms) or ('a' in perms) or ('f' in perms):
permdir += 'c'
if 'd' in perms:
permdir += 'p'
type = size = perm = modify = create = unique = mode = uid = gid = ""
for basename in listing:
file = os.path.join(basedir, basename)
try:
st = self.stat(file)
except OSError:
if ignore_err:
continue
raise
# type + perm
if stat.S_ISDIR(st.st_mode):
if 'type' in facts:
if basename == '.':
type = 'type=cdir;'
elif basename == '..':
type = 'type=pdir;'
else:
type = 'type=dir;'
if 'perm' in facts:
perm = 'perm=%s;' %permdir
else:
if 'type' in facts:
type = 'type=file;'
if 'perm' in facts:
perm = 'perm=%s;' %permfile
if 'size' in facts:
size = 'size=%s;' %st.st_size # file size
# last modification time
if 'modify' in facts:
try:
modify = 'modify=%s;' %time.strftime("%Y%m%d%H%M%S",
time.localtime(st.st_mtime))
except ValueError:
# stat.st_mtime could fail (-1) if last mtime is too old
modify = ""
if 'create' in facts:
# on Windows we can provide also the creation time
try:
create = 'create=%s;' %time.strftime("%Y%m%d%H%M%S",
time.localtime(st.st_ctime))
except ValueError:
create = ""
# UNIX only
if 'unix.mode' in facts:
mode = 'unix.mode=%s;' %oct(st.st_mode & 0777)
if 'unix.uid' in facts:
uid = 'unix.uid=%s;' %st.st_uid
if 'unix.gid' in facts:
gid = 'unix.gid=%s;' %st.st_gid
# We provide unique fact (see RFC-3659, chapter 7.5.2) on
# posix platforms only; we get it by mixing st_dev and
# st_ino values which should be enough for granting an
# uniqueness for the file listed.
# The same approach is used by pure-ftpd.
# Implementors who want to provide unique fact on other
# platforms should use some platform-specific method (e.g.
# on Windows NTFS filesystems MTF records could be used).
if 'unique' in facts:
unique = "unique=%x%x;" %(st.st_dev, st.st_ino)
yield "%s%s%s%s%s%s%s%s%s %s\r\n" %(type, size, perm, modify, create,
mode, uid, gid, unique, basename)

View File

@ -0,0 +1,70 @@
#import pooler
class authorizer:
read_perms = "elr"
write_perms = "adfmw"
def __init__(self):
self.password = ''
def validate_authentication(self, username, password):
"""Return True if the supplied username and password match the
stored credentials."""
self.password = password
return True
def impersonate_user(self, username, password):
"""Impersonate another user (noop).
It is always called before accessing the filesystem.
By default it does nothing. The subclass overriding this
method is expected to provide a mechanism to change the
current user.
"""
def terminate_impersonation(self):
"""Terminate impersonation (noop).
It is always called after having accessed the filesystem.
By default it does nothing. The subclass overriding this
method is expected to provide a mechanism to switch back
to the original user.
"""
def has_user(self, username):
"""Whether the username exists in the virtual users table."""
return True
def has_perm(self, username, perm, path=None):
"""Whether the user has permission over path (an absolute
pathname of a file or a directory).
Expected perm argument is one of the following letters:
"elradfmw".
"""
return True
paths = path.split('/')
if not len(paths)>2:
return True
db_name = paths[1]
db,pool = pooler.get_db_and_pool(db_name)
res = security.login(db_name, username, self.password)
return bool(res)
def get_perms(self, username):
"""Return current user permissions."""
return 'elr'
def get_home_dir(self, username):
"""Return the user's home directory."""
return '/'
def get_msg_login(self, username):
"""Return the user's login message."""
return 'Welcome on OpenERP document management system.'
def get_msg_quit(self, username):
"""Return the user's quitting message."""
return 'Bye.'

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
#!/usr/bin/python
import sys, zipfile, xml.dom.minidom
import StringIO
class OpenDocumentTextFile :
def __init__ (self, filepath) :
zip = zipfile.ZipFile(filepath)
self.content = xml.dom.minidom.parseString(zip.read("content.xml"))
def toString (self) :
""" Converts the document to a string. """
buffer = u""
for val in ["text:p", "text:h", "text:list"]:
for paragraph in self.content.getElementsByTagName(val) :
buffer += self.textToString(paragraph) + "\n"
return buffer
def textToString(self, element) :
buffer = u""
for node in element.childNodes :
if node.nodeType == xml.dom.Node.TEXT_NODE :
buffer += node.nodeValue
elif node.nodeType == xml.dom.Node.ELEMENT_NODE :
buffer += self.textToString(node)
return buffer
if __name__ == "__main__" :
s =StringIO.StringIO(file(sys.argv[1]).read())
odt = OpenDocumentTextFile(s)
print odt.toString().encode('ascii','replace')

View File

@ -134,8 +134,8 @@ class event(osv.osv):
'date_begin': fields.datetime('Beginning date', required=True),
'date_end': fields.datetime('Ending date', required=True),
'state': fields.selection([('draft','Draft'),('confirm','Confirmed'),('done','Done'),('cancel','Canceled')], 'Status', readonly=True, required=True),
'mail_auto_registr':fields.boolean('Mail Auto Register',help='A mail is send when the registration is confirmed'),
'mail_auto_confirm':fields.boolean('Mail Auto Confirm',help='A mail is send when the event is confimed'),
'mail_auto_registr':fields.boolean('Mail Auto Register',help='A mail is sent when the registration is confirmed'),
'mail_auto_confirm':fields.boolean('Mail Auto Confirm',help='A mail is sent when the event is confimed'),
'mail_registr':fields.text('Mail Register',help='Template for the mail'),
'mail_confirm':fields.text('Mail Confirm',help='Template for the mail'),
'budget_id':fields.many2one('account.budget.post','Budget'),
@ -163,13 +163,6 @@ class event_registration(osv.osv):
obj.create(cr, uid, data, context)
return True
def button_reg_open(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state':'open',})
cases = self.browse(cr, uid, ids)
self._history(cr, uid, cases, 'Open', history=True)
self.mail_user(cr,uid,ids)
return True
def button_reg_close(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state':'done',})
cases = self.browse(cr, uid, ids)
@ -223,7 +216,7 @@ class event_registration(osv.osv):
"badge_name":fields.char('Badge Name',size=128),
"badge_partner":fields.char('Badge Partner',size=128),
"invoice_label":fields.char("Label Invoice",size=128,required=True),
"tobe_invoiced":fields.boolean("To be Invoice"),
"tobe_invoiced":fields.boolean("To be Invoiced"),
"invoice_id":fields.many2one("account.invoice","Invoice"),
}
_defaults = {

View File

@ -198,7 +198,7 @@
<form string="Registration">
<notebook>
<page string="General">
<field name="event_id" select="1" on_change="onchange_event(event_id, partner_invoice_id)" colspan="1"/>
<field name="event_id" select="1" on_change="onchange_event(event_id, partner_invoice_id)" colspan="1" domain="[('state','in',('draft','confirm'))]"/>
<field name="nb_register"/>
<newline/>
<field name="partner_id" required="1" select="1" on_change="onchange_partner_id(partner_id,event_id, email_from)" />
@ -220,7 +220,7 @@
<group col="8" colspan="4">
<field name="state" select="1" colspan="2"/>
<button name="button_reg_close" string="Registration Invoiced" states="open" type="object"/>
<button name="button_reg_open" string="Confirm Registration" states="draft" type="object"/>
<button name="%(event_confirm_registration)d" string="Confirm Registration" states="draft" type="action"/>
<button name="button_reg_cancel" string="Cancel Registration" states="draft,open" type="object"/>
</group>
</page>

View File

@ -1,52 +1,43 @@
<?xml version="1.0" ?>
<openerp>
<data>
<wizard string="Project"
model="event.event"
name="event.project"
id="event_wiz"
menu="False"/>
<data>
<wizard string="Project"
model="event.event"
name="event.project"
id="event_wiz"
menu="False"/>
<wizard
string="Tasks"
model="event.event"
name="wizard_event_tasks"
id="wizard_event_task"/>
<wizard
string="Tasks"
model="event.event"
name="wizard_event_tasks"
id="wizard_event_task"/>
<wizard
string="Registrations"
model="event.event"
name="wizard_event_registration"
id="wizard_event_registration"/>
<wizard
string="Registrations"
model="event.event"
name="wizard_event_registration"
id="wizard_event_registration"/>
<!--<wizard
string="New child event"
model="event.event"
name="wizard_event_new"
keyword="client_action_multi"
menu="False"
id="wizard_event_new"/>-->
<wizard
string="List Register Partners"
model="event.event"
name="event.event_reg_partners"
id="wizard_event_reg_partners"/>
<wizard
string="List Register Partners"
model="event.event"
name="event.event_reg_partners"
id="wizard_event_reg_partners"/>
<wizard string="Make Invoice"
model="event.registration"
name="event.reg_make_invoice"
id="event_reg_invoice"
menu="True"
/>
<wizard string="Make Invoice"
model="event.registration"
name="event.reg_make_invoice"
id="event_reg_invoice"
menu="True"
/>
<!--
<record model="ir.values" id="ir_open_new_event">
<field name="key2">tree_but_open</field>
<field name="model">event.event</field>
<field name="name">New child event</field>
<field name="value" eval="'ir.actions.wizard,%d'%wizard_event_new"/>
<field name="object" eval="True"/>
</record>
-->
</data>
<wizard string="Confirm Registration"
model="event.registration"
name="event.confirm_registration"
id="event_confirm_registration"
menu="False"
/>
</data>
</openerp>

View File

@ -3,6 +3,7 @@ import event_registration
import project_wizard
import make_invoice
import event_registrations_partner
import confirm_registration
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,86 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
import ir
import pooler
from osv.osv import except_osv
from osv import fields,osv
import netsvc
ARCH = '''<?xml version="1.0"?>
<form string="Registration Confirmation">
<label string="The event limit is reached. What do you want to do?" colspan="4"/>
</form>'''
ARCH_fields={}
def _confirm(self, cr, uid, data, context):
registration_obj = pooler.get_pool(cr.dbname).get('event.registration')
current_registration = registration_obj.browse(cr, uid, [data['id']])[0]
total_confirmed = current_registration.event_id.register_current + current_registration.nb_register
if total_confirmed <= current_registration.event_id.register_max:
return 'confirm'
return 'split'
def _check_confirm(self, cr, uid, data, context):
registration_obj = pooler.get_pool(cr.dbname).get('event.registration')
registration_obj.write(cr, uid, [data['id']], {'state':'open',})
reg = registration_obj.browse(cr, uid, [data['id']])
registration_obj._history(cr, uid, reg, 'Open', history=True)
registration_obj.mail_user(cr,uid,[data['id']])
return {}
class confirm_registration(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'choice', 'next_state' : _confirm}
},
'split' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : ARCH,'fields':ARCH_fields,
'state' : [('end', 'Cancel'),('confirm', 'Confirm Anyway') ]}
},
'confirm' : {
'actions' : [],
'result' : {'type' : 'action', 'action': _check_confirm, 'state' : 'end'}
},
'end' : {
'actions' : [],
'result': {'type': 'state', 'state': 'end'},
},
}
confirm_registration('event.confirm_registration')

View File

@ -47,8 +47,8 @@
"hr_department_demo.xml",
],
"update_xml" : [
# "security/hr_security.xml",
# "security/ir.model.access.csv",
"security/hr_security.xml",
"security/ir.model.access.csv",
"hr_view.xml",
"hr_wizard.xml",
"hr_department_view.xml",

View File

@ -144,7 +144,7 @@
</field>
</record>
<record id="action2" model="ir.actions.act_window">
<field name="name">Hierarchical view of this employee</field>
<field name="name">Employee Hierarchy</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.employee</field>
<field name="domain">[('id','in',active_ids)]</field>

View File

@ -3,8 +3,6 @@ access_hr_timesheet_group,hr.timesheet.group,model_hr_timesheet_group,hr.group_h
access_hr_employee_category,hr.employee.category,model_hr_employee_category,hr.group_hr_user,1,0,0,0
access_hr_employee,hr.employee,model_hr_employee,hr.group_hr_user,1,1,1,1
access_hr_timesheet,hr.timesheet,model_hr_timesheet,hr.group_hr_user,1,1,1,1
access_hr_action_reason,hr.action.reason,model_hr_action_reason,hr.group_hr_user,1,1,1,1
access_hr_attendance,hr.attendance,model_hr_attendance,hr.group_hr_user,1,1,1,1
access_hr_department,hr.department,model_hr_department,hr.group_hr_user,1,0,0,0
access_hr_timesheet_group_manager,hr.timesheet.group.manager,model_hr_timesheet_group,hr.group_hr_manager,1,1,1,1
access_hr_employee_category_manager,hr.employee.category.manager,model_hr_employee_category,hr.group_hr_manager,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
3 access_hr_employee_category hr.employee.category model_hr_employee_category hr.group_hr_user 1 0 0 0
4 access_hr_employee hr.employee model_hr_employee hr.group_hr_user 1 1 1 1
5 access_hr_timesheet hr.timesheet model_hr_timesheet hr.group_hr_user 1 1 1 1
access_hr_action_reason hr.action.reason model_hr_action_reason hr.group_hr_user 1 1 1 1
access_hr_attendance hr.attendance model_hr_attendance hr.group_hr_user 1 1 1 1
6 access_hr_department hr.department model_hr_department hr.group_hr_user 1 0 0 0
7 access_hr_timesheet_group_manager hr.timesheet.group.manager model_hr_timesheet_group hr.group_hr_manager 1 1 1 1
8 access_hr_employee_category_manager hr.employee.category.manager model_hr_employee_category hr.group_hr_manager 1 1 1 1

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report auto="False" id="attendance_error_report" keyword="client_print_multi" menu="False" model="hr.employee" multi="True" name="hr.timesheet.attendance.error" rml="hr/report/attendance_errors.rml" string="Attendance Error Report"/>
<report auto="False" id="attendance_error_report" keyword="client_print_multi" menu="False" model="hr.employee" multi="True" name="report.hr.timesheet.attendance.error" rml="hr_attendance/report/attendance_errors.rml" string="Attendance Error Report"/>
</data>
</openerp>

View File

@ -52,6 +52,7 @@
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
@ -87,11 +88,11 @@
<story>
<para style="terp_default_8">[[ repeatIn(objects,'employee') ]]</para>
<para style="terp_header_Centre">Attendance Errors</para>
<para style="terp_header">[[ employee.name ]]</para>
<para style="P1">[[ employee.name ]]</para>
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="60.0,114.0,146.0,85.0,77.0" style="Table_employee_detail_header">
<blockTable colWidths="78.0,118.0,151.0,98.0,75.0" style="Table_employee_detail_header">
<tr>
<td>
<para style="terp_tblheader_Details_Centre">Operation</para>
@ -110,11 +111,11 @@
</td>
</tr>
</blockTable>
<blockTable colWidths="482.0" style="tbl_detail">
<blockTable colWidths="519.0" style="tbl_detail">
<tr>
<td>
<para style="terp_default_8">[[ repeatIn(lst(employee.id,data['form']['init_date'], data['form']['end_date'], data['form']['max_delay']), 'att') ]]</para>
<blockTable colWidths="58.0,114.0,143.0,93.0,69.0" style="Table_employee_detail_content">
<blockTable colWidths="62.0,123.0,154.0,100.0,75.0" style="Table_employee_detail_content">
<tr>
<td>
<para style="terp_default_Centre_9">[[ att['action'] ]]</para>
@ -136,7 +137,7 @@
</td>
</tr>
</blockTable>
<blockTable colWidths="319.0,99.0,63.0" style="Table_employee_total">
<blockTable colWidths="357.0,99.0,63.0" style="Table_employee_total">
<tr>
<td>
<para style="terp_default_Bold_9">Total period:</para>
@ -152,7 +153,7 @@
<para style="terp_default_8">
<font color="white"> </font>
</para>
<para style="terp_default_8">(*) A positive delay means that the employee worked less than recorded.</para>
<para style="terp_default_8">(*) A negative delay means that the employee worked more than encoded.</para>
<para style="terp_default_9">(*) A positive delay means that the employee worked less than recorded.</para>
<para style="terp_default_9">(*) A negative delay means that the employee worked more than encoded.</para>
</story>
</document>
</document>

View File

@ -38,7 +38,7 @@
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_employee_detail_header">
<blockTableStyle id="Table_hr_expense_line_header">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
@ -48,43 +48,27 @@
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockTableStyle id="Table_expense_line">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="6,-1" stop="6,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="7,-1" stop="7,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="6,-1" stop="6,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="6,-1" stop="6,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="7,-1" stop="7,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_employee_detail_content">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="6,-1" stop="6,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_employee_total">
<blockTableStyle id="Table_Final_total">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="1,0" stop="1,0"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="2,0" stop="2,0"/>
<lineStyle kind="LINEABOVE" colorName="#ffffff" start="3,0" stop="3,0"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="4,0" stop="4,0"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="5,0" stop="5,0"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
@ -112,7 +96,7 @@
<paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="14.0" leading="17" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Bold_centre_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
@ -124,10 +108,16 @@
<images/>
<story>
<para style="terp_default_8">[[ repeatIn(objects,'o') ]]</para>
<para style="terp_default_8">
<font color="white"> </font>
</para>
<para style="terp_header_Centre">HR Expenses [[ o.name or '' ]]</para>
<para style="terp_default_8">
<font color="white"> </font>
</para>
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="174.0,174.0,174.0" style="Table_employee_ref_header">
<tr>
<td>
@ -157,10 +147,7 @@
<para style="terp_default_8">
<font color="white"> </font>
</para>
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="63.0,224.0,72.0,58.0,43.0,62.0" style="Table_employee_detail_header">
<blockTable colWidths="49.0,204.0,45.0,80.0,53.0,91.0" style="Table_hr_expense_line_header">
<tr>
<td>
<para style="terp_tblheader_Details">Date</para>
@ -169,52 +156,54 @@
<para style="terp_tblheader_Details">Name</para>
</td>
<td>
<para style="terp_tblheader_Details_Centre">Ref.</para>
<para style="terp_tblheader_Details">Ref.</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Unit price</para>
<para style="terp_tblheader_Details_Right">Unit Price</para>
</td>
<td>
<para style="terp_tblheader_Details_Centre">Qty</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Total</para>
<para style="terp_tblheader_Details_Right">Total Price</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="523.0" style="Table1">
<tr>
<td>
<para style="terp_default_8">[[ repeatIn(o.line_ids,'line') ]]</para>
<blockTable colWidths="61.0,224.0,72.0,58.0,43.0,34.0,24.0" style="Table_employee_detail_content">
<tr>
<td>
<para style="terp_default_9">[[ time.strftime('%d/%m/%Y', time.strptime(line.date_value, '%Y-%m-%d')) or '' ]]</para>
</td>
<td>
<para style="terp_default_9">[[ line.name or '' ]] [[ line.description or '' ]]</para>
</td>
<td>
<para style="terp_default_Centre_9">[[ line.ref or '' ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ '%.2f' % line.unit_amount or '' ]]</para>
</td>
<td>
<para style="terp_default_Centre_9">[[ '%.2f' % line.unit_quantity or '' ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ '%.2f' % line.total_amount or '' ]] </para>
</td>
<td>
<para style="terp_default_Right_9">[[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<blockTable colWidths="418.0,43.0,39.0,23.0" style="Table_employee_total">
<para style="terp_default_1">
<font color="white"> </font>
</para>
<section>
<para style="terp_default_8">[[ repeatIn(o.line_ids,'line') ]]</para>
<blockTable colWidths="49.0,204.0,46.0,58.0,23.0,52.0,71.0,21.0" style="Table_expense_line">
<tr>
<td>
<para style="terp_default_9">[[ time.strftime('%d/%m/%Y', time.strptime(line.date_value, '%Y-%m-%d')) or '' ]]</para>
</td>
<td>
<para style="terp_default_9">[[ line.name or '' ]] [[ line.description or '' ]]</para>
</td>
<td>
<para style="terp_default_9">[[ line.ref or '' ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ '%.2f' % line.unit_amount or '' ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ company.currency_id.name ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ '%.2f' % line.unit_quantity or '' ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ '%.2f' % line.total_amount or '' ]] </para>
</td>
<td>
<para style="terp_default_Right_9">[[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
</section>
<blockTable colWidths="57.0,171.0,171.0,32.0,71.0,21.0" style="Table_Final_total">
<tr>
<td>
<para style="terp_default_8">
@ -222,26 +211,39 @@
</para>
</td>
<td>
<para style="terp_tblheader_Details">Total:</para>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_9_bold_right">[[ '%.2f' % o.amount ]]</para>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_9_bold_right">[[ company.currency_id.name ]]</para>
<para style="terp_tblheader_Details_Right">Total:</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">[[ '%.2f' % o.amount ]]</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">[[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="terp_default_9">
<font color="white"> </font>
</para>
<para style="terp_default_9">[[ o.note or '' ]] [[ setTag('para','xpre') ]]</para>
<para style="terp_default_8">
<para style="terp_default_9">
<font color="white"> </font>
</para>
<para style="terp_default_9">Certified honest and conform,</para>
<para style="terp_default_9">(Date and signature)</para>
<para style="terp_default_8">
<para style="terp_default_9">
<font color="white"> </font>
</para>
<para style="terp_default_8">
<para style="terp_default_9">
<font color="white"> </font>
</para>
<para style="terp_default_9">This document must be dated and signed for reimbursment</para>

View File

@ -10,11 +10,11 @@
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockTableStyle id="Table_Title">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockTableStyle id="Table_header_Date">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="0,0" stop="0,-1"/>
@ -28,7 +28,7 @@
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockTableStyle id="Table_Content_Date">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="0,0" stop="0,-1"/>
@ -42,7 +42,7 @@
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="Table8">
<blockTableStyle id="Table_Header_Employee">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
@ -52,37 +52,35 @@
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="6,-1" stop="6,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="7,-1" stop="7,-1"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockTableStyle id="Table_Final_Total">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="22,-1" stop="22,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="6,-1" stop="6,-1"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockTableStyle id="Table_Journal_Total_detail">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_Journal_title">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table7">
<blockTableStyle id="Table_Move_line">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="10.0" leading="13"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT"/>
<paraStyle name="P4" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="LEFT"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT"/>
<paraStyle name="P8" fontName="Times-Roman" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
@ -92,7 +90,6 @@
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="Preformatted Text" fontName="Courier" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Untitled1" fontName="Times-Roman"/>
<paraStyle name="Footer" fontName="Times-Roman"/>
<paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
<paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
@ -113,15 +110,18 @@
<paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_9_bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_centre_bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_9_bold_U" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
</stylesheet>
<images/>
<story>
<blockTable colWidths="175.0,175.0,175.0" repeatRows="1" style="Table5">
<blockTable colWidths="175.0,175.0,175.0" repeatRows="1" style="Table_Title">
<tr>
<td>
<para style="terp_default_9">
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
@ -129,240 +129,205 @@
<para style="terp_header_Centre">Invoice rate by user</para>
</td>
<td>
<para style="P4">
<para style="terp_default_8">
<font color="white"> </font>
</para>
<para style="P3">
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P6">
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="175.0,175.0,175.0" style="Table1">
<blockTable colWidths="175.0,175.0,175.0" style="Table_header_Date">
<tr>
<td>
<para style="terp_default_centre_bold_9">Period from startdate</para>
<para style="terp_tblheader_General_Centre">Period from startdate</para>
</td>
<td>
<para style="terp_default_centre_bold_9">Period to enddate</para>
<para style="terp_tblheader_General_Centre">Period to enddate</para>
</td>
<td>
<para style="terp_default_centre_bold_9">Currency</para>
<para style="terp_tblheader_General_Centre">Currency</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="175.0,175.0,175.0" style="Table3">
<blockTable colWidths="175.0,175.0,175.0" style="Table_Content_Date">
<tr>
<td>
<para style="terp_default_Centre_9">[[ data['form']['date_from'] ]]</para>
<para style="terp_default_Centre_8">[[ data['form']['date_from'] ]]</para>
</td>
<td>
<para style="terp_default_Centre_9">[[ data['form']['date_to'] ]]</para>
<para style="terp_default_Centre_8">[[ data['form']['date_to'] ]]</para>
</td>
<td>
<para style="terp_default_Centre_9">[[ company.currency_id.name ]]</para>
<para style="terp_default_Centre_8">[[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="P6">
<para style="terp_default_8">
<font color="white"> </font>
</para>
<para style="terp_default_9">
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="118.0,44.0,55.0,67.0,71.0,66.0,52.0,50.0" style="Table8">
<blockTable colWidths="159.0,62.0,63.0,68.0,65.0,53.0,52.0" style="Table_Header_Employee">
<tr>
<td>
<para style="terp_tblheader_Details">Employee</para>
<para style="terp_tblheader_Details">Employee or Journal Name</para>
</td>
<td>
<para style="terp_default_Bold_9">
<para style="terp_tblheader_Details_Right">Units</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Theorical</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Income</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Cost</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Profit</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Eff.</para>
</td>
</tr>
</blockTable>
<para style="terp_default_2">
<font color="white"> </font>
</para>
<blockTable colWidths="154.0,65.0,60.0,72.0,66.0,52.0,51.0" style="Table_Final_Total">
<tr>
<td>
<para style="terp_default_Bold_9">Totals:</para>
</td>
<td>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</u></para>
</td>
<td>
<para style="terp_default_Right_9_bold">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_tblheader_Details">Units</para>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</u></para>
</td>
<td>
<para style="terp_tblheader_Details">Theorical</para>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</u></para>
</td>
<td>
<para style="terp_tblheader_Details">Income</para>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['profit'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</u></para>
</td>
<td>
<para style="terp_tblheader_Details">Cost</para>
</td>
<td>
<para style="terp_tblheader_Details">Profit</para>
</td>
<td>
<para style="terp_tblheader_Details">Eff.</para>
<para style="terp_default_Right_9_bold_U"><u>[[ round(reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)/reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)* -100, 2)]] %</u></para>
</td>
</tr>
</blockTable>
<para style="P6">
<font color="white"> </font>
</para>
<para style="terp_default_2"/>
<section>
<para style="terp_default_9">[[ repeatIn(user_ids(lines(data['form'])), 'e') ]]</para>
<blockTable colWidths="521.0,4.0" style="Table4">
<para style="terp_default_8">[[ repeatIn(user_ids(lines(data['form'])), 'e') ]]</para>
<blockTable colWidths="137.0,16.0,65.0,61.0,71.0,66.0,52.0,51.0" style="Table_Journal_Total_detail">
<tr>
<td>
<para style="terp_header">[[ e.name ]]</para>
<para style="terp_default_Bold_9">[[ e.name ]]</para>
</td>
<td>
<para style="terp_default_8">[[ repeatIn(journal_ids(data['form'], e.id), 'j') ]]</para>
</td>
<td>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], [j.id], [e.id]), 0) ]]</u></para>
</td>
<td>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['amount_th'], line(data['form'], [j.id], [e.id]), 0) ]]</u></para>
</td>
<td>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) ]]</u></para>
</td>
<td>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) ]]</u></para>
</td>
<td>
<para style="terp_default_Right_9_bold_U"><u>[[ reduce(lambda x, y: x+y['profit'], line(data['form'], [j.id], [e.id]), 0) ]]</u></para>
</td>
<td>
<para style="terp_default_Right_9_bold_U"><u>[[ '%d' % (reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) / reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) * 100.0,)]] %</u></para>
</td>
</tr>
</blockTable>
<blockTable colWidths="154.0,65.0,61.0,71.0,66.0,52.0,51.0" style="Table_Journal_title">
<tr>
<td>
<para style="P1">[[ repeatIn(journal_ids(data['form'], e.id), 'j') ]]</para>
<para style="terp_default_9">[[ j.name ]]</para>
<blockTable colWidths="160.0,57.0,66.0,61.0,68.0,52.0,334.0" style="Table2">
<tr>
<td>
<para style="P7">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_9">[[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], [j.id], [e.id]), 0) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ reduce(lambda x, y: x+y['amount_th'], line(data['form'], [j.id], [e.id]), 0) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ reduce(lambda x, y: x+y['profit'], line(data['form'], [j.id], [e.id]), 0) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ '%d' % (reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) / reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) * 100.0,)]] % </para>
</td>
</tr>
<tr>
<td>
<para style="terp_default_9">[[ repeatIn(line(data['form'], [j.id], [e.id]), 'l') ]]</para>
<para style="terp_default_9">[[ l['name'] ]]</para>
</td>
<td>
<para style="terp_default_9">[[ l['unit_amount'] ]]</para>
</td>
<td>
<para style="terp_default_9">[[ l['amount_th'] ]]</para>
</td>
<td>
<para style="terp_default_9">[[ l['amount'] ]]</para>
</td>
<td>
<para style="terp_default_9">[[ l['cost'] ]]</para>
</td>
<td>
<para style="terp_default_9">[[ l['profit'] ]]</para>
</td>
<td>
<para style="terp_default_9">[[ l['eff'] ]] %</para>
</td>
</tr>
<tr>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
</td>
<td>
<para style="terp_default_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="Standard">
<para style="terp_default_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_9">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<section>
<blockTable colWidths="103.0,422.0" style="Table6">
<tr>
<td>
<para style="terp_default_Bold_9">Totals</para>
</td>
<td>
<blockTable colWidths="59.0,56.0,67.0,62.0,67.0,55.0,55.0" style="Table7">
<tr>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_Bold_9">[[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</para>
</td>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_Bold_9">[[ reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</para>
</td>
<td>
<para style="terp_default_Bold_9">[[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</para>
</td>
<td>
<para style="terp_default_Bold_9">[[ reduce(lambda x, y: x+y['profit'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</para>
</td>
<td>
<para style="terp_default_Bold_9">[[ round(reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)/reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)* -100, 2)]] %</para>
</td>
</tr>
</blockTable>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</section>
<para style="terp_default_8">[[ repeatIn(line(data['form'], [j.id],[e.id]), 'l') ]] </para>
<blockTable colWidths="155.0,64.0,61.0,71.0,66.0,52.0,50.0" style="Table_Move_line">
<tr>
<td>
<para style="terp_default_8">[[ l['name'] ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ l['unit_amount'] ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ l['amount_th'] ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ l['amount'] ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ l['cost'] ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ l['profit'] ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ l['eff'] ]] %</para>
</td>
</tr>
</blockTable>
<para style="terp_default_9">
<font color="white"> </font>
</para>
</section>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</story>
</document>
</document>

View File

@ -30,7 +30,7 @@
"name" : "Belgium - Plan Comptable Minimum Normalise",
"version" : "1.1",
"author" : "Tiny",
"category" : "Localisation/Account charts",
"category" : "Localisation/Account Charts",
"depends" : ["account", "account_report", "base_vat", "base_iban",
"account_chart"],
"init_xml" : [],

View File

@ -6,25 +6,25 @@
model="res.partner"
name="list.vat.detail"
menu="False"
id="base.partner_wizard_vat"/>
id="partner_wizard_vat"/>
<menuitem
name="Financial Management/Reporting/Listing of VAT Customers"
action="base.partner_wizard_vat"
action="partner_wizard_vat"
type="wizard"
id="base.partner_wizard_vat_menu"/>
id="partner_wizard_vat_menu"/>
<wizard
string="VAT Declaration"
name="wizard.account.vat.declaration"
name="wizard.account.xml.vat.declaration"
menu="False"
id="account.wizard_vat_declaration"/>
id="wizard_xml_vat_declaration"/>
<menuitem
name="Financial Management/Periodical Processing/Taxes/VAT Declaration"
action="account.wizard_vat_declaration"
action="wizard_xml_vat_declaration"
type="wizard"
id="account_wizard_vat_declaration"/>
<record id="config_call_account_template" model="ir.module.module.configuration.step">
<record id="config_call_account_template" model="ir.actions.todo">
<field name="name">Generate Chart of Accounts from a Chart Template</field>
<field name="note">Generate Chart of Accounts from a Chart Template. You will be asked to pass the name of the company, the chart template to follow, the no. of digits to generate the code for your accounts and Bank account, currency to create Journals. Thus,the pure copy of chart Template is generated.
This is the same wizard that runs from Financial Managament/Configuration/Financial Accounting/Financial Accounts/Generate Chart of Accounts from a Chart Template.</field>

View File

@ -98,4 +98,4 @@ class wizard_vat_declaration(wizard.interface):
}
}
wizard_vat_declaration('wizard.account.vat.declaration')
wizard_vat_declaration('wizard.account.xml.vat.declaration')

View File

@ -1205,7 +1205,7 @@ msgstr "Index numériques"
#. module: mrp
#: field:mrp.routing,location_id:0
msgid "Production Location"
msgstr "Emplacement de production\\""
msgstr "Emplacement de production"
#. module: mrp
#: selection:stock.warehouse.orderpoint,logic:0

View File

@ -947,17 +947,41 @@ class mrp_procurement(osv.osv):
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - DateTime.RelativeDateTime(days=procurement.product_id.product_tmpl_id.seller_delay or 0.0)
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
context.update({'lang':partner.lang})
product=self.pool.get('product.product').browse(cr,uid,procurement.product_id.id,context=context)
line = {
'name': procurement.product_id.name,
'name': product.name,
'product_qty': qty,
'product_id': procurement.product_id.id,
'product_uom': uom_id,
'price_unit': price,
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'taxes_id': [(6, 0, [x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id])],
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'move_dest_id': res_id,
'notes':product.description_purchase,
}
taxes = self.pool.get('account.tax').browse(cr, uid,
[x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id])
taxep = None
if partner_id:
taxep_id = self.pool.get('res.partner').property_get(cr, uid,partner_id,property_pref=['property_account_supplier_tax']).get('property_account_supplier_tax',False)
if taxep_id:
taxep=self.pool.get('account.tax').browse(cr, uid,taxep_id)
if not taxep or not taxep.id:
taxes_ids = [x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id]
else:
res5 = [taxep.id]
for t in taxes:
if not t.tax_group==taxep.tax_group:
res5.append(t.id)
taxes_ids = res5
line.update({
'taxes_id':[(6,0,taxes_ids)]
})
purchase_id = self.pool.get('purchase.order').create(cr, uid, {
'origin': procurement.origin,
'partner_id': partner_id,

View File

@ -383,17 +383,17 @@
</field>
</record>
<record model="ir.ui.view" id="view_production_graph">
<field name="name">mrp.production.graph</field>
<field name="model">mrp.production</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Production orders" type="bar">
<field name="product_id"/>
<field name="product_qty" operator="+"/>
</graph>
</field>
</record>
<record model="ir.ui.view" id="view_production_graph">
<field name="name">mrp.production.graph</field>
<field name="model">mrp.production</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Production orders" type="bar">
<field name="product_id"/>
<field name="product_qty" operator="+"/>
</graph>
</field>
</record>
<record id="mrp_production_form_view" model="ir.ui.view">
@ -448,7 +448,7 @@
<field name="picking_id"/>
<field name="move_prod_id"/>
<field name="sale_name"/>
<field name="sale_ref"/>
<field name="sale_ref"/>
</page>
</notebook>
</form>
@ -623,20 +623,19 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Procurement">
<group col="2" colspan="2">
<separator colspan="2" string="References"/>
<field name="name" select="1" string="Procurement Reason"/>
<field name="origin" select="2"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Planification"/>
<field name="date_planned" select="1"/>
<field name="procure_method" select="2"/>
<field name="priority"/>
</group>
<notebook>
<page string="Procurement Details">
<group col="2" colspan="2">
<separator colspan="2" string="References"/>
<field name="name" select="1" string="Procurement Reason"/>
<field name="origin" select="2"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Planification"/>
<field name="date_planned" select="1"/>
<field name="procure_method" select="2"/>
<field name="priority"/>
</group>
<separator colspan="4" string="Product &amp; Location"/>
<field name="product_id" select="1"/>
<field name="location_id" select="2"/>

View File

@ -132,7 +132,7 @@ class mrp_procurement(osv.osv):
cr.close()
return {}
def create_automatic_op(cr, uid, context=None):
def create_automatic_op(self,cr, uid, context=None):
if not context:
context={}
product_obj = self.pool.get('product.product')
@ -192,7 +192,7 @@ class mrp_procurement(osv.osv):
offset = 0
ids = [1]
if automatic:
create_automatic_op(cr, uid, context=context)
self.create_automatic_op(cr, uid, context=context)
while ids:
ids=orderpoint_obj.search(cr,uid,[],offset=offset,limit=100)
for op in orderpoint_obj.browse(cr, uid, ids):

0
addons/mrp_operations/__init__.py Normal file → Executable file
View File

0
addons/mrp_operations/__terp__.py Normal file → Executable file
View File

0
addons/mrp_operations/i18n/cs_CZ.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/de_DE.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/es_AR.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/es_ES.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/fr_FR.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/hu_HU.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/it_IT.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/mrp_operations.pot Normal file → Executable file
View File

0
addons/mrp_operations/i18n/nl_NL.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/pt_BR.po Normal file → Executable file
View File

0
addons/mrp_operations/i18n/pt_PT.po Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More