mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-13 20:05:09 +00:00
fix(accounts): handle drop ship in company linked address validation
(cherry picked from commit 2ec119e561)
This commit is contained in:
@@ -312,13 +312,30 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
def validate_company_linked_addresses(self):
|
def validate_company_linked_addresses(self):
|
||||||
address_fields = []
|
address_fields = []
|
||||||
if self.doctype in ("Quotation", "Sales Order", "Delivery Note", "Sales Invoice"):
|
sales_doctypes = ("Quotation", "Sales Order", "Delivery Note", "Sales Invoice")
|
||||||
|
purchase_doctypes = ("Purchase Order", "Purchase Receipt", "Purchase Invoice", "Supplier Quotation")
|
||||||
|
|
||||||
|
if self.doctype in sales_doctypes:
|
||||||
address_fields = ["dispatch_address_name", "company_address"]
|
address_fields = ["dispatch_address_name", "company_address"]
|
||||||
elif self.doctype in ("Purchase Order", "Purchase Receipt", "Purchase Invoice", "Supplier Quotation"):
|
elif self.doctype in purchase_doctypes:
|
||||||
address_fields = ["billing_address", "shipping_address"]
|
address_fields = ["billing_address", "shipping_address"]
|
||||||
|
|
||||||
|
if not address_fields:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Determine if drop ship applies
|
||||||
|
is_drop_ship = self.doctype in {
|
||||||
|
"Purchase Order",
|
||||||
|
"Sales Order",
|
||||||
|
"Sales Invoice",
|
||||||
|
} and self.is_drop_ship(self.items)
|
||||||
|
|
||||||
for field in address_fields:
|
for field in address_fields:
|
||||||
address = self.get(field)
|
address = self.get(field)
|
||||||
|
|
||||||
|
if (field in ["dispatch_address_name", "shipping_address"]) and is_drop_ship:
|
||||||
|
continue
|
||||||
|
|
||||||
if address and not frappe.db.exists(
|
if address and not frappe.db.exists(
|
||||||
"Dynamic Link",
|
"Dynamic Link",
|
||||||
{
|
{
|
||||||
@@ -329,11 +346,15 @@ class AccountsController(TransactionBase):
|
|||||||
},
|
},
|
||||||
):
|
):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("{0} does not belong to the {1}.").format(
|
_("{0} does not belong to the Company {1}.").format(
|
||||||
_(self.meta.get_label(field)), bold(self.company)
|
_(self.meta.get_label(field)), bold(self.company)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_drop_ship(items):
|
||||||
|
return any(item.delivered_by_supplier for item in items)
|
||||||
|
|
||||||
def set_default_letter_head(self):
|
def set_default_letter_head(self):
|
||||||
if hasattr(self, "letter_head") and not self.letter_head:
|
if hasattr(self, "letter_head") and not self.letter_head:
|
||||||
self.letter_head = frappe.db.get_value("Company", self.company, "default_letter_head")
|
self.letter_head = frappe.db.get_value("Company", self.company, "default_letter_head")
|
||||||
|
|||||||
Reference in New Issue
Block a user