it is possible to create multi purchase orders in sales order if dropship is checked and supplier is specified in sales order items, but it is not possible to create multi purchase orders for work order( make to order), as there is no supplier in work order’s required items table.
we have enhanced the system the following way( created one auto po APP):
-
customize form
1.1 bom item: add supplier link field
1.2 work order item: add supplier link field
1.3 work order:remove default 1 for use multi level bom field
1.4 purchase order item:add work order link field, add work order item and plan_remark data field) -
custom script
2.1 work order:
2.1.1 add create purchase order button
2.1.2 set_query to call get_item_supplier for supplier field in required_items table
2.2 BOM
2.2.1 set_query to call get_item_supplier for supplier field in bom items table -
python script:
3.1 get_supplier: get suppliers from the work order required items table
3.2 get_item_supplier:restrict supplier to be only the supplier in item supplier,
also show price and note info from item supplier
3.3 make_purchase_order
3.4 hooks:
3.4.1 overwrite bom.py get_bom_items_as_dict
3.4.2 overwrite work_order.py set_required_items -
work_order_dash_board.py
4.1 add purchase order
How it works:
pre-condition:
- work order submitted,
- not in stopped, cancelled and completed status,
- use multi level bom unchecked
- work order component(item in required items table)'s UOM same as item master’s UOM(stock uom), this is defined by BOM
-
click the create->purchase order button
-
system display popup window with supplier selection field and create purchase order button
-
supplier dropdown list shows all distinct suppliers assigned to work order item, if select one supplier
the program will create the purchase order for all items assigned to the selected supplier,
if leave the supplier field empty, program will create multi purchase orders for each supplier -
if the item’s projected quantity is greater than 0, it means there is enough stock to cover the current work order’s requirement,
this item will be skipped, a comment with skipped item info will be added to purchase order which was created for same
supplier’s other items, or to the work order itself if not purchase order created for the supplier -
if item’s projected quantity is negative, the work order item’s required quantity is compared against the projected quantity
the smaller quantity is used, e.g if required quantity is 10, projected quantity is -15, the proposed purchase quantity is 10
if projected quantity is -8, then proposed purchase quantity is 8, -
if proposed purchase quantity is less than the required quantity(using existing available stock), a plan remark like
“existing stock used:3.0, original required qty: 45.0” will be added to the purchase order item record. -
if there is default purchase UOM defined in item master, the quantity is converted into purchase UOM
-
if there is min order quantity defined in item master and proposed purchase quantity is less than min order quantity,
then the min order quantity will be taken as purchase quantity
screenshot
Fig1: added create purchase order button(same as in sales order)
added the link in dashboard
Fig2: work order , work order item and plan remark added to purchase order item
Fig3: skipped item as comment in purchase order
Fig4: if skipped the supplier, add the comment to work order instead
What do you think? any ideas to further improve it?