[item] default warehouse is selected with item
This commit is contained in:
parent
b3f947aca6
commit
1bcc19e019
@ -51,6 +51,9 @@ def get_item_details(args):
|
|||||||
|
|
||||||
out.supplier_part_no = _get_supplier_part_no(args, item_bean)
|
out.supplier_part_no = _get_supplier_part_no(args, item_bean)
|
||||||
|
|
||||||
|
if not out.warehouse:
|
||||||
|
out.warehouse = item_bean.doc.default_warehouse
|
||||||
|
|
||||||
if out.warehouse:
|
if out.warehouse:
|
||||||
out.projected_qty = get_projected_qty(item.name, out.warehouse)
|
out.projected_qty = get_projected_qty(item.name, out.warehouse)
|
||||||
|
|
||||||
|
@ -201,8 +201,8 @@ class DocType:
|
|||||||
|
|
||||||
for a in accounts:
|
for a in accounts:
|
||||||
account_name = accounts[a] + " - " + self.doc.abbr
|
account_name = accounts[a] + " - " + self.doc.abbr
|
||||||
if not self.doc.fields[a] and webnotes.conn.exists("Account", account_name):
|
if not self.doc.fields.get(a) and webnotes.conn.exists("Account", account_name):
|
||||||
webnotes.conn.set(self.doc, account_name)
|
webnotes.conn.set(self.doc, a, account_name)
|
||||||
|
|
||||||
if not self.doc.stock_adjustment_cost_center:
|
if not self.doc.stock_adjustment_cost_center:
|
||||||
webnotes.conn.set(self.doc, "stock_adjustment_cost_center", self.doc.cost_center)
|
webnotes.conn.set(self.doc, "stock_adjustment_cost_center", self.doc.cost_center)
|
||||||
|
@ -25,6 +25,7 @@ from webnotes import msgprint, _
|
|||||||
from webnotes.model.controller import DocListController
|
from webnotes.model.controller import DocListController
|
||||||
|
|
||||||
class PriceListCurrencyMismatch(Exception): pass
|
class PriceListCurrencyMismatch(Exception): pass
|
||||||
|
class WarehouseNotSet(Exception): pass
|
||||||
|
|
||||||
class DocType(DocListController):
|
class DocType(DocListController):
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
@ -40,6 +41,7 @@ class DocType(DocListController):
|
|||||||
if not self.doc.stock_uom:
|
if not self.doc.stock_uom:
|
||||||
msgprint(_("Please enter Default Unit of Measure"), raise_exception=1)
|
msgprint(_("Please enter Default Unit of Measure"), raise_exception=1)
|
||||||
|
|
||||||
|
self.check_warehouse_is_set_for_stock_item()
|
||||||
self.check_stock_uom_with_bin()
|
self.check_stock_uom_with_bin()
|
||||||
self.validate_conversion_factor()
|
self.validate_conversion_factor()
|
||||||
self.add_default_uom_in_conversion_factor_table()
|
self.add_default_uom_in_conversion_factor_table()
|
||||||
@ -60,6 +62,11 @@ class DocType(DocListController):
|
|||||||
self.validate_name_with_item_group()
|
self.validate_name_with_item_group()
|
||||||
self.update_website()
|
self.update_website()
|
||||||
|
|
||||||
|
def check_warehouse_is_set_for_stock_item(self):
|
||||||
|
if self.doc.is_stock_item=="Yes" and not self.doc.default_warehouse:
|
||||||
|
webnotes.msgprint(_("Default Warehouse is mandatory for Stock Item."),
|
||||||
|
raise_exception=WarehouseNotSet)
|
||||||
|
|
||||||
def add_default_uom_in_conversion_factor_table(self):
|
def add_default_uom_in_conversion_factor_table(self):
|
||||||
uom_conv_list = [d.uom for d in self.doclist.get({"parentfield": "uom_conversion_details"})]
|
uom_conv_list = [d.uom for d in self.doclist.get({"parentfield": "uom_conversion_details"})]
|
||||||
if self.doc.stock_uom not in uom_conv_list:
|
if self.doc.stock_uom not in uom_conv_list:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-05-03 10:45:46",
|
"creation": "2013-05-03 10:45:46",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-06-26 21:39:46",
|
"modified": "2013-07-01 11:45:59",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -205,11 +205,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
|
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
|
||||||
"description": "Mandatory if Stock Item is \"Yes\"",
|
"description": "Mandatory if Stock Item is \"Yes\". Also the default warehouse where reserved quantity is set from Sales Order.",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "default_warehouse",
|
"fieldname": "default_warehouse",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Default Reserved Warehouse",
|
"label": "Default Warehouse",
|
||||||
"oldfieldname": "default_warehouse",
|
"oldfieldname": "default_warehouse",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"options": "Warehouse",
|
"options": "Warehouse",
|
||||||
|
@ -35,6 +35,13 @@ class TestItem(unittest.TestCase):
|
|||||||
item_price = item.doclist.get({"doctype": "Item Price"})[0].ref_currency="USD"
|
item_price = item.doclist.get({"doctype": "Item Price"})[0].ref_currency="USD"
|
||||||
self.assertRaises(PriceListCurrencyMismatch, item.insert)
|
self.assertRaises(PriceListCurrencyMismatch, item.insert)
|
||||||
|
|
||||||
|
def test_default_warehouse(self):
|
||||||
|
from stock.doctype.item.item import WarehouseNotSet
|
||||||
|
item = webnotes.bean(copy=test_records[0])
|
||||||
|
item.doc.is_stock_item = "Yes"
|
||||||
|
item.doc.default_warehouse = None
|
||||||
|
self.assertRaises(WarehouseNotSet, item.insert)
|
||||||
|
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
[{
|
[{
|
||||||
@ -77,6 +84,7 @@ test_records = [
|
|||||||
"item_name": "_Test Item Home Desktop 100",
|
"item_name": "_Test Item Home Desktop 100",
|
||||||
"description": "_Test Item Home Desktop 100",
|
"description": "_Test Item Home Desktop 100",
|
||||||
"item_group": "_Test Item Group Desktops",
|
"item_group": "_Test Item Group Desktops",
|
||||||
|
"default_warehouse": "_Test Warehouse",
|
||||||
"is_stock_item": "Yes",
|
"is_stock_item": "Yes",
|
||||||
"is_asset_item": "No",
|
"is_asset_item": "No",
|
||||||
"has_batch_no": "No",
|
"has_batch_no": "No",
|
||||||
@ -101,6 +109,7 @@ test_records = [
|
|||||||
"item_name": "_Test Item Home Desktop 200",
|
"item_name": "_Test Item Home Desktop 200",
|
||||||
"description": "_Test Item Home Desktop 200",
|
"description": "_Test Item Home Desktop 200",
|
||||||
"item_group": "_Test Item Group Desktops",
|
"item_group": "_Test Item Group Desktops",
|
||||||
|
"default_warehouse": "_Test Warehouse",
|
||||||
"is_stock_item": "Yes",
|
"is_stock_item": "Yes",
|
||||||
"is_asset_item": "No",
|
"is_asset_item": "No",
|
||||||
"has_batch_no": "No",
|
"has_batch_no": "No",
|
||||||
@ -140,6 +149,7 @@ test_records = [
|
|||||||
"description": "_Test FG Item",
|
"description": "_Test FG Item",
|
||||||
"item_group": "_Test Item Group Desktops",
|
"item_group": "_Test Item Group Desktops",
|
||||||
"is_stock_item": "Yes",
|
"is_stock_item": "Yes",
|
||||||
|
"default_warehouse": "_Test Warehouse",
|
||||||
"is_asset_item": "No",
|
"is_asset_item": "No",
|
||||||
"has_batch_no": "No",
|
"has_batch_no": "No",
|
||||||
"has_serial_no": "No",
|
"has_serial_no": "No",
|
||||||
@ -178,6 +188,7 @@ test_records = [
|
|||||||
"description": "_Test Serialized Item",
|
"description": "_Test Serialized Item",
|
||||||
"item_group": "_Test Item Group Desktops",
|
"item_group": "_Test Item Group Desktops",
|
||||||
"is_stock_item": "Yes",
|
"is_stock_item": "Yes",
|
||||||
|
"default_warehouse": "_Test Warehouse",
|
||||||
"is_asset_item": "No",
|
"is_asset_item": "No",
|
||||||
"has_batch_no": "No",
|
"has_batch_no": "No",
|
||||||
"has_serial_no": "Yes",
|
"has_serial_no": "Yes",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user