frappe/frappe#478 erpnext install works

This commit is contained in:
Rushabh Mehta 2014-04-02 18:09:34 +05:30
parent 943e614810
commit f191f854cd
55 changed files with 165 additions and 167 deletions

View File

@ -7,7 +7,7 @@ from frappe.utils import cstr
from unidecode import unidecode
from frappe.model.document import Document
class ChartOfAccounts(Document):
class ChartofAccounts(Document):
no_report_type = False
def create_accounts(self, company):

View File

@ -24,7 +24,7 @@ class JournalVoucher(AccountsController):
self.clearance_date = None
super(DocType, self).validate_date_with_fiscal_year()
super(JournalVoucher, self).validate_date_with_fiscal_year()
self.validate_debit_credit()
self.validate_cheque_info()
@ -268,7 +268,7 @@ class JournalVoucher(AccountsController):
master_type, master_name = frappe.db.get_value("Account", d.account,
["master_type", "master_name"])
if master_type == "Customer" and master_name:
super(DocType, self).check_credit_limit(d.account)
super(JournalVoucher, self).check_credit_limit(d.account)
def get_balance(self):
if not self.get('entries'):

View File

@ -10,7 +10,7 @@ from frappe import msgprint, _
from frappe.model.document import Document
class PaymentToInvoiceMatchingTool(Document):
class PaymenttoInvoiceMatchingTool(Document):
def get_voucher_details(self):
total_amount = frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry`

View File

@ -33,7 +33,7 @@ class PurchaseInvoice(BuyingController):
if not self.is_opening:
self.is_opening = 'No'
super(DocType, self).validate()
super(PurchaseInvoice, self).validate()
self.po_required()
self.pr_required()
@ -61,10 +61,10 @@ class PurchaseInvoice(BuyingController):
self.due_date = get_due_date(self.posting_date, self.supplier, "Supplier",
self.credit_to, self.company)
super(DocType, self).set_missing_values(for_validate)
super(PurchaseInvoice, self).set_missing_values(for_validate)
def get_advances(self):
super(DocType, self).get_advances(self.credit_to,
super(PurchaseInvoice, self).get_advances(self.credit_to,
"Purchase Invoice Advance", "advance_allocation_details", "debit")
def check_active_purchase_items(self):
@ -131,7 +131,7 @@ class PurchaseInvoice(BuyingController):
raise Exception
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, {
"Purchase Order": {
"ref_dn_field": "purchase_order",
"compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]],
@ -154,7 +154,7 @@ class PurchaseInvoice(BuyingController):
})
if cint(frappe.defaults.get_global_default('maintain_same_rate')):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, {
"Purchase Order Item": {
"ref_dn_field": "po_detail",
"compare_fields": [["rate", "="]],

View File

@ -38,7 +38,7 @@ class SalesInvoice(SellingController):
}]
def validate(self):
super(DocType, self).validate()
super(SalesInvoice, self).validate()
self.validate_posting_time()
self.so_dn_required()
self.validate_proj_cust()
@ -150,17 +150,17 @@ class SalesInvoice(SellingController):
self.due_date = get_due_date(self.posting_date, self.customer, "Customer",
self.debit_to, self.company)
super(DocType, self).set_missing_values(for_validate)
super(SalesInvoice, self).set_missing_values(for_validate)
def update_time_log_batch(self, sales_invoice):
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
for d in self.get(self.fname):
if d.time_log_batch:
tlb = frappe.get_doc("Time Log Batch", d.time_log_batch)
tlb.sales_invoice = sales_invoice
tlb.update_after_submit()
def validate_time_logs_are_submitted(self):
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
for d in self.get(self.fname):
if d.time_log_batch:
status = frappe.db.get_value("Time Log Batch", d.time_log_batch, "status")
if status!="Submitted":
@ -206,7 +206,7 @@ class SalesInvoice(SellingController):
self.set_taxes("other_charges", "taxes_and_charges")
def get_advances(self):
super(DocType, self).get_advances(self.debit_to,
super(SalesInvoice, self).get_advances(self.debit_to,
"Sales Invoice Advance", "advance_adjustment_details", "credit")
def get_company_abbr(self):
@ -269,7 +269,7 @@ class SalesInvoice(SellingController):
msgprint("Please select income head with account type 'Fixed Asset' as Item %s is an asset item" % d.item_code, raise_exception=True)
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(SalesInvoice, self).validate_with_previous_doc(self.tname, {
"Sales Order": {
"ref_dn_field": "sales_order",
"compare_fields": [["customer", "="], ["company", "="], ["project_name", "="],
@ -283,7 +283,7 @@ class SalesInvoice(SellingController):
})
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(SalesInvoice, self).validate_with_previous_doc(self.tname, {
"Sales Order Item": {
"ref_dn_field": "so_detail",
"compare_fields": [["rate", "="]],
@ -537,7 +537,7 @@ class SalesInvoice(SellingController):
# expense account gl entries
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
and cint(self.update_stock):
gl_entries += super(DocType, self).get_gl_entries()
gl_entries += super(SalesInvoice, self).get_gl_entries()
def make_pos_gl_entries(self, gl_entries):
if cint(self.is_pos) and self.cash_bank_account and self.paid_amount:

View File

@ -26,7 +26,7 @@ class PurchaseOrder(BuyingController):
}]
def validate(self):
super(DocType, self).validate()
super(PurchaseOrder, self).validate()
if not self.status:
self.status = "Draft"
@ -47,7 +47,7 @@ class PurchaseOrder(BuyingController):
self.update_raw_materials_supplied("po_raw_material_details")
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(PurchaseOrder, self).validate_with_previous_doc(self.tname, {
"Supplier Quotation": {
"ref_dn_field": "supplier_quotation",
"compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]],

View File

@ -10,7 +10,7 @@ class SupplierQuotation(BuyingController):
fname = "quotation_items"
def validate(self):
super(DocType, self).validate()
super(SupplierQuotation, self).validate()
if not self.status:
self.status = "Draft"
@ -33,7 +33,7 @@ class SupplierQuotation(BuyingController):
pass
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(SupplierQuotation, self).validate_with_previous_doc(self.tname, {
"Material Request": {
"ref_dn_field": "prevdoc_docname",
"compare_fields": [["company", "="]],

View File

@ -378,8 +378,8 @@ class AccountsController(TransactionBase):
return gl_dict
def clear_unallocated_advances(self, childtype, parentfield):
self.doclist.remove_items({"parentfield": parentfield, "allocated_amount": ["in", [0, None, ""]]})
self.set(parentfield, self.get(parentfield, {"allocated_amount": ["not in", [0, None, ""]]}))
frappe.db.sql("""delete from `tab%s` where parentfield=%s and parent = %s
and ifnull(allocated_amount, 0) = 0""" % (childtype, '%s', '%s'), (parentfield, self.name))

View File

@ -40,7 +40,7 @@ class BuyingController(StockController):
def set_supplier_from_item_default(self):
if self.meta.get_field("supplier") and not self.supplier:
for d in self.doclist.get({"doctype": self.tname}):
for d in self.get(self.fname):
supplier = frappe.db.get_value("Item", d.item_code, "default_supplier")
if supplier:
self.supplier = supplier
@ -50,7 +50,7 @@ class BuyingController(StockController):
from erpnext.stock.utils import validate_warehouse_company
warehouses = list(set([d.warehouse for d in
self.doclist.get({"doctype": self.tname}) if d.warehouse]))
self.get(self.fname) if d.warehouse]))
for w in warehouses:
validate_warehouse_company(w, self.company)

View File

@ -94,13 +94,13 @@ class StatusUpdater(DocListController):
def communication_received(self):
if getattr(self, "communication_set", False):
last_comm = self.doclist.get({"doctype":"Communication"})
last_comm = self.get("communications")
if last_comm:
return last_comm[-1].sent_or_received == "Received"
def communication_sent(self):
if getattr(self, "communication_set", False):
last_comm = self.doclist.get({"doctype":"Communication"})
last_comm = self.get("communications")
if last_comm:
return last_comm[-1].sent_or_received == "Sent"
@ -113,7 +113,7 @@ class StatusUpdater(DocListController):
for args in self.status_updater:
# get unique transactions to update
for d in self.doclist:
for d in self.get_all_children():
if d.doctype == args['source_dt'] and d.get(args["join_field"]):
args['name'] = d.get(args['join_field'])
@ -191,7 +191,7 @@ class StatusUpdater(DocListController):
args['modified_cond'] = ', modified = now()'
# update quantities in child table
for d in self.doclist:
for d in self.get_all_children():
if d.doctype == args['source_dt']:
# updates qty in the child table
args['detail_id'] = d.get(args['join_field'])
@ -212,8 +212,7 @@ class StatusUpdater(DocListController):
where name='%(detail_id)s'""" % args)
# get unique transactions to update
for name in set([d.get(args['percent_join_field']) for d in self.doclist
if d.doctype == args['source_dt']]):
for name in set([d.get(args['percent_join_field']) for d in self.get_all_children(args['source_dt'])]):
if name:
args['name'] = name

View File

@ -90,7 +90,7 @@ class StockController(AccountsController):
warehouse_account = get_warehouse_account()
if hasattr(self, "fname"):
item_doclist = self.doclist.get({"parentfield": self.fname})
item_doclist = self.get(self.fname)
elif self.doctype == "Stock Reconciliation":
import json
item_doclist = []

View File

@ -22,8 +22,7 @@ class HolidayList(Document):
self.validate_values()
yr_start_date, yr_end_date = self.get_fy_start_end_dates()
date_list = self.get_weekly_off_date_list(yr_start_date, yr_end_date)
last_idx = max([cint(d.idx) for d in self.doclist.get(
{"parentfield": "holiday_list_details"})] or [0,])
last_idx = max([cint(d.idx) for d in self.get("holiday_list_details")] or [0,])
for i, d in enumerate(date_list):
ch = self.append('holiday_list_details', {})
ch.description = self.weekly_off

View File

@ -10,7 +10,7 @@ from frappe.utils import cint
from frappe.model.document import Document
class HrSettings(Document):
class HRSettings(Document):
def validate(self):
self.update_birthday_reminders()

View File

@ -14,7 +14,7 @@ class LeaveBlockList(Document):
def validate(self):
dates = []
for d in self.doclist.get({"doctype":"Leave Block List Date"}):
for d in self.get("leave_block_list_dates"):
# validate fiscal year
validate_fiscal_year(d.block_date, self.year, _("Block Date"))

View File

@ -34,7 +34,7 @@ class SalarySlip(TransactionBase):
def pull_sal_struct(self, struct):
from erpnext.hr.doctype.salary_structure.salary_structure import get_mapped_doc
self.doclist = get_mapped_doc(struct, self.doclist)
self.update(get_mapped_doc(struct, self))
def pull_emp_details(self):
emp = frappe.db.get_value("Employee", self.employee,

View File

@ -82,7 +82,7 @@ def get_mapped_doc(source_name, target_doc=None):
sal_slip.run_method("get_leave_details")
sal_slip.run_method("calculate_net_pay")
doclist = get_mapped_doc("Salary Structure", source_name, {
doc = get_mapped_doc("Salary Structure", source_name, {
"Salary Structure": {
"doctype": "Salary Slip",
"field_map": {
@ -109,4 +109,4 @@ def get_mapped_doc(source_name, target_doc=None):
}
}, target_doc, postprocess)
return doclist
return doc

View File

@ -11,7 +11,7 @@ from frappe import msgprint, _
from frappe.model.document import Document
class Bom(Document):
class BOM(Document):
def autoname(self):
last_name = frappe.db.sql("""select max(name) from `tabBOM`
@ -28,7 +28,7 @@ class Bom(Document):
self.validate_main_item()
from erpnext.utilities.transaction_base import validate_uom_is_integer
validate_uom_is_integer(self.doclist, "stock_uom", "qty")
validate_uom_is_integer(self, "stock_uom", "qty")
self.validate_operations()
self.validate_materials()
@ -133,11 +133,11 @@ class Bom(Document):
})["rate"]
if self.docstatus == 0:
frappe.get_doc(self.doclist).save()
self.save()
elif self.docstatus == 1:
self.calculate_cost()
self.update_exploded_items()
frappe.get_doc(self.doclist).update_after_submit()
self.update_after_submit()
def get_bom_unitcost(self, bom_no):
bom = frappe.db.sql("""select name, total_cost/quantity as unit_cost from `tabBOM`

View File

@ -6,5 +6,5 @@ import frappe
from frappe.model.document import Document
class BomItem(Document):
class BOMItem(Document):
pass

View File

@ -6,5 +6,5 @@ import frappe
from frappe.model.document import Document
class BomOperation(Document):
class BOMOperation(Document):
pass

View File

@ -8,7 +8,7 @@ from frappe import msgprint, _
from frappe.model.document import Document
class BomReplaceTool(Document):
class BOMReplaceTool(Document):
def replace_bom(self):
self.validate_bom()
self.update_new_bom()

View File

@ -26,7 +26,7 @@ class ProductionOrder(Document):
self.validate_warehouse()
from erpnext.utilities.transaction_base import validate_uom_is_integer
validate_uom_is_integer(self.doclist, "stock_uom", ["qty", "produced_qty"])
validate_uom_is_integer(self, "stock_uom", ["qty", "produced_qty"])
def validate_bom_no(self):
if self.bom_no:

View File

@ -173,7 +173,7 @@ class ProductionPlanningTool(Document):
self.validate_data()
from erpnext.utilities.transaction_base import validate_uom_is_integer
validate_uom_is_integer(self.doclist, "stock_uom", "planned_qty")
validate_uom_is_integer(self, "stock_uom", "planned_qty")
items = self.get_distinct_items_and_boms()[1]
pro = self.create_production_order(items)

View File

@ -14,7 +14,7 @@ class TimeLogBatch(Document):
def validate(self):
self.set_status()
self.total_hours = 0.0
for d in self.doclist.get({"doctype":"Time Log Batch Detail"}):
for d in self.get("time_log_batch_details"):
tl = frappe.get_doc("Time Log", d.time_log)
self.update_time_log_values(d, tl)
self.validate_time_log_is_submitted(tl)
@ -53,7 +53,7 @@ class TimeLogBatch(Document):
def update_status(self, time_log_batch):
self.set_status()
for d in self.doclist.get({"doctype":"Time Log Batch Detail"}):
for d in self.get("time_log_batch_details"):
tl = frappe.get_doc("Time Log", d.time_log)
tl.time_log_batch = time_log_batch
tl.sales_invoice = self.sales_invoice

View File

@ -38,7 +38,7 @@ class Lead(SellingController):
self.add_calendar_event()
def add_calendar_event(self, opts=None, force=False):
super(DocType, self).add_calendar_event({
super(Lead, self).add_calendar_event({
"owner": self.lead_owner,
"subject": ('Contact ' + cstr(self.lead_name)),
"description": ('Contact ' + cstr(self.lead_name)) + \

View File

@ -78,7 +78,7 @@ class Opportunity(TransactionBase):
if self.to_discuss:
opts.description += ' To Discuss : ' + cstr(self.to_discuss)
super(DocType, self).add_calendar_event(opts, force)
super(Opportunity, self).add_calendar_event(opts, force)
def validate_item_details(self):
if not self.get('enquiry_details'):

View File

@ -10,8 +10,8 @@ from frappe import _, msgprint
from erpnext.controllers.selling_controller import SellingController
class Quotation(SellingController):
self.tname = 'Quotation Item'
self.fname = 'quotation_details'
tname = 'Quotation Item'
fname = 'quotation_details'
def has_sales_order(self):
return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1})
@ -26,7 +26,7 @@ class Quotation(SellingController):
chk_dupl_itm.append([cstr(d.item_code),cstr(d.description)])
def validate_order_type(self):
super(DocType, self).validate_order_type()
super(Quotation, self).validate_order_type()
if self.order_type in ['Maintenance', 'Service']:
for d in self.get('quotation_details'):
@ -46,15 +46,16 @@ class Quotation(SellingController):
raise Exception
def validate(self):
super(DocType, self).validate()
super(Quotation, self).validate()
self.set_status()
self.validate_order_type()
self.validate_for_items()
self.validate_uom_is_integer("stock_uom", "qty")
def update_opportunity(self):
for opportunity in self.doclist.get_distinct_values("prevdoc_docname"):
frappe.get_doc("Opportunity", opportunity).set_status(update=True)
for opportunity in list(set([d.prevdoc_docname for d in self.get("quotation_details")])):
if opportunity:
frappe.get_doc("Opportunity", opportunity).set_status(update=True)
def declare_order_lost(self, arg):
if not self.has_sales_order():

View File

@ -6,7 +6,7 @@ import frappe
from frappe.model.document import Document
class SalesBom(Document):
class SalesBOM(Document):
def autoname(self):
@ -16,7 +16,7 @@ class SalesBom(Document):
self.validate_main_item()
from erpnext.utilities.transaction_base import validate_uom_is_integer
validate_uom_is_integer(self.doclist, "uom", "qty")
validate_uom_is_integer(self, "uom", "qty")
def validate_main_item(self):
"""main item must have Is Stock Item as No and Is Sales Item as Yes"""

View File

@ -78,7 +78,7 @@ class SalesOrder(SellingController):
and current Sales Order""" % (self.order_type, d.prevdoc_docname))
def validate_order_type(self):
super(DocType, self).validate_order_type()
super(SalesOrder, self).validate_order_type()
def validate_delivery_date(self):
if self.order_type == 'Sales' and not self.delivery_date:
@ -97,7 +97,7 @@ class SalesOrder(SellingController):
raise Exception
def validate(self):
super(DocType, self).validate()
super(SalesOrder, self).validate()
self.validate_order_type()
self.validate_delivery_date()
@ -110,7 +110,7 @@ class SalesOrder(SellingController):
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
self.doclist = make_packing_list(self,'sales_order_details')
make_packing_list(self,'sales_order_details')
self.validate_with_previous_doc()
@ -128,13 +128,13 @@ class SalesOrder(SellingController):
from erpnext.stock.utils import validate_warehouse_company
warehouses = list(set([d.warehouse for d in
self.doclist.get({"doctype": self.tname}) if d.warehouse]))
self.get(self.fname) if d.warehouse]))
for w in warehouses:
validate_warehouse_company(w, self.company)
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(SalesOrder, self).validate_with_previous_doc(self.tname, {
"Quotation": {
"ref_dn_field": "prevdoc_docname",
"compare_fields": [["company", "="], ["currency", "="]]
@ -148,12 +148,13 @@ class SalesOrder(SellingController):
frappe.db.sql("update `tabOpportunity` set status = %s where name=%s",(flag,enq[0][0]))
def update_prevdoc_status(self, flag):
for quotation in self.doclist.get_distinct_values("prevdoc_docname"):
bean = frappe.get_doc("Quotation", quotation)
if bean.docstatus==2:
frappe.throw(quotation + ": " + frappe._("Quotation is cancelled."))
for quotation in list(set([d.prevdoc_docname for d in self.get(self.fname)])):
if quotation:
doc = frappe.get_doc("Quotation", quotation)
if doc.docstatus==2:
frappe.throw(quotation + ": " + frappe._("Quotation is cancelled."))
bean.set_status(update=True)
doc.set_status(update=True)
def on_submit(self):
self.update_stock_ledger(update_stock = 1)

View File

@ -9,7 +9,7 @@ from frappe import msgprint, _
from frappe.model.document import Document
class SmsCenter(Document):
class SMSCenter(Document):
def create_receiver_list(self):
rec, where_clause = '', ''

View File

@ -10,6 +10,7 @@ from frappe import _
from frappe.model.document import Document
class BackupManager(Document):
pass
def take_backups_daily():
take_backups_if("Daily")

View File

@ -8,7 +8,8 @@ from frappe import throw, _
from frappe.model.document import Document
class Currency(Document):
pass
def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
"""common validation for currency and price list currency"""

View File

@ -8,7 +8,7 @@ from frappe import msgprint
from frappe.utils.nestedset import DocTypeNestedSet
class CustomerGroup(DocTypeNestedSet):
self.nsm_parent_field = 'parent_customer_group';
nsm_parent_field = 'parent_customer_group';
def validate(self):
if frappe.db.sql("select name from `tabCustomer Group` where name = %s and docstatus = 2",
@ -19,7 +19,7 @@ class CustomerGroup(DocTypeNestedSet):
def on_update(self):
self.validate_name_with_customer()
super(DocType, self).on_update()
super(CustomerGroup, self).on_update()
self.validate_one_root()
def validate_name_with_customer(self):
@ -44,4 +44,4 @@ class CustomerGroup(DocTypeNestedSet):
You can not trash/cancel/delete this customer group.", raise_exception=1)
# rebuild tree
super(DocType, self).on_trash()
super(CustomerGroup, self).on_trash()

View File

@ -471,7 +471,6 @@ class EmailDigest(DocListController):
self.get_next_sending()
def send():
from frappe.utils import getdate
now_date = now_datetime().date()
for ed in frappe.db.sql("""select name from `tabEmail Digest`

View File

@ -12,6 +12,6 @@ class FeaturesSetup(Document):
"""
from frappe.model import default_fields
from frappe.utils import set_default
for key in self.fields:
for key in self.meta.get_valid_columns():
if key not in default_fields:
set_default(key, self.get(key))

View File

@ -55,7 +55,7 @@ class NamingSeries(Document):
default = options[0]
# update in property setter
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'

View File

@ -8,7 +8,7 @@ from frappe.utils import flt
from frappe.utils.nestedset import DocTypeNestedSet
class SalesPerson(DocTypeNestedSet):
self.nsm_parent_field = 'parent_sales_person';
nsm_parent_field = 'parent_sales_person';
def validate(self):
for d in self.get('target_details'):
@ -16,7 +16,7 @@ class SalesPerson(DocTypeNestedSet):
frappe.throw(_("Either target qty or target amount is mandatory."))
def on_update(self):
super(DocType, self).on_update()
super(SalesPerson, self).on_update()
self.validate_one_root()
def get_email_id(self):

View File

@ -6,5 +6,5 @@ import frappe
from frappe.model.document import Document
class SmsParameter(Document):
class SMSParameter(Document):
pass

View File

@ -6,5 +6,5 @@ import frappe
from frappe.model.document import Document
class SmsSettings(Document):
class SMSSettings(Document):
pass

View File

@ -19,5 +19,5 @@ class Territory(DocTypeNestedSet):
raise Exception
def on_update(self):
super(DocType, self).on_update()
super(Territory, self).on_update()
self.validate_one_root()

View File

@ -6,5 +6,5 @@ import frappe
from frappe.model.document import Document
class Uom(Document):
class UOM(Document):
pass

View File

@ -111,19 +111,19 @@ def import_defaults():
from frappe.modules import scrub
for r in records:
bean = frappe.get_doc(r)
doc = frappe.get_doc(r)
# ignore mandatory for root
parent_link_field = ("parent_" + scrub(bean.doctype))
if parent_link_field in bean.fields and not bean.get(parent_link_field):
bean.ignore_mandatory = True
parent_link_field = ("parent_" + scrub(doc.doctype))
if doc.meta.get_field(parent_link_field) and not doc.get(parent_link_field):
doc.ignore_mandatory = True
bean.insert()
doc.insert()
def feature_setup():
"""save global defaults and features setup"""
bean = frappe.get_doc("Features Setup", "Features Setup")
bean.ignore_permissions = True
doc = frappe.get_doc("Features Setup", "Features Setup")
doc.ignore_permissions = True
# store value as 1 for all these fields
flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
@ -133,8 +133,8 @@ def feature_setup():
'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
'fs_page_break', 'fs_more_info', 'fs_pos_view'
]
bean.update(dict(zip(flds, [1]*len(flds))))
bean.save()
doc.update(dict(zip(flds, [1]*len(flds))))
doc.save()
def set_single_defaults():
for dt in frappe.db.sql_list("""select name from `tabDocType` where issingle=1"""):

View File

@ -13,21 +13,21 @@ from erpnext.stock.utils import update_bin
from erpnext.controllers.selling_controller import SellingController
class DeliveryNote(SellingController):
self.tname = 'Delivery Note Item'
self.fname = 'delivery_note_details'
self.status_updater = [{
'source_dt': 'Delivery Note Item',
'target_dt': 'Sales Order Item',
'join_field': 'prevdoc_detail_docname',
'target_field': 'delivered_qty',
'target_parent_dt': 'Sales Order',
'target_parent_field': 'per_delivered',
'target_ref_field': 'qty',
'source_field': 'qty',
'percent_join_field': 'against_sales_order',
'status_field': 'delivery_status',
'keyword': 'Delivered'
}]
tname = 'Delivery Note Item'
fname = 'delivery_note_details'
status_updater = [{
'source_dt': 'Delivery Note Item',
'target_dt': 'Sales Order Item',
'join_field': 'prevdoc_detail_docname',
'target_field': 'delivered_qty',
'target_parent_dt': 'Sales Order',
'target_parent_field': 'per_delivered',
'target_ref_field': 'qty',
'source_field': 'qty',
'percent_join_field': 'against_sales_order',
'status_field': 'delivery_status',
'keyword': 'Delivered'
}]
def onload(self):
billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabSales Invoice Item`
@ -56,7 +56,7 @@ class DeliveryNote(SellingController):
def validate(self):
super(DocType, self).validate()
super(DeliveryNote, self).validate()
from erpnext.utilities import validate_status
validate_status(self.status, ["Draft", "Submitted", "Cancelled"])
@ -71,7 +71,7 @@ class DeliveryNote(SellingController):
self.validate_with_previous_doc()
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
self.doclist = make_packing_list(self, 'delivery_note_details')
make_packing_list(self, 'delivery_note_details')
self.status = 'Draft'
if not self.installation_status: self.installation_status = 'Not Installed'
@ -80,8 +80,8 @@ class DeliveryNote(SellingController):
items = self.get("delivery_note_details")
for fn in (("Sales Order", "against_sales_order"), ("Sales Invoice", "against_sales_invoice")):
if items.get_distinct_values(fn[1]):
super(DocType, self).validate_with_previous_doc(self.tname, {
if filter(None, [(d[fn[1]] or None) for d in self.get(self.fname)]):
super(DeliveryNote, self).validate_with_previous_doc(self.tname, {
fn[0]: {
"ref_dn_field": fn[1],
"compare_fields": [["customer", "="], ["company", "="], ["project_name", "="],
@ -90,7 +90,7 @@ class DeliveryNote(SellingController):
})
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(DeliveryNote, self).validate_with_previous_doc(self.tname, {
fn[0] + " Item": {
"ref_dn_field": "prevdoc_detail_docname",
"compare_fields": [["rate", "="]],

View File

@ -179,8 +179,7 @@ class Item(DocListController):
frappe.throw(_("As there are existing stock transactions for this item, you can not change the values of 'Has Serial No', 'Is Stock Item' and 'Valuation Method'"))
def validate_item_type_for_reorder(self):
if self.re_order_level or len(self.doclist.get({"parentfield": "item_reorder",
"material_request_type": "Purchase"})):
if self.re_order_level or len(self.get("item_reorder", {"material_request_type": "Purchase"})):
if not self.is_purchase_item:
frappe.msgprint(_("""To set reorder level, item must be Purchase Item"""),
raise_exception=1)

View File

@ -12,8 +12,8 @@ from frappe import msgprint, _
from erpnext.controllers.buying_controller import BuyingController
class MaterialRequest(BuyingController):
self.tname = 'Material Request Item'
self.fname = 'indent_details'
tname = 'Material Request Item'
fname = 'indent_details'
def check_if_already_pulled(self):
pass#if self.[d.sales_order_no for d in self.get('indent_details')]
@ -55,7 +55,7 @@ class MaterialRequest(BuyingController):
# Validate
# ---------------------
def validate(self):
super(DocType, self).validate()
super(MaterialRequest, self).validate()
self.validate_schedule_date()
self.validate_uom_is_integer("uom", "qty")

View File

@ -11,6 +11,7 @@ from frappe.utils import cstr, flt
from frappe.model.document import Document
class PackedItem(Document):
pass
def get_sales_bom_items(item_code):
return frappe.db.sql("""select t1.item_code, t1.qty, t1.uom
@ -62,7 +63,7 @@ def make_packing_list(obj, item_table_fieldname):
"""make packing list for sales bom item"""
packing_list_idx = 0
parent_items = []
for d in obj.doclist.get({"parentfield": item_table_fieldname}):
for d in obj.get(item_table_fieldname):
warehouse = (item_table_fieldname == "sales_order_details") \
and d.warehouse or d.warehouse
if frappe.db.get_value("Sales BOM", {"new_item_code": d.item_code}):
@ -73,23 +74,22 @@ def make_packing_list(obj, item_table_fieldname):
if [d.item_code, d.name] not in parent_items:
parent_items.append([d.item_code, d.name])
obj.doclist = cleanup_packing_list(obj, parent_items)
return obj.doclist
cleanup_packing_list(obj, parent_items)
def cleanup_packing_list(obj, parent_items):
"""Remove all those child items which are no longer present in main item table"""
delete_list = []
for d in obj.get("packing_details"):
if [d.parent_item, d.parent_detail_docname] not in parent_items:
# mark for deletion from doclist
delete_list.append([d.parent_item, d.parent_detail_docname])
delete_list.append(d)
if not delete_list:
return obj.doclist
return obj
# delete from doclist
obj.doclist = frappe.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname]
not in delete_list, obj.doclist))
return obj.doclist
packing_details = obj.get("packing_details")
obj.set("packing_details", [])
for d in packing_details:
if d not in delete_list:
obj.append("packing_details", d)

View File

@ -12,20 +12,20 @@ from erpnext.stock.utils import update_bin
from erpnext.controllers.buying_controller import BuyingController
class PurchaseReceipt(BuyingController):
self.tname = 'Purchase Receipt Item'
self.fname = 'purchase_receipt_details'
self.count = 0
self.status_updater = [{
'source_dt': 'Purchase Receipt Item',
'target_dt': 'Purchase Order Item',
'join_field': 'prevdoc_detail_docname',
'target_field': 'received_qty',
'target_parent_dt': 'Purchase Order',
'target_parent_field': 'per_received',
'target_ref_field': 'qty',
'source_field': 'qty',
'percent_join_field': 'prevdoc_docname',
}]
tname = 'Purchase Receipt Item'
fname = 'purchase_receipt_details'
count = 0
status_updater = [{
'source_dt': 'Purchase Receipt Item',
'target_dt': 'Purchase Order Item',
'join_field': 'prevdoc_detail_docname',
'target_field': 'received_qty',
'target_parent_dt': 'Purchase Order',
'target_parent_field': 'per_received',
'target_ref_field': 'qty',
'source_field': 'qty',
'percent_join_field': 'prevdoc_docname',
}]
def onload(self):
billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabPurchase Invoice Item`
@ -35,7 +35,7 @@ class PurchaseReceipt(BuyingController):
self.set("__billing_complete", billed_qty[0][0] == total_qty)
def validate(self):
super(DocType, self).validate()
super(PurchaseReceipt, self).validate()
self.po_required()
@ -101,7 +101,7 @@ class PurchaseReceipt(BuyingController):
Please enter a valid Challan No.", raise_exception=1)
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(PurchaseReceipt, self).validate_with_previous_doc(self.tname, {
"Purchase Order": {
"ref_dn_field": "prevdoc_docname",
"compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]],
@ -114,7 +114,7 @@ class PurchaseReceipt(BuyingController):
})
if cint(frappe.defaults.get_global_default('maintain_same_rate')):
super(DocType, self).validate_with_previous_doc(self.tname, {
super(PurchaseReceipt, self).validate_with_previous_doc(self.tname, {
"Purchase Order Item": {
"ref_dn_field": "prevdoc_detail_docname",
"compare_fields": [["rate", "="]],
@ -289,7 +289,7 @@ class PurchaseReceipt(BuyingController):
def get_gl_entries(self, warehouse_account=None):
against_stock_account = self.get_company_default("stock_received_but_not_billed")
gl_entries = super(DocType, self).get_gl_entries(warehouse_account, against_stock_account)
gl_entries = super(PurchaseReceipt, self).get_gl_entries(warehouse_account, against_stock_account)
return gl_entries

View File

@ -23,7 +23,7 @@ class StockOverProductionError(frappe.ValidationError): pass
from erpnext.controllers.stock_controller import StockController
class StockEntry(StockController):
self.fname = 'mtn_details'
fname = 'mtn_details'
def validate(self):
self.validate_posting_time()
@ -83,8 +83,7 @@ class StockEntry(StockController):
source_mandatory = ["Material Issue", "Material Transfer", "Purchase Return"]
target_mandatory = ["Material Receipt", "Material Transfer", "Sales Return"]
validate_for_manufacture_repack = any([d.bom_no for d in self.doclist.get(
{"parentfield": "mtn_details"})])
validate_for_manufacture_repack = any([d.bom_no for d in self.get("mtn_details")])
if self.purpose in source_mandatory and self.purpose not in target_mandatory:
self.to_warehouse = None

View File

@ -279,10 +279,9 @@ class StockReconciliation(StockController):
if not self.cost_center:
msgprint(_("Please enter Cost Center"), raise_exception=1)
return super(DocType, self).get_gl_entries(warehouse_account,
return super(StockReconciliation, self).get_gl_entries(warehouse_account,
self.expense_account, self.cost_center)
def validate_expense_account(self):
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
return

View File

@ -9,7 +9,7 @@ from frappe import msgprint, _
from frappe.model.document import Document
class StockUomReplaceUtility(Document):
class StockUOMReplaceUtility(Document):
def validate_mandatory(self):
if not cstr(self.item_code):
msgprint("Please Enter an Item.")

View File

@ -10,12 +10,11 @@ from frappe import msgprint, throw, _
from frappe.model.document import Document
class Newsletter(Document):
def onload(self):
if self.email_sent:
self.set("__status_count", dict(frappe.db.sql("""select status, count(*))
self.set("__status_count", dict(frappe.db.sql("""select status, count(*)
from `tabBulk Email` where ref_doctype=%s and ref_docname=%s
group by status""", (self.doctype, self.name))) or None
group by status""", (self.doctype, self.name))) or None)
def test_send(self, doctype="Lead"):
self.recipients = self.test_email_id.split(",")

View File

@ -7,6 +7,8 @@ from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.utils.email_lib.receive import POP3Mailbox
import _socket, poplib
class SupportEmailSettings(Document):
@ -14,10 +16,7 @@ class SupportEmailSettings(Document):
"""
Checks support ticket email settings
"""
if self.sync_support_mails and self.mail_server:
from frappe.utils.email_lib.receive import POP3Mailbox
import _socket, poplib
if self.sync_support_mails and self.mail_server:
inc_email = frappe.get_doc('Incoming Email Settings')
# inc_email.encode()
inc_email.host = self.mail_server

View File

@ -10,6 +10,7 @@ from frappe import _
from frappe.model.document import Document
class RenameTool(Document):
pass
@frappe.whitelist()
def get_doctypes():

View File

@ -10,7 +10,7 @@ from frappe import msgprint, throw, _
from frappe.model.document import Document
class SmsControl(Document):
class SMSControl(Document):
def validate_receiver_nos(self,receiver_list):
validated_receiver_list = []

View File

@ -6,5 +6,5 @@ import frappe
from frappe.model.document import Document
class SmsLog(Document):
class SMSLog(Document):
pass

View File

@ -63,7 +63,7 @@ class TransactionBase(StatusUpdater):
is_child = val.get("is_child_table")
ref_doc = {}
item_ref_dn = []
for d in self.doclist.get({"doctype": source_dt}):
for d in self.get_all_children(source_dt):
ref_dn = d.get(val["ref_dn_field"])
if ref_dn:
if is_child:
@ -96,17 +96,18 @@ def delete_events(ref_type, ref_name):
class UOMMustBeIntegerError(frappe.ValidationError): pass
def validate_uom_is_integer(doclist, uom_field, qty_fields):
def validate_uom_is_integer(doc, uom_field, qty_fields):
if isinstance(qty_fields, basestring):
qty_fields = [qty_fields]
distinct_uoms = list(set([d.get(uom_field) for d in doc.get_all_children()]))
integer_uoms = filter(lambda uom: frappe.db.get_value("UOM", uom,
"must_be_whole_number") or None, doclist.get_distinct_values(uom_field))
"must_be_whole_number") or None, distinct_uoms)
if not integer_uoms:
return
for d in doclist:
for d in doc.get_all_children():
if d.get(uom_field) in integer_uoms:
for f in qty_fields:
if d.get(f):