def action_report(self):
product_list = self.env['product.template'].search([])
categ_list_groupby_dict = {}
for categories in self.categ_ids:
filtered_product_list = list(filter(lambda x: x.categ_id == categories, product_list))
if self.date_from and self.date_to:
filtered_by_date = list(
filter(lambda x: x.create_date >= self.date_from and x.create_date <= self.date_to,
filtered_product_list))
elif self.date_from:
filtered_by_date = list(filter(lambda x: x.create_date >= self.date_from,
filtered_product_list))
elif self.date_to:
filtered_by_date = list(filter(lambda x: x.create_date <= self.date_to,
filtered_product_list))
categ_list_groupby_dict[categories.name] = filtered_by_date
final_dist = {}
for categories in categ_list_groupby_dict.keys():
product_data = []
for products in categ_list_groupby_dict[categories]:
if products.sales_count > 0:
sales = self.sudo().env['sale\.order\.line'\]\.search\(\[\('product_template_id',\ '=',\ products\.id\)\]\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ total_net_sale\ =\ 0
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ temp_data\ =\ \[\]
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ temp_data\.append\(products\.name\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ temp_data\.append\(products\.sales_count\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ temp_data\.append\(products.uom_id.name)
for i in sales:
total_net_sale = total_net_sale + i.price_subtotal
temp_data.append(total_net_sale)
product_data.append(temp_data)
final_dist[categories] = product_data
Here this code how can I select date_from and date_to from sale.order instead of product.template. I want to select date_range from sale.order model date_order wise. Please help me