[RMV] remove improvemets to calculate amount based on currency from analysis reports.
authorTurkesh Patel (Open ERP) <tpa@tinyerp.com>
Wed, 4 Sep 2013 11:25:40 +0000 (16:55 +0530)
committerTurkesh Patel (Open ERP) <tpa@tinyerp.com>
Wed, 4 Sep 2013 11:25:40 +0000 (16:55 +0530)
bzr revid: tpa@tinyerp.com-20130904112540-4ovecz1mpjkok7ge

addons/account/report/account_invoice_report.py
addons/account/report/account_invoice_report_view.xml
addons/crm/report/crm_lead_report.py
addons/crm/report/crm_lead_report_view.xml
addons/sale/report/sale_report.py

index ef9478f..c08ea91 100644 (file)
@@ -29,7 +29,7 @@ class account_invoice_report(osv.osv):
     _auto = False
     _rec_name = 'date'
 
-    def _compute_amounts_in_user_currency(self, cr, uid, ids, field_names=[], args={}, context=None):
+    def def _compute_amounts_in_user_currency(self, cr, uid, ids, field_names, args, context=None):
         """Compute the amounts in the currency of the user
         """
         if context is None:
@@ -103,18 +103,6 @@ class account_invoice_report(osv.osv):
     }
     _order = 'date desc'
 
-    #FIX:To show sum of values of function fields in groupby
-    def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
-        res = super(account_invoice_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby)
-        for group in res:
-            group['user_currency_price_total'] = 0
-            if group.get('__domain'):
-                group_ids = self.search(cr, uid, group.get('__domain'),context=context)
-                record = self._compute_amounts_in_user_currency(cr, uid, group_ids, context=context)
-                for id, rec in record.iteritems():
-                    group['user_currency_price_total'] += rec['user_currency_price_total']
-        return res
-
     def _select(self):
         select_str = """
             SELECT sub.id, sub.date, sub.year, sub.month, sub.day, sub.product_id, sub.partner_id, sub.country_id,
index 4c297fd..5f38db5 100644 (file)
@@ -30,7 +30,7 @@
                 <field name="nbr" sum="# of Lines"/>
                 <field name="product_qty" sum="Qty"/>
                 <!-- <field name="reconciled"  sum="# Reconciled"/> -->
-                <field name="user_currency_price_total" sum="Total Without Tax"/>
+                <field name="price_total" sum="Total Without Tax"/>
             </tree>
         </field>
     </record>
@@ -41,7 +41,7 @@
          <field name="arch" type="xml">
              <graph string="Invoices Analysis" type="bar">
                  <field name="product_id"/>
-                 <field name="user_currency_price_total"/>
+                 <field name="price_total"/>
              </graph>
          </field>
     </record>
index c2f1c0b..f379e06 100644 (file)
@@ -45,19 +45,6 @@ class crm_lead_report(osv.osv):
     _description = "CRM Lead Analysis"
     _rec_name = 'deadline_day'
 
-    def _compute_amounts_in_user_currency(self, cr, uid, ids, field_names=[], args={}, context=None):
-        """Compute the amounts in the currency of the user
-        """
-        res = {}
-        currency_obj = self.pool.get('res.currency')
-        user_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
-        for item in self.browse(cr, uid, ids, context=context):
-            res[item.id] = {
-                'user_currency_planned_revenue': currency_obj.compute(cr, uid, item.company_id.currency_id.id, user_currency_id, item.planned_revenue, context=context),
-                'user_currency_probable_revenue': currency_obj.compute(cr, uid, item.company_id.currency_id.id, user_currency_id, item.probable_revenue, context=context),
-            }
-        return res
-
     _columns = {
         # grouping fields based on Deadline Date
         'deadline_year': fields.char('Ex. Closing Year', size=10, readonly=True, help="Expected closing year"),
@@ -88,9 +75,7 @@ class crm_lead_report(osv.osv):
         'company_id': fields.many2one('res.company', 'Company', readonly=True),
         'probability': fields.float('Probability',digits=(16,2),readonly=True, group_operator="avg"),
         'planned_revenue': fields.float('Planned Revenue',digits=(16,2),readonly=True),
-        'user_currency_planned_revenue': fields.function(_compute_amounts_in_user_currency, string="Planned Revenue", type='float',digits=(16,2), multi="_compute_amounts", readonly=True),
         'probable_revenue': fields.float('Probable Revenue', digits=(16,2),readonly=True),
-        'user_currency_probable_revenue': fields.function(_compute_amounts_in_user_currency, string="Probable Revenue", type='float',digits=(16,2), multi="_compute_amounts",readonly=True),
         'stage_id': fields.many2one ('crm.case.stage', 'Stage', readonly=True, domain="[('section_ids', '=', section_id)]"),
         'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True),
         'nbr': fields.integer('# of Cases', readonly=True),
@@ -101,20 +86,6 @@ class crm_lead_report(osv.osv):
             ('opportunity','Opportunity'),
         ],'Type', help="Type is used to separate Leads and Opportunities"),
     }
-
-    #FIX:To show sum of values of function fields in groupby
-    def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
-        res = super(crm_lead_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby)
-        for group in res:
-            group['user_currency_probable_revenue'] = 0
-            group['user_currency_planned_revenue'] = 0
-            if group.get('__domain'):
-                group_ids = self.search(cr, uid, group.get('__domain'),context=context)
-                record = self._compute_amounts_in_user_currency(cr, uid, group_ids, context=context)
-                for id, rec in record.iteritems():
-                    group['user_currency_planned_revenue'] += rec['user_currency_planned_revenue']
-                    group['user_currency_probable_revenue'] += rec['user_currency_probable_revenue']
-        return res
     
     def init(self, cr):
         """
index f718d7a..c7220fe 100644 (file)
@@ -28,7 +28,7 @@
                 <field name="nbr" sum="# Leads"/>
                 <field name="delay_open"/>
                 <field name="delay_close"/>
-                <field name="user_currency_planned_revenue"/>
+                <field name="planned_revenue"/>
              </tree>
             </field>
         </record>
@@ -53,7 +53,7 @@
             <field name="arch" type="xml">
                 <graph orientation="vertical" string="Leads Analysis" type="bar">
                     <field name="stage_id"/>
-                    <field name="user_currency_planned_revenue" operator="+"/>
+                    <field name="planned_revenue" operator="+"/>
                     <field group="True" name="user_id"/>
                 </graph>
             </field>
                 <field name="type" invisible="1"/>
                 <field name="company_id" invisible="1" groups="base.group_multi_company"/>
                 <field name="nbr" string="#Opportunities" sum="#Opportunities"/>
-                <field name="user_currency_planned_revenue" sum="Planned Revenues"/>
+                <field name="planned_revenue" sum="Planned Revenues"/>
                 <field name="delay_open" sum='Delay to Assign'/>
                 <field name="delay_close" sum='Delay to close'/>
                 <field name="date_last_stage_update"/>
                 <field name="delay_expected"/>
                 <field name="probability" widget="progressbar"/>
-                <field name="user_currency_probable_revenue"/>
+                <field name="probable_revenue"/>
              </tree>
             </field>
         </record>
index fb7ac78..969df76 100644 (file)
@@ -27,17 +27,7 @@ class sale_report(osv.osv):
     _description = "Sales Orders Statistics"
     _auto = False
     _rec_name = 'date'
-    def _compute_total_in_user_currency(self, cr, uid, ids, field_names=[], args={}, context=None):
-        """Compute the Price total in the currency of the user
-        """
-        res = {}
-        currency_obj = self.pool.get('res.currency')
-        user_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
-        for item in self.browse(cr, uid, ids, context=context):
-            res[item.id] = {
-                'user_price_total': currency_obj.compute(cr, uid, item.pricelist_id.currency_id.id, user_currency_id, item.price_total, context=context),
-            }
-        return res
+
     _columns = {
         'date': fields.date('Date Order', readonly=True),
         'date_confirm': fields.date('Date Confirm', readonly=True),
@@ -68,7 +58,6 @@ class sale_report(osv.osv):
             ], 'Order Status', readonly=True),
         'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', readonly=True),
         'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True),
-        'user_price_total': fields.function(_compute_total_in_user_currency, string="Total Price", type='float',digits=(16,2), multi="_compute_amounts", readonly=True),
     }
     _order = 'date desc'
 
@@ -125,16 +114,6 @@ class sale_report(osv.osv):
         """
         return group_by_str
 
-    def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
-        res = super(sale_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby)
-        for group in res:
-            group['user_price_total'] = 0
-            group_ids = self.search(cr, uid, group.get('__domain'),context=context)
-            record = self._compute_total_in_user_currency(cr, uid, group_ids, context=context)
-            for id, rec in record.iteritems():
-                group['user_price_total'] += rec['user_price_total']
-        return res
-
     def init(self, cr):
         # self._table = sale_report
         tools.drop_view_if_exists(cr, self._table)