Skip to content

Commit

Permalink
fix: overlap error not raised for job card in case of workstation wit…
Browse files Browse the repository at this point in the history
…h production capacity

(cherry picked from commit 8b2165e)
  • Loading branch information
rohitwaghchaure authored and mergify[bot] committed Oct 19, 2022
1 parent 8a88105 commit ed2a093
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion erpnext/manufacturing/doctype/job_card/job_card.py
Expand Up @@ -133,7 +133,7 @@ def get_overlap_for(self, args, check_next_available_slot=False):
(%(from_time)s <= jctl.from_time and %(to_time)s >= jctl.to_time) {0}
)
and jctl.name != %(name)s and jc.name != %(parent)s and jc.docstatus < 2 {1}
order by jctl.to_time desc limit 1""".format(
order by jctl.to_time desc""".format(
extra_cond, validate_overlap_for
),
{
Expand Down
39 changes: 39 additions & 0 deletions erpnext/manufacturing/doctype/job_card/test_job_card.py
Expand Up @@ -136,6 +136,45 @@ def test_job_card_overlap(self):
)
self.assertRaises(OverlapError, jc2.save)

def test_job_card_overlap_with_capacity(self):
wo2 = make_wo_order_test_record(item="_Test FG Item 2", qty=2)

workstation = make_workstation(workstation_name=random_string(5)).name
frappe.db.set_value("Workstation", workstation, "production_capacity", 1)

jc1 = frappe.get_last_doc("Job Card", {"work_order": self.work_order.name})
jc2 = frappe.get_last_doc("Job Card", {"work_order": wo2.name})

jc1.workstation = workstation
jc1.append(
"time_logs",
{"from_time": "2021-01-01 00:00:00", "to_time": "2021-01-01 08:00:00", "completed_qty": 1},
)
jc1.save()

jc2.workstation = workstation

# add a new entry in same time slice
jc2.append(
"time_logs",
{"from_time": "2021-01-01 00:01:00", "to_time": "2021-01-01 06:00:00", "completed_qty": 1},
)
self.assertRaises(OverlapError, jc2.save)

frappe.db.set_value("Workstation", workstation, "production_capacity", 2)
jc2.load_from_db()

jc2.workstation = workstation

# add a new entry in same time slice
jc2.append(
"time_logs",
{"from_time": "2021-01-01 00:01:00", "to_time": "2021-01-01 06:00:00", "completed_qty": 1},
)

jc2.save()
self.assertTrue(jc2.name)

def test_job_card_multiple_materials_transfer(self):
"Test transferring RMs separately against Job Card with multiple RMs."
self.transfer_material_against = "Job Card"
Expand Down

0 comments on commit ed2a093

Please sign in to comment.