[IMP] l10n_fr: Code improved
bzr revid: mra@mra-laptop-20100818045314-kg11zkfizxlnn1bs
This commit is contained in:
parent
ad32f01bae
commit
18b8ed7835
|
@ -29,9 +29,11 @@ class l10n_fr_report(osv.osv):
|
|||
'name': fields.char('Name', size=128),
|
||||
'line_ids': fields.one2many('l10n.fr.line', 'report_id', 'Lines'),
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
('code_uniq', 'unique (code)','The code report must be unique !')
|
||||
]
|
||||
|
||||
l10n_fr_report()
|
||||
|
||||
class l10n_fr_line(osv.osv):
|
||||
|
@ -46,6 +48,7 @@ class l10n_fr_line(osv.osv):
|
|||
_sql_constraints = [
|
||||
('code_uniq', 'unique (code)', 'The variable name must be unique !')
|
||||
]
|
||||
|
||||
l10n_fr_line()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -27,10 +27,11 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from report import report_sxw
|
||||
|
||||
class base_report(report_sxw.rml_parse):
|
||||
def __init__(self, cr, uid, name, context):
|
||||
def __init__(self, cr, uid, name, context=None):
|
||||
super(base_report, self).__init__(cr, uid, name, context=context)
|
||||
self.localcontext.update({
|
||||
'time': time,
|
||||
|
@ -40,48 +41,46 @@ class base_report(report_sxw.rml_parse):
|
|||
})
|
||||
self.context = context
|
||||
|
||||
def _load(self,name,form):
|
||||
fiscalyear=self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear'])
|
||||
def _load(self, name, form):
|
||||
fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear'])
|
||||
period_query_cond=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear'])])
|
||||
|
||||
period_query_cond=self.pool.get('account.period').search(self.cr, self.uid,[('fiscalyear_id','=',form['fiscalyear'])])
|
||||
|
||||
self.cr.execute("SELECT MIN(date_start) AS date_start, MAX(date_stop) AS date_stop FROM account_period WHERE id IN %s",(tuple(period_query_cond),))
|
||||
dates =self.cr.dictfetchall()
|
||||
self.cr.execute("SELECT MIN(date_start) AS date_start, MAX(date_stop) AS date_stop FROM account_period WHERE id IN %s", (tuple(period_query_cond),))
|
||||
dates = self.cr.dictfetchall()
|
||||
self._set_variable('date_start', dates[0]['date_start'])
|
||||
self._set_variable('date_stop', dates[0]['date_stop'])
|
||||
|
||||
self.cr.execute("SELECT l10n_fr_line.code,definition FROM l10n_fr_line LEFT JOIN l10n_fr_report ON l10n_fr_report.id=report_id WHERE l10n_fr_report.code=%s",(name,))
|
||||
datas =self.cr.dictfetchall()
|
||||
datas = self.cr.dictfetchall()
|
||||
for line in datas:
|
||||
self._load_accounts(form,line['code'],eval(line['definition']),fiscalyear,period_query_cond)
|
||||
|
||||
def _set_variable(self,variable,valeur):
|
||||
self.localcontext.update({variable:valeur})
|
||||
def _set_variable(self, variable, valeur):
|
||||
self.localcontext.update({variable: valeur})
|
||||
|
||||
def _get_variable(self,variable):
|
||||
def _get_variable(self, variable):
|
||||
return self.localcontext[variable]
|
||||
|
||||
def _load_accounts(self,form,code,definition,fiscalyear,period_query_cond):
|
||||
accounts={}
|
||||
accounts = {}
|
||||
for x in definition['load']:
|
||||
p=x.split(":")
|
||||
accounts[p[1]]=[p[0],p[2]]
|
||||
sum=0.0
|
||||
|
||||
if fiscalyear.state!='done' or not code.startswith('bpcheck'):
|
||||
query_cond="("
|
||||
p = x.split(":")
|
||||
accounts[p[1]] = [p[0],p[2]]
|
||||
sum = 0.0
|
||||
if fiscalyear.state != 'done' or not code.startswith('bpcheck'):
|
||||
query_cond = "("
|
||||
for account in accounts:
|
||||
query_cond += "aa.code LIKE '"+account+"%' OR "
|
||||
query_cond += "aa.code LIKE '" + account + "%' OR "
|
||||
query_cond = query_cond[:-4]+")"
|
||||
|
||||
if len(definition['except'])>0:
|
||||
if len(definition['except']) > 0:
|
||||
query_cond = query_cond+" and ("
|
||||
for account in definition['except']:
|
||||
query_cond += "aa.code NOT LIKE '"+account+"%' AND "
|
||||
query_cond = query_cond[:-5]+")"
|
||||
|
||||
closed_cond=""
|
||||
if fiscalyear.state=='done':
|
||||
closed_cond = ""
|
||||
if fiscalyear.state == 'done':
|
||||
closed_cond=" AND (aml.move_id NOT IN (SELECT account_move.id as move_id FROM account_move WHERE period_id IN "+str(tuple(period_query_cond))+" AND journal_id=(SELECT res_id FROM ir_model_data WHERE name='closing_journal' AND module='l10n_fr')) OR (aa.type != 'income' AND aa.type !='expense'))"
|
||||
|
||||
query = "SELECT aa.code AS code, SUM(debit) as debit, SUM(credit) as credit FROM account_move_line aml LEFT JOIN account_account aa ON aa.id=aml.account_id WHERE "+query_cond+closed_cond+" AND aml.state='valid' AND aml.period_id IN "+str(tuple(period_query_cond))+" GROUP BY code"
|
||||
|
@ -94,19 +93,19 @@ class base_report(report_sxw.rml_parse):
|
|||
operator=accounts[account][0]
|
||||
type=accounts[account][1]
|
||||
value=0.0
|
||||
if(type=="S"):
|
||||
if(type == "S"):
|
||||
value=line["debit"]-line["credit"]
|
||||
elif(type=="D"):
|
||||
elif(type == "D"):
|
||||
value=line["debit"]-line["credit"]
|
||||
if(value<0.001): value=0.0
|
||||
elif(type=="C"):
|
||||
elif(type == "C"):
|
||||
value=line["credit"]-line["debit"]
|
||||
if(value<0.001): value=0.0
|
||||
if(operator=='+'):
|
||||
sum+=value
|
||||
if(operator == '+'):
|
||||
sum += value
|
||||
else:
|
||||
sum-=value
|
||||
sum -= value
|
||||
break
|
||||
self._set_variable(code, sum)
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -32,24 +32,25 @@ class account_bilan_report(osv.osv_memory):
|
|||
_name = 'account.bilan.report'
|
||||
_description = 'Account Bilan Report'
|
||||
|
||||
def _get_default_fiscalyear(self, cr, uid, context):
|
||||
def _get_default_fiscalyear(self, cr, uid, context=None):
|
||||
fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid)
|
||||
return fiscalyear_id
|
||||
|
||||
_columns = {
|
||||
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True),
|
||||
}
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'fiscalyear_id':_get_default_fiscalyear
|
||||
}
|
||||
}
|
||||
|
||||
def print_bilan_report(self, cr, uid, ids, context=None):
|
||||
active_ids = context.get('active_ids',[])
|
||||
active_ids = context.get('active_ids', [])
|
||||
data = {}
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
data['form']['fiscalyear'] = self.browse(cr, uid, ids)[0].fiscalyear_id.id
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'l10n.fr.bilan', 'datas': data }
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'l10n.fr.bilan', 'datas': data}
|
||||
|
||||
account_bilan_report()
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="bilan_report_view" model="ir.ui.view">
|
||||
<field name="name">Bilan Report</field>
|
||||
<field name="model">account.bilan.report</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form string="Bilan Report">
|
||||
<field name="fiscalyear_id"/>
|
||||
<separator colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
|
@ -36,5 +38,6 @@
|
|||
<field name="key">action</field>
|
||||
<field name="model">account.move.line</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
|
@ -31,21 +31,21 @@ from osv import osv, fields
|
|||
class account_cdr_report(osv.osv_memory):
|
||||
_name = 'account.cdr.report'
|
||||
_description = 'Account CDR Report'
|
||||
|
||||
def _get_defaults(self, cr, uid, context):
|
||||
fiscalyear_obj = self.pool.get('account.fiscalyear')
|
||||
fiscalyear_id = fiscalyear_obj.find(cr, uid)
|
||||
|
||||
def _get_defaults(self, cr, uid, context=None):
|
||||
fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid)
|
||||
return fiscalyear_id
|
||||
|
||||
|
||||
_columns = {
|
||||
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True),
|
||||
}
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'fiscalyear_id': _get_defaults
|
||||
}
|
||||
'fiscalyear_id': _get_defaults
|
||||
}
|
||||
|
||||
def print_cdr_report(self, cr, uid, ids, context=None):
|
||||
active_ids = context.get('active_ids',[])
|
||||
active_ids = context.get('active_ids', [])
|
||||
data = {}
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
|
@ -54,5 +54,4 @@ class account_cdr_report(osv.osv_memory):
|
|||
|
||||
account_cdr_report()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,12 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="cdr_report_view" model="ir.ui.view">
|
||||
<field name="name">Compte de resultat Report</field>
|
||||
<field name="model">account.cdr.report</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form string='Compte de resultant'>
|
||||
<field name="fiscalyear_id"/>
|
||||
<separator colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
|
@ -36,5 +37,6 @@
|
|||
<field name="key">action</field>
|
||||
<field name="model">account.move.line</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
Loading…
Reference in New Issue