[IMP]:point_of_sale:Improves the pos_details report
authorsaz-OpenERP <azaz.201186@gmail.com>
Thu, 14 Oct 2010 12:57:19 +0000 (18:27 +0530)
committersaz-OpenERP <azaz.201186@gmail.com>
Thu, 14 Oct 2010 12:57:19 +0000 (18:27 +0530)
bzr revid: azaz.201186@gmail.com-20101014125719-jsh654bm8dvtf97a

addons/point_of_sale/report/pos_details.py
addons/point_of_sale/report/pos_details.rml

index 69a691a..a4b5b8f 100644 (file)
@@ -76,7 +76,7 @@ class pos_details(report_sxw.rml_parse):
         res2=[]
         self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))" \
                          "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt ,res_users as ru,res_company as rc " \
-                         "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state  in('invoiced')  " \
+                         "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state  IN ('invoiced')  " \
                          "and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date  >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date  <= %s " \
                          "and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
                          ,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
@@ -88,7 +88,7 @@ class pos_details(report_sxw.rml_parse):
         res3=[]
         self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))" \
                          "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt, res_users as ru,res_company as rc " \
-                         "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state  in('paid','invoiced','done')  " \
+                         "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state  IN ('paid','invoiced','done')  " \
                          "and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date  >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date  <= %s " \
                          "and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
                          ,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
@@ -96,6 +96,19 @@ class pos_details(report_sxw.rml_parse):
         self.total_paid=res3[0]
         return res3[0] or False
 
+    def _get_sum_dis_2(self,form,user):
+        res4=[]
+        self.cr.execute ("select sum(pol.price_ded * pol.qty)" \
+                         "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt ,res_users as ru,res_company as rc " \
+                         "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state  IN ('paid')  " \
+                         "and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date  >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date  <= %s " \
+                         "and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
+                         ,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
+        res4=self.cr.fetchone()
+        self.total_invoiced=res4[0]
+        return res4[0] or False
+
+
     def _get_sum_discount(self, objects):
         #code for the sum of discount value
         return reduce(lambda acc, object:
@@ -187,7 +200,7 @@ class pos_details(report_sxw.rml_parse):
             'time': time,
             'strip_name': self._strip_name,
             'getpayments': self._get_payments,
-            'getsumdisc': self._get_sum_discount,
+            'getsumdisc': self._get_sum_dis_2,
             'gettotalofthaday': self._total_of_the_day,
             'gettaxamount': self._get_tax_amount,
             'getperiod': self._get_period,
index 36f509a..ae9d725 100644 (file)
             <para style="terp_default_Centre_9">[[ formatLang(line_ids['discount']) ]]</para>
           </td>
           <td>
-            <para style="terp_default_9">[[ getinvoice(line_ids['invoice_id'],user) or removeParentNode('font') ]]</para>
+            <para style="terp_default_Centre_9">[[ getinvoice(line_ids['invoice_id'],user) or removeParentNode('font') ]]</para>
           </td>
         </tr>
       </blockTable>
           <para style="terp_default_Bold_9">Total discount</para>
         </td>
         <td>
-          <para style="terp_default_Right_9_Bold">[[ formatLang(getsumdisc(objects)) ]] [[ company.currency_id.symbol ]]</para>
+          <para style="terp_default_Right_9_Bold">[[ formatLang(getsumdisc(data['form'],user)) ]] [[ company.currency_id.symbol ]]</para>
         </td>
       </tr>
       <tr>