model_wrapper is now bean, refactoring defaults
This commit is contained in:
parent
9c880da381
commit
c53231a841
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cstr, flt, getdate, now, nowdate
|
from webnotes.utils import cstr, flt, getdate, now, nowdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.bean import getlist, copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.utils import flt, getdate
|
from webnotes.utils import flt, getdate
|
||||||
from webnotes.model.doc import make_autoname
|
from webnotes.model.doc import make_autoname
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,d,dl):
|
def __init__(self,d,dl):
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
from webnotes.utils.nestedset import DocTypeNestedSet
|
from webnotes.utils.nestedset import DocTypeNestedSet
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate
|
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate
|
||||||
from webnotes.model.doc import addchild, make_autoname
|
from webnotes.model.doc import addchild, make_autoname
|
||||||
from webnotes.model.wrapper 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
|
||||||
from setup.utils import get_company_currency
|
from setup.utils import get_company_currency
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cint, cstr, flt, get_defaults, get_first_day, get_last_day, has_common
|
from webnotes.utils import cint, cstr, flt, get_defaults, get_first_day, get_last_day, has_common
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import session, msgprint
|
from webnotes import session, msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cstr, flt, getdate
|
from webnotes.utils import cstr, flt, getdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import add_days, cint, cstr, flt, formatdate, get_defaults
|
from webnotes.utils import add_days, cint, cstr, flt, formatdate, get_defaults
|
||||||
from webnotes.model.wrapper 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, _
|
||||||
from setup.utils import get_company_currency
|
from setup.utils import get_company_currency
|
||||||
|
@ -25,7 +25,7 @@ test_dependencies = ["Item", "Cost Center"]
|
|||||||
|
|
||||||
class TestPurchaseInvoice(unittest.TestCase):
|
class TestPurchaseInvoice(unittest.TestCase):
|
||||||
def test_gl_entries(self):
|
def test_gl_entries(self):
|
||||||
wrapper = webnotes.model_wrapper(self.get_test_doclist())
|
wrapper = webnotes.bean(self.get_test_doclist())
|
||||||
|
|
||||||
# circumvent the disabled calculation call
|
# circumvent the disabled calculation call
|
||||||
obj = webnotes.get_obj(doc=wrapper.doc, doclist=wrapper.doclist)
|
obj = webnotes.get_obj(doc=wrapper.doc, doclist=wrapper.doclist)
|
||||||
@ -54,7 +54,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
|
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
|
||||||
|
|
||||||
def test_purchase_invoice_calculation(self):
|
def test_purchase_invoice_calculation(self):
|
||||||
wrapper = webnotes.model_wrapper(self.get_test_doclist())
|
wrapper = webnotes.bean(self.get_test_doclist())
|
||||||
|
|
||||||
# circumvent the disabled calculation call
|
# circumvent the disabled calculation call
|
||||||
obj = webnotes.get_obj(doc=wrapper.doc, doclist=wrapper.doclist)
|
obj = webnotes.get_obj(doc=wrapper.doc, doclist=wrapper.doclist)
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, sendmail
|
from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, sendmail
|
||||||
from webnotes.utils import comma_and
|
from webnotes.utils import comma_and
|
||||||
from webnotes.model.doc import make_autoname
|
from webnotes.model.doc import make_autoname
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
@ -858,7 +858,7 @@ def manage_recurring_invoices(next_date=None):
|
|||||||
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
||||||
(next_date, recurring_id)):
|
(next_date, recurring_id)):
|
||||||
try:
|
try:
|
||||||
ref_wrapper = webnotes.model_wrapper('Sales Invoice', ref_invoice)
|
ref_wrapper = webnotes.bean('Sales Invoice', ref_invoice)
|
||||||
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
|
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
|
||||||
send_notification(new_invoice_wrapper)
|
send_notification(new_invoice_wrapper)
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
@ -880,7 +880,7 @@ def manage_recurring_invoices(next_date=None):
|
|||||||
raise Exception, exception_message
|
raise Exception, exception_message
|
||||||
|
|
||||||
def make_new_invoice(ref_wrapper, posting_date):
|
def make_new_invoice(ref_wrapper, posting_date):
|
||||||
from webnotes.model.wrapper import clone
|
from webnotes.model.bean import clone
|
||||||
from accounts.utils import get_fiscal_year
|
from accounts.utils import get_fiscal_year
|
||||||
new_invoice = clone(ref_wrapper)
|
new_invoice = clone(ref_wrapper)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import unittest
|
|||||||
|
|
||||||
class TestSalesInvoice(unittest.TestCase):
|
class TestSalesInvoice(unittest.TestCase):
|
||||||
def make(self):
|
def make(self):
|
||||||
w = webnotes.model_wrapper(webnotes.copy_doclist(test_records[0]))
|
w = webnotes.bean(webnotes.copy_doclist(test_records[0]))
|
||||||
w.insert()
|
w.insert()
|
||||||
w.submit()
|
w.submit()
|
||||||
return w
|
return w
|
||||||
@ -17,7 +17,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
from accounts.doctype.journal_voucher.test_journal_voucher \
|
from accounts.doctype.journal_voucher.test_journal_voucher \
|
||||||
import test_records as jv_test_records
|
import test_records as jv_test_records
|
||||||
|
|
||||||
jv = webnotes.model_wrapper(webnotes.copy_doclist(jv_test_records[0]))
|
jv = webnotes.bean(webnotes.copy_doclist(jv_test_records[0]))
|
||||||
jv.doclist[1].against_invoice = w.doc.name
|
jv.doclist[1].against_invoice = w.doc.name
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import add_days, add_months, cint, cstr
|
from webnotes.utils import add_days, add_months, cint, cstr
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ def map_fields(field_list, source, target):
|
|||||||
|
|
||||||
def import_vouchers(common_values, data, start_idx, import_type):
|
def import_vouchers(common_values, data, start_idx, import_type):
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper import ModelWrapper
|
from webnotes.model.bean import Bean
|
||||||
from accounts.utils import get_fiscal_year
|
from accounts.utils import get_fiscal_year
|
||||||
from webnotes.utils.dateutils import parse_date
|
from webnotes.utils.dateutils import parse_date
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ def import_vouchers(common_values, data, start_idx, import_type):
|
|||||||
If you entered accounts correctly, please check template once"""]
|
If you entered accounts correctly, please check template once"""]
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
doclist = ModelWrapper([jv]+details)
|
doclist = Bean([jv]+details)
|
||||||
doclist.submit()
|
doclist.submit()
|
||||||
|
|
||||||
messages.append("""<p style='color: green'>[row #%s]
|
messages.append("""<p style='color: green'>[row #%s]
|
||||||
|
@ -121,7 +121,7 @@ def add_ac(args=None):
|
|||||||
args = webnotes.form_dict
|
args = webnotes.form_dict
|
||||||
args.pop("cmd")
|
args.pop("cmd")
|
||||||
|
|
||||||
ac = webnotes.model_wrapper(args)
|
ac = webnotes.bean(args)
|
||||||
ac.doc.doctype = "Account"
|
ac.doc.doctype = "Account"
|
||||||
ac.doc.old_parent = ""
|
ac.doc.old_parent = ""
|
||||||
ac.doc.freeze_account = "No"
|
ac.doc.freeze_account = "No"
|
||||||
@ -135,7 +135,7 @@ def add_cc(args=None):
|
|||||||
args = webnotes.form_dict
|
args = webnotes.form_dict
|
||||||
args.pop("cmd")
|
args.pop("cmd")
|
||||||
|
|
||||||
cc = webnotes.model_wrapper(args)
|
cc = webnotes.bean(args)
|
||||||
cc.doc.doctype = "Cost Center"
|
cc.doc.doctype = "Cost Center"
|
||||||
cc.doc.old_parent = ""
|
cc.doc.old_parent = ""
|
||||||
cc.ignore_permissions = 1
|
cc.ignore_permissions = 1
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import add_days, cint, cstr, flt
|
from webnotes.utils import add_days, cint, cstr, flt
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper 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, _
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cstr, flt, get_defaults
|
from webnotes.utils import cstr, flt, get_defaults
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper 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
|
||||||
from buying.utils import get_last_purchase_details
|
from buying.utils import get_last_purchase_details
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import addchild, make_autoname
|
from webnotes.model.doc import addchild, make_autoname
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class DocType(BuyingController):
|
|||||||
self.doc, self.doclist, """[['Material Request', 'Supplier Quotation'],
|
self.doc, self.doclist, """[['Material Request', 'Supplier Quotation'],
|
||||||
['Material Request Item', 'Supplier Quotation Item']]""")
|
['Material Request Item', 'Supplier Quotation Item']]""")
|
||||||
|
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
for d in getlist(self.doclist, self.fname):
|
for d in getlist(self.doclist, self.fname):
|
||||||
if d.item_code and not d.purchase_rate:
|
if d.item_code and not d.purchase_rate:
|
||||||
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0
|
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0
|
||||||
|
@ -37,7 +37,7 @@ def get_item_details(args):
|
|||||||
|
|
||||||
args = webnotes._dict(args)
|
args = webnotes._dict(args)
|
||||||
|
|
||||||
item_wrapper = webnotes.model_wrapper("Item", args.item_code)
|
item_wrapper = webnotes.bean("Item", args.item_code)
|
||||||
item = item_wrapper.doc
|
item = item_wrapper.doc
|
||||||
|
|
||||||
from stock.utils import validate_end_of_life
|
from stock.utils import validate_end_of_life
|
||||||
@ -98,7 +98,7 @@ def get_item_details(args):
|
|||||||
|
|
||||||
def get_rates_as_per_price_list(args, item_doclist=None):
|
def get_rates_as_per_price_list(args, item_doclist=None):
|
||||||
if not item_doclist:
|
if not item_doclist:
|
||||||
item_doclist = webnotes.model_wrapper("Item", args.item_code).doclist
|
item_doclist = webnotes.bean("Item", args.item_code).doclist
|
||||||
|
|
||||||
result = item_doclist.get({"parentfield": "ref_rate_details",
|
result = item_doclist.get({"parentfield": "ref_rate_details",
|
||||||
"price_list_name": args.price_list_name, "ref_currency": args.price_list_currency,
|
"price_list_name": args.price_list_name, "ref_currency": args.price_list_currency,
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import cstr, flt, getdate
|
from webnotes.utils import cstr, flt, getdate
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import add_days, getdate, now
|
from webnotes.utils import add_days, getdate, now
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import make_autoname
|
from webnotes.model.doc import make_autoname
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cint, cstr, date_diff, formatdate, get_defaults, getdate, now
|
from webnotes.utils import cint, cstr, date_diff, formatdate, get_defaults, getdate, now
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import form, msgprint
|
from webnotes import form, msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -79,7 +79,7 @@ class DocType:
|
|||||||
from webnotes.profile import add_role
|
from webnotes.profile import add_role
|
||||||
add_role(self.doc.user_id, "HR User")
|
add_role(self.doc.user_id, "HR User")
|
||||||
|
|
||||||
profile_wrapper = webnotes.model_wrapper("Profile", self.doc.user_id)
|
profile_wrapper = webnotes.bean("Profile", self.doc.user_id)
|
||||||
|
|
||||||
# copy details like Fullname, DOB and Image to Profile
|
# copy details like Fullname, DOB and Image to Profile
|
||||||
if self.doc.employee_name:
|
if self.doc.employee_name:
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import add_days
|
from webnotes.utils import add_days
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes import form, msgprint
|
from webnotes import form, msgprint
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import add_days, add_years, cint, getdate
|
from webnotes.utils import add_days, add_years, cint, getdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import addchild, make_autoname
|
from webnotes.model.doc import addchild, make_autoname
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -31,14 +31,14 @@ class JobsMailbox(POP3Mailbox):
|
|||||||
name = webnotes.conn.get_value("Job Applicant", {"email_id": mail.from_email},
|
name = webnotes.conn.get_value("Job Applicant", {"email_id": mail.from_email},
|
||||||
"name")
|
"name")
|
||||||
if name:
|
if name:
|
||||||
applicant = webnotes.model_wrapper("Job Applicant", name)
|
applicant = webnotes.bean("Job Applicant", name)
|
||||||
if applicant.doc.status!="Rejected":
|
if applicant.doc.status!="Rejected":
|
||||||
applicant.doc.status = "Open"
|
applicant.doc.status = "Open"
|
||||||
applicant.doc.save()
|
applicant.doc.save()
|
||||||
else:
|
else:
|
||||||
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
|
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
|
||||||
+ mail.from_email
|
+ mail.from_email
|
||||||
applicant = webnotes.model_wrapper({
|
applicant = webnotes.bean({
|
||||||
"creation": mail.date,
|
"creation": mail.date,
|
||||||
"doctype":"Job Applicant",
|
"doctype":"Job Applicant",
|
||||||
"applicant_name": name,
|
"applicant_name": name,
|
||||||
|
@ -5,18 +5,18 @@ from hr.doctype.leave_application.leave_application import LeaveDayBlockedError
|
|||||||
|
|
||||||
class TestLeaveApplication(unittest.TestCase):
|
class TestLeaveApplication(unittest.TestCase):
|
||||||
def get_application(self, doclist):
|
def get_application(self, doclist):
|
||||||
application = webnotes.model_wrapper(doclist)
|
application = webnotes.bean(copy=doclist)
|
||||||
application.doc.from_date = "2013-01-01"
|
application.doc.from_date = "2013-01-01"
|
||||||
application.doc.to_date = "2013-01-05"
|
application.doc.to_date = "2013-01-05"
|
||||||
return application
|
return application
|
||||||
|
|
||||||
def test_block_list(self):
|
def test_block_list(self):
|
||||||
import webnotes
|
import webnotes
|
||||||
webnotes.conn.set_value("Employee", "_T-Employee-0001", "department",
|
webnotes.conn.set_value("Department", "_Test Department", "leave_block_list", "_Test Leave Block List")
|
||||||
"_Test Department with Block List")
|
|
||||||
|
|
||||||
application = self.get_application(test_records[1])
|
application = self.get_application(test_records[1])
|
||||||
application.insert()
|
application.insert()
|
||||||
|
application.doc.status = "Approved"
|
||||||
self.assertRaises(LeaveDayBlockedError, application.submit)
|
self.assertRaises(LeaveDayBlockedError, application.submit)
|
||||||
|
|
||||||
webnotes.session.user = "test1@example.com"
|
webnotes.session.user = "test1@example.com"
|
||||||
@ -45,6 +45,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
from webnotes.profile import add_role
|
from webnotes.profile import add_role
|
||||||
add_role("test@example.com", "Leave Approver")
|
add_role("test@example.com", "Leave Approver")
|
||||||
|
|
||||||
|
application.doc.status = "Approved"
|
||||||
self.assertRaises(LeaveDayBlockedError, application.submit)
|
self.assertRaises(LeaveDayBlockedError, application.submit)
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cint, cstr, flt, now, nowdate
|
from webnotes.utils import cint, cstr, flt, now, nowdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cint, flt
|
from webnotes.utils import cint, flt
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.bean import getlist, copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import add_days, cint, cstr, flt, getdate
|
from webnotes.utils import add_days, cint, cstr, flt, getdate
|
||||||
from webnotes.model.doc import make_autoname
|
from webnotes.model.doc import make_autoname
|
||||||
from webnotes.model.wrapper 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
|
||||||
from setup.utils import get_company_currency
|
from setup.utils import get_company_currency
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cstr, flt
|
from webnotes.utils import cstr, flt
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import addchild, make_autoname
|
from webnotes.model.doc import addchild, make_autoname
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.utils import cint, cstr, flt, now, nowdate
|
from webnotes.utils import cint, cstr, flt, now, nowdate
|
||||||
from webnotes.model.doc import Document, addchild
|
from webnotes.model.doc import Document, addchild
|
||||||
from webnotes.model.wrapper 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, _
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cstr, flt, now, nowdate
|
from webnotes.utils import cstr, flt, now, nowdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import make_autoname
|
from webnotes.model.doc import make_autoname
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.utils import cstr, flt, cint, nowdate, add_days
|
from webnotes.utils import cstr, flt, cint, nowdate, add_days
|
||||||
from webnotes.model.doc import addchild, Document
|
from webnotes.model.doc import addchild, Document
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ class DocType:
|
|||||||
purchase_request_list = []
|
purchase_request_list = []
|
||||||
if items_to_be_requested:
|
if items_to_be_requested:
|
||||||
for item in items_to_be_requested:
|
for item in items_to_be_requested:
|
||||||
item_wrapper = webnotes.model_wrapper("Item", item)
|
item_wrapper = webnotes.bean("Item", item)
|
||||||
pr_doclist = [
|
pr_doclist = [
|
||||||
{
|
{
|
||||||
"doctype": "Material Request",
|
"doctype": "Material Request",
|
||||||
@ -367,7 +367,7 @@ class DocType:
|
|||||||
"warehouse": self.doc.purchase_request_for_warehouse
|
"warehouse": self.doc.purchase_request_for_warehouse
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
pr_wrapper = webnotes.model_wrapper(pr_doclist)
|
pr_wrapper = webnotes.bean(pr_doclist)
|
||||||
pr_wrapper.ignore_permissions = 1
|
pr_wrapper.ignore_permissions = 1
|
||||||
pr_wrapper.submit()
|
pr_wrapper.submit()
|
||||||
purchase_request_list.append(pr_wrapper.doc.name)
|
purchase_request_list.append(pr_wrapper.doc.name)
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
def execute():
|
def execute():
|
||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.model.wrapper import ModelWrapper
|
from webnotes.model.bean import Bean
|
||||||
ModelWrapper("Website Settings", "Website Settings").save()
|
Bean("Website Settings", "Website Settings").save()
|
@ -4,10 +4,10 @@ def execute():
|
|||||||
# new roles
|
# new roles
|
||||||
roles = [r[0] for r in webnotes.conn.sql("""select name from tabRole""")]
|
roles = [r[0] for r in webnotes.conn.sql("""select name from tabRole""")]
|
||||||
if not "Leave Approver" in roles:
|
if not "Leave Approver" in roles:
|
||||||
webnotes.model_wrapper([{"doctype":"Role", "role_name":"Leave Approver",
|
webnotes.bean([{"doctype":"Role", "role_name":"Leave Approver",
|
||||||
"__islocal":1, "module":"HR"}]).save()
|
"__islocal":1, "module":"HR"}]).save()
|
||||||
if not "Expense Approver" in roles:
|
if not "Expense Approver" in roles:
|
||||||
webnotes.model_wrapper([{"doctype":"Role", "role_name":"Expense Approver",
|
webnotes.bean([{"doctype":"Role", "role_name":"Expense Approver",
|
||||||
"__islocal":1, "module":"HR"}]).save()
|
"__islocal":1, "module":"HR"}]).save()
|
||||||
|
|
||||||
# reload
|
# reload
|
||||||
|
@ -6,6 +6,8 @@ def execute():
|
|||||||
webnotes.rename_doc("DocType", "Purchase Request", "Material Request", force=True)
|
webnotes.rename_doc("DocType", "Purchase Request", "Material Request", force=True)
|
||||||
webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_bill")
|
webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_bill")
|
||||||
webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_receive")
|
webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_receive")
|
||||||
|
|
||||||
|
webnotes.conn.sql("""update `tabMaterial Request` set material_request_type='Purchase'""")
|
||||||
|
|
||||||
os.system("rm -rf app/buying/doctype/purchase_request")
|
os.system("rm -rf app/buying/doctype/purchase_request")
|
||||||
os.system("rm -rf app/buying/doctype/purchase_request_item")
|
os.system("rm -rf app/buying/doctype/purchase_request_item")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import webnotes
|
import webnotes
|
||||||
def execute():
|
def execute():
|
||||||
for name in webnotes.conn.sql("""select name from `tabHoliday List`"""):
|
for name in webnotes.conn.sql("""select name from `tabHoliday List`"""):
|
||||||
holiday_list_wrapper = webnotes.model_wrapper("Holiday List", name[0])
|
holiday_list_wrapper = webnotes.bean("Holiday List", name[0])
|
||||||
|
|
||||||
desc_count = _count([d.description for d in
|
desc_count = _count([d.description for d in
|
||||||
holiday_list_wrapper.doclist.get({"doctype": "Holiday"})])
|
holiday_list_wrapper.doclist.get({"doctype": "Holiday"})])
|
||||||
|
@ -5,7 +5,7 @@ def execute():
|
|||||||
webnotes.conn.sql("""update tabDocPerm set report = 0 where parent = %s""", dt[0])
|
webnotes.conn.sql("""update tabDocPerm set report = 0 where parent = %s""", dt[0])
|
||||||
|
|
||||||
|
|
||||||
doctype = webnotes.model_wrapper("DocType", dt[0])
|
doctype = webnotes.bean("DocType", dt[0])
|
||||||
for pl in [1, 2, 3]:
|
for pl in [1, 2, 3]:
|
||||||
if not doctype.doclist.get({"doctype": "DocField", "permlevel": pl}):
|
if not doctype.doclist.get({"doctype": "DocField", "permlevel": pl}):
|
||||||
if doctype.doclist.get({"doctype":"DocPerm", "permlevel":pl}):
|
if doctype.doclist.get({"doctype":"DocPerm", "permlevel":pl}):
|
||||||
|
@ -23,7 +23,7 @@ def move_remarks_to_comments():
|
|||||||
where ifnull(remark, '')!=''""")
|
where ifnull(remark, '')!=''""")
|
||||||
fullname_map = {}
|
fullname_map = {}
|
||||||
for reco, remark, modified_by in result:
|
for reco, remark, modified_by in result:
|
||||||
webnotes.model_wrapper([{
|
webnotes.bean([{
|
||||||
"doctype": "Comment",
|
"doctype": "Comment",
|
||||||
"comment": remark,
|
"comment": remark,
|
||||||
"comment_by": modified_by,
|
"comment_by": modified_by,
|
||||||
|
@ -67,13 +67,13 @@ def save_pages():
|
|||||||
}
|
}
|
||||||
|
|
||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.model.wrapper import ModelWrapper
|
from webnotes.model.bean import Bean
|
||||||
import webnotes.modules.patch_handler
|
import webnotes.modules.patch_handler
|
||||||
|
|
||||||
for dt in query_map:
|
for dt in query_map:
|
||||||
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
|
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
|
||||||
try:
|
try:
|
||||||
ModelWrapper(dt, result['name'].encode('utf-8')).save()
|
Bean(dt, result['name'].encode('utf-8')).save()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
webnotes.modules.patch_handler.log(unicode(e))
|
webnotes.modules.patch_handler.log(unicode(e))
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import flt, getdate
|
from webnotes.utils import flt, getdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import add_days, cint, cstr, date_diff, flt, now, nowdate, add_days
|
from webnotes.utils import add_days, cint, cstr, date_diff, flt, now, nowdate, add_days
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
from webnotes.utils.email_lib import sendmail
|
from webnotes.utils.email_lib import sendmail
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import getdate, today
|
from webnotes.utils import getdate, today
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -20,7 +20,7 @@ import time, datetime
|
|||||||
|
|
||||||
from webnotes.utils import cint, cstr, getdate, now, nowdate
|
from webnotes.utils import cint, cstr, getdate, now, nowdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.bean import getlist, copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cstr, getdate
|
from webnotes.utils import cstr, getdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import make_autoname
|
from webnotes.model.doc import make_autoname
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.bean import getlist, copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
from stock.utils import get_valid_serial_nos
|
from stock.utils import get_valid_serial_nos
|
||||||
|
@ -23,7 +23,7 @@ from core.doctype.communication.communication import make
|
|||||||
def add_sales_communication(subject, content, sender, real_name, mail=None,
|
def add_sales_communication(subject, content, sender, real_name, mail=None,
|
||||||
status="Open", date=None):
|
status="Open", date=None):
|
||||||
def set_status(doctype, name):
|
def set_status(doctype, name):
|
||||||
w = webnotes.model_wrapper(doctype, name)
|
w = webnotes.bean(doctype, name)
|
||||||
w.ignore_permissions = True
|
w.ignore_permissions = True
|
||||||
w.doc.status = is_system_user and "Replied" or status
|
w.doc.status = is_system_user and "Replied" or status
|
||||||
w.doc.save()
|
w.doc.save()
|
||||||
@ -36,7 +36,7 @@ def add_sales_communication(subject, content, sender, real_name, mail=None,
|
|||||||
|
|
||||||
if not (lead_name or contact_name):
|
if not (lead_name or contact_name):
|
||||||
# none, create a new Lead
|
# none, create a new Lead
|
||||||
lead = webnotes.model_wrapper({
|
lead = webnotes.bean({
|
||||||
"doctype":"Lead",
|
"doctype":"Lead",
|
||||||
"lead_name": real_name or sender,
|
"lead_name": real_name or sender,
|
||||||
"email_id": sender,
|
"email_id": sender,
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import add_days, cstr, getdate
|
from webnotes.utils import add_days, cstr, getdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document, addchild
|
from webnotes.model.doc import Document, addchild
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cint, cstr, get_defaults, now
|
from webnotes.utils import cint, cstr, get_defaults, now
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import cstr, getdate
|
from webnotes.utils import cstr, getdate
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cint, cstr, flt, getdate, nowdate, formatdate
|
from webnotes.utils import cint, cstr, flt, getdate, nowdate, formatdate
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper 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, _
|
||||||
from setup.utils import get_company_currency
|
from setup.utils import get_company_currency
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import cstr, flt, getdate
|
from webnotes.utils import cstr, flt, getdate
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cstr
|
from webnotes.utils import cstr
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -30,4 +30,4 @@ def add_node():
|
|||||||
parent_field: webnotes.form_dict['parent'],
|
parent_field: webnotes.form_dict['parent'],
|
||||||
"is_group": webnotes.form_dict['is_group']
|
"is_group": webnotes.form_dict['is_group']
|
||||||
}]
|
}]
|
||||||
webnotes.model_wrapper(doclist).save()
|
webnotes.bean(doclist).save()
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import cstr, flt, has_common, make_esc
|
from webnotes.utils import cstr, flt, has_common, make_esc
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes import session, msgprint
|
from webnotes import session, msgprint
|
||||||
from setup.utils import get_company_currency
|
from setup.utils import get_company_currency
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cint, cstr, flt, has_common
|
from webnotes.utils import cint, cstr, flt, has_common
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -5,7 +5,7 @@ import webnotes
|
|||||||
from webnotes.utils import set_default
|
from webnotes.utils import set_default
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cstr
|
from webnotes.utils import cstr
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
|
|
||||||
from webnotes.utils.nestedset import DocTypeNestedSet
|
from webnotes.utils.nestedset import DocTypeNestedSet
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
|
|
||||||
from webnotes.utils.nestedset import DocTypeNestedSet
|
from webnotes.utils.nestedset import DocTypeNestedSet
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.bean import getlist, copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import form, msgprint
|
from webnotes import form, msgprint
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cstr
|
from webnotes.utils import cstr
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.bean import getlist, copy_doclist
|
||||||
from webnotes import form, msgprint
|
from webnotes import form, msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import add_days, cint, cstr, flt, get_defaults, now, nowdate
|
from webnotes.utils import add_days, cint, cstr, flt, now, nowdate
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document, addchild
|
from webnotes.model.doc import Document, addchild
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
@ -97,28 +97,34 @@ class DocType:
|
|||||||
|
|
||||||
def reorder_item(self,doc_type,doc_name):
|
def reorder_item(self,doc_type,doc_name):
|
||||||
""" Reorder item if stock reaches reorder level"""
|
""" Reorder item if stock reaches reorder level"""
|
||||||
|
if not hasattr(webnotes, "auto_indent"):
|
||||||
|
webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent')
|
||||||
|
|
||||||
if webnotes.conn.get_value('Global Defaults', None, 'auto_indent'):
|
if webnotes.auto_indent:
|
||||||
#check if re-order is required
|
#check if re-order is required
|
||||||
ret = sql("""select re_order_level, item_name, description, brand, item_group,
|
item_reorder = webnotes.conn.get("Item Reorder",
|
||||||
lead_time_days, min_order_qty, email_notify, re_order_qty
|
{"parent": self.doc.item_code, "warehouse": self.doc.warehouse}, as_dict=1)
|
||||||
from tabItem where name = %s""", (self.doc.item_code), as_dict=1)
|
|
||||||
|
|
||||||
current_qty = sql("""
|
if item_reorder:
|
||||||
select sum(t1.actual_qty) + sum(t1.indented_qty) + sum(t1.ordered_qty) -sum(t1.reserved_qty)
|
reorder_level = item_reorder.warehouse_reorder_level
|
||||||
from tabBin t1, tabWarehouse t2
|
reorder_qty = item_reorder.warehouse_reorder_qty
|
||||||
where t1.item_code = %s
|
else:
|
||||||
and t1.warehouse = t2.name
|
reorder_level, reorder_qty = webnotes.conn.get_valuee("Item", self.doc.item_code,
|
||||||
and t2.warehouse_type in ('Stores', 'Reserved', 'Default Warehouse Type')
|
["re_order_level", "re_order_qty"])
|
||||||
and t1.docstatus != 2
|
|
||||||
""", self.doc.item_code)
|
if flt(reorder_qty) and flt(self.doc.projected_qty) < flt(reorder_level):
|
||||||
|
self.create_material_request(doc_type, doc_name)
|
||||||
|
|
||||||
if ret[0]["re_order_level"] and current_qty and \
|
def create_material_request(self, doc_type, doc_name):
|
||||||
(flt(ret[0]['re_order_level']) > flt(current_qty[0][0])):
|
|
||||||
self.create_auto_indent(ret[0], doc_type, doc_name, current_qty[0][0])
|
|
||||||
|
|
||||||
def create_auto_indent(self, i , doc_type, doc_name, cur_qty):
|
|
||||||
""" Create indent on reaching reorder level """
|
""" Create indent on reaching reorder level """
|
||||||
|
defaults = webnotes.conn.get_defaults()
|
||||||
|
mr = webnotes.bean([{
|
||||||
|
"doctype": "Material Request",
|
||||||
|
"company": defaults.company,
|
||||||
|
|
||||||
|
}])
|
||||||
|
|
||||||
|
|
||||||
indent = Document('Material Request')
|
indent = Document('Material Request')
|
||||||
indent.transaction_date = nowdate()
|
indent.transaction_date = nowdate()
|
||||||
indent.naming_series = 'IDT'
|
indent.naming_series = 'IDT'
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import cstr, flt, getdate
|
from webnotes.utils import cstr, flt, getdate
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
@ -312,9 +312,9 @@ class DocType(SellingController):
|
|||||||
""", self.doc.name)
|
""", self.doc.name)
|
||||||
|
|
||||||
if res and res[0][1]>0:
|
if res and res[0][1]>0:
|
||||||
from webnotes.model.wrapper import ModelWrapper
|
from webnotes.model.bean import Bean
|
||||||
for r in res:
|
for r in res:
|
||||||
ps = ModelWrapper(dt='Packing Slip', dn=r[0])
|
ps = Bean(dt='Packing Slip', dn=r[0])
|
||||||
ps.cancel()
|
ps.cancel()
|
||||||
webnotes.msgprint("%s Packing Slip(s) Cancelled" % res[0][1])
|
webnotes.msgprint("%s Packing Slip(s) Cancelled" % res[0][1])
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cstr, flt
|
from webnotes.utils import cstr, flt
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
@ -19,7 +19,7 @@ import unittest
|
|||||||
import webnotes
|
import webnotes
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from webnotes.model.wrapper import ModelWrapper
|
from webnotes.model.bean import Bean
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class TestItem(unittest.TestCase):
|
|||||||
webnotes.conn.rollback()
|
webnotes.conn.rollback()
|
||||||
|
|
||||||
def testInsert(self):
|
def testInsert(self):
|
||||||
d = ModelWrapper()
|
d = Bean()
|
||||||
|
|
||||||
count_before = flt(sql("select count(*) from tab"+_doctype)[0][0])
|
count_before = flt(sql("select count(*) from tab"+_doctype)[0][0])
|
||||||
if docok:
|
if docok:
|
||||||
@ -49,7 +49,7 @@ class TestItem(unittest.TestCase):
|
|||||||
def testFailAssert(self):
|
def testFailAssert(self):
|
||||||
if docnotok:
|
if docnotok:
|
||||||
with self.assertRaises(Exception) as context:
|
with self.assertRaises(Exception) as context:
|
||||||
d = ModelWrapper()
|
d = Bean()
|
||||||
d.doc = docnotok[0]
|
d.doc = docnotok[0]
|
||||||
d.children = None
|
d.children = None
|
||||||
d.doc.fields['__islocal']=1
|
d.doc.fields['__islocal']=1
|
||||||
@ -77,6 +77,31 @@ docnotok = [Document(fielddata=r) for r in tabNotOK]
|
|||||||
|
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
|
[{
|
||||||
|
"doctype": "Item",
|
||||||
|
"item_code": "_Test Item",
|
||||||
|
"item_name": "_Test Item",
|
||||||
|
"description": "_Test Item",
|
||||||
|
"item_group": "_Test Item Group",
|
||||||
|
"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",
|
||||||
|
"is_sample_item": "No",
|
||||||
|
"inspection_required": "No",
|
||||||
|
"is_pro_applicable": "No",
|
||||||
|
"is_sub_contracted_item": "No",
|
||||||
|
"stock_uom": "_Test UOM"
|
||||||
|
}, {
|
||||||
|
"doctype": "Item Reorder",
|
||||||
|
"parentfield": "item_reorder",
|
||||||
|
"warehouse": "_Test Warehouse",
|
||||||
|
"warehouse_reorder_level": 20,
|
||||||
|
"warehouse_reorder_qty": 20
|
||||||
|
}],
|
||||||
[{
|
[{
|
||||||
"doctype": "Item",
|
"doctype": "Item",
|
||||||
"item_code": "_Test Item Home Desktop 100",
|
"item_code": "_Test Item Home Desktop 100",
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.utils import cint, cstr, flt
|
from webnotes.utils import cint, cstr, flt
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ cur_frm.cscript.fname = "indent_details";
|
|||||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||||
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
||||||
|
|
||||||
erpnext.buying.PurchaseRequestController = erpnext.buying.BuyingController.extend({
|
erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.extend({
|
||||||
refresh: function(doc) {
|
refresh: function(doc) {
|
||||||
this._super();
|
this._super();
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ erpnext.buying.PurchaseRequestController = erpnext.buying.BuyingController.exten
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var new_cscript = new erpnext.buying.PurchaseRequestController({frm: cur_frm});
|
var new_cscript = new erpnext.buying.MaterialRequestController({frm: cur_frm});
|
||||||
|
|
||||||
// for backward compatibility: combine new and previous states
|
// for backward compatibility: combine new and previous states
|
||||||
$.extend(cur_frm.cscript, new_cscript);
|
$.extend(cur_frm.cscript, new_cscript);
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import cstr, flt, get_defaults
|
from webnotes.utils import cstr, flt, get_defaults
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"creation": "2013-01-29 19:25:55",
|
"creation": "2013-02-18 13:50:55",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-02-18 13:10:37",
|
"modified": "2013-02-18 14:41:41",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -37,6 +37,19 @@
|
|||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"name": "Material Request"
|
"name": "Material Request"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "material_request_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Material Request Type",
|
||||||
|
"options": "Purchase\nTransfer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "column_break_2",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
@ -46,25 +59,10 @@
|
|||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "naming_series",
|
"oldfieldname": "naming_series",
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"options": "MREQ\nIDT",
|
"options": "MREQ-\nIDT",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"description": "The date at which current entry is made in system.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "transaction_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Transaction Date",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "transaction_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"print_width": "100px",
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1,
|
|
||||||
"width": "100px"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "items",
|
"fieldname": "items",
|
||||||
@ -140,6 +138,21 @@
|
|||||||
"print_width": "50%",
|
"print_width": "50%",
|
||||||
"width": "50%"
|
"width": "50%"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "The date at which current entry is made in system.",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "transaction_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Transaction Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "transaction_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"print_width": "100px",
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1,
|
||||||
|
"width": "100px"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "Select the relevant company name if you have multiple companies",
|
"description": "Select the relevant company name if you have multiple companies",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
@ -276,7 +289,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "remark",
|
"fieldname": "remark",
|
||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
"in_list_view": 1,
|
"in_list_view": 0,
|
||||||
"label": "Remarks",
|
"label": "Remarks",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "remark",
|
"oldfieldname": "remark",
|
||||||
|
32
stock/doctype/material_request/test_material_request.py
Normal file
32
stock/doctype/material_request/test_material_request.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
test_records = [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Material Request",
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
|
"transaction_date": "2013-02-18"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "A 6",
|
||||||
|
"doctype": "Material Request Item",
|
||||||
|
"item_code": "_Test Item Home Desktop 100",
|
||||||
|
"item_name": "A 6",
|
||||||
|
"parentfield": "indent_details",
|
||||||
|
"qty": 54.0,
|
||||||
|
"schedule_date": "2013-02-18",
|
||||||
|
"uom": "_Test UOM",
|
||||||
|
"warehouse": "_Test Warehouse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Value 3.5",
|
||||||
|
"doctype": "Material Request Item",
|
||||||
|
"item_code": "_Test Item Home Desktop 200",
|
||||||
|
"item_name": "Valve 3.5",
|
||||||
|
"parentfield": "indent_details",
|
||||||
|
"qty": 3.0,
|
||||||
|
"schedule_date": "2013-02-19",
|
||||||
|
"uom": "_Test UOM",
|
||||||
|
"warehouse": "_Test Warehouse"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cstr, flt, get_defaults
|
from webnotes.utils import cstr, flt, get_defaults
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class TestSerialNo(unittest.TestCase):
|
|||||||
["2012-01-01", "02:00", "10006", 1200, 800],
|
["2012-01-01", "02:00", "10006", 1200, 800],
|
||||||
["2012-01-01", "06:00", "10007", 1500, 900]]
|
["2012-01-01", "06:00", "10007", 1500, 900]]
|
||||||
for d in data:
|
for d in data:
|
||||||
webnotes.model_wrapper([{
|
webnotes.bean([{
|
||||||
"doctype": "Serial No",
|
"doctype": "Serial No",
|
||||||
"item_code": "Nebula 8",
|
"item_code": "Nebula 8",
|
||||||
"warehouse": "Default Warehouse",
|
"warehouse": "Default Warehouse",
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cstr, cint, flt, comma_or
|
from webnotes.utils import cstr, cint, flt, comma_or
|
||||||
from webnotes.model.doc import Document, addchild
|
from webnotes.model.doc import Document, addchild
|
||||||
from webnotes.model.wrapper 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, _
|
||||||
from stock.utils import get_incoming_rate
|
from stock.utils import get_incoming_rate
|
||||||
|
99
stock/doctype/stock_entry/test_stock_entry.py
Normal file
99
stock/doctype/stock_entry/test_stock_entry.py
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
import webnotes, unittest
|
||||||
|
|
||||||
|
class TestStockEntry(unittest.TestCase):
|
||||||
|
def test_auto_material_request(self):
|
||||||
|
webnotes.conn.sql("""delete from `tabMaterial Request Item`""")
|
||||||
|
webnotes.conn.sql("""delete from `tabMaterial Request`""")
|
||||||
|
|
||||||
|
st1 = webnotes.bean(copy=test_records[0])
|
||||||
|
st1.insert()
|
||||||
|
st1.submit()
|
||||||
|
|
||||||
|
st2 = webnotes.bean(copy=test_records[0])
|
||||||
|
st2.insert()
|
||||||
|
st2.submit()
|
||||||
|
|
||||||
|
mr_name = webnotes.conn.sql("""select parent from `tabMaterial Request Item`
|
||||||
|
where item_code='_Test Item'""")
|
||||||
|
|
||||||
|
self.assertTrue(mr_name)
|
||||||
|
|
||||||
|
test_records = [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Stock Entry",
|
||||||
|
"posting_date": "2013-01-25",
|
||||||
|
"posting_time": "17:14:24",
|
||||||
|
"purpose": "Material Receipt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"conversion_factor": 1.0,
|
||||||
|
"doctype": "Stock Entry Detail",
|
||||||
|
"item_code": "_Test Item",
|
||||||
|
"parentfield": "mtn_details",
|
||||||
|
"incoming_rate": 100,
|
||||||
|
"qty": 50.0,
|
||||||
|
"stock_uom": "_Test UOM",
|
||||||
|
"transfer_qty": 50.0,
|
||||||
|
"uom": "_Test UOM",
|
||||||
|
"t_warehouse": "_Test Warehouse",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Stock Entry",
|
||||||
|
"posting_date": "2013-01-25",
|
||||||
|
"posting_time": "17:15",
|
||||||
|
"purpose": "Material Issue"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"conversion_factor": 1.0,
|
||||||
|
"doctype": "Stock Entry Detail",
|
||||||
|
"item_code": "_Test Item",
|
||||||
|
"parentfield": "mtn_details",
|
||||||
|
"incoming_rate": 100,
|
||||||
|
"qty": 40.0,
|
||||||
|
"stock_uom": "_Test UOM",
|
||||||
|
"transfer_qty": 40.0,
|
||||||
|
"uom": "_Test UOM",
|
||||||
|
"s_warehouse": "_Test Warehouse",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Stock Entry",
|
||||||
|
"posting_date": "2013-01-25",
|
||||||
|
"posting_time": "17:14:24",
|
||||||
|
"purpose": "Material Transfer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"conversion_factor": 1.0,
|
||||||
|
"doctype": "Stock Entry Detail",
|
||||||
|
"item_code": "_Test Item Home Desktop 100",
|
||||||
|
"parentfield": "mtn_details",
|
||||||
|
"incoming_rate": 100,
|
||||||
|
"qty": 45.0,
|
||||||
|
"stock_uom": "_Test UOM",
|
||||||
|
"transfer_qty": 45.0,
|
||||||
|
"uom": "_Test UOM",
|
||||||
|
"s_warehouse": "_Test Warehouse",
|
||||||
|
"t_warehouse": "_Test Warehouse 1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"conversion_factor": 1.0,
|
||||||
|
"doctype": "Stock Entry Detail",
|
||||||
|
"item_code": "_Test Item Home Desktop 100",
|
||||||
|
"parentfield": "mtn_details",
|
||||||
|
"qty": 45.0,
|
||||||
|
"incoming_rate": 100,
|
||||||
|
"stock_uom": "_Test UOM",
|
||||||
|
"transfer_qty": 45.0,
|
||||||
|
"uom": "_Test UOM",
|
||||||
|
"s_warehouse": "_Test Warehouse",
|
||||||
|
"t_warehouse": "_Test Warehouse 1",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import add_days, cstr, flt, nowdate, cint
|
from webnotes.utils import add_days, cstr, flt, nowdate, cint
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper 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 session, msgprint
|
from webnotes import session, msgprint
|
||||||
from stock.utils import get_valid_serial_nos
|
from stock.utils import get_valid_serial_nos
|
||||||
@ -221,7 +221,7 @@ class DocType:
|
|||||||
if args.get("warehouse"):
|
if args.get("warehouse"):
|
||||||
args["warehouse_type"] = webnotes.conn.get_value('Warehouse' , args["warehouse"],
|
args["warehouse_type"] = webnotes.conn.get_value('Warehouse' , args["warehouse"],
|
||||||
'warehouse_type')
|
'warehouse_type')
|
||||||
sle = webnotes.model_wrapper([args])
|
sle = webnotes.bean([args])
|
||||||
sle.ignore_permissions = 1
|
sle.ignore_permissions = 1
|
||||||
sle.insert()
|
sle.insert()
|
||||||
return sle.doc.name
|
return sle.doc.name
|
||||||
|
@ -248,7 +248,7 @@ class DocType(DocListController):
|
|||||||
}
|
}
|
||||||
args.update(opts)
|
args.update(opts)
|
||||||
# create stock ledger entry
|
# create stock ledger entry
|
||||||
sle_wrapper = webnotes.model_wrapper([args])
|
sle_wrapper = webnotes.bean([args])
|
||||||
sle_wrapper.ignore_permissions = 1
|
sle_wrapper.ignore_permissions = 1
|
||||||
sle_wrapper.insert()
|
sle_wrapper.insert()
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
self.setUp()
|
self.setUp()
|
||||||
|
|
||||||
def submit_stock_reconciliation(self, qty, rate, posting_date, posting_time):
|
def submit_stock_reconciliation(self, qty, rate, posting_date, posting_time):
|
||||||
return webnotes.model_wrapper([{
|
return webnotes.bean([{
|
||||||
"doctype": "Stock Reconciliation",
|
"doctype": "Stock Reconciliation",
|
||||||
"name": "RECO-001",
|
"name": "RECO-001",
|
||||||
"__islocal": 1,
|
"__islocal": 1,
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cstr, flt, now
|
from webnotes.utils import cstr, flt, now
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -3,5 +3,10 @@ test_records = [
|
|||||||
"doctype": "Warehouse",
|
"doctype": "Warehouse",
|
||||||
"warehouse_name": "_Test Warehouse",
|
"warehouse_name": "_Test Warehouse",
|
||||||
"warehouse_type": "_Test Warehouse Type"
|
"warehouse_type": "_Test Warehouse Type"
|
||||||
}]
|
}],
|
||||||
|
[{
|
||||||
|
"doctype": "Warehouse",
|
||||||
|
"warehouse_name": "_Test Warehouse 1",
|
||||||
|
"warehouse_type": "_Test Warehouse Type"
|
||||||
|
}]
|
||||||
]
|
]
|
@ -34,7 +34,7 @@ class DocType:
|
|||||||
warehouse = %s", (item_code, warehouse))
|
warehouse = %s", (item_code, warehouse))
|
||||||
bin = bin and bin[0][0] or ''
|
bin = bin and bin[0][0] or ''
|
||||||
if not bin:
|
if not bin:
|
||||||
bin_wrapper = webnotes.model_wrapper([{
|
bin_wrapper = webnotes.bean([{
|
||||||
"doctype": "Bin",
|
"doctype": "Bin",
|
||||||
"item_code": item_code,
|
"item_code": item_code,
|
||||||
"warehouse": warehouse,
|
"warehouse": warehouse,
|
||||||
|
@ -6,6 +6,11 @@ wn.module_page["Stock"] = [
|
|||||||
title: wn._("Documents"),
|
title: wn._("Documents"),
|
||||||
icon: "icon-copy",
|
icon: "icon-copy",
|
||||||
items: [
|
items: [
|
||||||
|
{
|
||||||
|
label: wn._("Material Request"),
|
||||||
|
description: wn._("Request Material for Transfer or Purchase."),
|
||||||
|
doctype:"Material Request"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: wn._("Stock Entry"),
|
label: wn._("Stock Entry"),
|
||||||
description: wn._("Transfer stock from one warehouse to another."),
|
description: wn._("Transfer stock from one warehouse to another."),
|
||||||
|
@ -86,7 +86,7 @@ def update_entries_after(args, verbose=1):
|
|||||||
# update bin
|
# update bin
|
||||||
if not webnotes.conn.exists({"doctype": "Bin", "item_code": args["item_code"],
|
if not webnotes.conn.exists({"doctype": "Bin", "item_code": args["item_code"],
|
||||||
"warehouse": args["warehouse"]}):
|
"warehouse": args["warehouse"]}):
|
||||||
bin_wrapper = webnotes.model_wrapper([{
|
bin_wrapper = webnotes.bean([{
|
||||||
"doctype": "Bin",
|
"doctype": "Bin",
|
||||||
"item_code": args["item_code"],
|
"item_code": args["item_code"],
|
||||||
"warehouse": args["warehouse"],
|
"warehouse": args["warehouse"],
|
||||||
|
@ -19,7 +19,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes import session, msgprint
|
from webnotes import session, msgprint
|
||||||
from webnotes.utils import today
|
from webnotes.utils import today
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import add_days, cstr, getdate
|
from webnotes.utils import add_days, cstr, getdate
|
||||||
from webnotes.model.doc import Document, addchild
|
from webnotes.model.doc import Document, addchild
|
||||||
from webnotes.model.wrapper 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
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import cstr
|
from webnotes.utils import cstr
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.bean import getlist, copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import webnotes, unittest
|
|||||||
|
|
||||||
class TestNewsletter(unittest.TestCase):
|
class TestNewsletter(unittest.TestCase):
|
||||||
def test_get_recipients_lead(self):
|
def test_get_recipients_lead(self):
|
||||||
w = webnotes.model_wrapper(test_records[0])
|
w = webnotes.bean(test_records[0])
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_lead@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_lead@example.com" in w.controller.get_recipients())
|
||||||
webnotes.conn.sql("""delete from `tabBulk Email`""")
|
webnotes.conn.sql("""delete from `tabBulk Email`""")
|
||||||
@ -10,24 +10,24 @@ class TestNewsletter(unittest.TestCase):
|
|||||||
self.assertTrue(webnotes.conn.get_value("Bulk Email", {"recipient": "test_lead@example.com"}))
|
self.assertTrue(webnotes.conn.get_value("Bulk Email", {"recipient": "test_lead@example.com"}))
|
||||||
|
|
||||||
def test_get_recipients_lead_by_status(self):
|
def test_get_recipients_lead_by_status(self):
|
||||||
w = webnotes.model_wrapper(test_records[0])
|
w = webnotes.bean(test_records[0])
|
||||||
w.doc.lead_status="Converted"
|
w.doc.lead_status="Converted"
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_lead3@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_lead3@example.com" in w.controller.get_recipients())
|
||||||
|
|
||||||
def test_get_recipients_contact_customer(self):
|
def test_get_recipients_contact_customer(self):
|
||||||
w = webnotes.model_wrapper(test_records[1])
|
w = webnotes.bean(test_records[1])
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_contact_customer@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_contact_customer@example.com" in w.controller.get_recipients())
|
||||||
|
|
||||||
def test_get_recipients_contact_supplier(self):
|
def test_get_recipients_contact_supplier(self):
|
||||||
w = webnotes.model_wrapper(test_records[1])
|
w = webnotes.bean(test_records[1])
|
||||||
w.doc.contact_type="Supplier"
|
w.doc.contact_type="Supplier"
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_contact_supplier@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_contact_supplier@example.com" in w.controller.get_recipients())
|
||||||
|
|
||||||
def test_get_recipients_custom(self):
|
def test_get_recipients_custom(self):
|
||||||
w = webnotes.model_wrapper(test_records[2])
|
w = webnotes.bean(test_records[2])
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_custom2@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_custom2@example.com" in w.controller.get_recipients())
|
||||||
self.assertTrue(webnotes.conn.get("Lead",
|
self.assertTrue(webnotes.conn.get("Lead",
|
||||||
|
@ -38,12 +38,12 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
ticket = None
|
ticket = None
|
||||||
|
|
||||||
if thread_id and webnotes.conn.exists("Support Ticket", thread_id):
|
if thread_id and webnotes.conn.exists("Support Ticket", thread_id):
|
||||||
ticket = webnotes.model_wrapper("Support Ticket", thread_id)
|
ticket = webnotes.bean("Support Ticket", thread_id)
|
||||||
ticket.doc.status = 'Open'
|
ticket.doc.status = 'Open'
|
||||||
ticket.doc.save()
|
ticket.doc.save()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
ticket = webnotes.model_wrapper([{
|
ticket = webnotes.bean([{
|
||||||
"doctype":"Support Ticket",
|
"doctype":"Support Ticket",
|
||||||
"description": mail.content,
|
"description": mail.content,
|
||||||
"subject": mail.mail["Subject"],
|
"subject": mail.mail["Subject"],
|
||||||
|
@ -67,7 +67,7 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def set_status(name, status):
|
def set_status(name, status):
|
||||||
st = webnotes.model_wrapper("Support Ticket", name)
|
st = webnotes.bean("Support Ticket", name)
|
||||||
st.doc.status = status
|
st.doc.status = status
|
||||||
st.save()
|
st.save()
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import webnotes
|
|||||||
from webnotes.utils import cstr
|
from webnotes.utils import cstr
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from webnotes.utils import load_json, nowdate, cstr
|
|||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.bean import getlist, copy_doclist
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import webnotes
|
|||||||
|
|
||||||
from webnotes.utils import now
|
from webnotes.utils import now
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user