mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-17 00:25:01 +00:00
feat: allow fallback to default selling price list (#49634)
Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
027a4ea1bf
commit
ff78aaeb3b
@@ -17,6 +17,7 @@
|
||||
"role_to_override_stop_action",
|
||||
"column_break_15",
|
||||
"maintain_same_sales_rate",
|
||||
"fallback_to_default_price_list",
|
||||
"editable_price_list_rate",
|
||||
"validate_selling_price",
|
||||
"editable_bundle_item_rates",
|
||||
@@ -236,6 +237,12 @@
|
||||
"fieldname": "allow_zero_qty_in_quotation",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Quotation with Zero Quantity"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "fallback_to_default_price_list",
|
||||
"fieldtype": "Check",
|
||||
"label": "Use Prices from Default Price List as Fallback"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
@@ -244,7 +251,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2025-05-06 15:23:14.332971",
|
||||
"modified": "2025-09-23 21:10:14.826653",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Selling Settings",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import cint
|
||||
@@ -34,6 +35,7 @@ class SellingSettings(Document):
|
||||
editable_price_list_rate: DF.Check
|
||||
enable_cutoff_date_on_bulk_delivery_note_creation: DF.Check
|
||||
enable_discount_accounting: DF.Check
|
||||
fallback_to_default_price_list: DF.Check
|
||||
hide_tax_id: DF.Check
|
||||
maintain_same_rate_action: DF.Literal["Stop", "Warn"]
|
||||
maintain_same_sales_rate: DF.Check
|
||||
@@ -71,6 +73,25 @@ class SellingSettings(Document):
|
||||
hide_name_field=False,
|
||||
)
|
||||
|
||||
self.validate_fallback_to_default_price_list()
|
||||
|
||||
def validate_fallback_to_default_price_list(self):
|
||||
if (
|
||||
self.fallback_to_default_price_list
|
||||
and self.has_value_changed("fallback_to_default_price_list")
|
||||
and frappe.get_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing")
|
||||
):
|
||||
stock_meta = frappe.get_meta("Stock Settings")
|
||||
frappe.msgprint(
|
||||
_(
|
||||
"You have enabled {0} and {1} in {2}. This can lead to prices from the default price list being inserted into the transaction price list."
|
||||
).format(
|
||||
"<i>{}</i>".format(_(self.meta.get_label("fallback_to_default_price_list"))),
|
||||
"<i>{}</i>".format(_(stock_meta.get_label("auto_insert_price_list_rate_if_missing"))),
|
||||
frappe.bold(_("Stock Settings")),
|
||||
)
|
||||
)
|
||||
|
||||
def toggle_hide_tax_id(self):
|
||||
_hide_tax_id = cint(self.hide_tax_id)
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ class StockSettings(Document):
|
||||
self.validate_clean_description_html()
|
||||
self.validate_pending_reposts()
|
||||
self.validate_stock_reservation()
|
||||
self.validate_auto_insert_price_list_rate_if_missing()
|
||||
self.change_precision_for_for_sales()
|
||||
self.change_precision_for_purchase()
|
||||
|
||||
@@ -223,6 +224,23 @@ class StockSettings(Document):
|
||||
)
|
||||
)
|
||||
|
||||
def validate_auto_insert_price_list_rate_if_missing(self):
|
||||
if (
|
||||
self.auto_insert_price_list_rate_if_missing
|
||||
and self.has_value_changed("auto_insert_price_list_rate_if_missing")
|
||||
and frappe.get_single_value("Selling Settings", "fallback_to_default_price_list")
|
||||
):
|
||||
selling_meta = frappe.get_meta("Selling Settings")
|
||||
frappe.msgprint(
|
||||
_(
|
||||
"You have enabled {0} and {1} in {2}. This can lead to prices from the default price list being inserted in the transaction price list."
|
||||
).format(
|
||||
"<i>{}</i>".format(_(self.meta.get_label("auto_insert_price_list_rate_if_missing"))),
|
||||
"<i>{}</i>".format(_(selling_meta.get_label("fallback_to_default_price_list"))),
|
||||
frappe.bold(_("Selling Settings")),
|
||||
)
|
||||
)
|
||||
|
||||
def on_update(self):
|
||||
self.toggle_warehouse_field_for_inter_warehouse_transfer()
|
||||
|
||||
|
||||
@@ -118,6 +118,13 @@ def get_item_details(
|
||||
|
||||
out.update(get_price_list_rate(ctx, item))
|
||||
|
||||
if not out.price_list_rate and frappe.get_single_value(
|
||||
"Selling Settings", "fallback_to_default_price_list"
|
||||
):
|
||||
fallback_args = ctx.copy()
|
||||
fallback_args.price_list = frappe.get_single_value("Selling Settings", "selling_price_list")
|
||||
out.update(get_price_list_rate(fallback_args, item))
|
||||
|
||||
ctx.customer = current_customer
|
||||
|
||||
if ctx.customer and cint(ctx.is_pos):
|
||||
|
||||
Reference in New Issue
Block a user