Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

odoo 8 how to do sorting in point of sale "sale details report" ?

pos
By
JC
on 4/3/15, 9:19 AM 736 views

I would like to sort sale details report in ascending order, could someone help?

I have identified 3 files and sorted function but not sure what to do with them. 

 /addons/point_of_sale/views/report_detailsofsales.xml

/addons/point_of_sale/wizard/pos_details.py 

/addons/point_of_sale/report/pos_details.py 

records.sorted(key=lambda r: r.name)

0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 4/3/15, 10:11 AM

You must inherit class pos_details() in your module and add order='date_start asc' clause, like this:

class pos_details(osv.osv_memory):
      _inherit = 'pos.details'
      

def print_report(self, cr, uid, ids, context=None):
if context is None:
context = {}
datas = {'ids': context.get('active_ids', [])}

res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_ids'], order='date_start asc', context=context)
# or # res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_ids'], order='date_end asc', context=context)

res = res and res[0] or {}
datas['form'] = res
if res.get('id',False):
datas['ids']=[res['id']]
return self.pool['report'].get_action(cr, uid, [], 'point_of_sale.report_detailsofsales', data=datas, context=context)


pos details as far as I know only kept the start date, end date, user ID etc for printing pos orders and details , I wonder how the above class can sort the order base on order date?

JC
on 4/3/15, 10:29 AM

Sorry, my mistake. Answer updated.

zbik
on 4/3/15, 1:14 PM

zbik, currently I can make changes directly in addons/views/report_detailsofsales.xml and it will get change after I do an upgrade, but when I try to make changes in addons/report/pos_details.py , follow the same process to upgrade the changes is not reflected at all. could you help?

JC
on 5/9/15, 10:05 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/3/15, 9:19 AM
Seen: 736 times
Last updated: 4/3/15, 8:15 PM