mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
model_wrapper is now bean, refactoring defaults
This commit is contained in:
@@ -20,7 +20,7 @@ import webnotes
|
||||
from webnotes.utils import cstr, flt, getdate, now, nowdate
|
||||
from webnotes.model import db_exists
|
||||
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
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@@ -19,7 +19,7 @@ import webnotes
|
||||
|
||||
from webnotes.utils import flt
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint
|
||||
|
||||
class DocType:
|
||||
|
||||
@@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt, getdate
|
||||
from webnotes.model.doc import make_autoname
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.bean import getlist
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint
|
||||
|
||||
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.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 import msgprint
|
||||
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.model import db_exists
|
||||
from webnotes.model.wrapper import copy_doclist
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes import session, msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@@ -19,7 +19,7 @@ import webnotes
|
||||
|
||||
from webnotes.utils import flt
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint
|
||||
|
||||
class DocType:
|
||||
|
||||
@@ -20,7 +20,7 @@ import webnotes
|
||||
from webnotes.utils import cstr, flt, getdate
|
||||
from webnotes.model import db_exists
|
||||
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 import msgprint
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.wrapper import copy_doclist
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
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 import msgprint, _
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
@@ -25,7 +25,7 @@ test_dependencies = ["Item", "Cost Center"]
|
||||
|
||||
class TestPurchaseInvoice(unittest.TestCase):
|
||||
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
|
||||
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))
|
||||
|
||||
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
|
||||
obj = webnotes.get_obj(doc=wrapper.doc, doclist=wrapper.doclist)
|
||||
|
||||
@@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
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
|
||||
|
||||
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 comma_and
|
||||
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 import _, msgprint
|
||||
|
||||
@@ -858,7 +858,7 @@ def manage_recurring_invoices(next_date=None):
|
||||
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
||||
(next_date, recurring_id)):
|
||||
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)
|
||||
send_notification(new_invoice_wrapper)
|
||||
webnotes.conn.commit()
|
||||
@@ -880,7 +880,7 @@ def manage_recurring_invoices(next_date=None):
|
||||
raise Exception, exception_message
|
||||
|
||||
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
|
||||
new_invoice = clone(ref_wrapper)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import unittest
|
||||
|
||||
class TestSalesInvoice(unittest.TestCase):
|
||||
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.submit()
|
||||
return w
|
||||
@@ -17,7 +17,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
from accounts.doctype.journal_voucher.test_journal_voucher \
|
||||
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.insert()
|
||||
jv.submit()
|
||||
|
||||
@@ -19,7 +19,7 @@ import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, cint, cstr
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.wrapper import copy_doclist
|
||||
from webnotes.model.bean import copy_doclist
|
||||
|
||||
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):
|
||||
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 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"""]
|
||||
raise Exception
|
||||
|
||||
doclist = ModelWrapper([jv]+details)
|
||||
doclist = Bean([jv]+details)
|
||||
doclist.submit()
|
||||
|
||||
messages.append("""<p style='color: green'>[row #%s]
|
||||
|
||||
@@ -121,7 +121,7 @@ def add_ac(args=None):
|
||||
args = webnotes.form_dict
|
||||
args.pop("cmd")
|
||||
|
||||
ac = webnotes.model_wrapper(args)
|
||||
ac = webnotes.bean(args)
|
||||
ac.doc.doctype = "Account"
|
||||
ac.doc.old_parent = ""
|
||||
ac.doc.freeze_account = "No"
|
||||
@@ -135,7 +135,7 @@ def add_cc(args=None):
|
||||
args = webnotes.form_dict
|
||||
args.pop("cmd")
|
||||
|
||||
cc = webnotes.model_wrapper(args)
|
||||
cc = webnotes.bean(args)
|
||||
cc.doc.doctype = "Cost Center"
|
||||
cc.doc.old_parent = ""
|
||||
cc.ignore_permissions = 1
|
||||
|
||||
Reference in New Issue
Block a user