diff --git a/product_management_app/__manifest__.py b/product_management_app/__manifest__.py index d92eca439..da4611689 100644 --- a/product_management_app/__manifest__.py +++ b/product_management_app/__manifest__.py @@ -20,7 +20,7 @@ ############################################################################### { 'name': 'Product Management', - 'version': '15.0.1.0.0', + 'version': '15.0.1.0.1', 'category': 'Sales', 'summary': 'Product Management Dashboard', 'description': """This module allows you Effortlessly manage your products, diff --git a/product_management_app/doc/RELEASE_NOTES.md b/product_management_app/doc/RELEASE_NOTES.md index 2170d3541..beeb7779e 100644 --- a/product_management_app/doc/RELEASE_NOTES.md +++ b/product_management_app/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 15.0.1.0.0 ##### ADD - Initial Commit for product Management +#### 17.04.2025 +#### Version 15.0.1.0.1 +##### UPDT +- Fixed the issue of product selection in the product moves monthly analysis graph + diff --git a/product_management_app/models/product_template.py b/product_management_app/models/product_template.py index 3d7828199..08231c13b 100644 --- a/product_management_app/models/product_template.py +++ b/product_management_app/models/product_template.py @@ -19,6 +19,7 @@ ############################################################################### import calendar +from collections import OrderedDict from odoo import api, models @@ -104,7 +105,7 @@ class ProductTemplate(models.Model): product_product.id inner join product_template on product_product.product_tmpl_id = product_template.id where stock_move_line.company_id = %s and - stock_move_line.product_id = %s group by + product_template.id = %s group by product_template.name,stock_move_line.date""" % (self.env.company.id, data)) self._cr.execute(query) @@ -120,10 +121,38 @@ class ProductTemplate(models.Model): for rec in range(1, 13): if rec not in month: product_move.append({'count': 0,'dates': calendar.month_name[rec],'month': rec}) + count = [] + months = [] cr = sorted(product_move, key=lambda i: i['month']) - count = [item['count'] for item in cr] - months = [item['dates'] for item in cr] - return {'count': count,'dates': months} + month_of_num = 0 + total_count = 0 + for rec in cr: + if month_of_num == rec['month']: + total_count += rec['count'] + if rec['count'] > 0: + rec.update({'count': total_count}) + else: + month_of_num = rec['month'] + total_count = rec['count'] + # OrderedDict to maintain insertion order + result = OrderedDict() + for item in cr: + # Check if month already exists + if item['month'] not in result: + result[item['month']] = item + else: + # Update if count is higher + if item['count'] > result[item['month']]['count']: + result[item['month']] = item + # Convert back to list + result = list(result.values()) + for rec in result: + count.append(rec['count']) + months.append(rec['dates']) + return { + 'count': count, + 'dates': months + } @api.model def get_product_qty_by_loc(self, args):