diff --git a/addons/point_of_sale/report/pos_details.py b/addons/point_of_sale/report/pos_details.py index 69a691a14f9..a4b5b8f4c1e 100644 --- a/addons/point_of_sale/report/pos_details.py +++ b/addons/point_of_sale/report/pos_details.py @@ -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, diff --git a/addons/point_of_sale/report/pos_details.rml b/addons/point_of_sale/report/pos_details.rml index 36f509a770e..ae9d7252984 100644 --- a/addons/point_of_sale/report/pos_details.rml +++ b/addons/point_of_sale/report/pos_details.rml @@ -247,7 +247,7 @@ [[ formatLang(line_ids['discount']) ]] - [[ getinvoice(line_ids['invoice_id'],user) or removeParentNode('font') ]] + [[ getinvoice(line_ids['invoice_id'],user) or removeParentNode('font') ]] @@ -359,7 +359,7 @@ Total discount - [[ formatLang(getsumdisc(objects)) ]] [[ company.currency_id.symbol ]] + [[ formatLang(getsumdisc(data['form'],user)) ]] [[ company.currency_id.symbol ]]