ACCOUNT: add fiscalyear test in the accounting instead of active

bzr revid: ced-6d8d78647326c5a7de31db80112e4ce9ed649b31
This commit is contained in:
ced 2007-05-18 14:15:35 +00:00
parent e93593d197
commit f03ddb6199
18 changed files with 254 additions and 72 deletions

View File

@ -142,8 +142,11 @@ class account_account(osv.osv):
return super(account_account,self).search(cr, uid, args, offset, limit, order, context=context)
def _credit(self, cr, uid, ids, field_name, arg, context={}):
if not 'fiscalyear' in context:
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
acc_set = ",".join(map(str, ids))
cr.execute("SELECT a.id, COALESCE(SUM(l.credit*a.sign),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.type!='view' AND a.id IN (%s) AND l.active AND l.state<>'draft' GROUP BY a.id" % acc_set)
cr.execute("SELECT a.id, COALESCE(SUM(l.credit*a.sign),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.type!='view' AND a.id IN (%s) AND l.active AND l.state<>'draft' AND l.period_id in (SELECT id from account_period WHERE fiscalyear_id=%d) GROUP BY a.id" % (acc_set, context['fiscalyear']))
res2 = cr.fetchall()
res = {}
for id in ids:
@ -153,8 +156,11 @@ class account_account(osv.osv):
return res
def _debit(self, cr, uid, ids, field_name, arg, context={}):
if not 'fiscalyear' in context:
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
acc_set = ",".join(map(str, ids))
cr.execute("SELECT a.id, COALESCE(SUM(l.debit*a.sign),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.type!='view' AND a.id IN (%s) and l.active AND l.state<>'draft' GROUP BY a.id" % acc_set)
cr.execute("SELECT a.id, COALESCE(SUM(l.debit*a.sign),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.type!='view' AND a.id IN (%s) and l.active AND l.state<>'draft' AND l.period_id in (SELECT id from account_period WHERE fiscalyear_id=%d) GROUP BY a.id" % (acc_set, context['fiscalyear']))
res2 = cr.fetchall()
res = {}
for id in ids:
@ -164,9 +170,12 @@ class account_account(osv.osv):
return res
def _balance(self, cr, uid, ids, field_name, arg, context={}):
if not 'fiscalyear' in context:
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
acc_set = ",".join(map(str, ids2))
cr.execute("SELECT a.id, COALESCE(SUM((l.debit-l.credit)),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.id IN (%s) and l.active AND l.state<>'draft' GROUP BY a.id" % acc_set)
cr.execute("SELECT a.id, COALESCE(SUM((l.debit-l.credit)),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.id IN (%s) and l.active AND l.state<>'draft' AND l.period_id in (SELECT id from account_period WHERE fiscalyear_id=%d) GROUP BY a.id" % (acc_set, context['fiscalyear']))
res = {}
for account_id, sum in cr.fetchall():
res[account_id] = round(sum,2)
@ -409,7 +418,7 @@ class account_fiscalyear(osv.osv):
_defaults = {
'state': lambda *a: 'draft',
}
_order = "code"
_order = "date_start"
def create_period3(self,cr, uid, ids, context={}):
return self.create_period(cr, uid, ids, context, 3)
@ -428,6 +437,14 @@ class account_fiscalyear(osv.osv):
})
ds = ds + RelativeDateTime(months=interval)
return True
def find(self, cr, uid, dt=None, context={}):
if not dt:
dt = time.strftime('%Y-%m-%d')
ids = self.search(cr, uid, [('date_start', '<=', dt), ('date_stop', '>=', dt)])
if not ids:
raise osv.except_osv('Error !', 'No fiscal year defined for this date !\nPlease create one.')
return ids[0]
account_fiscalyear()
class account_period(osv.osv):

View File

@ -5,7 +5,6 @@
<menuitem name="Financial Management/End of year treatments" sequence="20"/>
<record model="ir.actions.act_window" id="action_account_period_tree">
<field name="name">account.period.tree</field>
<field name="res_model">account.period</field>
<field name="view_type">tree</field>
<field name="domain">[('state','=','draft')]</field>
@ -16,7 +15,7 @@
action="action_account_period_tree" />
<record model="ir.actions.act_window" id="action_account_fiscalyear_tree">
<field name="name">account.fiscalyear.tree</field>
<field name="name">Old fiscal years</field>
<field name="res_model">account.fiscalyear</field>
<field name="view_type">tree</field>
<field name="domain">[('state','=','done')]</field>

View File

@ -11,8 +11,8 @@
<report id="account_3rdparty_ledger"
string="Third party ledger"
model="res.partner"
name="account.grand.livre.tiers"
rml="account/report/grand_livre_tiers.rml"
name="account.third_party_ledger"
rml="account/report/third_party_ledger.rml"
auto="False"
menu="False"/>
<report id="account_account_balance"

View File

@ -19,7 +19,7 @@
<field name="date_start"/>
<field name="date_stop"/>
<separator string="Periods" colspan="4"/>
<field name="period_ids" colspan="4" widget="one2many_list">
<field name="period_ids" colspan="4" widget="one2many_list" nolable="1">
<form string="Period">
<field name="name" select="1"/>
<field name="code" select="1"/>
@ -939,7 +939,8 @@
<menuitem name="Financial Management/Entries/Entry lookup/" id="menu_action_move_line_search" action="action_move_line_search"/>
<menuitem name="Financial Management/Charts" sequence="7"/>
<menuitem name="Financial Management/Charts/Accounts Charts" id="menu_action_account_tree2" action="action_account_tree"/>
<wizard string="Accounts Charts" menu="False" model="account.account" name="account.chart" id="wizard_account_chart"/>
<menuitem name="Financial Management/Charts/Accounts Charts" id="menu_action_account_tree2" action="wizard_account_chart" type="wizard"/>
<menuitem name="Financial Management/Charts/Accounts Charts/Fast Account Chart" id="menu_action_account_tree3" action="action_account_tree2"/>
<menuitem name="Financial Management/Periodical Processing" sequence="3"/>
@ -1319,11 +1320,12 @@
<field name="view_mode">tree,form</field>
<field name="domain">[('account_id','=',active_id),('state','&lt;&gt;','draft')]</field>
</record>
<wizard string="Move line select" menu="False" model="account.move.line" name="account.move.line.select" id="wizard_move_line_select"/>
<record model="ir.values" id="ir_open_account_account">
<field name="key2" eval="'tree_but_open'"/>
<field name="model" eval="'account.account'"/>
<field name="name">Open all entries lines</field>
<field name="value" eval="'ir.actions.act_window,%d'%action_move_line_tree1"/>
<field name="value" eval="'ir.actions.wizard,%d'%wizard_move_line_select"/>
<field name="object" eval="True"/>
</record>

View File

@ -142,12 +142,12 @@
<wizard
string="Third party ledger"
model="res.partner"
name="account.grand.livre.tiers.report"
name="account.third_party_ledger.report"
menu="False"
id="wizard_grand_livre_tiers"/>
id="wizard_third_party_ledger"/>
<menuitem
name="Financial Management/Reporting/Third party ledger"
action="wizard_grand_livre_tiers"
action="wizard_third_party_ledger"
type="wizard"
id="menu_third_party_ledger"/>

View File

@ -32,7 +32,7 @@ import account_journal
import account_balance
import partner_balance
import grand_livre
import grand_livre_tiers
import third_party_ledger
import invoice
import rappel
import aged_trial_balance

View File

@ -49,25 +49,26 @@ class aged_trial_report(report_sxw.rml_parse):
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.state<>'draft') \
ORDER BY res_partner.name")
AND (line.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d))\
ORDER BY res_partner.name" % (form['fiscalyear'],))
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 ('payable','receivable')) \
AND (date<'%s') AND (partner_id=%d) AND (reconcile_id IS NULL) AND (line.state<>'draft')" % (form['0']['start'], partner['id']))
AND (date<'%s') AND (partner_id=%d) AND (reconcile_id IS NULL) AND (line.state<>'draft') AND (line.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d))" % (form['0']['start'], partner['id'], form['fiscalyear']))
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 ('payable','receivable')) \
AND (date>='%s') AND (date<='%s') AND (partner_id=%d) AND (reconcile_id IS NULL) AND line.state<>'draft'" % (form[str(i)]['start'], form[str(i)]['stop'], partner['id']))
AND (date>='%s') AND (date<='%s') AND (partner_id=%d) AND (reconcile_id IS NULL) AND line.state<>'draft' AND (line.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d))" % (form[str(i)]['start'], form[str(i)]['stop'], partner['id'], form['fiscalyear']))
during = self.cr.fetchone()
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 ('payable','receivable')) \
AND (partner_id=%d) AND (reconcile_id IS NULL) AND (line.state<>'draft')" % (partner['id']))
AND (partner_id=%d) AND (reconcile_id IS NULL) AND (line.state<>'draft') AND (line.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d))" % (partner['id'], form['fiscalyear']))
total = self.cr.fetchone()
values['total'] = total and total[0] or 0.0
values['name'] = partner['name']
@ -85,22 +86,22 @@ class aged_trial_report(report_sxw.rml_parse):
totals[str(i)] += float(r[str(i)] or 0.0)
return res
def _get_total(self):
def _get_total(self, fiscalyear):
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 ('payable','receivable')) AND reconcile_id IS NULL AND (line.state<>'draft') and partner_id is not null")
WHERE (line.account_id=account_account.id) AND (account_account.type IN ('payable','receivable')) AND reconcile_id IS NULL AND (line.state<>'draft') and partner_id is not null AND (line.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d))" % (fiscalyear,))
total = self.cr.fetchone()
return total and total[0] or 0.0
def _get_before(self, date):
def _get_before(self, date, fiscalyear):
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 ('payable','receivable')) AND reconcile_id IS NULL AND (date<'%s') and (line.state<>'draft') and partner_id is not null" % (date))
WHERE (line.account_id=account_account.id) AND (account_account.type IN ('payable','receivable')) AND reconcile_id IS NULL AND (date<'%s') and (line.state<>'draft') and partner_id is not null AND (line.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d))" % (date, fiscalyear))
before = self.cr.fetchone()
return before and before[0] or 0.0
def _get_for_period(self, period):
def _get_for_period(self, period, fiscalyear):
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 ('payable','receivable')) \
AND reconcile_id IS NULL AND (date>='%s') AND (date<='%s') and (line.state<>'draft') and partner_id is not null" % (period['start'], period['stop']))
AND reconcile_id IS NULL AND (date>='%s') AND (date<='%s') and (line.state<>'draft') and partner_id is not null AND (line.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d))" % (period['start'], period['stop'], fiscalyear))
period = self.cr.fetchone()
return period and period[0] or 0.0

View File

@ -156,25 +156,25 @@
<para style="P6">Account total</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['4']) ]]</para>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['4'], data['form']['fiscalyear']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['3']) ]]</para>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['3'], data['form']['fiscalyear']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['2']) ]]</para>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['2'], data['form']['fiscalyear']) ]]</para>
</td>
<td>
<para style="P9">[['%.2f' % get_for_period(data['form']['1']) ]]</para>
<para style="P9">[['%.2f' % get_for_period(data['form']['1'], data['form']['fiscalyear']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['0']) ]]</para>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['0'], data['form']['fiscalyear']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_before(data['form']['0']['start']) ]]</para>
<para style="P9">[[ '%.2f' % get_before(data['form']['0']['start'], data['form']['fiscalyear']) ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % get_total() ]]</para>
<para style="P10">[[ '%.2f' % get_total( data['form']['fiscalyear']) ]]</para>
</td>
</tr>
</blockTable>

View File

@ -45,7 +45,7 @@ class partner_balance(report_sxw.rml_parse):
})
def preprocess(self, objects, data, ids):
self.cr.execute('select distinct partner_id from account_move_line where partner_id is not null and date>=%s and date<=%s', (data['form']['date1'], data['form']['date2']))
self.cr.execute('select distinct partner_id from account_move_line where partner_id is not null and date>=%s and date<=%s and period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)', (data['form']['date1'], data['form']['date2'], data['form']['fiscalyear']))
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")
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
@ -58,18 +58,18 @@ class partner_balance(report_sxw.rml_parse):
return []
#TODO: use an SQL CASE to compute sdebit and scredit
#CHECKME: est-ce que les "enlitige", il fautdrait pas tester l etat de la ligne aussi?
self.cr.execute(
"SELECT p.ref, p.name, sum(debit) as debit, sum(credit) as credit, " \
"(SELECT sum(debit-credit) FROM account_move_line WHERE partner_id=p.id AND date>=%s AND date<=%s AND blocked=TRUE) as enlitige " \
"(SELECT sum(debit-credit) FROM account_move_line WHERE partner_id=p.id AND date>=%s AND date<=%s AND blocked=TRUE AND state <>'draft' AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)) as enlitige " \
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
"AND account_id IN (" + self.account_ids + ") " \
"AND l.date>=%s AND l.date<=%s " \
"AND l.state<>'draft' " \
"AND l.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d) " \
"GROUP BY p.id, p.ref, p.name " \
"ORDER BY p.ref, p.name",
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['date1'], self.datas['form']['date2']))
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear'], self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
res = self.cr.dictfetchall()
for r in res:
r['sdebit'] = r['debit'] > r['credit'] and r['debit'] - r['credit']
@ -86,8 +86,9 @@ class partner_balance(report_sxw.rml_parse):
'WHERE partner_id IN (' + self.partner_ids + ') ' \
'AND account_id IN (' + self.account_ids + ') ' \
"AND state<>'draft' " \
'AND date>=%s AND date<=%s',
(self.datas['form']['date1'], self.datas['form']['date2']))
'AND date>=%s AND date<=%s ' \
"AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)",
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self):
@ -100,8 +101,9 @@ class partner_balance(report_sxw.rml_parse):
'WHERE partner_id IN (' + self.partner_ids + ') ' \
'AND account_id IN (' + self.account_ids + ') ' \
"AND state<>'draft' " \
'AND date>=%s AND date<=%s',
(self.datas['form']['date1'], self.datas['form']['date2']))
'AND date>=%s AND date<=%s ' \
'AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)',
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
def _sum_litige(self):
@ -114,8 +116,9 @@ class partner_balance(report_sxw.rml_parse):
'WHERE partner_id IN (' + self.partner_ids + ') ' \
'AND account_id IN (' + self.account_ids + ') ' \
"AND state<>'draft' " \
'AND date>=%s AND date<=%s AND blocked=TRUE',
(self.datas['form']['date1'], self.datas['form']['date2']))
'AND date>=%s AND date<=%s AND blocked=TRUE ' \
'AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)',
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
def _sum_sdebit(self):
@ -131,10 +134,11 @@ class partner_balance(report_sxw.rml_parse):
'AND account_id IN (' + self.account_ids + ') ' \
'AND date>=%s AND date<=%s ' \
"AND state<>'draft' " \
"AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d) " \
'GROUP BY partner_id' \
') AS dc (debit,credit) ' \
'WHERE debit>credit',
(self.datas['form']['date1'], self.datas['form']['date2']))
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
def _sum_scredit(self):
@ -150,10 +154,11 @@ class partner_balance(report_sxw.rml_parse):
'AND account_id IN (' + self.account_ids + ') ' \
'AND date>=%s AND date<=%s ' \
"AND state<>'draft' " \
"AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d) " \
'GROUP BY partner_id' \
') AS dc (debit,credit) ' \
'WHERE credit>debit',
(self.datas['form']['date1'], self.datas['form']['date2']))
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
def _solde_balance_debit(self):

View File

@ -29,9 +29,9 @@ import pooler
import time
from report import report_sxw
class grand_livre_tiers(report_sxw.rml_parse):
class third_party_ledger(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(grand_livre_tiers, self).__init__(cr, uid, name, context)
super(third_party_ledger, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
@ -45,8 +45,8 @@ class grand_livre_tiers(report_sxw.rml_parse):
self.cr.execute(
"SELECT DISTINCT partner_id " \
"FROM account_move_line " \
"WHERE partner_id IS NOT NULL AND date>=%s AND date<=%s AND state<>'draft'",
(data['form']['date1'], data['form']['date2']))
"WHERE partner_id IS NOT NULL AND date>=%s AND date<=%s AND state<>'draft' AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)",
(data['form']['date1'], data['form']['date2'], data['form']['fiscalyear']))
new_ids = [id for (id,) in self.cr.fetchall()]
self.cr.execute(
"SELECT a.id " \
@ -55,7 +55,7 @@ class grand_livre_tiers(report_sxw.rml_parse):
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(grand_livre_tiers, self).preprocess(objects, data, new_ids)
super(third_party_ledger, self).preprocess(objects, data, new_ids)
def lines(self, partner):
self.cr.execute(
@ -63,9 +63,10 @@ class grand_livre_tiers(report_sxw.rml_parse):
"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 state<>'draft'" \
"AND l.date>=%s AND l.date<=%s AND state<>'draft' " \
"AND l.period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d) "\
"ORDER BY l.id",
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
(partner.id, self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
@ -79,8 +80,9 @@ class grand_livre_tiers(report_sxw.rml_parse):
"FROM account_move_line " \
"WHERE partner_id=%d " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date>=%s AND date<=%s AND state<>'draft'",
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
"AND date>=%s AND date<=%s AND state<>'draft' " \
"AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)",
(partner.id, self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit_partner(self, partner):
@ -89,8 +91,9 @@ class grand_livre_tiers(report_sxw.rml_parse):
"FROM account_move_line " \
"WHERE partner_id=%d " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date>=%s AND date<=%s AND state<>'draft'",
(partner.id, self.datas["form"]["date1"], self.datas["form"]["date2"]))
"AND date>=%s AND date<=%s AND state<>'draft' " \
"AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)",
(partner.id, self.datas["form"]["date1"], self.datas["form"]["date2"], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self):
@ -102,8 +105,9 @@ class grand_livre_tiers(report_sxw.rml_parse):
"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 state<>'draft'",
(self.datas['form']['date1'], self.datas['form']['date2']))
"AND date>=%s AND date<=%s AND state<>'draft'" \
"AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)",
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self):
@ -115,8 +119,9 @@ class grand_livre_tiers(report_sxw.rml_parse):
"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 state<>'draft'",
(self.datas['form']['date1'], self.datas['form']['date2']))
"AND date>=%s AND date<=%s AND state<>'draft'" \
"AND period_id in (SELECT id FROM account_period WHERE fiscalyear_id=%d)",
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['fiscalyear']))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.grand.livre.tiers', 'res.partner', 'addons/account/report/grand_livre_tiers.rml',parser=grand_livre_tiers)
report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner', 'addons/account/report/third_party_ledger.rml',parser=third_party_ledger)

View File

@ -43,7 +43,7 @@ import wizard_subscription_generate
import wizard_aged_trial_balance
import wizard_budget_report
import wizard_grand_livre_report
import wizard_grand_livre_tiers_report
import wizard_third_party_ledger
import wizard_account_balance_report
import wizard_partner_balance_report
@ -55,3 +55,5 @@ import wizard_vat
import wizard_invoice_state
import wizard_account_duplicate
import wizard_account_chart
import wizard_move_line_select

View File

@ -0,0 +1,68 @@
##############################################################################
#
# Copyright (c) 2005-2007 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 wizard
import pooler
class wizard_account_chart(wizard.interface):
_account_chart_arch = '''<?xml version="1.0"?>
<form string="Account charts">
<field name="fiscalyear"/>
</form>'''
_account_chart_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True },
}
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)
return data['form']
def _account_chart_open_window(self, cr, uid, data, context):
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
result['context'] = str({'fiscalyear': data['form']['fiscalyear']})
return result
states = {
'init': {
'actions': [_get_defaults],
'result': {'type': 'form', 'arch':_account_chart_arch, 'fields':_account_chart_fields, 'state': [('end', 'Cancel'), ('open', 'Open Charts')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action':_account_chart_open_window, 'state':'end'}
}
}
wizard_account_chart('account.chart')

View File

@ -29,15 +29,19 @@
import wizard
import time
import datetime
import pooler
from mx.DateTime import *
_aged_trial_form = """<?xml version="1.0"?>
<form string="Aged Trial Balance">
<field name="fiscalyear"/>
<newline/>
<field name="period_length"/>
</form>"""
_aged_trial_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
}
@ -58,9 +62,14 @@ def _calc_dates(self, cr, uid, data, context):
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)
return data['form']
states = {
'init': {
'actions': [],
'actions': [_get_defaults],
'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Trial Balance')]},
},
'print': {

View File

@ -62,16 +62,12 @@ def _data_save(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
fy_id = data['form']['fy_id']
cr.execute('update account_journal_period set state=%s where period_id in (select id from account_period where fiscalyear_id=%d)', ('done',fy_id))
cr.execute('update account_period set state=%s where fiscalyear_id=%d', ('done',fy_id))
cr.execute('update account_fiscalyear set state=%s where id=%d', ('done',fy_id))
if data['form']['report_new']:
period = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids[0]
cr.execute('select id from account_account')
ids = map(lambda x: x[0], cr.fetchall())
for account in pool.get('account.account').browse(cr, uid, ids):
if account.close_method=='none':
if account.close_method=='none' or account.type == 'view':
continue
if account.close_method=='balance':
if abs(account.balance)>0.0001:
@ -117,7 +113,9 @@ def _data_save(self, cr, uid, data, context):
pool.get('account.move.line').create(cr, uid, move)
offset += limit
cr.execute('update account_move_line set active=False where period_id in (select id from account_period where fiscalyear_id=%d)', (fy_id,))
cr.execute('update account_journal_period set state=%s where period_id in (select id from account_period where fiscalyear_id=%d)', ('done',fy_id))
cr.execute('update account_period set state=%s where fiscalyear_id=%d', ('done',fy_id))
cr.execute('update account_fiscalyear set state=%s where id=%d', ('done',fy_id))
return {}
class wiz_journal_close(wizard.interface):

View File

@ -0,0 +1,58 @@
##############################################################################
#
# Copyright (c) 2005-2007 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 wizard
import pooler
class wizard_move_line_select(wizard.interface):
def _open_window(self, cr, uid, data, context):
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
if not 'fiscalyear' in context:
context['fiscalyear'] = fiscalyear_obj.find(cr, uid)
fy = fiscalyear_obj.browse(cr, uid, [context['fiscalyear']])[0]
domain = str(('period_id', 'in', [x.id for x in fy.period_ids]))
result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_tree1')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
result['context'] = str({'fiscalyear': context['fiscalyear']})
result['domain']=result['domain'][0:-1]+','+domain+result['domain'][-1]
return result
states = {
'init': {
'actions': [],
'result': {'type': 'action', 'action': _open_window, 'state': 'end'}
}
}
wizard_move_line_select('account.move.line.select')

View File

@ -27,22 +27,31 @@
import time
import wizard
import pooler
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="fiscalyear"/>
<newline/>
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
'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')},
}
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)
return data['form']
states = {
'init': {
'actions': [],
'actions': [_get_defaults],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
},
'report': {

View File

@ -27,29 +27,38 @@
import time
import wizard
import pooler
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="fiscalyear"/>
<newline/>
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
'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')},
}
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)
return data['form']
states = {
'init': {
'actions': [],
'actions': [_get_defaults],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.grand.livre.tiers', 'state':'end'}
'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
}
}
wizard_report('account.grand.livre.tiers.report')
wizard_report('account.third_party_ledger.report')