This commit is contained in:
parent
d2b34dc30c
commit
e88bc8b12a
@ -389,19 +389,12 @@ def get_payment_entry(doc):
|
||||
jv.doc.company = doc.company
|
||||
jv.doc.fiscal_year = doc.fiscal_year
|
||||
|
||||
jv.doclist.append({
|
||||
"doctype": "Journal Voucher Detail",
|
||||
"parentfield": "entries"
|
||||
})
|
||||
d1 = jv.append("entries")
|
||||
d2 = jv.append("entries")
|
||||
|
||||
jv.doclist.append({
|
||||
"doctype": "Journal Voucher Detail",
|
||||
"parentfield": "entries"
|
||||
})
|
||||
|
||||
if bank_account:
|
||||
jv.doclist[2].account = bank_account["account"]
|
||||
jv.doclist[2].balance = bank_account["balance"]
|
||||
d2.account = bank_account["account"]
|
||||
d2.balance = bank_account["balance"]
|
||||
|
||||
return jv
|
||||
|
||||
|
@ -174,9 +174,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
jv.submit()
|
||||
|
||||
pi = frappe.bean(copy=test_records[0])
|
||||
pi.doclist.append({
|
||||
"doctype": "Purchase Invoice Advance",
|
||||
"parentfield": "advance_allocation_details",
|
||||
pi.append("advance_allocation_details", {
|
||||
"journal_voucher": jv.doc.name,
|
||||
"jv_detail_no": jv.doclist[1].name,
|
||||
"advance_amount": 400,
|
||||
|
@ -9,7 +9,7 @@ from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate,
|
||||
get_first_day, get_last_day
|
||||
|
||||
from frappe.utils import comma_and, get_url
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import _, msgprint
|
||||
@ -587,12 +587,6 @@ class SalesInvoice(SellingController):
|
||||
invoice_date = %s, territory = %s, net_total = %s,
|
||||
grand_total = %s where invoice_no = %s and parent = %s""",
|
||||
(self.doc.name, self.doc.amended_from, self.doc.c_form_no))
|
||||
|
||||
@property
|
||||
def meta(self):
|
||||
if not hasattr(self, "_meta"):
|
||||
self._meta = frappe.get_doctype(self.doc.doctype)
|
||||
return self._meta
|
||||
|
||||
def validate_recurring_invoice(self):
|
||||
if self.doc.convert_into_recurring_invoice:
|
||||
|
@ -139,16 +139,14 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
def test_sales_invoice_discount_amount(self):
|
||||
si = frappe.bean(copy=test_records[3])
|
||||
si.doc.discount_amount = 104.95
|
||||
si.doclist.append({
|
||||
si.append("other_charges", {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Service Tax",
|
||||
"rate": 10,
|
||||
"row_id": 8,
|
||||
"idx": 9
|
||||
})
|
||||
si.insert()
|
||||
|
||||
@ -196,16 +194,14 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
def test_discount_amount_gl_entry(self):
|
||||
si = frappe.bean(copy=test_records[3])
|
||||
si.doc.discount_amount = 104.95
|
||||
si.doclist.append({
|
||||
si.append("other_charges", {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Service Tax",
|
||||
"rate": 10,
|
||||
"row_id": 8,
|
||||
"idx": 9
|
||||
"row_id": 8
|
||||
})
|
||||
si.insert()
|
||||
si.submit()
|
||||
@ -369,7 +365,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||
import test_records as jv_test_records
|
||||
|
||||
jv = frappe.bean(frappe.copy_doclist(jv_test_records[0]))
|
||||
jv = frappe.bean(frappe.copy_doc(jv_test_records[0]))
|
||||
jv.doclist[1].against_invoice = w.doc.name
|
||||
jv.insert()
|
||||
jv.submit()
|
||||
@ -385,7 +381,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
tlb = frappe.bean("Time Log Batch", "_T-Time Log Batch-00001")
|
||||
tlb.submit()
|
||||
|
||||
si = frappe.bean(frappe.copy_doclist(test_records[0]))
|
||||
si = frappe.bean(frappe.copy_doc(test_records[0]))
|
||||
si.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
|
||||
si.insert()
|
||||
si.submit()
|
||||
@ -444,7 +440,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self._insert_purchase_receipt()
|
||||
self._insert_pos_settings()
|
||||
|
||||
pos = frappe.copy_doclist(test_records[1])
|
||||
pos = frappe.copy_doc(test_records[1])
|
||||
pos[0]["is_pos"] = 1
|
||||
pos[0]["update_stock"] = 1
|
||||
pos[0]["posting_time"] = "12:05"
|
||||
@ -510,7 +506,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
|
||||
si_doclist = frappe.copy_doclist(test_records[1])
|
||||
si_doclist = frappe.copy_doc(test_records[1])
|
||||
si_doclist[0]["update_stock"] = 1
|
||||
si_doclist[0]["posting_time"] = "12:05"
|
||||
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
|
||||
@ -555,7 +551,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.clear_stock_account_balance()
|
||||
set_perpetual_inventory()
|
||||
|
||||
si_copy = frappe.copy_doclist(test_records[1])
|
||||
si_copy = frappe.copy_doc(test_records[1])
|
||||
si_copy[1]["item_code"] = None
|
||||
si = frappe.bean(si_copy)
|
||||
si.insert()
|
||||
@ -582,7 +578,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
def test_sales_invoice_gl_entry_with_aii_non_stock_item(self):
|
||||
self.clear_stock_account_balance()
|
||||
set_perpetual_inventory()
|
||||
si_copy = frappe.copy_doclist(test_records[1])
|
||||
si_copy = frappe.copy_doc(test_records[1])
|
||||
si_copy[1]["item_code"] = "_Test Non Stock Item"
|
||||
si = frappe.bean(si_copy)
|
||||
si.insert()
|
||||
@ -640,9 +636,8 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
jv.submit()
|
||||
|
||||
si = frappe.bean(copy=test_records[0])
|
||||
si.doclist.append({
|
||||
si.append("advance_adjustment_details", {
|
||||
"doctype": "Sales Invoice Advance",
|
||||
"parentfield": "advance_adjustment_details",
|
||||
"journal_voucher": jv.doc.name,
|
||||
"jv_detail_no": jv.doclist[1].name,
|
||||
"advance_amount": 400,
|
||||
|
@ -242,7 +242,7 @@ def get_company_default(company, fieldname):
|
||||
|
||||
if not value:
|
||||
throw(_("Please mention default value for '") +
|
||||
_(frappe.get_doctype("company").get_label(fieldname) +
|
||||
_(frappe.get_meta("Company").get_label(fieldname) +
|
||||
_("' in Company: ") + company))
|
||||
|
||||
return value
|
||||
|
@ -7,7 +7,7 @@ import frappe.defaults
|
||||
|
||||
from frappe.utils import cint
|
||||
from frappe import msgprint, _
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
from erpnext.accounts.party import create_party_account
|
||||
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
|
@ -121,17 +121,11 @@ class AccountsController(TransactionBase):
|
||||
from frappe.model import default_fields
|
||||
tax_master = frappe.bean(tax_master_doctype, self.doc.fields.get(tax_master_field))
|
||||
|
||||
for i, tax in enumerate(tax_master.doclist.get({"parentfield": tax_parentfield})):
|
||||
for i, tax in enumerate(tax_master.get(tax_parentfield)):
|
||||
for fieldname in default_fields:
|
||||
tax.fields[fieldname] = None
|
||||
|
||||
tax.fields.update({
|
||||
"doctype": tax_doctype,
|
||||
"parentfield": tax_parentfield,
|
||||
"idx": i+1
|
||||
})
|
||||
|
||||
self.doclist.append(tax)
|
||||
tax.set(fieldname, None)
|
||||
|
||||
self.append(tax_parentfield, tax)
|
||||
|
||||
def get_other_charges(self):
|
||||
self.set("other_charges", [])
|
||||
@ -410,9 +404,8 @@ class AccountsController(TransactionBase):
|
||||
|
||||
self.set(parentfield, [])
|
||||
for d in res:
|
||||
self.doclist.append({
|
||||
self.append(parentfield, {
|
||||
"doctype": child_doctype,
|
||||
"parentfield": parentfield,
|
||||
"journal_voucher": d.jv_no,
|
||||
"jv_detail_no": d.jv_detail_no,
|
||||
"remarks": d.remark,
|
||||
|
@ -230,7 +230,6 @@ class BuyingController(StockController):
|
||||
for item in bom_items:
|
||||
required_qty = flt(item.qty_consumed_per_unit) * flt(d.qty) * flt(d.conversion_factor)
|
||||
rm_doclist = {
|
||||
"parentfield": raw_material_table,
|
||||
"doctype": self.doc.doctype + " Item Supplied",
|
||||
"reference_name": d.name,
|
||||
"bom_detail_no": item.name,
|
||||
@ -248,7 +247,7 @@ class BuyingController(StockController):
|
||||
"description": item.description,
|
||||
})
|
||||
|
||||
self.doclist.append(rm_doclist)
|
||||
self.append(raw_material_table, rm_doclist)
|
||||
|
||||
raw_materials_cost += required_qty * flt(item.rate)
|
||||
|
||||
|
@ -59,9 +59,8 @@ class SellingController(StockController):
|
||||
shipping_amount = condition.shipping_amount
|
||||
break
|
||||
|
||||
self.doclist.append({
|
||||
self.append("other_charges", {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"parentfield": "other_charges",
|
||||
"charge_type": "Actual",
|
||||
"account_head": shipping_rule.doc.account,
|
||||
"cost_center": shipping_rule.doc.cost_center,
|
||||
|
@ -59,8 +59,7 @@ feed_dict = {
|
||||
def make_feed(feedtype, doctype, name, owner, subject, color):
|
||||
"makes a new Feed record"
|
||||
#msgprint(subject)
|
||||
from frappe.model.doc import Document
|
||||
from frappe.utils import get_fullname
|
||||
from frappe.utils import get_fullname
|
||||
|
||||
if feedtype in ('Login', 'Comment', 'Assignment'):
|
||||
# delete old login, comment feed
|
||||
@ -72,7 +71,7 @@ def make_feed(feedtype, doctype, name, owner, subject, color):
|
||||
where doc_type=%s and doc_name=%s
|
||||
and ifnull(feed_type,'') != 'Comment'""", (doctype, name))
|
||||
|
||||
f = Document('Feed')
|
||||
f = frappe.get_doc('Feed')
|
||||
f.owner = owner
|
||||
f.feed_type = feedtype
|
||||
f.doc_type = doctype
|
||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import getdate, validate_email_add, cstr, cint
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe import msgprint, throw, _
|
||||
import frappe.permissions
|
||||
from frappe.defaults import get_restrictions
|
||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import add_days, add_years, cint, getdate
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe import msgprint, throw, _
|
||||
import datetime
|
||||
|
||||
|
@ -24,9 +24,8 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
temp_session_user = frappe.session.user
|
||||
frappe.set_user("Administrator")
|
||||
employee = frappe.bean("Employee", employee)
|
||||
employee.doclist.append({
|
||||
employee.append("employee_leave_approvers", {
|
||||
"doctype": "Employee Leave Approver",
|
||||
"parentfield": "employee_leave_approvers",
|
||||
"leave_approver": leave_approver
|
||||
})
|
||||
employee.save()
|
||||
|
@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import cint, cstr, flt, nowdate
|
||||
from frappe.model.doc import Document
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
|
||||
@ -38,10 +37,9 @@ class LeaveControlPanel(Document):
|
||||
return e
|
||||
|
||||
def validate_values(self):
|
||||
meta = frappe.get_doctype(self.doc.doctype)
|
||||
for f in ["fiscal_year", "leave_type", "no_of_days"]:
|
||||
if not self.doc.fields[f]:
|
||||
frappe.throw(_(meta.get_label(f)) + _(" is mandatory"))
|
||||
if not self.get(f):
|
||||
frappe.throw(_(self.meta.get_label(f)) + _(" is mandatory"))
|
||||
|
||||
def allocate_leave(self):
|
||||
self.validate_values()
|
||||
@ -52,7 +50,8 @@ class LeaveControlPanel(Document):
|
||||
|
||||
for d in self.get_employees():
|
||||
try:
|
||||
la = Document('Leave Allocation')
|
||||
la = frappe.get_doc('Leave Allocation')
|
||||
la.set("__islocal", 1)
|
||||
la.employee = cstr(d[0])
|
||||
la.employee_name = frappe.db.get_value('Employee',cstr(d[0]),'employee_name')
|
||||
la.leave_type = self.doc.leave_type
|
||||
@ -60,11 +59,8 @@ class LeaveControlPanel(Document):
|
||||
la.posting_date = nowdate()
|
||||
la.carry_forward = cint(self.doc.carry_forward)
|
||||
la.new_leaves_allocated = flt(self.doc.no_of_days)
|
||||
la_obj = get_obj(doc=la)
|
||||
la_obj.doc.docstatus = 1
|
||||
la_obj.validate()
|
||||
la_obj.on_update()
|
||||
la_obj.doc.save(1)
|
||||
la.docstatus = 1
|
||||
la.save()
|
||||
leave_allocated_for.append(d[0])
|
||||
except:
|
||||
pass
|
||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, _round
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe import msgprint, _
|
||||
|
||||
|
||||
|
@ -120,7 +120,7 @@ def upload():
|
||||
error = False
|
||||
|
||||
from frappe.utils.datautils import check_record, import_doc
|
||||
doctype_dl = frappe.get_doctype("Attendance")
|
||||
doctype_dl = frappe.get_meta("Attendance")
|
||||
|
||||
for i, row in enumerate(rows[5:]):
|
||||
if not row: continue
|
||||
@ -131,7 +131,7 @@ def upload():
|
||||
d["docstatus"] = frappe.db.get_value("Attendance", d.name, "docstatus")
|
||||
|
||||
try:
|
||||
check_record(d, doctype_dl=doctype_dl)
|
||||
check_record(d)
|
||||
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
|
||||
except Exception, e:
|
||||
error = True
|
||||
|
@ -366,7 +366,7 @@ class ProductionPlanningTool(Document):
|
||||
if items_to_be_requested:
|
||||
for item in items_to_be_requested:
|
||||
item_wrapper = frappe.bean("Item", item)
|
||||
pr_doclist = [{
|
||||
pr_doc = frappe.get_doc({
|
||||
"doctype": "Material Request",
|
||||
"__islocal": 1,
|
||||
"naming_series": "IDT",
|
||||
@ -376,12 +376,11 @@ class ProductionPlanningTool(Document):
|
||||
"fiscal_year": fiscal_year,
|
||||
"requested_by": frappe.session.user,
|
||||
"material_request_type": "Purchase"
|
||||
}]
|
||||
})
|
||||
for sales_order, requested_qty in items_to_be_requested[item].items():
|
||||
pr_doclist.append({
|
||||
pr_doc.append("indent_details", {
|
||||
"doctype": "Material Request Item",
|
||||
"__islocal": 1,
|
||||
"parentfield": "indent_details",
|
||||
"item_code": item,
|
||||
"item_name": item_wrapper.doc.item_name,
|
||||
"description": item_wrapper.doc.description,
|
||||
@ -394,10 +393,9 @@ class ProductionPlanningTool(Document):
|
||||
"sales_order_no": sales_order if sales_order!="No Sales Order" else None
|
||||
})
|
||||
|
||||
pr_wrapper = frappe.bean(pr_doclist)
|
||||
pr_wrapper.ignore_permissions = 1
|
||||
pr_wrapper.submit()
|
||||
purchase_request_list.append(pr_wrapper.doc.name)
|
||||
pr_doc.ignore_permissions = 1
|
||||
pr_doc.submit()
|
||||
purchase_request_list.append(pr_doc.name)
|
||||
|
||||
if purchase_request_list:
|
||||
pur_req = ["""<a href="#Form/Material Request/%s" target="_blank">%s</a>""" % \
|
||||
|
@ -39,7 +39,7 @@ def update_user_match():
|
||||
doctype_matches.setdefault(doctype, []).append(match)
|
||||
|
||||
for doctype, user_matches in doctype_matches.items():
|
||||
meta = frappe.get_doctype(doctype)
|
||||
meta = frappe.get_meta(doctype)
|
||||
|
||||
# for each user with roles of this doctype, check if match condition applies
|
||||
for user in frappe.db.sql_list("""select name from `tabUser`
|
||||
|
@ -8,7 +8,7 @@ from erpnext.projects.doctype.time_log.time_log import OverlapError
|
||||
|
||||
class TestTimeLog(unittest.TestCase):
|
||||
def test_duplication(self):
|
||||
ts = frappe.bean(frappe.copy_doclist(test_records[0]))
|
||||
ts = frappe.bean(frappe.copy_doc(test_records[0]))
|
||||
self.assertRaises(OverlapError, ts.insert)
|
||||
|
||||
test_records = [[{
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.doc import Document, make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe import msgprint, _
|
||||
import frappe.defaults
|
||||
|
||||
@ -56,7 +56,8 @@ class Customer(TransactionBase):
|
||||
(self.doc.name, self.doc.customer_name, self.doc.lead_name))
|
||||
|
||||
lead = frappe.db.get_value("Lead", self.doc.lead_name, ["lead_name", "email_id", "phone", "mobile_no"], as_dict=True)
|
||||
c = Document('Contact')
|
||||
c = frappe.get_doc('Contact')
|
||||
c.set("__islocal", 1)
|
||||
c.first_name = lead.lead_name
|
||||
c.email_id = lead.email_id
|
||||
c.phone = lead.phone
|
||||
@ -65,7 +66,7 @@ class Customer(TransactionBase):
|
||||
c.customer_name = self.doc.customer_name
|
||||
c.is_primary_contact = 1
|
||||
try:
|
||||
c.save(1)
|
||||
c.save()
|
||||
except NameError, e:
|
||||
pass
|
||||
|
||||
|
@ -80,7 +80,7 @@ class TestSalesOrder(unittest.TestCase):
|
||||
|
||||
_insert_purchase_receipt(so.doclist[1].item_code)
|
||||
|
||||
dn = frappe.bean(frappe.copy_doclist(dn_test_records[0]))
|
||||
dn = frappe.bean(frappe.copy_doc(dn_test_records[0]))
|
||||
dn.doclist[1].item_code = so.doclist[1].item_code
|
||||
dn.doclist[1].against_sales_order = so.doc.name
|
||||
dn.doclist[1].prevdoc_detail_docname = so.doclist[1].name
|
||||
@ -199,7 +199,7 @@ class TestSalesOrder(unittest.TestCase):
|
||||
|
||||
# change item in test so record
|
||||
|
||||
test_record = frappe.copy_doclist(test_records[0])
|
||||
test_record = frappe.copy_doc(test_records[0])
|
||||
test_record[1]["item_code"] = "_Test Sales BOM Item"
|
||||
|
||||
# reset bin
|
||||
@ -248,7 +248,7 @@ class TestSalesOrder(unittest.TestCase):
|
||||
from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records
|
||||
|
||||
# change item in test so record
|
||||
test_record = frappe.copy_doclist(test_records[0])
|
||||
test_record = frappe.copy_doc(test_records[0])
|
||||
test_record[1]["item_code"] = "_Test Sales BOM Item"
|
||||
|
||||
# reset bin
|
||||
|
@ -21,8 +21,7 @@ def get_children():
|
||||
|
||||
@frappe.whitelist()
|
||||
def add_node():
|
||||
# from frappe.model.doc import Document
|
||||
ctype = frappe.form_dict.get('ctype')
|
||||
# ctype = frappe.form_dict.get('ctype')
|
||||
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
|
||||
name_field = ctype.lower().replace(' ', '_') + '_name'
|
||||
|
||||
|
@ -86,15 +86,13 @@ class Company(Document):
|
||||
website_settings.doc.home_page = webpage.doc.name
|
||||
website_settings.doc.brand_html = self.doc.name
|
||||
website_settings.doc.copyright = self.doc.name
|
||||
website_settings.doclist.append({
|
||||
website_settings.append("top_bar_items", {
|
||||
"doctype": "Top Bar Item",
|
||||
"parentfield": "top_bar_items",
|
||||
"label":"Contact",
|
||||
"url": "contact"
|
||||
})
|
||||
website_settings.doclist.append({
|
||||
website_settings.append("top_bar_items", {
|
||||
"doctype": "Top Bar Item",
|
||||
"parentfield": "top_bar_items",
|
||||
"label":"Blog",
|
||||
"url": "blog"
|
||||
})
|
||||
|
@ -56,26 +56,27 @@ class NamingSeries(Document):
|
||||
default = options[0]
|
||||
|
||||
# update in property setter
|
||||
from frappe.model.doc import Document
|
||||
prop_dict = {'options': "\n".join(options), 'default': default}
|
||||
prop_dict = {'options': "\n".join(options), 'default': default}
|
||||
for prop in prop_dict:
|
||||
ps_exists = frappe.db.sql("""SELECT name FROM `tabProperty Setter`
|
||||
WHERE doc_type = %s AND field_name = 'naming_series'
|
||||
AND property = %s""", (doctype, prop))
|
||||
if ps_exists:
|
||||
ps = Document('Property Setter', ps_exists[0][0])
|
||||
ps = frappe.get_doc('Property Setter', ps_exists[0][0])
|
||||
ps.value = prop_dict[prop]
|
||||
ps.save()
|
||||
else:
|
||||
ps = Document('Property Setter', fielddata = {
|
||||
ps = frappe.get_doc({
|
||||
'doctype': 'Property Setter',
|
||||
'doctype_or_field': 'DocField',
|
||||
'doc_type': doctype,
|
||||
'field_name': 'naming_series',
|
||||
'property': prop,
|
||||
'value': prop_dict[prop],
|
||||
'property_type': 'Select',
|
||||
'__islocal': 1
|
||||
})
|
||||
ps.save(1)
|
||||
ps.save()
|
||||
|
||||
self.doc.set_options = "\n".join(options)
|
||||
|
||||
|
@ -18,7 +18,7 @@ class Item(DocListController):
|
||||
|
||||
def autoname(self):
|
||||
if frappe.db.get_default("item_naming_by")=="Naming Series":
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
self.doc.item_code = make_autoname(self.doc.naming_series+'.#####')
|
||||
elif not self.doc.item_code:
|
||||
msgprint(_("Item Code (item_code) is mandatory because Item naming is not sequential."), raise_exception=1)
|
||||
@ -272,7 +272,7 @@ def validate_end_of_life(item_code, end_of_life=None, verbose=1):
|
||||
"in Item master") % {
|
||||
"item_code": item_code,
|
||||
"date": formatdate(end_of_life),
|
||||
"end_of_life_label": frappe.get_doctype("Item").get_label("end_of_life")
|
||||
"end_of_life_label": frappe.get_meta("Item").get_label("end_of_life")
|
||||
}
|
||||
|
||||
_msgprint(msg, verbose)
|
||||
|
@ -177,7 +177,7 @@ def update_completed_qty(bean, method):
|
||||
|
||||
for mr_name, mr_items in material_request_map.items():
|
||||
mr_obj = frappe.get_obj("Material Request", mr_name, with_children=1)
|
||||
mr_doctype = frappe.get_doctype("Material Request")
|
||||
mr_doctype = frappe.get_meta("Material Request")
|
||||
|
||||
if mr_obj.doc.status in ["Stopped", "Cancelled"]:
|
||||
frappe.throw(_("Material Request") + ": %s, " % mr_obj.doc.name
|
||||
|
@ -16,9 +16,8 @@ class PriceList(DocListController):
|
||||
if not self.get("valid_for_territories"):
|
||||
# if no territory, set default territory
|
||||
if frappe.defaults.get_user_default("territory"):
|
||||
self.doclist.append({
|
||||
self.append("valid_for_territories", {
|
||||
"doctype": "Applicable Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": frappe.defaults.get_user_default("territory")
|
||||
})
|
||||
else:
|
||||
|
@ -254,7 +254,7 @@ def validate_serial_no(sle, item_det):
|
||||
|
||||
def update_serial_nos(sle, item_det):
|
||||
if sle.is_cancelled == "No" and not sle.serial_no and sle.actual_qty > 0 and item_det.serial_no_series:
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.naming import make_autoname
|
||||
serial_nos = []
|
||||
for i in xrange(cint(sle.actual_qty)):
|
||||
serial_nos.append(make_autoname(item_det.serial_no_series))
|
||||
|
@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import add_days, cstr, flt, nowdate, cint, now
|
||||
from frappe.model.doc import Document
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import session, msgprint
|
||||
|
@ -158,7 +158,7 @@ def get_basic_details(args, item_bean):
|
||||
return out
|
||||
|
||||
def get_price_list_rate(args, item_bean, out):
|
||||
meta = frappe.get_doctype(args.doctype)
|
||||
meta = frappe.get_meta(args.doctype)
|
||||
|
||||
if meta.get_field("currency"):
|
||||
validate_price_list(args)
|
||||
|
@ -116,7 +116,7 @@ def update_entries_after(args, verbose=1):
|
||||
|
||||
# rounding as per precision
|
||||
from frappe.model.meta import get_field_precision
|
||||
meta = frappe.get_doctype("Stock Ledger Entry")
|
||||
meta = frappe.get_meta("Stock Ledger Entry")
|
||||
|
||||
stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"),
|
||||
frappe._dict({"fields": sle})))
|
||||
|
@ -16,11 +16,10 @@ class SupportEmailSettings(Document):
|
||||
"""
|
||||
if self.doc.sync_support_mails and self.doc.mail_server:
|
||||
from frappe.utils.email_lib.receive import POP3Mailbox
|
||||
from frappe.model.doc import Document
|
||||
import _socket, poplib
|
||||
import _socket, poplib
|
||||
|
||||
inc_email = Document('Incoming Email Settings')
|
||||
inc_email.encode()
|
||||
inc_email = frappe.get_doc('Incoming Email Settings')
|
||||
# inc_email.encode()
|
||||
inc_email.host = self.doc.mail_server
|
||||
inc_email.use_ssl = self.doc.use_ssl
|
||||
try:
|
||||
|
@ -56,7 +56,7 @@ def get_address_display(address_dict):
|
||||
if not isinstance(address_dict, dict):
|
||||
address_dict = frappe.db.get_value("Address", address_dict, "*", as_dict=True) or {}
|
||||
|
||||
meta = frappe.get_doctype("Address")
|
||||
meta = frappe.get_meta("Address")
|
||||
sequence = (("", "address_line1"),
|
||||
("\n", "address_line2"),
|
||||
("\n", "city"),
|
||||
|
@ -6,7 +6,6 @@ import frappe, json
|
||||
|
||||
from frappe.utils import nowdate, cstr
|
||||
from frappe.model.code import get_obj
|
||||
from frappe.model.doc import Document
|
||||
from frappe import msgprint, throw, _
|
||||
from frappe.model.bean import getlist
|
||||
|
||||
@ -109,11 +108,11 @@ class SmsControl(Document):
|
||||
# Create SMS Log
|
||||
# =========================================================
|
||||
def create_sms_log(self, arg, sent_sms):
|
||||
sl = Document('SMS Log')
|
||||
sl = frappe.get_doc('SMS Log')
|
||||
sl.sender_name = arg['sender_name']
|
||||
sl.sent_on = nowdate()
|
||||
sl.receiver_list = cstr(arg['receiver_list'])
|
||||
sl.message = arg['message']
|
||||
sl.no_of_requested_sms = len(arg['receiver_list'])
|
||||
sl.no_of_sent_sms = sent_sms
|
||||
sl.save(new=1)
|
||||
sl.save()
|
||||
|
@ -36,7 +36,7 @@ class TransactionBase(StatusUpdater):
|
||||
opts = frappe._dict(opts)
|
||||
|
||||
if self.doc.contact_date:
|
||||
event_doclist = [{
|
||||
event_doclist = frappe.get_doc({
|
||||
"doctype": "Event",
|
||||
"owner": opts.owner or self.doc.owner,
|
||||
"subject": opts.subject,
|
||||
@ -45,16 +45,15 @@ class TransactionBase(StatusUpdater):
|
||||
"event_type": "Private",
|
||||
"ref_type": self.doc.doctype,
|
||||
"ref_name": self.doc.name
|
||||
}]
|
||||
})
|
||||
|
||||
if frappe.db.exists("User", self.doc.contact_by):
|
||||
event_doclist.append({
|
||||
event_doclist.append("event_individuals", {
|
||||
"doctype": "Event User",
|
||||
"parentfield": "event_individuals",
|
||||
"person": self.doc.contact_by
|
||||
})
|
||||
|
||||
frappe.bean(event_doclist).insert()
|
||||
event_doclist.insert()
|
||||
|
||||
def validate_uom_is_integer(self, uom_field, qty_fields):
|
||||
validate_uom_is_integer(self.doclist, uom_field, qty_fields)
|
||||
|
Loading…
x
Reference in New Issue
Block a user