Chris Biersbach (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-580115-cbi into 
lp:openobject-addons/6.1.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-580115-cbi/+merge/130497

In the l10n_fr module, 2 reports (Cilan and COmpte de Résultats) did not 
contain any values when printed.

This fixes these 2 reports and also cleans up the code a bit.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-580115-cbi/+merge/130497
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-580115-cbi.
=== modified file 'l10n_fr/report/base_report.py'
--- l10n_fr/report/base_report.py	2011-01-14 00:11:01 +0000
+++ l10n_fr/report/base_report.py	2012-10-19 08:06:23 +0000
@@ -30,6 +30,8 @@
 
 from report import report_sxw
 
+from tools import float_round
+
 class base_report(report_sxw.rml_parse):
     def __init__(self, cr, uid, name, context=None):
         super(base_report, self).__init__(cr, uid, name, context=context)
@@ -42,8 +44,8 @@
         self.context = context
 
     def _load(self, name, form):
-        fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear_id'])
-        period_ids=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear_id'])])
+        fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear'])
+        period_ids=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear'])])
 
         if period_ids:
             self.cr.execute("SELECT MIN(date_start) AS date_start, MAX(date_stop) AS date_stop FROM account_period WHERE id = ANY(%s)", (period_ids,))
@@ -95,26 +97,23 @@
             query_params.append(list(period_ids))
             self.cr.execute(query, query_params)
 
-            lines =self.cr.dictfetchall()
+            lines = self.cr.dictfetchall()
             for line in lines:
                 for account in accounts:
                     if(line["code"].startswith(account)):
-                        operator=accounts[account][0]
-                        type=accounts[account][1]
-                        value=0.0
-                        if(type == "S"):
-                            value=line["debit"]-line["credit"]
-                        elif(type == "D"):
-                            value=line["debit"]-line["credit"]
-                            if(value<0.001): value=0.0
-                        elif(type == "C"):
+                        operator = accounts[account][0]
+                        type = accounts[account][1]
+                        value = 0.0
+                        if type in ["S", "D"]:
+                            value=line["debit"]-line["credit"]
+                        else:
                             value=line["credit"]-line["debit"]
-                            if(value<0.001): value=0.0
+                        if type in ["D", "C"]:
+                            value = float_round(value, precision_digits=3)
                         if(operator == '+'):
                             sum += value
                         else:
                             sum -= value
-                        break
         self._set_variable(code, sum)
 
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to