2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Overdue order notification (#3114)

* Adds a background task to notify users when a PurchaseOrder becomes overdue

* Schedule the overdue purchaseorder check to occur daily

* Allow notifications to be sent to "Owner" instances

- Extract user information from the Owner instance

* add unit test to ensure notifications are sent for overdue purchase orders

* Adds notification for overdue sales orders

* Clean up notification display panel

- Simplify rendering
- Order "newest at top"
- Element alignment tweaks

* style fixes

* More style fixes

* Tweak notification padding

* Fix import order

* Adds task to notify user of overdue build orders

* Adds unit tests for build order notifications

* Refactor subject line for emails:

- Use the configured instance title as a prefix for the subject line

* Add email template for overdue build orders

* Fix unit tests to accommodate new default value

* Logic error fix
This commit is contained in:
Oliver
2022-06-06 19:12:29 +10:00
committed by GitHub
parent 7b4d0605b8
commit 1e6bdfbcab
17 changed files with 439 additions and 22 deletions

View File

@ -0,0 +1,24 @@
{% extends "email/email.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block title %}
{{ message }}
{% if link %}
<p>{% trans "Click on the following link to view this order" %}: <a href="{{ link }}">{{ link }}</a></p>
{% endif %}
{% endblock title %}
{% block body %}
<tr style="height: 3rem; border-bottom: 1px solid">
<th>{% trans "Build Order" %}</th>
<th>{% trans "Part" %}</th>
</tr>
<tr style="height: 3rem">
<td style="text-align: center;">{{ order }}</td>
<td style="text-align: center;">{{ order.part.full_name }}</td>
</tr>
{% endblock body %}

View File

@ -0,0 +1,24 @@
{% extends "email/email.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block title %}
{{ message }}
{% if link %}
<p>{% trans "Click on the following link to view this order" %}: <a href="{{ link }}">{{ link }}</a></p>
{% endif %}
{% endblock title %}
{% block body %}
<tr style="height: 3rem; border-bottom: 1px solid">
<th>{% trans "Purchase Order" %}</th>
<th>{% trans "Supplier" %}</th>
</tr>
<tr style="height: 3rem">
<td style="text-align: center;">{{ order }}</td>
<td style="text-align: center;">{{ order.supplier }}</td>
</tr>
{% endblock body %}

View File

@ -0,0 +1,24 @@
{% extends "email/email.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block title %}
{{ message }}
{% if link %}
<p>{% trans "Click on the following link to view this order" %}: <a href="{{ link }}">{{ link }}</a></p>
{% endif %}
{% endblock title %}
{% block body %}
<tr style="height: 3rem; border-bottom: 1px solid">
<th>{% trans "Sales Order" %}</th>
<th>{% trans "Customer" %}</th>
</tr>
<tr style="height: 3rem">
<td style="text-align: center;">{{ order }}</td>
<td style="text-align: center;">{{ order.customer }}</td>
</tr>
{% endblock body %}

View File

@ -238,7 +238,7 @@ function getReadEditButton(pk, state, small=false) {
}
var style = (small) ? 'btn-sm ' : '';
return `<button title='${bReadText}' class='notification-read btn ${style}btn-outline-secondary' type='button' pk='${pk}' target='${bReadTarget}'><span class='${bReadIcon}'></span></button>`;
return `<button title='${bReadText}' class='notification-read btn ${style}btn-outline-secondary float-right' type='button' pk='${pk}' target='${bReadTarget}'><span class='${bReadIcon}'></span></button>`;
}
/**
@ -252,6 +252,7 @@ function openNotificationPanel() {
'/api/notifications/',
{
read: false,
ordering: '-creation',
},
{
success: function(response) {
@ -261,20 +262,21 @@ function openNotificationPanel() {
// build up items
response.forEach(function(item, index) {
html += '<li class="list-group-item">';
// d-flex justify-content-between align-items-start
html += '<div>';
html += `<span class="badge rounded-pill bg-primary">${item.category}</span><span class="ms-2">${item.name}</span>`;
html += '</div>';
html += `<div>`;
html += `<span class="badge bg-secondary rounded-pill">${item.name}</span>`;
html += getReadEditButton(item.pk, item.read, true);
html += `</div>`;
if (item.target) {
var link_text = `${item.target.model}: ${item.target.name}`;
var link_text = `${item.target.name}`;
if (item.target.link) {
link_text = `<a href='${item.target.link}'>${link_text}</a>`;
}
html += link_text;
}
html += '<div>';
html += `<span class="text-muted">${item.age_human}</span>`;
html += getReadEditButton(item.pk, item.read, true);
html += `<span class="text-muted"><small>${item.age_human}</small></span>`;
html += '</div></li>';
});