test: SO > MR > WO flow
This commit is contained in:
parent
18731622c4
commit
f9d52e7346
@ -6,7 +6,7 @@ import json
|
|||||||
import frappe
|
import frappe
|
||||||
import frappe.permissions
|
import frappe.permissions
|
||||||
from frappe.core.doctype.user_permission.test_user_permission import create_user
|
from frappe.core.doctype.user_permission.test_user_permission import create_user
|
||||||
from frappe.utils import add_days, flt, getdate, nowdate
|
from frappe.utils import add_days, flt, getdate, nowdate, today
|
||||||
|
|
||||||
from erpnext.controllers.accounts_controller import update_child_qty_rate
|
from erpnext.controllers.accounts_controller import update_child_qty_rate
|
||||||
from erpnext.maintenance.doctype.maintenance_schedule.test_maintenance_schedule import (
|
from erpnext.maintenance.doctype.maintenance_schedule.test_maintenance_schedule import (
|
||||||
@ -1399,6 +1399,48 @@ class TestSalesOrder(ERPNextTestCase):
|
|||||||
so.load_from_db()
|
so.load_from_db()
|
||||||
self.assertEqual(so.billing_status, 'Fully Billed')
|
self.assertEqual(so.billing_status, 'Fully Billed')
|
||||||
|
|
||||||
|
def test_so_back_updated_from_wo_via_mr(self):
|
||||||
|
"SO -> MR (Manufacture) -> WO. Test if WO Qty is updated in SO."
|
||||||
|
from erpnext.stock.doctype.material_request.material_request import raise_work_orders
|
||||||
|
from erpnext.manufacturing.doctype.work_order.work_order import (
|
||||||
|
make_stock_entry as make_se_from_wo,
|
||||||
|
)
|
||||||
|
|
||||||
|
so = make_sales_order(item_list=[{"item_code": "_Test FG Item","qty": 2, "rate":100}])
|
||||||
|
|
||||||
|
mr = make_material_request(so.name)
|
||||||
|
mr.material_request_type = "Manufacture"
|
||||||
|
mr.schedule_date = today()
|
||||||
|
mr.submit()
|
||||||
|
|
||||||
|
# WO from MR
|
||||||
|
wo_name = raise_work_orders(mr.name)[0]
|
||||||
|
wo = frappe.get_doc("Work Order", wo_name)
|
||||||
|
wo.wip_warehouse = "Work In Progress - _TC"
|
||||||
|
wo.skip_transfer = True
|
||||||
|
|
||||||
|
self.assertEqual(wo.sales_order, so.name)
|
||||||
|
self.assertEqual(wo.sales_order_item, so.items[0].name)
|
||||||
|
|
||||||
|
wo.submit()
|
||||||
|
make_stock_entry(item_code="_Test Item", # Stock RM
|
||||||
|
target="Work In Progress - _TC",
|
||||||
|
qty=4, basic_rate=100
|
||||||
|
)
|
||||||
|
make_stock_entry(item_code="_Test Item Home Desktop 100", # Stock RM
|
||||||
|
target="Work In Progress - _TC",
|
||||||
|
qty=4, basic_rate=100
|
||||||
|
)
|
||||||
|
|
||||||
|
se = frappe.get_doc(make_se_from_wo(wo.name, "Manufacture", 2))
|
||||||
|
se.submit() # Finish WO
|
||||||
|
|
||||||
|
mr.reload()
|
||||||
|
wo.reload()
|
||||||
|
so.reload()
|
||||||
|
self.assertEqual(so.items[0].work_order_qty, wo.produced_qty)
|
||||||
|
self.assertEqual(mr.status, "Manufactured")
|
||||||
|
|
||||||
def automatically_fetch_payment_terms(enable=1):
|
def automatically_fetch_payment_terms(enable=1):
|
||||||
accounts_settings = frappe.get_doc("Accounts Settings")
|
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||||
accounts_settings.automatically_fetch_payment_terms = enable
|
accounts_settings.automatically_fetch_payment_terms = enable
|
||||||
|
Loading…
Reference in New Issue
Block a user