I want to generate a list (tree) that shows the most purchased products with extra data (product, quantity of orders, total of units purchased, total amount, date of last purchase, average of days between purchases).
I supose I should create a new class, process the data and associate it res_partner. I don't have idea about how to implement this: Should be a stored model? Can I process this data without store the result?
I hope you can help me!
You can Create On Screen Report For that.
from openerp import fields,api,models
from openerp import tools
class on_screen_report(models.Model):
_name = "on.screen.report"
_description = "On Screen Report"
_auto = False
"""
Needed fields.
"""
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
_query = """ create or replace view on_screen_report as(
select
min(sol.id) as id
//Further query to get data.
)
"""
def search(self, cr, uid, args, offset=0, limit=None, order=None,context=None, count=False):
return super(on_screen_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
context=context, count=count)
sale_analysis_report_ept()
For query you need to create same view as your model name. So, it will store output of the query in that table. When we create tree view of this model it will execute this query and get all the data.