Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added customer and supplier information to Batch #1187

Merged
merged 7 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion erpnext/stock/doctype/batch/batch.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"source",
"supplier",
"customer",
"provided_by_customer",
"column_break_9",
"reference_doctype",
"reference_name",
Expand Down Expand Up @@ -226,13 +227,20 @@
"fieldname": "coa_batch",
"fieldtype": "Data",
"label": "COA Batch"
},
{
"fieldname": "provided_by_customer",
"fieldtype": "Link",
"label": "Provided by Customer",
"options": "Customer",
"read_only": 1
}
],
"icon": "fa fa-archive",
"idx": 1,
"image_field": "image",
"max_attachments": 5,
"modified": "2021-03-23 18:06:00.946525",
"modified": "2021-04-28 01:50:19.183569",
"modified_by": "Administrator",
"module": "Stock",
"name": "Batch",
Expand Down
7 changes: 7 additions & 0 deletions erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def on_submit(self):
self.update_package_tag_batch()
update_per_received_in_production_plan(self)
self.update_package_tag_is_used()
self.update_batch_with_supplier()


def before_cancel(self):
Expand Down Expand Up @@ -215,6 +216,12 @@ def get_current_stock(self):
bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.supplier_warehouse), as_dict = 1)
d.current_stock = bin and flt(bin[0]['actual_qty']) or 0

def update_batch_with_supplier(self):
for item in self.items:
batch_supplier = frappe.db.get_value("Batch", item.batch_no, "supplier")
if not batch_supplier:
frappe.db.set_value("Batch", item.batch_no, "supplier", self.supplier)

def get_gl_entries(self, warehouse_account=None):
from erpnext.accounts.general_ledger import process_gl_map

Expand Down
11 changes: 11 additions & 0 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def on_submit(self):
self.update_so_in_serial_number()
self.update_package_tag()
self.update_package_tag_is_used()
self.update_batch_with_customer_provided_item()

def on_cancel(self):

Expand Down Expand Up @@ -689,6 +690,16 @@ def update_stock_ledger(self):

self.make_sl_entries(sl_entries, self.amended_from and 'Yes' or 'No')

def update_batch_with_customer_provided_item(self):
if self.stock_entry_type == "Material Receipt":
for item in self.items:
item_data = frappe.db.get_values("Item", item.item_code, ["is_customer_provided_item", "has_batch_no"], as_dict=1)
if item_data[0].is_customer_provided_item and item_data[0].has_batch_no and item.batch_no and item.material_request:
batch_provided_by_customer = frappe.db.get_value("Batch", item.batch_no, "provided_by_customer")
if not batch_provided_by_customer:
customer = frappe.db.get_value("Material Request", item.material_request, "customer")
frappe.db.set_value("Batch", item.batch_no, "provided_by_customer", customer)

def get_gl_entries(self, warehouse_account):
gl_entries = super(StockEntry, self).get_gl_entries(warehouse_account)

Expand Down