feat: added jinja method get_serial_or_batch_nos for print format and new print format 'Purchase Receipt Serial and Batch Bundle Print for reference
This commit is contained in:
parent
40ab3bdd35
commit
bb95451db6
@ -67,6 +67,12 @@ treeviews = [
|
|||||||
"Department",
|
"Department",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
jinja = {
|
||||||
|
"methods": [
|
||||||
|
"erpnext.stock.serial_batch_bundle.get_serial_or_batch_nos",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
# website
|
# website
|
||||||
update_website_context = [
|
update_website_context = [
|
||||||
"erpnext.e_commerce.shopping_cart.utils.update_website_context",
|
"erpnext.e_commerce.shopping_cart.utils.update_website_context",
|
||||||
|
@ -300,20 +300,10 @@ erpnext.selling.SellingController = class SellingController extends erpnext.Tran
|
|||||||
|
|
||||||
conversion_factor(doc, cdt, cdn, dont_fetch_price_list_rate) {
|
conversion_factor(doc, cdt, cdn, dont_fetch_price_list_rate) {
|
||||||
super.conversion_factor(doc, cdt, cdn, dont_fetch_price_list_rate);
|
super.conversion_factor(doc, cdt, cdn, dont_fetch_price_list_rate);
|
||||||
if(frappe.meta.get_docfield(cdt, "stock_qty", cdn) &&
|
|
||||||
in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
|
|
||||||
if (doc.doctype === 'Sales Invoice' && (!doc.update_stock)) return;
|
|
||||||
this.set_batch_number(cdt, cdn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qty(doc, cdt, cdn) {
|
qty(doc, cdt, cdn) {
|
||||||
super.qty(doc, cdt, cdn);
|
super.qty(doc, cdt, cdn);
|
||||||
|
|
||||||
if(in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
|
|
||||||
if (doc.doctype === 'Sales Invoice' && (!doc.update_stock)) return;
|
|
||||||
this.set_batch_number(cdt, cdn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pick_serial_and_batch(doc, cdt, cdn) {
|
pick_serial_and_batch(doc, cdt, cdn) {
|
||||||
|
@ -52,6 +52,7 @@ class StockLedgerEntry(Document):
|
|||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.check_stock_frozen_date()
|
self.check_stock_frozen_date()
|
||||||
|
|
||||||
|
# Added to handle few test cases where serial_and_batch_bundles are not required
|
||||||
if frappe.flags.in_test and frappe.flags.ignore_serial_batch_bundle_validation:
|
if frappe.flags.in_test and frappe.flags.ignore_serial_batch_bundle_validation:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -297,6 +297,7 @@ def create_material_receipt(
|
|||||||
se.set_stock_entry_type()
|
se.set_stock_entry_type()
|
||||||
se.insert()
|
se.insert()
|
||||||
se.submit()
|
se.submit()
|
||||||
|
se.reload()
|
||||||
|
|
||||||
return se
|
return se
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -22,35 +22,41 @@ def get_columns(filters):
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"fieldname": "voucher_type",
|
"fieldname": "voucher_type",
|
||||||
"options": "DocType",
|
"options": "DocType",
|
||||||
"width": 220,
|
"width": 160,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Voucher No"),
|
"label": _("Voucher No"),
|
||||||
"fieldtype": "Dynamic Link",
|
"fieldtype": "Dynamic Link",
|
||||||
"fieldname": "voucher_no",
|
"fieldname": "voucher_no",
|
||||||
"options": "voucher_type",
|
"options": "voucher_type",
|
||||||
"width": 220,
|
"width": 180,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Company"),
|
"label": _("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"fieldname": "company",
|
"fieldname": "company",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"width": 220,
|
"width": 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Warehouse"),
|
"label": _("Warehouse"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"fieldname": "warehouse",
|
"fieldname": "warehouse",
|
||||||
"options": "Warehouse",
|
"options": "Warehouse",
|
||||||
"width": 220,
|
"width": 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Serial No"),
|
"label": _("Serial No"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"fieldname": "serial_no",
|
"fieldname": "serial_no",
|
||||||
"options": "Serial No",
|
"options": "Serial No",
|
||||||
"width": 220,
|
"width": 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Valuation Rate"),
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"fieldname": "valuation_rate",
|
||||||
|
"width": 150,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -84,14 +90,16 @@ def get_data(filters):
|
|||||||
|
|
||||||
serial_nos = bundle_wise_serial_nos.get(row.serial_and_batch_bundle, [])
|
serial_nos = bundle_wise_serial_nos.get(row.serial_and_batch_bundle, [])
|
||||||
|
|
||||||
for index, serial_no in enumerate(serial_nos):
|
for index, bundle_data in enumerate(serial_nos):
|
||||||
if index == 0:
|
if index == 0:
|
||||||
args.serial_no = serial_no
|
args.serial_no = bundle_data.get("serial_no")
|
||||||
|
args.valuation_rate = bundle_data.get("valuation_rate")
|
||||||
data.append(args)
|
data.append(args)
|
||||||
else:
|
else:
|
||||||
data.append(
|
data.append(
|
||||||
{
|
{
|
||||||
"serial_no": serial_no,
|
"serial_no": bundle_data.get("serial_no"),
|
||||||
|
"valuation_rate": bundle_data.get("valuation_rate"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -106,10 +114,15 @@ def get_serial_nos(filters, serial_bundle_ids):
|
|||||||
|
|
||||||
for d in frappe.get_all(
|
for d in frappe.get_all(
|
||||||
"Serial and Batch Entry",
|
"Serial and Batch Entry",
|
||||||
fields=["serial_no", "parent"],
|
fields=["serial_no", "parent", "stock_value_difference as valuation_rate"],
|
||||||
filters=bundle_filters,
|
filters=bundle_filters,
|
||||||
order_by="idx asc",
|
order_by="idx asc",
|
||||||
):
|
):
|
||||||
bundle_wise_serial_nos.setdefault(d.parent, []).append(d.serial_no)
|
bundle_wise_serial_nos.setdefault(d.parent, []).append(
|
||||||
|
{
|
||||||
|
"serial_no": d.serial_no,
|
||||||
|
"valuation_rate": abs(d.valuation_rate),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return bundle_wise_serial_nos
|
return bundle_wise_serial_nos
|
||||||
|
@ -296,6 +296,10 @@ def get_serial_nos_from_bundle(serial_and_batch_bundle, serial_nos=None):
|
|||||||
return get_serial_nos(serial_and_batch_bundle, serial_nos=serial_nos)
|
return get_serial_nos(serial_and_batch_bundle, serial_nos=serial_nos)
|
||||||
|
|
||||||
|
|
||||||
|
def get_serial_or_batch_nos(bundle):
|
||||||
|
return frappe.get_all("Serial and Batch Entry", fields=["*"], filters={"parent": bundle})
|
||||||
|
|
||||||
|
|
||||||
class SerialNoValuation(DeprecatedSerialNoValuation):
|
class SerialNoValuation(DeprecatedSerialNoValuation):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
|
@ -8,10 +8,10 @@ from typing import Optional, Set, Tuple
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _, scrub
|
||||||
from frappe.model.meta import get_field_precision
|
from frappe.model.meta import get_field_precision
|
||||||
|
from frappe.query_builder import Case
|
||||||
from frappe.query_builder.functions import CombineDatetime, Sum
|
from frappe.query_builder.functions import CombineDatetime, Sum
|
||||||
from frappe.utils import (
|
from frappe.utils import (
|
||||||
cint,
|
cint,
|
||||||
cstr,
|
|
||||||
flt,
|
flt,
|
||||||
get_link_to_form,
|
get_link_to_form,
|
||||||
getdate,
|
getdate,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user