mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-16 13:25:10 +00:00
* feat: add price list field to material request Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
@@ -581,7 +581,8 @@ erpnext.buying.get_items_from_product_bundle = function(frm) {
|
|||||||
transaction_date: frm.doc.transaction_date || frm.doc.posting_date,
|
transaction_date: frm.doc.transaction_date || frm.doc.posting_date,
|
||||||
ignore_pricing_rule: frm.doc.ignore_pricing_rule,
|
ignore_pricing_rule: frm.doc.ignore_pricing_rule,
|
||||||
doctype: frm.doc.doctype
|
doctype: frm.doc.doctype
|
||||||
}
|
},
|
||||||
|
price_list: frm.doc.price_list,
|
||||||
},
|
},
|
||||||
freeze: true,
|
freeze: true,
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ frappe.ui.form.on("Material Request", {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("price_list", () => {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
buying: 1,
|
||||||
|
enabled: 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
@@ -70,6 +79,7 @@ frappe.ui.form.on("Material Request", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype);
|
erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype);
|
||||||
|
frm.doc.price_list = frappe.defaults.get_default("buying_price_list");
|
||||||
},
|
},
|
||||||
|
|
||||||
company: function (frm) {
|
company: function (frm) {
|
||||||
@@ -245,7 +255,7 @@ frappe.ui.form.on("Material Request", {
|
|||||||
from_warehouse: item.from_warehouse,
|
from_warehouse: item.from_warehouse,
|
||||||
warehouse: item.warehouse,
|
warehouse: item.warehouse,
|
||||||
doctype: frm.doc.doctype,
|
doctype: frm.doc.doctype,
|
||||||
buying_price_list: frappe.defaults.get_default("buying_price_list"),
|
buying_price_list: frm.doc.price_list,
|
||||||
currency: frappe.defaults.get_default("Currency"),
|
currency: frappe.defaults.get_default("Currency"),
|
||||||
name: frm.doc.name,
|
name: frm.doc.name,
|
||||||
qty: item.qty || 1,
|
qty: item.qty || 1,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"column_break_2",
|
"column_break_2",
|
||||||
"transaction_date",
|
"transaction_date",
|
||||||
"schedule_date",
|
"schedule_date",
|
||||||
|
"price_list",
|
||||||
"amended_from",
|
"amended_from",
|
||||||
"warehouse_section",
|
"warehouse_section",
|
||||||
"scan_barcode",
|
"scan_barcode",
|
||||||
@@ -351,13 +352,19 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_13",
|
"fieldname": "column_break_13",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "price_list",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Price List",
|
||||||
|
"options": "Price List"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-ticket",
|
"icon": "fa fa-ticket",
|
||||||
"idx": 70,
|
"idx": 70,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-04-21 18:36:04.827917",
|
"modified": "2025-07-07 13:15:28.615984",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Material Request",
|
"name": "Material Request",
|
||||||
@@ -425,10 +432,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
|
"row_format": "Dynamic",
|
||||||
"search_fields": "status,transaction_date",
|
"search_fields": "status,transaction_date",
|
||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
"title_field": "title"
|
"title_field": "title"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
import frappe.defaults
|
||||||
from frappe import _, msgprint
|
from frappe import _, msgprint
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.query_builder.functions import Sum
|
from frappe.query_builder.functions import Sum
|
||||||
@@ -45,6 +46,7 @@ class MaterialRequest(BuyingController):
|
|||||||
naming_series: DF.Literal["MAT-MR-.YYYY.-"]
|
naming_series: DF.Literal["MAT-MR-.YYYY.-"]
|
||||||
per_ordered: DF.Percent
|
per_ordered: DF.Percent
|
||||||
per_received: DF.Percent
|
per_received: DF.Percent
|
||||||
|
price_list: DF.Link | None
|
||||||
scan_barcode: DF.Data | None
|
scan_barcode: DF.Data | None
|
||||||
schedule_date: DF.Date | None
|
schedule_date: DF.Date | None
|
||||||
select_print_heading: DF.Link | None
|
select_print_heading: DF.Link | None
|
||||||
@@ -151,6 +153,9 @@ class MaterialRequest(BuyingController):
|
|||||||
self.reset_default_field_value("set_warehouse", "items", "warehouse")
|
self.reset_default_field_value("set_warehouse", "items", "warehouse")
|
||||||
self.reset_default_field_value("set_from_warehouse", "items", "from_warehouse")
|
self.reset_default_field_value("set_from_warehouse", "items", "from_warehouse")
|
||||||
|
|
||||||
|
if not self.price_list:
|
||||||
|
self.price_list = frappe.defaults.get_defaults().buying_price_list
|
||||||
|
|
||||||
def before_update_after_submit(self):
|
def before_update_after_submit(self):
|
||||||
self.validate_schedule_date()
|
self.validate_schedule_date()
|
||||||
|
|
||||||
|
|||||||
@@ -340,9 +340,8 @@ def on_doctype_update():
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_items_from_product_bundle(row):
|
def get_items_from_product_bundle(row, price_list):
|
||||||
row, items = json.loads(row), []
|
row, items = json.loads(row), []
|
||||||
defaults = frappe.defaults.get_defaults()
|
|
||||||
|
|
||||||
bundled_items = get_product_bundle_items(row["item_code"])
|
bundled_items = get_product_bundle_items(row["item_code"])
|
||||||
for item in bundled_items:
|
for item in bundled_items:
|
||||||
@@ -351,8 +350,8 @@ def get_items_from_product_bundle(row):
|
|||||||
"item_code": item.item_code,
|
"item_code": item.item_code,
|
||||||
"qty": flt(row["quantity"]) * flt(item.qty),
|
"qty": flt(row["quantity"]) * flt(item.qty),
|
||||||
"conversion_rate": 1,
|
"conversion_rate": 1,
|
||||||
"price_list": defaults.buying_price_list,
|
"price_list": price_list,
|
||||||
"currency": defaults.currency,
|
"currency": frappe.defaults.get_defaults().currency,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
items.append(get_item_details(row))
|
items.append(get_item_details(row))
|
||||||
|
|||||||
Reference in New Issue
Block a user