Ujjvala Collins (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-pos_sales_details_report-uco into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-pos_sales_details_report-uco/+merge/75123
[IMP] point_of_sale:
-------------------------------
Point 3 : Add a wizard in the print Sales details: Point of Sale / Reporting /
Sale Details
Once the user click on this menu item, he would be able to choose users (as in
Point of Sale/Reporting/Sales lines Report). If no user is chosen, it takes the
user who is currently logged in.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-pos_sales_details_report-uco/+merge/75123
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-pos_sales_details_report-uco.
=== modified file 'point_of_sale/report/pos_details.py'
--- point_of_sale/report/pos_details.py 2011-01-14 00:11:01 +0000
+++ point_of_sale/report/pos_details.py 2011-09-13 06:32:23 +0000
@@ -24,7 +24,7 @@
class pos_details(report_sxw.rml_parse):
- def _get_invoice(self,inv_id,user):
+ def _get_invoice(self,inv_id):
res={}
if inv_id:
self.cr.execute("select name from account_invoice as ac where id = %s", (inv_id,))
@@ -33,15 +33,16 @@
else:
return ''
- def _pos_sales_details(self,form,user):
- data={}
+ def _pos_sales_details(self,form):
+ data = {}
+ user_ids = form['user_ids'] or [self.uid]
self.cr.execute ("select po.name as pos_name,po.date_order,pt.name, pp.default_code as code,pol.qty,pu.name as uom,pol.price_unit,pol.discount,po.invoice_id,sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt,product_uom as pu,res_users as ru,res_company as rc " \
"where pt.id=pp.product_tmpl_id and pu.id=pt.uom_id and pp.id=pol.product_id and po.id = pol.order_id and po.state IN ('done','paid','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 " \
+ "and po.user_id = ru.id and rc.id = po.company_id and ru.id IN %s " \
"group by po.name,pol.qty,po.date_order,pt.name,pp.default_code,pu.name,pol.price_unit,pol.discount,po.invoice_id " \
- ,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
+ ,(form['date_start'],form['date_end'],tuple(user_ids)))
data=self.cr.dictfetchall()
if data:
for d in data:
@@ -51,58 +52,62 @@
else:
return {}
- def _get_qty_total_2(self, form,user):
+ def _get_qty_total_2(self, form):
qty=[]
+ user_ids = form['user_ids'] or [self.uid]
self.cr.execute("select sum(pol.qty) as 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 ('done','paid','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)))
+ "and po.user_id = ru.id and rc.id = po.company_id and ru.id IN %s " \
+ ,(form['date_start'],form['date_end'],tuple(user_ids)))
qty = self.cr.fetchone()
return qty[0] or 0.00
- def _get_sales_total_2(self, form,user):
+ def _get_sales_total_2(self, form):
self.cr.execute("select sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total " \
"from pos_order_line as pol, pos_order po, product_product as pp,product_template as pt " \
- " where po.company_id='%s' and po.id=pol.order_id and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= '%s' " \
+ " where po.id=pol.order_id 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.state IN ('paid','invoiced','done') " \
- " and pt.id=pp.product_tmpl_id and pol.product_id=pp.id"% (str(user.company_id.id),form['date_start'],form['date_end']))
+ " and pt.id=pp.product_tmpl_id and pol.product_id=pp.id"% (form['date_start'],form['date_end']))
res2=self.cr.fetchone()
return res2 and res2[0] or 0.0
- def _get_sum_invoice_2(self,form,user):
+ def _get_sum_invoice_2(self,form):
res2=[]
+ user_ids = form['user_ids'] or [self.uid]
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,account_invoice as ai " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and ai.id=po.invoice_id " \
"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)))
+ "and po.user_id = ru.id and rc.id = po.company_id and ru.id IN %s " \
+ ,(form['date_start'],form['date_end'],tuple(user_ids)))
res2=self.cr.fetchone()
self.total_invoiced=res2[0]
return res2[0] or False
- def _paid_total_2(self,form,user):
+ def _paid_total_2(self,form):
res3=[]
+ user_ids = form['user_ids'] or [self.uid]
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') " \
"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)))
+ "and po.user_id = ru.id and rc.id = po.company_id and ru.id IN %s " \
+ ,(form['date_start'],form['date_end'],tuple(user_ids)))
res3=self.cr.fetchone()
self.total_paid=res3[0]
return res3[0] or False
- def _get_sum_dis_2(self,form,user):
+ def _get_sum_dis_2(self,form):
res4=[]
+ user_ids = form['user_ids'] or [self.uid]
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)))
+ "and po.user_id = ru.id and rc.id = po.company_id and ru.id IN %s " \
+ ,(form['date_start'],form['date_end'],tuple(user_ids)))
res4=self.cr.fetchone()
self.total_invoiced=res4[0]
return res4[0] or False
@@ -118,10 +123,11 @@
objects,
0.0)
- def _get_payments(self, form,user):
+ def _get_payments(self, form):
statement_line_obj = self.pool.get("account.bank.statement.line")
pos_order_obj = self.pool.get("pos.order")
- pos_ids=pos_order_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','=',self.uid)])
+ user_ids = form['user_ids'] or [self.uid]
+ pos_ids=pos_order_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','in',user_ids)])
data={}
if pos_ids:
st_line_ids = statement_line_obj.search(self.cr, self.uid, [('pos_statement_id', 'in', pos_ids)])
@@ -164,13 +170,14 @@
def _strip_name(self, name, maxlen=50):
return self._ellipsis(name, maxlen, ' ...')
- def _get_tax_amount(self, form,user):
+ def _get_tax_amount(self, form):
res = {}
temp={}
list_ids = []
temp2 = 0.0
+ user_ids = form['user_ids'] or [self.uid]
pos_order_obj = self.pool.get("pos.order")
- pos_ids = pos_order_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','=',self.uid)])
+ pos_ids = pos_order_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','in',user_ids)])
temp.update({'name':''})
for order in pos_order_obj.browse(self.cr, self.uid, pos_ids):
temp2 +=order.amount_tax
=== modified file 'point_of_sale/report/pos_details.rml'
--- point_of_sale/report/pos_details.rml 2011-01-14 00:11:01 +0000
+++ point_of_sale/report/pos_details.rml 2011-09-13 06:32:23 +0000
@@ -225,7 +225,7 @@
</tr>
</blockTable>
<section>
- <para style="terp_default_1">[[ repeatIn(pos_sales_details(data['form'],user), 'line_ids') ]]</para>
+ <para style="terp_default_1">[[ repeatIn(pos_sales_details(data['form']), 'line_ids') ]]</para>
<blockTable colWidths="54.0,44.0,159.0,54.0,75.0,36.0,89.0" style="Table6">
<tr>
<td>
@@ -247,7 +247,7 @@
<para style="terp_default_Centre_9">[[ formatLang(line_ids['discount'], dp='Sale Price') ]]</para>
</td>
<td>
- <para style="terp_default_Centre_9">[[ getinvoice(line_ids['invoice_id'],user) or removeParentNode('font') ]]</para>
+ <para style="terp_default_Centre_9">[[ getinvoice(line_ids['invoice_id']) or removeParentNode('font') ]]</para>
</td>
</tr>
</blockTable>
@@ -268,7 +268,7 @@
</tr>
</blockTable>
<section>
- <para style="terp_default_1">[[ repeatIn(gettaxamount(data['form'],user), 'p')]]</para>
+ <para style="terp_default_1">[[ repeatIn(gettaxamount(data['form']), 'p')]]</para>
<blockTable colWidths="256.0,256.0" style="Table5">
<tr>
<td>
@@ -299,7 +299,7 @@
</tr>
</blockTable>
<section>
- <para style="terp_default_1">[[ repeatIn(getpayments(data['form'],user), 'p') ]]</para>
+ <para style="terp_default_1">[[ repeatIn(getpayments(data['form']), 'p') ]]</para>
<blockTable colWidths="255.0,255.0" style="Table11">
<tr>
<td>
@@ -335,7 +335,7 @@
<para style="terp_default_Bold_9">Sales total(Revenue)</para>
</td>
<td>
- <para style="terp_default_Right_9_Bold">[[ formatLang(getsalestotal2(data['form'],user), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
+ <para style="terp_default_Right_9_Bold">[[ formatLang(getsalestotal2(data['form']), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
</td>
</tr>
<tr>
@@ -343,7 +343,7 @@
<para style="terp_default_Bold_9">Qty of product</para>
</td>
<td>
- <para style="terp_default_Right_9_Bold">[[ formatLang(getqtytotal2(data['form'],user)) ]]</para>
+ <para style="terp_default_Right_9_Bold">[[ formatLang(getqtytotal2(data['form'])) ]]</para>
</td>
</tr>
<tr>
@@ -351,7 +351,7 @@
<para style="terp_default_Bold_9">Total invoiced</para>
</td>
<td>
- <para style="terp_default_Right_9_Bold">[[ formatLang(getsuminvoice2(data['form'],user), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
+ <para style="terp_default_Right_9_Bold">[[ formatLang(getsuminvoice2(data['form']), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
</td>
</tr>
<tr>
@@ -359,7 +359,7 @@
<para style="terp_default_Bold_9">Total discount</para>
</td>
<td>
- <para style="terp_default_Right_9_Bold">[[ formatLang(getsumdisc(data['form'],user), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
+ <para style="terp_default_Right_9_Bold">[[ formatLang(getsumdisc(data['form']), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
</td>
</tr>
<tr>
@@ -367,7 +367,7 @@
<para style="terp_default_Bold_9">Total paid</para>
</td>
<td>
- <para style="terp_default_Right_9_Bold">[[ formatLang(getpaidtotal2(data['form'],user), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
+ <para style="terp_default_Right_9_Bold">[[ formatLang(getpaidtotal2(data['form']), dp='Sale Price') ]] [[ company.currency_id.symbol ]]</para>
</td>
</tr>
<tr>
=== modified file 'point_of_sale/report/pos_details.sxw'
Binary files point_of_sale/report/pos_details.sxw 2011-01-14 00:11:01 +0000 and point_of_sale/report/pos_details.sxw 2011-09-13 06:32:23 +0000 differ
=== modified file 'point_of_sale/test/point_of_sale_report.yml'
--- point_of_sale/test/point_of_sale_report.yml 2011-02-03 13:15:11 +0000
+++ point_of_sale/test/point_of_sale_report.yml 2011-09-13 06:32:23 +0000
@@ -70,7 +70,7 @@
import time
ctx={}
ctx.update({'model': 'ir.ui.menu','active_ids': []})
- data_dict = {'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d')}
+ data_dict = {'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d'), 'user_ids': [(6,0,[ref('base.user_root')])]}
from tools import test_reports
test_reports.try_report_action(cr, uid, 'action_report_pos_details',wiz_data=data_dict, context=ctx, our_module='point_of_sale')
@@ -93,7 +93,7 @@
journal_id: account_journal_cash0
line_ids:
- name: statement
- date: !eval "(datetime.now() + timedelta(5*31)).strftime('%Y-%m-%d')"
+ date: !eval "(datetime.now() + timedelta(5*31)).strftime('%Y-%m-%d')"
type: customer
account_id: account_pos_account_sales
amount: 100
=== modified file 'point_of_sale/wizard/pos_details.py'
--- point_of_sale/wizard/pos_details.py 2011-01-14 00:11:01 +0000
+++ point_of_sale/wizard/pos_details.py 2011-09-13 06:32:23 +0000
@@ -29,7 +29,8 @@
_columns = {
'date_start': fields.date('Date Start', required=True),
- 'date_end': fields.date('Date End', required=True)
+ 'date_end': fields.date('Date End', required=True),
+ 'user_ids': fields.many2many('res.users', 'sale_user_rel', 'user_id', 'uid', 'Salesman'),
}
_defaults = {
'date_start': lambda *a: time.strftime('%Y-%m-%d'),
@@ -48,7 +49,7 @@
if context is None:
context = {}
datas = {'ids': context.get('active_ids', [])}
- res = self.read(cr, uid, ids, ['date_start', 'date_end'], context=context)
+ res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_ids'], context=context)
res = res and res[0] or {}
datas['form'] = res
if res.get('id',False):
=== modified file 'point_of_sale/wizard/pos_details.xml'
--- point_of_sale/wizard/pos_details.xml 2011-01-14 00:11:01 +0000
+++ point_of_sale/wizard/pos_details.xml 2011-09-13 06:32:23 +0000
@@ -1,23 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
- <data>
+ <data>
<!-- pos.details -->
-
+
<record id="view_pos_details" model="ir.ui.view">
<field name="name">POS Details</field>
<field name="model">pos.details</field>
<field name="type">form</field>
<field name="arch" type="xml">
- <form string="POS Details :">
- <group col="2" colspan="4">
- <field name="date_start"/>
- <field name="date_end"/>
- <separator colspan="4"/>
- <button icon='gtk-cancel' special="cancel"
- string="Close" />
- <button name="print_report" string="Print Report"
- colspan="1" type="object" icon="gtk-print" />
- </group>
+ <form string="POS Details">
+ <group col="4" colspan="4">
+ <separator string="Dates" colspan="4"/>
+ <field name="date_start"/>
+ <field name="date_end"/>
+ <separator string="User" colspan="4"/>
+ <field name="user_ids" nolabel="1" colspan="4"/>
+ <separator string="" colspan="4"/>
+ <label string="" colspan="2"/>
+ <group colspan="2" col="2">
+ <button icon='gtk-cancel' special="cancel"
+ string="Close" />
+ <button name="print_report" string="Print Report"
+ colspan="1" type="object" icon="gtk-print" />
+ </group>
+ </group>
</form>
</field>
</record>
@@ -32,6 +38,6 @@
<field name="target">new</field>
</record>
-
+
</data>
-</openerp>
\ No newline at end of file
+</openerp>
\ No newline at end of file
_______________________________________________
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