mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-04 14:08:29 +00:00
refactor(Sales Invoice Item): validate cost center
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
from erpnext.accounts.doctype.sales_invoice_item.sales_invoice_item import SalesInvoiceItem
|
||||
|
||||
|
||||
class POSInvoiceItem(Document):
|
||||
class POSInvoiceItem(SalesInvoiceItem):
|
||||
# begin: auto-generated types
|
||||
# This code is auto-generated. Do not modify anything in this block.
|
||||
|
||||
|
||||
@@ -379,13 +379,7 @@ class SalesInvoice(SellingController):
|
||||
|
||||
def validate_item_cost_centers(self):
|
||||
for item in self.items:
|
||||
cost_center_company = frappe.get_cached_value("Cost Center", item.cost_center, "company")
|
||||
if cost_center_company != self.company:
|
||||
frappe.throw(
|
||||
_("Row #{0}: Cost Center {1} does not belong to company {2}").format(
|
||||
frappe.bold(item.idx), frappe.bold(item.cost_center), frappe.bold(self.company)
|
||||
)
|
||||
)
|
||||
item.validate_cost_center(self.company)
|
||||
|
||||
def validate_income_account(self):
|
||||
for item in self.get("items"):
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
@@ -92,4 +94,11 @@ class SalesInvoiceItem(Document):
|
||||
weight_uom: DF.Link | None
|
||||
# end: auto-generated types
|
||||
|
||||
pass
|
||||
def validate_cost_center(self, company: str):
|
||||
cost_center_company = frappe.get_cached_value("Cost Center", self.cost_center, "company")
|
||||
if cost_center_company != company:
|
||||
frappe.throw(
|
||||
_("Row #{0}: Cost Center {1} does not belong to company {2}").format(
|
||||
frappe.bold(self.idx), frappe.bold(self.cost_center), frappe.bold(company)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user