This question has been flagged
1 Reply
3503 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)

Avatar
Discard
Best Answer

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)


Avatar
Discard
Author

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?

Sorry, my mistake. Answer updated.

Author

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?