when i select product group from wizard its show product with product group name. but when i not select product group its show all product not show the product group.
product show just like this:
product
product1
product2
but i want to show product when not selecting product group just like this:
product group 1
product1
product2
product group 2
product1
product2
Product-
Size Opening Qty. Received Qty. Issue Qty. Adjustment Qty. Balance Qty.
model:
from odoo import models, fields, api, _
class InventoryReport(models.TransientModel):
_name = 'inventory.valuation.wizard'
_description = "Print Inventory Valuation"
date_form = fields.Datetime('From', default=lambda self: fields.datetime.now(), required=True)
date_to = fields.Datetime('To', default=lambda self: fields.datetime.now(), required=True)
product_group = fields.Many2one('product.group', string='Product Group')
qty_available = fields.Float(related='product_id.qty_available', string='Available Qty')
product_id = fields.Many2one('product.product', ondelete='restrict',
string='Consultation Service', help="Consultation Services",
domain=[('hospital_product_type', '=', "consultation")], required=True,
)
uom_id = fields.Many2one('uom.uom', 'Unit of Measure ', required=True,
domain="[('category_id', '=', product_uom_category_id)]")
uom_name = fields.Char(string='Unit of Measure Name', related='uom_id.name', readonly=True)
def print_action_report(self):
# domain = []
# product_group = self.product_group
# if product_group:
# domain += [('product_group', '=', product_group.id)]
#
# products = self.env['product.template'].search_read(domain)
data = {
'form_data': self.read()[0],
}
if data['form_data']['product_group']:
selected_products = data['form_data']['product_group'][0]
products = self.env['product.template'].search([('product_group', '=', selected_products)])
else:
products = self.env['product.template'].search([])
product_list = []
for app in products:
vals = {
'name':app.name,
'qty_available':app.qty_available,
'uom_name':app.uom_name
}
product_list.append(vals)
data['products'] = product_list
return self.env.ref('custom_valuation_report.action_Inventory_report_valuation').report_action(self, data=data)
Product- | Size | Opening Qty. | Received Qty. | Issue Qty. | Adjustment Qty. | Balance Qty. |
---|---|---|---|---|---|---|