mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 09:54:47 +00:00
Merge branch 'wsgi' of github.com:webnotes/erpnext into wsgi
This commit is contained in:
@@ -8,6 +8,9 @@ import webnotes
|
|||||||
|
|
||||||
class TestPeriodClosingVoucher(unittest.TestCase):
|
class TestPeriodClosingVoucher(unittest.TestCase):
|
||||||
def test_closing_entry(self):
|
def test_closing_entry(self):
|
||||||
|
# clear GL Entries
|
||||||
|
webnotes.conn.sql("""delete from `tabGL Entry`""")
|
||||||
|
|
||||||
from accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
from accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
||||||
jv = webnotes.bean(copy=jv_records[2])
|
jv = webnotes.bean(copy=jv_records[2])
|
||||||
jv.insert()
|
jv.insert()
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ class DocType(BuyingController):
|
|||||||
def update_raw_material_cost(self):
|
def update_raw_material_cost(self):
|
||||||
if self.sub_contracted_items:
|
if self.sub_contracted_items:
|
||||||
for d in self.doclist.get({"parentfield": "entries"}):
|
for d in self.doclist.get({"parentfield": "entries"}):
|
||||||
rm_cost = webnotes.conn.sql(""" select raw_material_cost / quantity
|
rm_cost = webnotes.conn.sql("""select raw_material_cost / quantity
|
||||||
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
|
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
|
||||||
and is_active = 1 """, (d.item_code,))
|
and is_active = 1 """, (d.item_code,))
|
||||||
rm_cost = rm_cost and flt(rm_cost[0][0]) or 0
|
rm_cost = rm_cost and flt(rm_cost[0][0]) or 0
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
po.doc.company = "_Test Company 1"
|
po.doc.company = "_Test Company 1"
|
||||||
po.doc.conversion_rate = 0.0167
|
po.doc.conversion_rate = 0.0167
|
||||||
self.assertRaises(InvalidWarehouseCompany, po.insert)
|
self.assertRaises(InvalidWarehouseCompany, po.insert)
|
||||||
|
|
||||||
def test_uom_integer_validation(self):
|
def test_uom_integer_validation(self):
|
||||||
from utilities.transaction_base import UOMMustBeIntegerError
|
from utilities.transaction_base import UOMMustBeIntegerError
|
||||||
po = webnotes.bean(copy=test_records[0])
|
po = webnotes.bean(copy=test_records[0])
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import unittest
|
|||||||
from hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError
|
from hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError
|
||||||
|
|
||||||
class TestLeaveApplication(unittest.TestCase):
|
class TestLeaveApplication(unittest.TestCase):
|
||||||
|
def tearDown(self):
|
||||||
|
webnotes.session.user = "Administrator"
|
||||||
|
|
||||||
def _clear_roles(self):
|
def _clear_roles(self):
|
||||||
webnotes.conn.sql("""delete from `tabUserRole` where parent in
|
webnotes.conn.sql("""delete from `tabUserRole` where parent in
|
||||||
("test@example.com", "test1@example.com", "test2@example.com")""")
|
("test@example.com", "test1@example.com", "test2@example.com")""")
|
||||||
@@ -15,6 +18,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
webnotes.conn.sql("""delete from `tabLeave Application`""")
|
webnotes.conn.sql("""delete from `tabLeave Application`""")
|
||||||
|
|
||||||
def _add_employee_leave_approver(self, employee, leave_approver):
|
def _add_employee_leave_approver(self, employee, leave_approver):
|
||||||
|
temp_session_user = webnotes.session.user
|
||||||
webnotes.session.user = "Administrator"
|
webnotes.session.user = "Administrator"
|
||||||
employee = webnotes.bean("Employee", employee)
|
employee = webnotes.bean("Employee", employee)
|
||||||
employee.doclist.append({
|
employee.doclist.append({
|
||||||
@@ -23,6 +27,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
"leave_approver": leave_approver
|
"leave_approver": leave_approver
|
||||||
})
|
})
|
||||||
employee.save()
|
employee.save()
|
||||||
|
webnotes.session.user = temp_session_user
|
||||||
|
|
||||||
def get_application(self, doclist):
|
def get_application(self, doclist):
|
||||||
application = webnotes.bean(copy=doclist)
|
application = webnotes.bean(copy=doclist)
|
||||||
@@ -31,7 +36,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
return application
|
return application
|
||||||
|
|
||||||
def test_block_list(self):
|
def test_block_list(self):
|
||||||
webnotes.session.user = "Administrator"
|
|
||||||
self._clear_roles()
|
self._clear_roles()
|
||||||
|
|
||||||
from webnotes.profile import add_role
|
from webnotes.profile import add_role
|
||||||
@@ -54,7 +58,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
self.assertTrue(application.insert())
|
self.assertTrue(application.insert())
|
||||||
|
|
||||||
def test_overlap(self):
|
def test_overlap(self):
|
||||||
webnotes.session.user = "Administrator"
|
|
||||||
self._clear_roles()
|
self._clear_roles()
|
||||||
self._clear_applications()
|
self._clear_applications()
|
||||||
|
|
||||||
@@ -72,7 +75,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
self.assertRaises(OverlapError, application.insert)
|
self.assertRaises(OverlapError, application.insert)
|
||||||
|
|
||||||
def test_global_block_list(self):
|
def test_global_block_list(self):
|
||||||
webnotes.session.user = "Administrator"
|
|
||||||
self._clear_roles()
|
self._clear_roles()
|
||||||
|
|
||||||
from webnotes.profile import add_role
|
from webnotes.profile import add_role
|
||||||
@@ -98,7 +100,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
"applies_to_all_departments", 0)
|
"applies_to_all_departments", 0)
|
||||||
|
|
||||||
def test_leave_approval(self):
|
def test_leave_approval(self):
|
||||||
webnotes.session.user = "Administrator"
|
|
||||||
self._clear_roles()
|
self._clear_roles()
|
||||||
|
|
||||||
from webnotes.profile import add_role
|
from webnotes.profile import add_role
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import unittest
|
|||||||
from hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates
|
from hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates
|
||||||
|
|
||||||
class TestLeaveBlockList(unittest.TestCase):
|
class TestLeaveBlockList(unittest.TestCase):
|
||||||
|
def tearDown(self):
|
||||||
|
webnotes.session.user = "Administrator"
|
||||||
|
|
||||||
def test_get_applicable_block_dates(self):
|
def test_get_applicable_block_dates(self):
|
||||||
webnotes.session.user = "test@example.com"
|
webnotes.session.user = "test@example.com"
|
||||||
webnotes.conn.set_value("Department", "_Test Department", "leave_block_list",
|
webnotes.conn.set_value("Department", "_Test Department", "leave_block_list",
|
||||||
|
|||||||
@@ -332,6 +332,7 @@ class DocType:
|
|||||||
d.amount = flt(d.rate) * flt(d.qty)
|
d.amount = flt(d.rate) * flt(d.qty)
|
||||||
d.qty_consumed_per_unit = flt(d.qty) / flt(self.doc.quantity)
|
d.qty_consumed_per_unit = flt(d.qty) / flt(self.doc.quantity)
|
||||||
total_rm_cost += d.amount
|
total_rm_cost += d.amount
|
||||||
|
|
||||||
self.doc.raw_material_cost = total_rm_cost
|
self.doc.raw_material_cost = total_rm_cost
|
||||||
|
|
||||||
def update_exploded_items(self):
|
def update_exploded_items(self):
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ test_records = [
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"doctype": "BOM",
|
"doctype": "BOM",
|
||||||
"item": "_Test Item Home Desktop 100",
|
"item": "_Test Item Home Desktop Manufactured",
|
||||||
"quantity": 1.0,
|
"quantity": 1.0,
|
||||||
"is_active": 1,
|
"is_active": 1,
|
||||||
"is_default": 1,
|
"is_default": 1,
|
||||||
@@ -58,7 +58,36 @@ test_records = [
|
|||||||
"doctype": "BOM Item",
|
"doctype": "BOM Item",
|
||||||
"item_code": "_Test Item Home Desktop 100",
|
"item_code": "_Test Item Home Desktop 100",
|
||||||
"parentfield": "bom_materials",
|
"parentfield": "bom_materials",
|
||||||
"bom_no": "BOM/_Test Item Home Desktop 100/001",
|
"qty": 2.0,
|
||||||
|
"rate": 1000.0,
|
||||||
|
"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,
|
"qty": 2.0,
|
||||||
"rate": 1000.0,
|
"rate": 1000.0,
|
||||||
"amount": 2000.0,
|
"amount": 2000.0,
|
||||||
@@ -70,21 +99,21 @@ test_records = [
|
|||||||
class TestBOM(unittest.TestCase):
|
class TestBOM(unittest.TestCase):
|
||||||
def test_get_items(self):
|
def test_get_items(self):
|
||||||
from manufacturing.doctype.bom.bom import get_bom_items_as_dict
|
from manufacturing.doctype.bom.bom import get_bom_items_as_dict
|
||||||
items_dict = get_bom_items_as_dict(bom="BOM/_Test FG Item/001", qty=1, fetch_exploded=0)
|
items_dict = get_bom_items_as_dict(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=0)
|
||||||
self.assertTrue(test_records[1][1]["item_code"] in items_dict)
|
self.assertTrue(test_records[2][1]["item_code"] in items_dict)
|
||||||
self.assertTrue(test_records[1][2]["item_code"] in items_dict)
|
self.assertTrue(test_records[2][2]["item_code"] in items_dict)
|
||||||
self.assertEquals(len(items_dict.values()), 2)
|
self.assertEquals(len(items_dict.values()), 2)
|
||||||
|
|
||||||
def test_get_items_exploded(self):
|
def test_get_items_exploded(self):
|
||||||
from manufacturing.doctype.bom.bom import get_bom_items_as_dict
|
from manufacturing.doctype.bom.bom import get_bom_items_as_dict
|
||||||
items_dict = get_bom_items_as_dict(bom="BOM/_Test FG Item/001", qty=1, fetch_exploded=1)
|
items_dict = get_bom_items_as_dict(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1)
|
||||||
self.assertTrue(test_records[1][1]["item_code"] in items_dict)
|
self.assertTrue(test_records[2][1]["item_code"] in items_dict)
|
||||||
self.assertFalse(test_records[1][2]["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][1]["item_code"] in items_dict)
|
||||||
self.assertTrue(test_records[0][2]["item_code"] in items_dict)
|
self.assertTrue(test_records[0][2]["item_code"] in items_dict)
|
||||||
self.assertEquals(len(items_dict.values()), 3)
|
self.assertEquals(len(items_dict.values()), 3)
|
||||||
|
|
||||||
def test_get_items_list(self):
|
def test_get_items_list(self):
|
||||||
from manufacturing.doctype.bom.bom import get_bom_items
|
from manufacturing.doctype.bom.bom import get_bom_items
|
||||||
self.assertEquals(len(get_bom_items(bom="BOM/_Test FG Item/001", qty=1, fetch_exploded=1)), 3)
|
self.assertEquals(len(get_bom_items(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1)), 3)
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,31 @@ import webnotes, unittest
|
|||||||
|
|
||||||
class TimeLogBatchTest(unittest.TestCase):
|
class TimeLogBatchTest(unittest.TestCase):
|
||||||
def test_time_log_status(self):
|
def test_time_log_status(self):
|
||||||
self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"), "Submitted")
|
from projects.doctype.time_log.test_time_log import test_records as time_log_records
|
||||||
tlb = webnotes.bean("Time Log Batch", "_T-Time Log Batch-00001")
|
time_log = webnotes.bean(copy=time_log_records[0])
|
||||||
|
time_log.doc.fields.update({
|
||||||
|
"from_time": "2013-01-02 10:00:00",
|
||||||
|
"to_time": "2013-01-02 11:00:00",
|
||||||
|
"docstatus": 0
|
||||||
|
})
|
||||||
|
time_log.insert()
|
||||||
|
time_log.submit()
|
||||||
|
|
||||||
|
self.assertEquals(webnotes.conn.get_value("Time Log", time_log.doc.name, "status"), "Submitted")
|
||||||
|
tlb = webnotes.bean(copy=test_records[0])
|
||||||
|
tlb.doclist[1].time_log = time_log.doc.name
|
||||||
|
tlb.insert()
|
||||||
tlb.submit()
|
tlb.submit()
|
||||||
self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"), "Batched for Billing")
|
|
||||||
|
self.assertEquals(webnotes.conn.get_value("Time Log", time_log.doc.name, "status"), "Batched for Billing")
|
||||||
tlb.cancel()
|
tlb.cancel()
|
||||||
self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"), "Submitted")
|
self.assertEquals(webnotes.conn.get_value("Time Log", time_log.doc.name, "status"), "Submitted")
|
||||||
|
|
||||||
test_records = [[
|
test_records = [[
|
||||||
{"rate": "500"},
|
{
|
||||||
|
"doctype": "Time Log Batch",
|
||||||
|
"rate": "500"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Time Log Batch Detail",
|
"doctype": "Time Log Batch Detail",
|
||||||
"parenttype": "Time Log Batch",
|
"parenttype": "Time Log Batch",
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class TestCustomer(unittest.TestCase):
|
|||||||
(("_Test Customer 1 Renamed",),))
|
(("_Test Customer 1 Renamed",),))
|
||||||
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), ())
|
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), ())
|
||||||
|
|
||||||
|
webnotes.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1")
|
||||||
|
|
||||||
def test_merge(self):
|
def test_merge(self):
|
||||||
from webnotes.test_runner import make_test_records
|
from webnotes.test_runner import make_test_records
|
||||||
make_test_records("Sales Invoice")
|
make_test_records("Sales Invoice")
|
||||||
@@ -57,6 +59,9 @@ class TestCustomer(unittest.TestCase):
|
|||||||
# check that old name doesn't exist
|
# check that old name doesn't exist
|
||||||
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ())
|
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ())
|
||||||
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ())
|
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ())
|
||||||
|
|
||||||
|
# create back _Test Customer
|
||||||
|
webnotes.bean(copy=test_records[0]).insert()
|
||||||
|
|
||||||
test_ignore = ["Price List"]
|
test_ignore = ["Price List"]
|
||||||
|
|
||||||
|
|||||||
@@ -11,17 +11,19 @@ class TestQuotation(unittest.TestCase):
|
|||||||
def test_make_sales_order(self):
|
def test_make_sales_order(self):
|
||||||
from selling.doctype.quotation.quotation import make_sales_order
|
from selling.doctype.quotation.quotation import make_sales_order
|
||||||
|
|
||||||
self.assertRaises(webnotes.ValidationError, make_sales_order, "_T-Quotation-00001")
|
quotation = webnotes.bean(copy=test_records[0])
|
||||||
|
quotation.insert()
|
||||||
|
|
||||||
|
self.assertRaises(webnotes.ValidationError, make_sales_order, quotation.doc.name)
|
||||||
|
|
||||||
quotation = webnotes.bean("Quotation","_T-Quotation-00001")
|
|
||||||
quotation.submit()
|
quotation.submit()
|
||||||
|
|
||||||
sales_order = make_sales_order("_T-Quotation-00001")
|
sales_order = make_sales_order(quotation.doc.name)
|
||||||
|
|
||||||
self.assertEquals(sales_order[0]["doctype"], "Sales Order")
|
self.assertEquals(sales_order[0]["doctype"], "Sales Order")
|
||||||
self.assertEquals(len(sales_order), 2)
|
self.assertEquals(len(sales_order), 2)
|
||||||
self.assertEquals(sales_order[1]["doctype"], "Sales Order Item")
|
self.assertEquals(sales_order[1]["doctype"], "Sales Order Item")
|
||||||
self.assertEquals(sales_order[1]["prevdoc_docname"], "_T-Quotation-00001")
|
self.assertEquals(sales_order[1]["prevdoc_docname"], quotation.doc.name)
|
||||||
self.assertEquals(sales_order[0]["customer"], "_Test Customer")
|
self.assertEquals(sales_order[0]["customer"], "_Test Customer")
|
||||||
|
|
||||||
sales_order[0]["delivery_date"] = "2014-01-01"
|
sales_order[0]["delivery_date"] = "2014-01-01"
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
|
|
||||||
def create_dn_against_so(self, so, delivered_qty=0):
|
def create_dn_against_so(self, so, delivered_qty=0):
|
||||||
from stock.doctype.delivery_note.test_delivery_note import test_records as dn_test_records
|
from stock.doctype.delivery_note.test_delivery_note import test_records as dn_test_records
|
||||||
|
from stock.doctype.delivery_note.test_delivery_note import _insert_purchase_receipt
|
||||||
|
|
||||||
|
_insert_purchase_receipt(so.doclist[1].item_code)
|
||||||
|
|
||||||
dn = webnotes.bean(webnotes.copy_doclist(dn_test_records[0]))
|
dn = webnotes.bean(webnotes.copy_doclist(dn_test_records[0]))
|
||||||
dn.doclist[1].item_code = so.doclist[1].item_code
|
dn.doclist[1].item_code = so.doclist[1].item_code
|
||||||
dn.doclist[1].against_sales_order = so.doc.name
|
dn.doclist[1].against_sales_order = so.doc.name
|
||||||
@@ -272,14 +276,13 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
so.doclist[1].reserved_warehouse, 20.0)
|
so.doclist[1].reserved_warehouse, 20.0)
|
||||||
|
|
||||||
def test_warehouse_user(self):
|
def test_warehouse_user(self):
|
||||||
webnotes.session.user = "test@example.com"
|
|
||||||
|
|
||||||
webnotes.bean("Profile", "test@example.com").get_controller()\
|
webnotes.bean("Profile", "test@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
|
|
||||||
webnotes.bean("Profile", "test2@example.com").get_controller()\
|
webnotes.bean("Profile", "test2@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
|
|
||||||
|
webnotes.session.user = "test@example.com"
|
||||||
|
|
||||||
from stock.utils import UserNotAllowedForWarehouse
|
from stock.utils import UserNotAllowedForWarehouse
|
||||||
so = webnotes.bean(copy = test_records[0])
|
so = webnotes.bean(copy = test_records[0])
|
||||||
|
|||||||
@@ -9,20 +9,22 @@ import webnotes.defaults
|
|||||||
from webnotes.utils import cint
|
from webnotes.utils import cint
|
||||||
from stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_entries, set_perpetual_inventory, test_records as pr_test_records
|
from stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_entries, set_perpetual_inventory, test_records as pr_test_records
|
||||||
|
|
||||||
|
def _insert_purchase_receipt(item_code=None):
|
||||||
|
if not item_code:
|
||||||
|
item_code = pr_test_records[0][1]["item_code"]
|
||||||
|
|
||||||
|
pr = webnotes.bean(copy=pr_test_records[0])
|
||||||
|
pr.doclist[1].item_code = item_code
|
||||||
|
pr.insert()
|
||||||
|
pr.submit()
|
||||||
|
|
||||||
class TestDeliveryNote(unittest.TestCase):
|
class TestDeliveryNote(unittest.TestCase):
|
||||||
def _insert_purchase_receipt(self, item_code=None):
|
|
||||||
pr = webnotes.bean(copy=pr_test_records[0])
|
|
||||||
if item_code:
|
|
||||||
pr.doclist[1].item_code = item_code
|
|
||||||
pr.insert()
|
|
||||||
pr.submit()
|
|
||||||
|
|
||||||
def test_over_billing_against_dn(self):
|
def test_over_billing_against_dn(self):
|
||||||
self.clear_stock_account_balance()
|
self.clear_stock_account_balance()
|
||||||
self._insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
|
|
||||||
from stock.doctype.delivery_note.delivery_note import make_sales_invoice
|
from stock.doctype.delivery_note.delivery_note import make_sales_invoice
|
||||||
self._insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
dn = webnotes.bean(copy=test_records[0]).insert()
|
dn = webnotes.bean(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(webnotes.ValidationError, make_sales_invoice,
|
self.assertRaises(webnotes.ValidationError, make_sales_invoice,
|
||||||
@@ -44,7 +46,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 0)
|
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 0)
|
||||||
|
|
||||||
self._insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
|
|
||||||
dn = webnotes.bean(copy=test_records[0])
|
dn = webnotes.bean(copy=test_records[0])
|
||||||
dn.insert()
|
dn.insert()
|
||||||
@@ -69,7 +71,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||||
webnotes.conn.set_value("Item", "_Test Item", "valuation_method", "FIFO")
|
webnotes.conn.set_value("Item", "_Test Item", "valuation_method", "FIFO")
|
||||||
|
|
||||||
self._insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
|
|
||||||
dn = webnotes.bean(copy=test_records[0])
|
dn = webnotes.bean(copy=test_records[0])
|
||||||
dn.doclist[1].expense_account = "Cost of Goods Sold - _TC"
|
dn.doclist[1].expense_account = "Cost of Goods Sold - _TC"
|
||||||
@@ -123,8 +125,8 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
self.clear_stock_account_balance()
|
self.clear_stock_account_balance()
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
|
|
||||||
self._insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
self._insert_purchase_receipt("_Test Item Home Desktop 100")
|
_insert_purchase_receipt("_Test Item Home Desktop 100")
|
||||||
|
|
||||||
dn = webnotes.bean(copy=test_records[0])
|
dn = webnotes.bean(copy=test_records[0])
|
||||||
dn.doclist[1].item_code = "_Test Sales BOM Item"
|
dn.doclist[1].item_code = "_Test Sales BOM Item"
|
||||||
|
|||||||
@@ -81,9 +81,9 @@ test_records = [
|
|||||||
"is_sales_item": "Yes",
|
"is_sales_item": "Yes",
|
||||||
"is_service_item": "No",
|
"is_service_item": "No",
|
||||||
"inspection_required": "No",
|
"inspection_required": "No",
|
||||||
"is_pro_applicable": "Yes",
|
"is_pro_applicable": "No",
|
||||||
"is_sub_contracted_item": "No",
|
"is_sub_contracted_item": "No",
|
||||||
"is_manufactured_item": "Yes",
|
"is_manufactured_item": "No",
|
||||||
"stock_uom": "_Test UOM"
|
"stock_uom": "_Test UOM"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -109,6 +109,7 @@ test_records = [
|
|||||||
"inspection_required": "No",
|
"inspection_required": "No",
|
||||||
"is_pro_applicable": "No",
|
"is_pro_applicable": "No",
|
||||||
"is_sub_contracted_item": "No",
|
"is_sub_contracted_item": "No",
|
||||||
|
"is_manufactured_item": "No",
|
||||||
"stock_uom": "_Test UOM"
|
"stock_uom": "_Test UOM"
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
@@ -207,4 +208,45 @@ test_records = [
|
|||||||
"is_sub_contracted_item": "No",
|
"is_sub_contracted_item": "No",
|
||||||
"stock_uom": "_Test UOM"
|
"stock_uom": "_Test UOM"
|
||||||
}],
|
}],
|
||||||
|
[{
|
||||||
|
"doctype": "Item",
|
||||||
|
"item_code": "_Test Item Home Desktop Manufactured",
|
||||||
|
"item_name": "_Test Item Home Desktop Manufactured",
|
||||||
|
"description": "_Test Item Home Desktop Manufactured",
|
||||||
|
"item_group": "_Test Item Group Desktops",
|
||||||
|
"default_warehouse": "_Test Warehouse - _TC",
|
||||||
|
"default_income_account": "Sales - _TC",
|
||||||
|
"is_stock_item": "Yes",
|
||||||
|
"is_asset_item": "No",
|
||||||
|
"has_batch_no": "No",
|
||||||
|
"has_serial_no": "No",
|
||||||
|
"is_purchase_item": "Yes",
|
||||||
|
"is_sales_item": "Yes",
|
||||||
|
"is_service_item": "No",
|
||||||
|
"inspection_required": "No",
|
||||||
|
"is_pro_applicable": "Yes",
|
||||||
|
"is_sub_contracted_item": "No",
|
||||||
|
"is_manufactured_item": "Yes",
|
||||||
|
"stock_uom": "_Test UOM"
|
||||||
|
}],
|
||||||
|
[{
|
||||||
|
"doctype": "Item",
|
||||||
|
"item_code": "_Test FG Item 2",
|
||||||
|
"item_name": "_Test FG Item 2",
|
||||||
|
"description": "_Test FG Item 2",
|
||||||
|
"item_group": "_Test Item Group Desktops",
|
||||||
|
"is_stock_item": "Yes",
|
||||||
|
"default_warehouse": "_Test Warehouse - _TC",
|
||||||
|
"default_income_account": "Sales - _TC",
|
||||||
|
"is_asset_item": "No",
|
||||||
|
"has_batch_no": "No",
|
||||||
|
"has_serial_no": "No",
|
||||||
|
"is_purchase_item": "Yes",
|
||||||
|
"is_sales_item": "Yes",
|
||||||
|
"is_service_item": "No",
|
||||||
|
"inspection_required": "No",
|
||||||
|
"is_pro_applicable": "Yes",
|
||||||
|
"is_sub_contracted_item": "Yes",
|
||||||
|
"stock_uom": "_Test UOM"
|
||||||
|
}],
|
||||||
]
|
]
|
||||||
@@ -7,7 +7,7 @@ import webnotes
|
|||||||
from webnotes.utils import cstr, flt, cint
|
from webnotes.utils import cstr, flt, cint
|
||||||
from webnotes.model.bean import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint, _
|
||||||
import webnotes.defaults
|
import webnotes.defaults
|
||||||
from stock.utils import update_bin
|
from stock.utils import update_bin
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,12 @@ class DocType(StockController):
|
|||||||
webnotes.conn.sql("""update `tab%s` set serial_no = %s
|
webnotes.conn.sql("""update `tab%s` set serial_no = %s
|
||||||
where name=%s""" % (dt[0], '%s', '%s'),
|
where name=%s""" % (dt[0], '%s', '%s'),
|
||||||
('\n'.join(serial_nos), item[0]))
|
('\n'.join(serial_nos), item[0]))
|
||||||
|
|
||||||
|
def on_stock_ledger_entry(self):
|
||||||
|
if self.via_stock_ledger and not self.doc.fields.get("__islocal"):
|
||||||
|
self.set_status()
|
||||||
|
self.set_purchase_details()
|
||||||
|
self.set_sales_details()
|
||||||
|
|
||||||
def on_stock_ledger_entry(self):
|
def on_stock_ledger_entry(self):
|
||||||
if self.via_stock_ledger and not self.doc.fields.get("__islocal"):
|
if self.via_stock_ledger and not self.doc.fields.get("__islocal"):
|
||||||
@@ -240,9 +246,8 @@ def update_serial_nos(sle, item_det):
|
|||||||
serial_nos = []
|
serial_nos = []
|
||||||
for i in xrange(cint(sle.actual_qty)):
|
for i in xrange(cint(sle.actual_qty)):
|
||||||
serial_nos.append(make_autoname(item_det.serial_no_series))
|
serial_nos.append(make_autoname(item_det.serial_no_series))
|
||||||
|
|
||||||
webnotes.conn.set(sle, "serial_no", "\n".join(serial_nos))
|
webnotes.conn.set(sle, "serial_no", "\n".join(serial_nos))
|
||||||
|
|
||||||
if sle.serial_no:
|
if sle.serial_no:
|
||||||
serial_nos = get_serial_nos(sle.serial_no)
|
serial_nos = get_serial_nos(sle.serial_no)
|
||||||
for serial_no in serial_nos:
|
for serial_no in serial_nos:
|
||||||
@@ -280,7 +285,7 @@ def update_serial_nos_after_submit(controller, parentfield):
|
|||||||
(controller.doc.doctype, controller.doc.name), as_dict=True)
|
(controller.doc.doctype, controller.doc.name), as_dict=True)
|
||||||
|
|
||||||
if not stock_ledger_entries: return
|
if not stock_ledger_entries: return
|
||||||
|
|
||||||
for d in controller.doclist.get({"parentfield": parentfield}):
|
for d in controller.doclist.get({"parentfield": parentfield}):
|
||||||
serial_no = None
|
serial_no = None
|
||||||
for sle in stock_ledger_entries:
|
for sle in stock_ledger_entries:
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
webnotes.conn.set_default("company", self.old_default_company)
|
webnotes.conn.set_default("company", self.old_default_company)
|
||||||
|
|
||||||
def test_warehouse_company_validation(self):
|
def test_warehouse_company_validation(self):
|
||||||
|
set_perpetual_inventory(0)
|
||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
webnotes.bean("Profile", "test2@example.com").get_controller()\
|
webnotes.bean("Profile", "test2@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
|
|
||||||
webnotes.session.user = "test2@example.com"
|
webnotes.session.user = "test2@example.com"
|
||||||
|
|
||||||
from stock.utils import InvalidWarehouseCompany
|
from stock.utils import InvalidWarehouseCompany
|
||||||
@@ -55,6 +55,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
webnotes.session.user = "Administrator"
|
webnotes.session.user = "Administrator"
|
||||||
|
|
||||||
def test_warehouse_user(self):
|
def test_warehouse_user(self):
|
||||||
|
set_perpetual_inventory(0)
|
||||||
from stock.utils import UserNotAllowedForWarehouse
|
from stock.utils import UserNotAllowedForWarehouse
|
||||||
|
|
||||||
webnotes.bean("Profile", "test@example.com").get_controller()\
|
webnotes.bean("Profile", "test@example.com").get_controller()\
|
||||||
@@ -62,7 +63,6 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
webnotes.bean("Profile", "test2@example.com").get_controller()\
|
webnotes.bean("Profile", "test2@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
|
|
||||||
webnotes.session.user = "test@example.com"
|
webnotes.session.user = "test@example.com"
|
||||||
st1 = webnotes.bean(copy=test_records[0])
|
st1 = webnotes.bean(copy=test_records[0])
|
||||||
st1.doc.company = "_Test Company 1"
|
st1.doc.company = "_Test Company 1"
|
||||||
|
|||||||
@@ -76,14 +76,17 @@ class DocType():
|
|||||||
sender = self.doc.send_from or webnotes.utils.get_formatted_email(self.doc.owner)
|
sender = self.doc.send_from or webnotes.utils.get_formatted_email(self.doc.owner)
|
||||||
|
|
||||||
from webnotes.utils.email_lib.bulk import send
|
from webnotes.utils.email_lib.bulk import send
|
||||||
webnotes.conn.auto_commit_on_many_writes = True
|
|
||||||
|
if not webnotes.flags.in_test:
|
||||||
|
webnotes.conn.auto_commit_on_many_writes = True
|
||||||
|
|
||||||
send(recipients = self.recipients, sender = sender,
|
send(recipients = self.recipients, sender = sender,
|
||||||
subject = self.doc.subject, message = self.doc.message,
|
subject = self.doc.subject, message = self.doc.message,
|
||||||
doctype = self.send_to_doctype, email_field = "email_id",
|
doctype = self.send_to_doctype, email_field = "email_id",
|
||||||
ref_doctype = self.doc.doctype, ref_docname = self.doc.name)
|
ref_doctype = self.doc.doctype, ref_docname = self.doc.name)
|
||||||
|
|
||||||
webnotes.conn.auto_commit_on_many_writes = False
|
if not webnotes.flags.in_test:
|
||||||
|
webnotes.conn.auto_commit_on_many_writes = False
|
||||||
|
|
||||||
def validate_send(self):
|
def validate_send(self):
|
||||||
if self.doc.fields.get("__islocal"):
|
if self.doc.fields.get("__islocal"):
|
||||||
|
|||||||
@@ -45,20 +45,23 @@ test_records =[
|
|||||||
"subject": "_Test Newsletter to Lead",
|
"subject": "_Test Newsletter to Lead",
|
||||||
"send_to_type": "Lead",
|
"send_to_type": "Lead",
|
||||||
"lead_source": "All",
|
"lead_source": "All",
|
||||||
"message": "This is a test newsletter"
|
"message": "This is a test newsletter",
|
||||||
|
"send_from": "admin@example.com"
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
"doctype": "Newsletter",
|
"doctype": "Newsletter",
|
||||||
"subject": "_Test Newsletter to Contact",
|
"subject": "_Test Newsletter to Contact",
|
||||||
"send_to_type": "Contact",
|
"send_to_type": "Contact",
|
||||||
"contact_type": "Customer",
|
"contact_type": "Customer",
|
||||||
"message": "This is a test newsletter"
|
"message": "This is a test newsletter",
|
||||||
|
"send_from": "admin@example.com"
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
"doctype": "Newsletter",
|
"doctype": "Newsletter",
|
||||||
"subject": "_Test Newsletter to Custom",
|
"subject": "_Test Newsletter to Custom",
|
||||||
"send_to_type": "Custom",
|
"send_to_type": "Custom",
|
||||||
"email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com",
|
"email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com",
|
||||||
"message": "This is a test newsletter"
|
"message": "This is a test newsletter",
|
||||||
|
"send_from": "admin@example.com"
|
||||||
}],
|
}],
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ def import_data(dt, submit=False, overwrite=False):
|
|||||||
|
|
||||||
for doctype in dt:
|
for doctype in dt:
|
||||||
print "Importing", doctype.replace("_", " "), "..."
|
print "Importing", doctype.replace("_", " "), "..."
|
||||||
webnotes.form_dict = webnotes._dict()
|
webnotes.local.form_dict = webnotes._dict()
|
||||||
if submit:
|
if submit:
|
||||||
webnotes.form_dict["params"] = json.dumps({"_submit": 1})
|
webnotes.form_dict["params"] = json.dumps({"_submit": 1})
|
||||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", doctype+".csv")
|
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", doctype+".csv")
|
||||||
|
|||||||
Reference in New Issue
Block a user