mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge branch 'wsgi' of https://github.com/webnotes/erpnext into i18n
Conflicts: accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js public/js/complete_setup.js selling/doctype/opportunity/opportunity.js selling/doctype/quotation/quotation.js
This commit is contained in:
@@ -9,7 +9,6 @@ from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
class DocType:
|
||||
@@ -18,7 +17,7 @@ class DocType:
|
||||
self.doclist = doclist
|
||||
|
||||
def autoname(self):
|
||||
last_name = sql("""select max(name) from `tabBOM`
|
||||
last_name = webnotes.conn.sql("""select max(name) from `tabBOM`
|
||||
where name like "BOM/%s/%%" """ % cstr(self.doc.item).replace('"', '\\"'))
|
||||
if last_name:
|
||||
idx = cint(cstr(last_name[0][0]).split('/')[-1].split('-')[0]) + 1
|
||||
@@ -144,7 +143,7 @@ class DocType:
|
||||
webnotes.bean(self.doclist).update_after_submit()
|
||||
|
||||
def get_bom_unitcost(self, bom_no):
|
||||
bom = sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
|
||||
bom = webnotes.conn.sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
|
||||
where is_active = 1 and name = %s""", bom_no, as_dict=1)
|
||||
return bom and bom[0]['unit_cost'] or 0
|
||||
|
||||
@@ -156,7 +155,7 @@ class DocType:
|
||||
from stock.utils import get_incoming_rate
|
||||
dt = self.doc.costing_date or nowdate()
|
||||
time = self.doc.costing_date == nowdate() and now().split()[1] or '23:59'
|
||||
warehouse = sql("select warehouse from `tabBin` where item_code = %s", args['item_code'])
|
||||
warehouse = webnotes.conn.sql("select warehouse from `tabBin` where item_code = %s", args['item_code'])
|
||||
rate = []
|
||||
for wh in warehouse:
|
||||
r = get_incoming_rate({
|
||||
@@ -184,7 +183,7 @@ class DocType:
|
||||
if not self.doc.is_active:
|
||||
webnotes.conn.set(self.doc, "is_default", 0)
|
||||
|
||||
sql("update `tabItem` set default_bom = null where name = %s and default_bom = %s",
|
||||
webnotes.conn.sql("update `tabItem` set default_bom = null where name = %s and default_bom = %s",
|
||||
(self.doc.item, self.doc.name))
|
||||
|
||||
def clear_operations(self):
|
||||
@@ -250,7 +249,7 @@ class DocType:
|
||||
|
||||
def validate_bom_no(self, item, bom_no, idx):
|
||||
"""Validate BOM No of sub-contracted items"""
|
||||
bom = sql("""select name from `tabBOM` where name = %s and item = %s
|
||||
bom = webnotes.conn.sql("""select name from `tabBOM` where name = %s and item = %s
|
||||
and is_active=1 and docstatus=1""",
|
||||
(bom_no, item), as_dict =1)
|
||||
if not bom:
|
||||
@@ -272,7 +271,7 @@ class DocType:
|
||||
for d in check_list:
|
||||
bom_list, count = [self.doc.name], 0
|
||||
while (len(bom_list) > count ):
|
||||
boms = sql(" select %s from `tabBOM Item` where %s = '%s' " %
|
||||
boms = webnotes.conn.sql(" select %s from `tabBOM Item` where %s = '%s' " %
|
||||
(d[0], d[1], cstr(bom_list[count])))
|
||||
count = count + 1
|
||||
for b in boms:
|
||||
@@ -333,6 +332,7 @@ class DocType:
|
||||
d.amount = flt(d.rate) * flt(d.qty)
|
||||
d.qty_consumed_per_unit = flt(d.qty) / flt(self.doc.quantity)
|
||||
total_rm_cost += d.amount
|
||||
|
||||
self.doc.raw_material_cost = total_rm_cost
|
||||
|
||||
def update_exploded_items(self):
|
||||
@@ -364,7 +364,7 @@ class DocType:
|
||||
def get_child_exploded_items(self, bom_no, qty):
|
||||
""" Add all items from Flat BOM of child BOM"""
|
||||
|
||||
child_fb_items = sql("""select item_code, description, stock_uom, qty, rate,
|
||||
child_fb_items = webnotes.conn.sql("""select item_code, description, stock_uom, qty, rate,
|
||||
qty_consumed_per_unit from `tabBOM Explosion Item`
|
||||
where parent = %s and docstatus = 1""", bom_no, as_dict = 1)
|
||||
|
||||
@@ -390,12 +390,12 @@ class DocType:
|
||||
ch.save(1)
|
||||
|
||||
def get_parent_bom_list(self, bom_no):
|
||||
p_bom = sql("select parent from `tabBOM Item` where bom_no = '%s'" % bom_no)
|
||||
p_bom = webnotes.conn.sql("select parent from `tabBOM Item` where bom_no = '%s'" % bom_no)
|
||||
return p_bom and [i[0] for i in p_bom] or []
|
||||
|
||||
def validate_bom_links(self):
|
||||
if not self.doc.is_active:
|
||||
act_pbom = sql("""select distinct bom_item.parent from `tabBOM Item` bom_item
|
||||
act_pbom = webnotes.conn.sql("""select distinct bom_item.parent from `tabBOM Item` bom_item
|
||||
where bom_item.bom_no = %s and bom_item.docstatus = 1
|
||||
and exists (select * from `tabBOM` where name = bom_item.parent
|
||||
and docstatus = 1 and is_active = 1)""", self.doc.name)
|
||||
@@ -403,4 +403,53 @@ class DocType:
|
||||
if act_pbom and act_pbom[0][0]:
|
||||
action = self.doc.docstatus < 2 and _("deactivate") or _("cancel")
|
||||
msgprint(_("Cannot ") + action + _(": It is linked to other active BOM(s)"),
|
||||
raise_exception=1)
|
||||
raise_exception=1)
|
||||
|
||||
def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1):
|
||||
item_dict = {}
|
||||
|
||||
query = """select
|
||||
bom_item.item_code,
|
||||
ifnull(sum(bom_item.qty_consumed_per_unit),0) * %(qty)s as qty,
|
||||
item.description,
|
||||
item.stock_uom,
|
||||
item.default_warehouse
|
||||
from
|
||||
`tab%(table)s` bom_item, `tabItem` item
|
||||
where
|
||||
bom_item.docstatus < 2
|
||||
and bom_item.parent = "%(bom)s"
|
||||
and item.name = bom_item.item_code
|
||||
%(conditions)s
|
||||
group by item_code, stock_uom"""
|
||||
|
||||
if fetch_exploded:
|
||||
items = webnotes.conn.sql(query % {
|
||||
"qty": qty,
|
||||
"table": "BOM Explosion Item",
|
||||
"bom": bom,
|
||||
"conditions": """and ifnull(item.is_pro_applicable, 'No') = 'No'
|
||||
and ifnull(item.is_sub_contracted_item, 'No') = 'No' """
|
||||
}, as_dict=True)
|
||||
else:
|
||||
items = webnotes.conn.sql(query % {
|
||||
"qty": qty,
|
||||
"table": "BOM Item",
|
||||
"bom": bom,
|
||||
"conditions": ""
|
||||
}, as_dict=True)
|
||||
|
||||
# make unique
|
||||
for item in items:
|
||||
if item_dict.has_key(item.item_code):
|
||||
item_dict[item.item_code]["qty"] += flt(item.qty)
|
||||
else:
|
||||
item_dict[item.item_code] = item
|
||||
|
||||
return item_dict
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_bom_items(bom, qty=1, fetch_exploded=1):
|
||||
items = get_bom_items_as_dict(bom, qty, fetch_exploded).values()
|
||||
items.sort(lambda a, b: a.item_code > b.item_code and 1 or -1)
|
||||
return items
|
||||
@@ -7,6 +7,35 @@ import unittest
|
||||
import webnotes
|
||||
|
||||
test_records = [
|
||||
[
|
||||
{
|
||||
"doctype": "BOM",
|
||||
"item": "_Test Item Home Desktop Manufactured",
|
||||
"quantity": 1.0,
|
||||
"is_active": 1,
|
||||
"is_default": 1,
|
||||
"docstatus": 1
|
||||
},
|
||||
{
|
||||
"doctype": "BOM Item",
|
||||
"item_code": "_Test Serialized Item With Series",
|
||||
"parentfield": "bom_materials",
|
||||
"qty": 1.0,
|
||||
"rate": 5000.0,
|
||||
"amount": 5000.0,
|
||||
"stock_uom": "_Test UOM"
|
||||
},
|
||||
{
|
||||
"doctype": "BOM Item",
|
||||
"item_code": "_Test Item 2",
|
||||
"parentfield": "bom_materials",
|
||||
"qty": 2.0,
|
||||
"rate": 1000.0,
|
||||
"amount": 2000.0,
|
||||
"stock_uom": "_Test UOM"
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
"doctype": "BOM",
|
||||
@@ -34,5 +63,57 @@ test_records = [
|
||||
"amount": 2000.0,
|
||||
"stock_uom": "_Test UOM"
|
||||
}
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
"doctype": "BOM",
|
||||
"item": "_Test FG Item 2",
|
||||
"quantity": 1.0,
|
||||
"is_active": 1,
|
||||
"is_default": 1,
|
||||
"docstatus": 1
|
||||
},
|
||||
{
|
||||
"doctype": "BOM Item",
|
||||
"item_code": "_Test Item",
|
||||
"parentfield": "bom_materials",
|
||||
"qty": 1.0,
|
||||
"rate": 5000.0,
|
||||
"amount": 5000.0,
|
||||
"stock_uom": "_Test UOM"
|
||||
},
|
||||
{
|
||||
"doctype": "BOM Item",
|
||||
"item_code": "_Test Item Home Desktop Manufactured",
|
||||
"bom_no": "BOM/_Test Item Home Desktop Manufactured/001",
|
||||
"parentfield": "bom_materials",
|
||||
"qty": 2.0,
|
||||
"rate": 1000.0,
|
||||
"amount": 2000.0,
|
||||
"stock_uom": "_Test UOM"
|
||||
}
|
||||
],
|
||||
]
|
||||
|
||||
class TestBOM(unittest.TestCase):
|
||||
def test_get_items(self):
|
||||
from manufacturing.doctype.bom.bom import get_bom_items_as_dict
|
||||
items_dict = get_bom_items_as_dict(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=0)
|
||||
self.assertTrue(test_records[2][1]["item_code"] in items_dict)
|
||||
self.assertTrue(test_records[2][2]["item_code"] in items_dict)
|
||||
self.assertEquals(len(items_dict.values()), 2)
|
||||
|
||||
def test_get_items_exploded(self):
|
||||
from manufacturing.doctype.bom.bom import get_bom_items_as_dict
|
||||
items_dict = get_bom_items_as_dict(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1)
|
||||
self.assertTrue(test_records[2][1]["item_code"] in items_dict)
|
||||
self.assertFalse(test_records[2][2]["item_code"] in items_dict)
|
||||
self.assertTrue(test_records[0][1]["item_code"] in items_dict)
|
||||
self.assertTrue(test_records[0][2]["item_code"] in items_dict)
|
||||
self.assertEquals(len(items_dict.values()), 3)
|
||||
|
||||
def test_get_items_list(self):
|
||||
from manufacturing.doctype.bom.bom import get_bom_items
|
||||
self.assertEquals(len(get_bom_items(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1)), 3)
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ from webnotes.utils import cstr, flt, nowdate
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
class OverProductionError(webnotes.ValidationError): pass
|
||||
|
||||
@@ -18,19 +17,23 @@ class DocType:
|
||||
self.doclist = doclist
|
||||
|
||||
def validate(self):
|
||||
if self.doc.docstatus == 0:
|
||||
self.doc.status = "Draft"
|
||||
|
||||
import utilities
|
||||
utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped",
|
||||
"In Process", "Completed", "Cancelled"])
|
||||
|
||||
if self.doc.production_item :
|
||||
item_detail = sql("select name from `tabItem` where name = '%s' and docstatus != 2"
|
||||
% self.doc.production_item, as_dict = 1)
|
||||
if not item_detail:
|
||||
msgprint("Item '%s' does not exist or cancelled in the system."
|
||||
% cstr(self.doc.production_item), raise_exception=1)
|
||||
|
||||
self.validate_bom_no()
|
||||
self.validate_sales_order()
|
||||
self.validate_warehouse()
|
||||
|
||||
from utilities.transaction_base import validate_uom_is_integer
|
||||
validate_uom_is_integer(self.doclist, "stock_uom", ["qty", "produced_qty"])
|
||||
|
||||
def validate_bom_no(self):
|
||||
if self.doc.bom_no:
|
||||
bom = sql("""select name from `tabBOM` where name=%s and docstatus=1
|
||||
bom = webnotes.conn.sql("""select name from `tabBOM` where name=%s and docstatus=1
|
||||
and is_active=1 and item=%s"""
|
||||
, (self.doc.bom_no, self.doc.production_item), as_dict =1)
|
||||
if not bom:
|
||||
@@ -38,16 +41,20 @@ class DocType:
|
||||
May be BOM not exists or inactive or not submitted
|
||||
or for some other item.""" % cstr(self.doc.bom_no), raise_exception=1)
|
||||
|
||||
def validate_sales_order(self):
|
||||
if self.doc.sales_order:
|
||||
if not webnotes.conn.sql("""select name from `tabSales Order`
|
||||
where name=%s and docstatus = 1""", self.doc.sales_order):
|
||||
msgprint("Sales Order: %s is not valid" % self.doc.sales_order, raise_exception=1)
|
||||
|
||||
|
||||
self.validate_production_order_against_so()
|
||||
|
||||
from utilities.transaction_base import validate_uom_is_integer
|
||||
validate_uom_is_integer(self.doclist, "stock_uom", ["qty", "produced_qty"])
|
||||
|
||||
|
||||
def validate_warehouse(self):
|
||||
from stock.utils import validate_warehouse_user, validate_warehouse_company
|
||||
|
||||
for w in [self.doc.fg_warehouse, self.doc.wip_warehouse]:
|
||||
validate_warehouse_user(w)
|
||||
validate_warehouse_company(w, self.doc.company)
|
||||
|
||||
def validate_production_order_against_so(self):
|
||||
# already ordered qty
|
||||
@@ -104,7 +111,7 @@ class DocType:
|
||||
|
||||
def on_cancel(self):
|
||||
# Check whether any stock entry exists against this Production Order
|
||||
stock_entry = sql("""select name from `tabStock Entry`
|
||||
stock_entry = webnotes.conn.sql("""select name from `tabStock Entry`
|
||||
where production_order = %s and docstatus = 1""", self.doc.name)
|
||||
if stock_entry:
|
||||
msgprint("""Submitted Stock Entry %s exists against this production order.
|
||||
@@ -144,12 +151,6 @@ def get_item_details(item):
|
||||
@webnotes.whitelist()
|
||||
def make_stock_entry(production_order_id, purpose):
|
||||
production_order = webnotes.bean("Production Order", production_order_id)
|
||||
|
||||
# validate already existing
|
||||
ste = webnotes.conn.get_value("Stock Entry", {
|
||||
"production_order":production_order_id,
|
||||
"purpose": purpose
|
||||
}, "name")
|
||||
|
||||
stock_entry = webnotes.new_bean("Stock Entry")
|
||||
stock_entry.doc.purpose = purpose
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:16",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-08 14:22:12",
|
||||
"modified": "2013-10-02 14:25:03",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_import": 1,
|
||||
"autoname": "naming_series:",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-cogs",
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import webnotes
|
||||
from stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||
from manufacturing.doctype.production_order.production_order import make_stock_entry
|
||||
|
||||
|
||||
class TestProductionOrder(unittest.TestCase):
|
||||
def test_planned_qty(self):
|
||||
set_perpetual_inventory(0)
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.conn.sql("""delete from `tabBin`""")
|
||||
webnotes.conn.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
pro_bean = webnotes.bean(copy = test_records[0])
|
||||
pro_bean.insert()
|
||||
pro_bean.submit()
|
||||
|
||||
from stock.doctype.stock_entry.test_stock_entry import test_records as se_test_records
|
||||
mr1 = webnotes.bean(copy = se_test_records[0])
|
||||
mr1.insert()
|
||||
mr1.submit()
|
||||
|
||||
mr2 = webnotes.bean(copy = se_test_records[0])
|
||||
mr2.doclist[1].item_code = "_Test Item Home Desktop 100"
|
||||
mr2.insert()
|
||||
mr2.submit()
|
||||
|
||||
stock_entry = make_stock_entry(pro_bean.doc.name, "Manufacture/Repack")
|
||||
stock_entry = webnotes.bean(stock_entry)
|
||||
|
||||
stock_entry.doc.fg_completed_qty = 4
|
||||
stock_entry.run_method("get_items")
|
||||
stock_entry.submit()
|
||||
|
||||
self.assertEqual(webnotes.conn.get_value("Production Order", pro_bean.doc.name,
|
||||
"produced_qty"), 4)
|
||||
self.assertEqual(webnotes.conn.get_value("Bin", {"item_code": "_Test FG Item",
|
||||
"warehouse": "_Test Warehouse 1 - _TC"}, "planned_qty"), 6)
|
||||
|
||||
return pro_bean.doc.name
|
||||
|
||||
def test_over_production(self):
|
||||
from stock.doctype.stock_entry.stock_entry import StockOverProductionError
|
||||
pro_order = self.test_planned_qty()
|
||||
|
||||
stock_entry = make_stock_entry(pro_order, "Manufacture/Repack")
|
||||
stock_entry = webnotes.bean(stock_entry)
|
||||
|
||||
stock_entry.doc.fg_completed_qty = 15
|
||||
stock_entry.run_method("get_items")
|
||||
stock_entry.insert()
|
||||
|
||||
self.assertRaises(StockOverProductionError, stock_entry.submit)
|
||||
|
||||
|
||||
|
||||
test_records = [
|
||||
[
|
||||
{
|
||||
"bom_no": "BOM/_Test FG Item/001",
|
||||
"company": "_Test Company",
|
||||
"doctype": "Production Order",
|
||||
"production_item": "_Test FG Item",
|
||||
"qty": 10.0,
|
||||
"fg_warehouse": "_Test Warehouse 1 - _TC",
|
||||
"wip_warehouse": "_Test Warehouse - _TC",
|
||||
"stock_uom": "Nos"
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -9,7 +9,6 @@ from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -19,7 +18,7 @@ class DocType:
|
||||
|
||||
def get_so_details(self, so):
|
||||
"""Pull other details from so"""
|
||||
so = sql("""select transaction_date, customer, grand_total
|
||||
so = webnotes.conn.sql("""select transaction_date, customer, grand_total
|
||||
from `tabSales Order` where name = %s""", so, as_dict = 1)
|
||||
ret = {
|
||||
'sales_order_date': so and so[0]['transaction_date'] or '',
|
||||
@@ -31,7 +30,7 @@ class DocType:
|
||||
def get_item_details(self, item_code):
|
||||
""" Pull other item details from item master"""
|
||||
|
||||
item = sql("""select description, stock_uom, default_bom
|
||||
item = webnotes.conn.sql("""select description, stock_uom, default_bom
|
||||
from `tabItem` where name = %s""", item_code, as_dict =1)
|
||||
ret = {
|
||||
'description' : item and item[0]['description'],
|
||||
@@ -63,7 +62,7 @@ class DocType:
|
||||
if self.doc.fg_item:
|
||||
item_filter += ' and item.name = "' + self.doc.fg_item + '"'
|
||||
|
||||
open_so = sql("""
|
||||
open_so = webnotes.conn.sql("""
|
||||
select distinct so.name, so.transaction_date, so.customer, so.grand_total
|
||||
from `tabSales Order` so, `tabSales Order Item` so_item
|
||||
where so_item.parent = so.name
|
||||
@@ -108,7 +107,7 @@ class DocType:
|
||||
msgprint("Please enter sales order in the above table")
|
||||
return []
|
||||
|
||||
items = sql("""select distinct parent, item_code, reserved_warehouse,
|
||||
items = webnotes.conn.sql("""select distinct parent, item_code, reserved_warehouse,
|
||||
(qty - ifnull(delivered_qty, 0)) as pending_qty
|
||||
from `tabSales Order Item` so_item
|
||||
where parent in (%s) and docstatus = 1 and ifnull(qty, 0) > ifnull(delivered_qty, 0)
|
||||
@@ -117,7 +116,7 @@ class DocType:
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes'))""" % \
|
||||
(", ".join(["%s"] * len(so_list))), tuple(so_list), as_dict=1)
|
||||
|
||||
dnpi_items = sql("""select distinct dnpi.parent, dnpi.item_code, dnpi.warehouse as reserved_warhouse,
|
||||
dnpi_items = webnotes.conn.sql("""select distinct dnpi.parent, dnpi.item_code, dnpi.warehouse as reserved_warhouse,
|
||||
(((so_item.qty - ifnull(so_item.delivered_qty, 0)) * dnpi.qty) / so_item.qty)
|
||||
as pending_qty
|
||||
from `tabSales Order Item` so_item, `tabDelivery Note Packing Item` dnpi
|
||||
@@ -136,7 +135,7 @@ class DocType:
|
||||
self.clear_item_table()
|
||||
|
||||
for p in items:
|
||||
item_details = sql("""select description, stock_uom, default_bom
|
||||
item_details = webnotes.conn.sql("""select description, stock_uom, default_bom
|
||||
from tabItem where name=%s""", p['item_code'])
|
||||
pi = addchild(self.doc, 'pp_details', 'Production Plan Item', self.doclist)
|
||||
pi.sales_order = p['parent']
|
||||
@@ -162,7 +161,7 @@ class DocType:
|
||||
msgprint("Please enter bom no for item: %s at row no: %s" %
|
||||
(d.item_code, d.idx), raise_exception=1)
|
||||
else:
|
||||
bom = sql("""select name from `tabBOM` where name = %s and item = %s
|
||||
bom = webnotes.conn.sql("""select name from `tabBOM` where name = %s and item = %s
|
||||
and docstatus = 1 and is_active = 1""",
|
||||
(d.bom_no, d.item_code), as_dict = 1)
|
||||
if not bom:
|
||||
@@ -216,14 +215,14 @@ class DocType:
|
||||
pro = webnotes.new_bean("Production Order")
|
||||
pro.doc.fields.update(items[key])
|
||||
|
||||
webnotes.mute_messages = True
|
||||
webnotes.flags.mute_messages = True
|
||||
try:
|
||||
pro.insert()
|
||||
pro_list.append(pro.doc.name)
|
||||
except OverProductionError, e:
|
||||
pass
|
||||
|
||||
webnotes.mute_messages = False
|
||||
webnotes.flags.mute_messages = False
|
||||
|
||||
return pro_list
|
||||
|
||||
@@ -243,7 +242,7 @@ class DocType:
|
||||
for bom in bom_dict:
|
||||
if self.doc.use_multi_level_bom:
|
||||
# get all raw materials with sub assembly childs
|
||||
fl_bom_items = sql("""select fb.item_code,
|
||||
fl_bom_items = webnotes.conn.sql("""select fb.item_code,
|
||||
ifnull(sum(fb.qty_consumed_per_unit), 0)*%s as qty,
|
||||
fb.description, fb.stock_uom, it.min_order_qty
|
||||
from `tabBOM Explosion Item` fb,`tabItem` it
|
||||
@@ -254,7 +253,7 @@ class DocType:
|
||||
else:
|
||||
# Get all raw materials considering SA items as raw materials,
|
||||
# so no childs of SA items
|
||||
fl_bom_items = sql("""select bom_item.item_code,
|
||||
fl_bom_items = webnotes.conn.sql("""select bom_item.item_code,
|
||||
ifnull(sum(bom_item.qty_consumed_per_unit), 0) * %s,
|
||||
bom_item.description, bom_item.stock_uom, item.min_order_qty
|
||||
from `tabBOM Item` bom_item, tabItem item
|
||||
@@ -274,7 +273,7 @@ class DocType:
|
||||
'Quantity Requested for Purchase', 'Ordered Qty', 'Actual Qty']]
|
||||
for d in self.item_dict:
|
||||
item_list.append([d, self.item_dict[d][1], self.item_dict[d][2], self.item_dict[d][0]])
|
||||
item_qty= sql("""select warehouse, indented_qty, ordered_qty, actual_qty
|
||||
item_qty= webnotes.conn.sql("""select warehouse, indented_qty, ordered_qty, actual_qty
|
||||
from `tabBin` where item_code = %s""", d)
|
||||
i_qty, o_qty, a_qty = 0, 0, 0
|
||||
for w in item_qty:
|
||||
|
||||
@@ -8,7 +8,6 @@ from webnotes.utils import flt
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.bean import copy_doclist
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
|
||||
@@ -18,9 +17,9 @@ class DocType:
|
||||
self.doclist = doclist
|
||||
|
||||
def update_bom_operation(self):
|
||||
bom_list = sql(" select DISTINCT parent from `tabBOM Operation` where workstation = '%s'" % self.doc.name)
|
||||
bom_list = webnotes.conn.sql(" select DISTINCT parent from `tabBOM Operation` where workstation = '%s'" % self.doc.name)
|
||||
for bom_no in bom_list:
|
||||
sql("update `tabBOM Operation` set hour_rate = '%s' where parent = '%s' and workstation = '%s'"%( self.doc.hour_rate, bom_no[0], self.doc.name))
|
||||
webnotes.conn.sql("update `tabBOM Operation` set hour_rate = '%s' where parent = '%s' and workstation = '%s'"%( self.doc.hour_rate, bom_no[0], self.doc.name))
|
||||
|
||||
def on_update(self):
|
||||
webnotes.conn.set(self.doc, 'overhead', flt(self.doc.hour_rate_electricity) + flt(self.doc.hour_rate_consumable) + flt(self.doc.hour_rate_rent))
|
||||
|
||||
Reference in New Issue
Block a user