Merge pull request #4383 from anandpdoshi/fix/auto-material-request-template

[fix] Show Item Name in re-order email. Fixes #4381
This commit is contained in:
Anand Doshi 2015-11-27 11:31:36 +05:30
commit 15b22c9d7d
2 changed files with 35 additions and 10 deletions

View File

@ -3,6 +3,7 @@
import frappe
from frappe.utils import flt, cstr, nowdate, add_days, cint
from frappe import _
def reorder_item():
""" Reorder item if stock reaches reorder level"""
@ -162,17 +163,12 @@ def send_email_notification(mr_list):
and r.role in ('Purchase Manager','Stock Manager')
and p.name not in ('Administrator', 'All', 'Guest')""")
msg="""<h3>Following Material Requests has been raised automatically \
based on item reorder level:</h3>"""
for mr in mr_list:
msg += "<p><b><u>" + mr.name + """</u></b></p><table class='table table-bordered'><tr>
<th>Item Code</th><th>Warehouse</th><th>Qty</th><th>UOM</th></tr>"""
for item in mr.get("items"):
msg += "<tr><td>" + item.item_code + "</td><td>" + item.warehouse + "</td><td>" + \
cstr(item.qty) + "</td><td>" + cstr(item.uom) + "</td></tr>"
msg += "</table>"
msg = frappe.render_template("templates/emails/reorder_item.html", {
"mr_list": mr_list
})
frappe.sendmail(recipients=email_list,
subject='Auto Material Request Generation Notification', message = msg)
subject=_('Auto Material Requests Generated'), message = msg)
def notify_errors(exceptions_list):
subject = "[Important] [ERPNext] Auto Reorder Errors"

View File

@ -0,0 +1,29 @@
<p>{{ _("Following Material Requests have been raised automatically based on Item's re-order level") + ":" }}<p>
{% for mr in mr_list -%}
<div style="margin-bottom: 30px;">
<h4 style="margin-bottom: 5px;">{{ frappe.utils.get_link_to_form("Material Request", mr.name) }}</h4>
<table style="width: 100%; border-spacing: 0; border-collapse: collapse;">
<thead>
<tr>
<th style="border: 1px solid #d1d8dd; width: 35%; text-align: left; padding: 5px;">{{ _("Item") }}</th>
<th style="border: 1px solid #d1d8dd; width: 35%; text-align: left; padding: 5px;">{{ _("Warehouse") }}</th>
<th style="border: 1px solid #d1d8dd; width: 20%; text-align: right; padding: 5px;">{{ _("Quantity") }}</th>
<th style="border: 1px solid #d1d8dd; width: 10%; text-align: left; padding: 5px;">{{ _("UOM") }}</th>
</tr>
</thead>
<tbody>
{% for item in mr.get("items") -%}
<tr>
<td style="border: 1px solid #d1d8dd; text-align: left; padding: 5px;">
<b>{{ item.item_code }}</b>
{% if item.item_code != item.item_name -%} <br> {{ item.item_name }} {%- endif %}
</td>
<td style="border: 1px solid #d1d8dd; text-align: left; padding: 5px;">{{ item.warehouse }}</td>
<td style="border: 1px solid #d1d8dd; text-align: right; padding: 5px;">{{ item.qty }}</td>
<td style="border: 1px solid #d1d8dd; text-align: left; padding: 5px;">{{ item.uom }}</td>
</tr>
{%- endfor %}
</tbody>
</table>
</div>
{%- endfor %}