fix: delivery_document_no column issue

(cherry picked from commit 61efb2bb39)

# Conflicts:
#	erpnext/accounts/doctype/sales_invoice/sales_invoice.py
#	erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py
This commit is contained in:
Rohit Waghchaure
2025-01-10 18:19:48 +05:30
committed by Mergify
parent f5c9ab054f
commit 0df18080c7
4 changed files with 42 additions and 24 deletions

View File

@@ -321,9 +321,7 @@ class SalesInvoice(SellingController):
self.set_against_income_account()
self.validate_time_sheets_are_submitted()
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount")
if not self.is_return:
self.validate_serial_numbers()
else:
if self.is_return:
self.timesheets = []
self.update_packing_list()
self.set_billing_hours_and_amount()
@@ -1706,6 +1704,7 @@ class SalesInvoice(SellingController):
self.set("write_off_amount", reference_doc.get("write_off_amount"))
self.due_date = None
<<<<<<< HEAD
def validate_serial_numbers(self):
"""
validate serial number agains Delivery Note and Sales Invoice
@@ -1753,6 +1752,8 @@ class SalesInvoice(SellingController):
)
)
=======
>>>>>>> 61efb2bb39 (fix: delivery_document_no column issue)
def update_project(self):
unique_projects = list(set([d.project for d in self.get("items") if d.project]))
if self.project and self.project not in unique_projects:

View File

@@ -3,6 +3,13 @@
from frappe.model.document import Document
<<<<<<< HEAD
=======
from frappe.utils.data import cint
from erpnext.assets.doctype.asset.depreciation import get_disposal_account_and_cost_center
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
>>>>>>> 61efb2bb39 (fix: delivery_document_no column issue)
class SalesInvoiceItem(Document):
@@ -93,4 +100,35 @@ class SalesInvoiceItem(Document):
weight_uom: DF.Link | None
# end: auto-generated types
<<<<<<< HEAD
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)
)
)
def set_actual_qty(self):
if self.item_code and self.warehouse:
self.actual_qty = (
frappe.db.get_value(
"Bin", {"item_code": self.item_code, "warehouse": self.warehouse}, "actual_qty"
)
or 0
)
def set_income_account_for_fixed_asset(self, company: str):
"""Set income account for fixed asset item based on company's disposal account and cost center."""
if not self.is_fixed_asset:
return
disposal_account, depreciation_cost_center = get_disposal_account_and_cost_center(company)
self.income_account = disposal_account
if not self.cost_center:
self.cost_center = depreciation_cost_center
>>>>>>> 61efb2bb39 (fix: delivery_document_no column issue)

View File

@@ -12,7 +12,6 @@ from frappe.utils import cint, flt
from erpnext.controllers.accounts_controller import get_taxes_and_charges, merge_taxes
from erpnext.controllers.selling_controller import SellingController
from erpnext.stock.doctype.serial_no.serial_no import get_delivery_note_serial_no
form_grid_templates = {"items": "templates/form_grid/item_grid.html"}
@@ -980,11 +979,6 @@ def make_sales_invoice(source_name, target_doc=None, args=None):
def update_item(source_doc, target_doc, source_parent):
target_doc.qty = to_make_invoice_qty_map[source_doc.name]
if source_doc.serial_no and source_parent.per_billed > 0 and not source_parent.is_return:
target_doc.serial_no = get_delivery_note_serial_no(
source_doc.item_code, target_doc.qty, source_parent.name
)
def get_pending_qty(item_row):
pending_qty = item_row.qty - invoiced_qty_map.get(item_row.name, 0)

View File

@@ -169,21 +169,6 @@ def update_maintenance_status():
frappe.db.set_value("Serial No", doc.name, "maintenance_status", doc.maintenance_status)
def get_delivery_note_serial_no(item_code, qty, delivery_note):
serial_nos = ""
dn_serial_nos = frappe.db.sql_list(
f""" select name from `tabSerial No`
where item_code = %(item_code)s and delivery_document_no = %(delivery_note)s
and sales_invoice is null limit {cint(qty)}""",
{"item_code": item_code, "delivery_note": delivery_note},
)
if dn_serial_nos and len(dn_serial_nos) > 0:
serial_nos = "\n".join(dn_serial_nos)
return serial_nos
@frappe.whitelist()
def auto_fetch_serial_number(
qty: int,