def create_production_order(self, items):
        """Create production order. Called from Production Planning Tool"""
        from erpnext.manufacturing.doctype.production_order.production_order import (
            OverProductionError,
            get_default_warehouse,
        )

        warehouse = get_default_warehouse()
        pro_list = []
        for key in items:
            pro = frappe.new_doc("Production Order")
            pro.update(items[key])
            pro.set_production_order_operations()
            if warehouse:
                pro.wip_warehouse = warehouse.get("wip_warehouse")
                if not pro.fg_warehouse:
                    pro.fg_warehouse = warehouse.get("fg_warehouse")
            frappe.flags.mute_messages = True

            try:
                pro.insert()
                pro_list.append(pro.name)
            except OverProductionError:
                pass

            frappe.flags.mute_messages = False
        return pro_list
Exemplo n.º 2
0
def raise_production_orders(material_request):
    mr = frappe.get_doc("Material Request", material_request)
    errors = []
    production_orders = []
    from erpnext.manufacturing.doctype.production_order.production_order import OverProductionError, get_default_warehouse
    warehouse = get_default_warehouse()  # 2016-11-07 - JDLP
    for d in mr.items:
        if (d.qty - d.ordered_qty) > 0:
            if frappe.db.get_value("BOM", {
                    "item": d.item_code,
                    "is_default": 1
            }):
                prod_order = frappe.new_doc("Production Order")
                prod_order.production_item = d.item_code
                prod_order.qty = d.qty - d.ordered_qty
                prod_order.sales_order = d.sales_order
                prod_order.sales_order_item = d.sales_order_item
                prod_order.fg_warehouse = d.warehouse
                prod_order.source_warehouse = frappe.db.get_single_value(
                    "Manufacturing Settings", "default_raw_material_warehouse")
                prod_order.description = d.description
                prod_order.stock_uom = d.uom
                prod_order.expected_delivery_date = d.schedule_date
                prod_order.bom_no = get_item_details(d.item_code).bom_no
                prod_order.material_request = mr.name
                prod_order.material_request_item = d.name
                prod_order.planned_start_date = mr.transaction_date
                prod_order.company = mr.company
                prod_order.batch_no = d.batch_no  # 2016-11-07 - JDLP
                prod_order.wip_warehouse = warehouse.get(
                    'wip_warehouse')  # 2016-11-07 - JDLP
                prod_order.status = "Draft"
                prod_order.project = frappe.db.get_value(
                    "Sales Order", d.sales_order, "project")
                prod_order.reference_client = frappe.db.get_value(
                    "Sales Order", d.sales_order, "po_no")
                prod_order.customer = frappe.db.get_value(
                    "Sales Order", d.sales_order, "customer")
                #prod_order.save()

                prod_order = set_production_order_materials_and_operations(
                    prod_order.bom_no, prod_order)
                prod_order.save()
                production_orders.append(prod_order.name)
            else:
                errors.append(d.item_code + " in Row " + cstr(d.idx))
    if production_orders:
        message = ["""<a href="#Form/Production Order/%s" target="_blank">%s</a>""" % \
         (p, p) for p in production_orders]
        msgprint(
            _("The following Production Orders were created:" + '\n' +
              new_line_sep(message)))
    if errors:
        msgprint(
            _("Productions Orders cannot be raised for:" + '\n' +
              new_line_sep(errors)))
    return production_orders
    def create_production_order(self, item_dict):
        #Create production order. Called from Production Planning Tool
        from erpnext.manufacturing.doctype.production_order.production_order import OverProductionError, get_default_warehouse
        warehouse = get_default_warehouse()
        pro = frappe.new_doc("Production Order")
        pro.update(item_dict)

        try:
            pro.insert()
            return pro.name
        except OverProductionError:
            pass
    def create_production_order(self, item_dict):
        """Create production order. Called from Production Planning Tool"""
        from erpnext.manufacturing.doctype.production_order.production_order import OverProductionError, get_default_warehouse
        warehouse = get_default_warehouse()
        pro = frappe.new_doc("Production Order")
        pro.update(item_dict)
        pro.set_production_order_operations()
        if warehouse:
            pro.wip_warehouse = warehouse.get('wip_warehouse')
        if not pro.fg_warehouse:
            pro.fg_warehouse = warehouse.get('fg_warehouse')

        try:
            pro.insert()
            return pro.name
        except OverProductionError:
            pass
Exemplo n.º 5
0
	def create_production_order(self, item_dict):
		"""Create production order. Called from Production Planning Tool"""
		from erpnext.manufacturing.doctype.production_order.production_order import OverProductionError, get_default_warehouse
		warehouse = get_default_warehouse()
		pro = frappe.new_doc("Production Order")
		pro.update(item_dict)
		pro.set_production_order_operations()
		if warehouse:
			pro.wip_warehouse = warehouse.get('wip_warehouse')
		if not pro.fg_warehouse:
			pro.fg_warehouse = warehouse.get('fg_warehouse')

		try:
			pro.insert()
			return pro.name
		except OverProductionError:
			pass
Exemplo n.º 6
0
    def create_production_order(self, items):
        """Create production order. Called from Production Planning Tool"""
        from erpnext.manufacturing.doctype.production_order.production_order import OverProductionError, get_default_warehouse
        warehouse = get_default_warehouse()
        pro_list = []
        for key in items:
            pro = frappe.new_doc("Production Order")
            pro.update(items[key])
            pro.set_production_order_operations()
            if warehouse:
                pro.wip_warehouse = warehouse.get('wip_warehouse')
                if not pro.fg_warehouse:
                    pro.fg_warehouse = warehouse.get('fg_warehouse')
            frappe.flags.mute_messages = True

            try:
                pro.insert()
                pro_list.append(pro.name)
            except OverProductionError:
                pass

            frappe.flags.mute_messages = False
        return pro_list
    def make_stock_entry(self, item_dict):
        """Create a stock entry with purpose of manufacturing."""
        from erpnext.manufacturing.doctype.production_order.production_order import get_default_warehouse

        warehouse = get_default_warehouse()
        se = frappe.new_doc("Stock Entry")
        se.update(item_dict)

        se.purpose = "Manufacture"
        se.status = "submitted"  #submitted or "Draft"
        se.from_bom = 1
        se.use_multi_level_bom = 1
        se.title = "Manufacture %s x %s" % (se.fg_completed_qty,
                                            se.manufacture_item)
        if (se.sales_order):
            se.title += " for order %s" % (se.sales_order)
        if warehouse:
            se.from_warehouse = warehouse.get('wip_warehouse')
        if not se.to_warehouse:
            se.to_warehouse = warehouse.get('fg_warehouse')

        se.get_items()

        return se