Skip to content

Commit

Permalink
hyperlinks for the network status widget
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamlahlou committed Jan 30, 2024
1 parent 4a960f6 commit 4df38ed
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 12 deletions.
3 changes: 3 additions & 0 deletions doc/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ This release is scheduled for end Februari 2024. You can already check out a `pr
- | Addition of the item *unit of measure* column in the
`supply path screen <user-interface/plan-analysis/supply-path-where-used.html>`_.

- | Addition of hyperlinks in the network status widget to get detailed information
on the displayed numbers.

.. rubric:: Odoo integration

- | 15, 16, 17: The mapping of calendars now includes the odoo identifier.
Expand Down
51 changes: 45 additions & 6 deletions freppledb/input/static/operationplandetail/src/networkstatusDrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,51 @@ function shownetworkstatusDrv($window, gettextCatalog) {
+ "<a href=\"" + url_prefix + "/detail/input/location/" + admin_escape(thenetwork[2])
+ "/\" onclick='event.stopPropagation()'><span class='ps-2 fa fa-caret-right'></span></a>"
+ '</td><td>'
+ grid.formatNumber(thenetwork[3]) + '</td><td>'
+ grid.formatNumber(thenetwork[4]) + '</td><td>'
+ grid.formatNumber(thenetwork[5]) + '</td><td>'
+ grid.formatNumber(thenetwork[6]) + '</td><td>'
+ grid.formatNumber(thenetwork[7]) + '</td><td>'
+ grid.formatNumber(thenetwork[8]) + '</td></tr>';
+ grid.formatNumber(thenetwork[3])
+ '</td><td>'
+ grid.formatNumber(thenetwork[4]);

if (thenetwork[4] > 0) {
rows += "<a href=\"" + url_prefix + "/data/input/operationplanmaterial/buffer/"
+ admin_escape(thenetwork[0] + " @ " + thenetwork[2])
+ "/?noautofilter&operationplan__status__in=approved,confirmed&operationplan__type=PO&quantity__gt=0"
+ "\" onclick='event.stopPropagation()'><span class='ps-2 fa fa-caret-right'></span></a>";
}
rows += '</td><td>'
+ grid.formatNumber(thenetwork[5]);

if (thenetwork[5] != 0) {
rows += "<a href=\"" + url_prefix + "/data/input/operationplanmaterial/buffer/"
+ admin_escape(thenetwork[0] + " @ " + thenetwork[2])
+ "/?noautofilter&operationplan__status__in=approved,confirmed&operationplan__type=DO"
+ "\" onclick='event.stopPropagation()'><span class='ps-2 fa fa-caret-right'></span></a>";
}
rows += '</td><td>'
+ grid.formatNumber(thenetwork[6]);

if (thenetwork[6] > 0) {
rows += "<a href=\"" + url_prefix + "/data/input/operationplanmaterial/buffer/"
+ admin_escape(thenetwork[0] + " @ " + thenetwork[2])
+ "/?noautofilter&operationplan__status__in=approved,confirmed&operationplan__type=MO&quantity__gt=0"
+ "\" onclick='event.stopPropagation()'><span class='ps-2 fa fa-caret-right'></span></a>";
}
rows += '</td><td>'
+ grid.formatNumber(thenetwork[7]);

if (thenetwork[7] > 0) {
rows += "<a href=\"" + url_prefix + "/data/input/demand/?noautofilter&status__in=open,quote&item="
+ admin_escape(thenetwork[0]) + "&location=" + admin_escape(thenetwork[2]) + "&due__lt=" + admin_escape(thenetwork[9])
+ "\" onclick='event.stopPropagation()'><span class='ps-2 fa fa-caret-right'></span></a>";
}
rows += '</td><td>'
+ grid.formatNumber(thenetwork[8]);

if (thenetwork[8] > 0) {
rows += "<a href=\"" + url_prefix + "/data/input/demand/?noautofilter&status__in=open,quote&item="
+ admin_escape(thenetwork[0]) + "&location=" + admin_escape(thenetwork[2]) + "&due__gte=" + admin_escape(thenetwork[9])
+ "\" onclick='event.stopPropagation()'><span class='ps-2 fa fa-caret-right'></span></a>";
}
rows += '</td></tr>';
});
}
}
Expand Down
16 changes: 10 additions & 6 deletions freppledb/input/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,7 @@ def getData(self, request):
cursor.execute(
"""
with items as (
select name from item where name = %s
select name from item where name = %%s
)
select
items.name,
Expand All @@ -2120,7 +2120,8 @@ def getData(self, request):
coalesce(orders_plus.DO, 0) - coalesce(orders_minus.DO, 0),
orders_plus.MO,
sales.BO,
sales.SO
sales.SO,
to_char(%%s,'%s HH24:MI:SS') as current_date
from items
cross join location
left outer join (
Expand Down Expand Up @@ -2160,8 +2161,8 @@ def getData(self, request):
on orders_minus.item_id = items.name and orders_minus.location_id = location.name
left outer join (
select item_id, location_id,
sum(case when due < %s then quantity end) as BO,
sum(case when due >= %s then quantity end) as SO
sum(case when due < %%s then quantity end) as BO,
sum(case when due >= %%s then quantity end) as SO
from demand
inner join items on items.name = demand.item_id
where status in ('open', 'quote')
Expand All @@ -2176,13 +2177,15 @@ def getData(self, request):
or orders_minus.DO is not null
or sales.BO is not null
or sales.SO is not null
or (items.name = %s and location.name = %s)
or (items.name = %%s and location.name = %%s)
order by items.name, location.name
""",
"""
% (settings.DATE_FORMAT_JS,),
(
opplan.item_id,
current_date,
current_date,
current_date,
opplan.item_id,
opplan.location_id,
),
Expand All @@ -2200,6 +2203,7 @@ def getData(self, request):
float(a[6] or 0),
float(a[7] or 0),
float(a[8] or 0),
a[9],
]
)

Expand Down

0 comments on commit 4df38ed

Please sign in to comment.