class ProductCategoryReport(models.TransientModel):
_name = 'product.category.wizard'
_description = "Print Product Category Report"
date_from = fields.Datetime('From', default=lambda self: fields.datetime.now(), required=True)
date_to = fields.Datetime('To', default=lambda self: fields.datetime.now(), required=True)
categ_ids = fields.Many2many('product.category', copy=False)
def check_date(self, date_from, date_to):
today = fields.datetime.now()
if date_from > today:
raise UserError('You could not set the start date or the end date in the future.')
else:
return True
def action_report(self):
check_date = self.check_date(self.date_from, self.date_to)
data = {
'form_data': self.read()[0],
}
if check_date:
if data['form_data']['categ_ids']:
selected_products = data['form_data']['categ_ids']
products = self.env['product.template'].search([('categ_id', '=', selected_products)])
# order_date = self.env['purchase.order'].search([('date_order', '=', selected_products)])
else:
products = self.env['product.template'].search([])
product_list = []
for app in products:
vals = {
'categ_id': app.categ_id.name,
'id': app.id,
'name': app.name,
'qty_available': app.qty_available,
'uom_id': app.uom_id.name,
'standard_price': app.standard_price,
'create_date': app.create_date,
'item_code': app.item_code,
}
product_list.append(vals)
data['products'] = product_list
return self.env.ref('product_category_list_report.action_product_category_report').report_action(self, data)
-->
here i want to show product category wise example:
category1
product1
product2
category2
product1
product2
category3
product1
product2