This commit is contained in:
Rushabh Mehta 2014-03-27 16:12:56 +05:30
parent 66d52b55c0
commit d2b34dc30c
214 changed files with 898 additions and 973 deletions

View File

@ -9,10 +9,10 @@ from frappe import msgprint, throw, _
get_value = frappe.db.get_value
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
self.nsm_parent_field = 'parent_account'
from frappe.model.document import Document
class Account(Document):
nsm_parent_field = 'parent_account'
def autoname(self):
self.doc.name = self.doc.account_name.strip() + ' - ' + \

View File

@ -8,9 +8,9 @@ import frappe
from frappe import _
from frappe.utils import cint
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class AccountsSettings(Document):
def on_update(self):
frappe.db.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)

View File

@ -5,17 +5,11 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, flt, getdate, now, nowdate
from frappe.model import db_exists
from frappe.model.doc import addchild
from frappe.model.bean import getlist, copy_doclist
from frappe import msgprint
from frappe.model.document import Document
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
class BankReconciliation(Document):
def get_details(self):
if not (self.doc.bank_account and self.doc.from_date and self.doc.to_date):
@ -24,11 +18,11 @@ class DocType:
dl = frappe.db.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
self.doclist = self.doc.clear_table(self.doclist, 'entries')
self.set('entries', [])
self.doc.total_amount = 0.0
for d in dl:
nl = addchild(self.doc, 'entries', 'Bank Reconciliation Detail', self.doclist)
nl = self.doc.append('entries', {})
nl.posting_date = cstr(d[5])
nl.voucher_id = cstr(d[0])
nl.cheque_number = cstr(d[1])
@ -40,7 +34,7 @@ class DocType:
def update_details(self):
vouchers = []
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if d.clearance_date:
if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class BankReconciliationDetail(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class BudgetDetail(Document):
pass

View File

@ -5,21 +5,18 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import flt
from frappe.model.doc import addchild
from frappe.model.bean import getlist
from frappe import msgprint, _
class DocType:
def __init__(self,doc,doclist=[]):
self.doc,self.doclist = doc,doclist
from frappe.model.document import Document
class BudgetDistribution(Document):
def get_months(self):
month_list = ['January','February','March','April','May','June','July','August','September',
'October','November','December']
idx =1
for m in month_list:
mnth = addchild(self.doc, 'budget_distribution_details',
'Budget Distribution Detail', self.doclist)
mnth = self.append('budget_distribution_details')
mnth.month = m or ''
mnth.idx = idx
idx += 1

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class BudgetDistributionDetail(Document):
pass

View File

@ -6,15 +6,16 @@ import frappe
from frappe.utils import flt, getdate
from frappe.model.bean import getlist
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
from frappe.model.document import Document
class CForm(Document):
def validate(self):
"""Validate invoice that c-form is applicable
and no other c-form is received for that"""
for d in getlist(self.doclist, 'invoice_details'):
for d in self.get('invoice_details'):
if d.invoice_no:
inv = frappe.db.sql("""select c_form_applicable, c_form_no from
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
@ -46,7 +47,7 @@ class DocType:
where c_form_no=%s""", self.doc.name)
def set_cform_in_sales_invoices(self):
inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')]
inv = [d.invoice_no for d in self.get('invoice_details')]
if inv:
frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s
where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))),
@ -60,7 +61,7 @@ class DocType:
frappe.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1)
def set_total_invoiced_amount(self):
total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')])
total = sum([flt(d.grand_total) for d in self.get('invoice_details')])
frappe.db.set(self.doc, 'total_invoiced_amount', total)
def get_invoice_details(self, invoice_no):

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class CFormInvoiceDetail(Document):
pass

View File

@ -7,9 +7,9 @@ from frappe.utils import cstr
from unidecode import unidecode
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class ChartOfAccounts(Document):
self.no_report_type = False
def create_accounts(self, company):

View File

@ -8,9 +8,8 @@ from frappe import msgprint, _
from frappe.utils.nestedset import DocTypeNestedSet
class DocType(DocTypeNestedSet):
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
class CostCenter(DocTypeNestedSet):
self.nsm_parent_field = 'parent_cost_center'
def autoname(self):
@ -54,7 +53,7 @@ class DocType(DocTypeNestedSet):
def validate_budget_details(self):
check_acc_list = []
for d in getlist(self.doclist, 'budget_details'):
for d in self.get('budget_details'):
if self.doc.group_or_ledger=="Group":
msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1)

View File

@ -6,9 +6,9 @@ import frappe
from frappe import msgprint, _
from frappe.utils import getdate
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class FiscalYear(Document):
def set_as_default(self):
frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)

View File

@ -7,9 +7,9 @@ import frappe
from frappe.utils import flt, fmt_money, getdate
from frappe import _
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class GlEntry(Document):
def validate(self):
self.check_mandatory()

View File

@ -5,16 +5,13 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate
from frappe.model.doc import addchild
from frappe.model.bean import getlist
from frappe import msgprint, _
from erpnext.setup.utils import get_company_currency
from erpnext.controllers.accounts_controller import AccountsController
class DocType(AccountsController):
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
class JournalVoucher(AccountsController):
self.master_type = {}
self.credit_days_for = {}
self.credit_days_global = -1
@ -57,7 +54,7 @@ class DocType(AccountsController):
# frappe.delete_doc("Journal Voucher", self.doc.amended_from)
def validate_debit_credit(self):
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if d.debit and d.credit:
msgprint("You cannot credit and debit same account at the same time.",
raise_exception=1)
@ -72,7 +69,7 @@ class DocType(AccountsController):
msgprint("Reference No is mandatory if you entered Reference Date", raise_exception=1)
def validate_entries_for_advance(self):
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
if not d.is_advance and not d.against_voucher and \
not d.against_invoice and not d.against_jv:
master_type = frappe.db.get_value("Account", d.account, "master_type")
@ -82,7 +79,7 @@ class DocType(AccountsController):
Account %s if this is an advance entry." % d.account)
def validate_against_jv(self):
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if d.against_jv:
if d.against_jv == self.doc.name:
msgprint("You can not enter current voucher in 'Against JV' column",
@ -96,7 +93,7 @@ class DocType(AccountsController):
# Debit = Credit
debit, credit = 0.0, 0.0
debit_list, credit_list = [], []
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
debit += flt(d.debit, 2)
credit += flt(d.credit, 2)
if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account)
@ -110,7 +107,7 @@ class DocType(AccountsController):
(self.doc.total_debit-self.doc.total_credit), raise_exception=1)
# update against account
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if flt(d.debit) > 0: d.against_account = ', '.join(credit_list)
if flt(d.credit) > 0: d.against_account = ', '.join(debit_list)
@ -123,7 +120,7 @@ class DocType(AccountsController):
else :
msgprint("Please enter Reference date", raise_exception=1)
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if d.against_invoice and d.credit:
currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency")
r.append('%s %s against Invoice: %s' %
@ -152,7 +149,7 @@ class DocType(AccountsController):
else:
# check account type whether supplier or customer
exists = False
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
account_type = frappe.db.get_value("Account", d.account, "account_type")
if account_type in ["Supplier", "Customer"]:
exists = True
@ -165,7 +162,7 @@ class DocType(AccountsController):
self.doc.aging_date = self.doc.posting_date
def set_print_format_fields(self):
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
account_type, master_type = frappe.db.get_value("Account", d.account,
["account_type", "master_type"])
@ -191,7 +188,7 @@ class DocType(AccountsController):
# Get List of Customer Account
acc_list = filter(lambda d: frappe.db.get_value("Account", d.account,
"master_type")=='Customer', getlist(self.doclist,'entries'))
"master_type")=='Customer', self.get('entries'))
for d in acc_list:
credit_days = self.get_credit_days_for(d.account)
@ -228,7 +225,7 @@ class DocType(AccountsController):
return self.is_approving_authority
def check_account_against_entries(self):
for d in self.doclist.get({"parentfield": "entries"}):
for d in self.get("entries"):
if d.against_invoice and frappe.db.get_value("Sales Invoice",
d.against_invoice, "debit_to") != d.account:
frappe.throw(_("Row #") + cstr(d.idx) + ": " +
@ -246,7 +243,7 @@ class DocType(AccountsController):
self.check_account_against_entries()
gl_map = []
for d in self.doclist.get({"parentfield": "entries"}):
for d in self.get("entries"):
if d.debit or d.credit:
gl_map.append(
self.get_gl_dict({
@ -266,21 +263,21 @@ class DocType(AccountsController):
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
def check_credit_limit(self):
for d in self.doclist.get({"parentfield": "entries"}):
for d in self.get("entries"):
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)
def get_balance(self):
if not getlist(self.doclist,'entries'):
if not self.get('entries'):
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
else:
flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0
diff = flt(self.doc.difference, 2)
# If any row without amount, set the diff on that row
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
if not d.credit and not d.debit and diff != 0:
if diff>0:
d.credit = diff
@ -290,25 +287,25 @@ class DocType(AccountsController):
# Set the diff in a new row
if flag == 0 and diff != 0:
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
jd = self.doc.append('entries', {})
if diff>0:
jd.credit = abs(diff)
elif diff<0:
jd.debit = abs(diff)
# Set the total debit, total credit and difference
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
self.doc.total_debit += flt(d.debit, 2)
self.doc.total_credit += flt(d.credit, 2)
self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2)
def get_outstanding_invoices(self):
self.doclist = self.doc.clear_table(self.doclist, 'entries')
self.set('entries', [])
total = 0
for d in self.get_values():
total += flt(d[2])
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
jd = self.doc.append('entries', {})
jd.account = cstr(d[1])
if self.doc.write_off_based_on == 'Accounts Receivable':
jd.credit = flt(d[2])
@ -317,7 +314,7 @@ class DocType(AccountsController):
jd.debit = flt(d[2])
jd.against_voucher = cstr(d[0])
jd.save(1)
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
jd = self.doc.append('entries', {})
if self.doc.write_off_based_on == 'Accounts Receivable':
jd.debit = total
elif self.doc.write_off_based_on == 'Accounts Payable':

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class JournalVoucherDetail(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class ModeOfPayment(Document):
pass

View File

@ -5,14 +5,12 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import flt
from frappe.model.doc import addchild
from frappe.model.bean import getlist
from frappe import msgprint
class DocType:
def __init__(self, doc, doclist):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class PaymentToInvoiceMatchingTool(Document):
def set_account_type(self):
self.doc.account_type = ""
@ -49,7 +47,7 @@ class DocType:
Payment entry will be decided based on account type (Dr/Cr)
"""
self.doclist = self.doc.clear_table(self.doclist, 'ir_payment_details')
self.set('ir_payment_details', [])
gle = self.get_gl_entries()
self.create_payment_table(gle)
@ -79,8 +77,7 @@ class DocType:
def create_payment_table(self, gle):
for d in gle:
ch = addchild(self.doc, 'ir_payment_details',
'Payment to Invoice Matching Tool Detail', self.doclist)
ch = self.doc.append('ir_payment_details', {})
ch.voucher_no = d.get('voucher_no')
ch.posting_date = d.get('posting_date')
ch.amt_due = self.doc.account_type == 'debit' and flt(d.get('amt_due')) \
@ -106,7 +103,7 @@ class DocType:
msgprint("Please select valid Voucher No to proceed", raise_exception=1)
lst = []
for d in getlist(self.doclist, 'ir_payment_details'):
for d in self.get('ir_payment_details'):
if flt(d.amt_to_be_reconciled) > 0:
args = {
'voucher_no' : d.voucher_no,

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class PaymentToInvoiceMatchingToolDetail(Document):
pass

View File

@ -7,9 +7,7 @@ from frappe.utils import cstr, flt
from frappe import _
from erpnext.controllers.accounts_controller import AccountsController
class DocType(AccountsController):
def __init__(self,d,dl):
self.doc, self.doclist = d, dl
class PeriodClosingVoucher(AccountsController):
self.year_start_date = ''
def validate(self):

View File

@ -6,10 +6,9 @@ import frappe
from frappe import msgprint, _
from frappe.utils import cint
class DocType:
def __init__(self,doc,doclist):
self.doc, self.doclist = doc,doclist
from frappe.model.document import Document
class PosSetting(Document):
def get_series(self):
import frappe.model.doctype
docfield = frappe.model.doctype.get('Sales Invoice')

View File

@ -8,9 +8,7 @@ import frappe
from frappe import throw, _
from frappe.model.controller import DocListController
class DocType(DocListController):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
class PricingRule(DocListController):
def validate(self):
self.validate_mandatory()

View File

@ -15,22 +15,20 @@ import frappe.defaults
from erpnext.controllers.buying_controller import BuyingController
from erpnext.accounts.party import get_party_account, get_due_date
class DocType(BuyingController):
def __init__(self,d,dl):
self.doc, self.doclist = d, dl
self.tname = 'Purchase Invoice Item'
self.fname = 'entries'
self.status_updater = [{
'source_dt': 'Purchase Invoice Item',
'target_dt': 'Purchase Order Item',
'join_field': 'po_detail',
'target_field': 'billed_amt',
'target_parent_dt': 'Purchase Order',
'target_parent_field': 'per_billed',
'target_ref_field': 'amount',
'source_field': 'amount',
'percent_join_field': 'purchase_order',
}]
class PurchaseInvoice(BuyingController):
tname = 'Purchase Invoice Item'
fname = 'entries'
status_updater = [{
'source_dt': 'Purchase Invoice Item',
'target_dt': 'Purchase Order Item',
'join_field': 'po_detail',
'target_field': 'billed_amt',
'target_parent_dt': 'Purchase Order',
'target_parent_field': 'per_billed',
'target_ref_field': 'amount',
'source_field': 'amount',
'percent_join_field': 'purchase_order',
}]
def validate(self):
if not self.doc.is_opening:
@ -71,7 +69,7 @@ class DocType(BuyingController):
"Purchase Invoice Advance", "advance_allocation_details", "debit")
def check_active_purchase_items(self):
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if d.item_code: # extra condn coz item_code is not mandatory in PV
valid_item = frappe.db.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
if valid_item[0][0] == 2:
@ -125,7 +123,7 @@ class DocType(BuyingController):
# ---------------------
def check_for_stopped_status(self):
check_list = []
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
check_list.append(d.purhcase_order)
stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_order)
@ -187,7 +185,7 @@ class DocType(BuyingController):
against_accounts = []
stock_items = self.get_stock_items()
for item in self.doclist.get({"parentfield": "entries"}):
for item in self.get("entries"):
if auto_accounting_for_stock and item.item_code in stock_items \
and self.doc.is_opening == 'No':
# in case of auto inventory accounting, against expense account is always
@ -210,14 +208,14 @@ class DocType(BuyingController):
def po_required(self):
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
if not d.purchase_order:
msgprint("Purchse Order No. required against item %s"%d.item_code)
raise Exception
def pr_required(self):
if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes':
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
if not d.purchase_receipt:
msgprint("Purchase Receipt No. required against item %s"%d.item_code)
raise Exception
@ -227,7 +225,7 @@ class DocType(BuyingController):
msgprint("Please enter Write Off Account", raise_exception=1)
def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
if d.purchase_order:
submitted = frappe.db.sql("select name from `tabPurchase Order` where docstatus = 1 and name = %s", d.purchase_order)
if not submitted:
@ -247,7 +245,7 @@ class DocType(BuyingController):
"""
lst = []
for d in getlist(self.doclist, 'advance_allocation_details'):
for d in self.get('advance_allocation_details'):
if flt(d.allocated_amount) > 0:
args = {
'voucher_no' : d.journal_voucher,
@ -299,7 +297,7 @@ class DocType(BuyingController):
# tax table gl entries
valuation_tax = {}
for tax in self.doclist.get({"parentfield": "other_charges"}):
for tax in self.get("other_charges"):
if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount):
gl_entries.append(
self.get_gl_dict({
@ -325,7 +323,7 @@ class DocType(BuyingController):
# item gl entries
stock_item_and_auto_accounting_for_stock = False
stock_items = self.get_stock_items()
for item in self.doclist.get({"parentfield": "entries"}):
for item in self.get("entries"):
if auto_accounting_for_stock and item.item_code in stock_items:
if flt(item.valuation_rate):
# if auto inventory accounting enabled and stock item,
@ -404,7 +402,7 @@ class DocType(BuyingController):
def update_raw_material_cost(self):
if self.sub_contracted_items:
for d in self.doclist.get({"parentfield": "entries"}):
for d in self.get("entries"):
rm_cost = frappe.db.sql("""select raw_material_cost / quantity
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
and is_active = 1 """, (d.item_code,))

View File

@ -107,7 +107,7 @@ class TestPurchaseInvoice(unittest.TestCase):
["_Test Item Home Desktop 100", 90, 59],
["_Test Item Home Desktop 200", 135, 177]
]
for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})):
for i, item in enumerate(wrapper.get("entries")):
self.assertEqual(item.item_code, expected_values[i][0])
self.assertEqual(item.item_tax_amount, expected_values[i][1])
self.assertEqual(item.valuation_rate, expected_values[i][2])
@ -126,7 +126,7 @@ class TestPurchaseInvoice(unittest.TestCase):
["_Test Account Discount - _TC", 168.03, 1512.30],
]
for i, tax in enumerate(wrapper.doclist.get({"parentfield": "other_charges"})):
for i, tax in enumerate(wrapper.get("other_charges")):
self.assertEqual(tax.account_head, expected_values[i][0])
self.assertEqual(tax.tax_amount, expected_values[i][1])
self.assertEqual(tax.total, expected_values[i][2])
@ -141,7 +141,7 @@ class TestPurchaseInvoice(unittest.TestCase):
["_Test FG Item", 90, 7059],
["_Test Item Home Desktop 200", 135, 177]
]
for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})):
for i, item in enumerate(wrapper.get("entries")):
self.assertEqual(item.item_code, expected_values[i][0])
self.assertEqual(item.item_tax_amount, expected_values[i][1])
self.assertEqual(item.valuation_rate, expected_values[i][2])
@ -160,7 +160,7 @@ class TestPurchaseInvoice(unittest.TestCase):
["_Test Account Discount - _TC", 168.03, 1512.30],
]
for i, tax in enumerate(wrapper.doclist.get({"parentfield": "other_charges"})):
for i, tax in enumerate(wrapper.get("other_charges")):
self.assertEqual(tax.account_head, expected_values[i][0])
self.assertEqual(tax.tax_amount, expected_values[i][1])
self.assertEqual(tax.total, expected_values[i][2])

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class PurchaseInvoiceAdvance(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class PurchaseInvoiceItem(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class PurchaseTaxesAndCharges(Document):
pass

View File

@ -3,15 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.model import db_exists
from frappe.model.bean import copy_doclist
from frappe.model.code import get_obj
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
class PurchaseTaxesAndChargesMaster(Document):
pass

View File

@ -20,27 +20,23 @@ month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
from erpnext.controllers.selling_controller import SellingController
class DocType(SellingController):
def __init__(self,d,dl):
self.doc, self.doclist = d, dl
self.log = []
self.tname = 'Sales Invoice Item'
self.fname = 'entries'
self.status_updater = [{
'source_dt': 'Sales Invoice Item',
'target_field': 'billed_amt',
'target_ref_field': 'amount',
'target_dt': 'Sales Order Item',
'join_field': 'so_detail',
'target_parent_dt': 'Sales Order',
'target_parent_field': 'per_billed',
'source_field': 'amount',
'join_field': 'so_detail',
'percent_join_field': 'sales_order',
'status_field': 'billing_status',
'keyword': 'Billed'
}]
class SalesInvoice(SellingController):
tname = 'Sales Invoice Item'
fname = 'entries'
status_updater = [{
'source_dt': 'Sales Invoice Item',
'target_field': 'billed_amt',
'target_ref_field': 'amount',
'target_dt': 'Sales Order Item',
'join_field': 'so_detail',
'target_parent_dt': 'Sales Order',
'target_parent_field': 'per_billed',
'source_field': 'amount',
'join_field': 'so_detail',
'percent_join_field': 'sales_order',
'status_field': 'billing_status',
'keyword': 'Billed'
}]
def validate(self):
super(DocType, self).validate()
@ -194,7 +190,7 @@ class DocType(SellingController):
self.doc.update_stock = cint(pos.get("update_stock"))
# set pos values in items
for item in self.doclist.get({"parentfield": "entries"}):
for item in self.get("entries"):
if item.fields.get('item_code'):
for fname, val in get_pos_settings_item_details(pos,
frappe._dict(item.fields), pos).items():
@ -207,7 +203,7 @@ class DocType(SellingController):
self.doc.terms = frappe.db.get_value("Terms and Conditions", self.doc.tc_name, "terms")
# fetch charges
if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})):
if self.doc.charge and not len(self.get("other_charges")):
self.set_taxes("other_charges", "taxes_and_charges")
def get_advances(self):
@ -226,7 +222,7 @@ class DocType(SellingController):
"""
lst = []
for d in getlist(self.doclist, 'advance_adjustment_details'):
for d in self.get('advance_adjustment_details'):
if flt(d.allocated_amount) > 0:
args = {
'voucher_no' : d.journal_voucher,
@ -262,7 +258,7 @@ class DocType(SellingController):
def validate_fixed_asset_account(self):
"""Validate Fixed Asset and whether Income Account Entered Exists"""
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem`
where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00'
or end_of_life > now())""", d.item_code)
@ -314,7 +310,7 @@ class DocType(SellingController):
def set_against_income_account(self):
"""Set against account for debit to account"""
against_acc = []
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if d.income_account not in against_acc:
against_acc.append(d.income_account)
self.doc.against_income_account = ','.join(against_acc)
@ -329,7 +325,7 @@ class DocType(SellingController):
dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
for i in dic:
if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes':
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
and not d.fields[i.lower().replace(' ','_')]:
msgprint("%s is mandatory for stock item which is not mentioed against item: %s"%(i,d.item_code), raise_exception=1)
@ -356,13 +352,13 @@ class DocType(SellingController):
def validate_item_code(self):
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if not d.item_code:
msgprint("Please enter Item Code at line no : %s to update stock or remove check from Update Stock in Basic Info Tab." % (d.idx),
raise_exception=True)
def validate_delivery_note(self):
for d in self.doclist.get({"parentfield": "entries"}):
for d in self.get("entries"):
if d.delivery_note:
msgprint("""Stock update can not be made against Delivery Note""", raise_exception=1)
@ -381,12 +377,12 @@ class DocType(SellingController):
frappe.db.set(self.doc, 'c_form_no', '')
def update_current_stock(self):
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if d.item_code and d.warehouse:
bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
for d in getlist(self.doclist, 'packing_details'):
for d in self.get('packing_details'):
bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
@ -414,14 +410,14 @@ class DocType(SellingController):
if cint(self.doc.is_pos) == 1:
w = self.get_warehouse()
if w:
for d in getlist(self.doclist, 'entries'):
for d in self.get('entries'):
if not d.warehouse:
d.warehouse = cstr(w)
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
make_packing_list(self, 'entries')
else:
self.doclist = self.doc.clear_table(self.doclist, 'packing_details')
self.set('packing_details', [])
if cint(self.doc.is_pos) == 1:
if flt(self.doc.paid_amount) == 0:
@ -436,7 +432,7 @@ class DocType(SellingController):
frappe.db.set(self.doc,'paid_amount',0)
def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'):
for d in self.get('entries'):
if d.sales_order:
submitted = frappe.db.sql("""select name from `tabSales Order`
where docstatus = 1 and name = %s""", d.sales_order)
@ -510,7 +506,7 @@ class DocType(SellingController):
)
def make_tax_gl_entries(self, gl_entries):
for tax in self.doclist.get({"parentfield": "other_charges"}):
for tax in self.get("other_charges"):
if flt(tax.tax_amount_after_discount_amount):
gl_entries.append(
self.get_gl_dict({
@ -524,7 +520,7 @@ class DocType(SellingController):
def make_item_gl_entries(self, gl_entries):
# income account gl entries
for item in self.doclist.get({"parentfield": "entries"}):
for item in self.get("entries"):
if flt(item.base_amount):
gl_entries.append(
self.get_gl_dict({

View File

@ -54,11 +54,11 @@ class TestSalesInvoice(unittest.TestCase):
}
# check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
self.assertEquals(len(si.get("entries")),
len(expected_values)-1)
# check if item values are calculated
for d in si.doclist.get({"parentfield": "entries"}):
for d in si.get("entries"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
@ -79,7 +79,7 @@ class TestSalesInvoice(unittest.TestCase):
"_Test Account Discount - _TC": [-180.78, 1627.05]
}
for d in si.doclist.get({"parentfield": "other_charges"}):
for d in si.get("other_charges"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
@ -104,11 +104,11 @@ class TestSalesInvoice(unittest.TestCase):
}
# check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
self.assertEquals(len(si.get("entries")),
len(expected_values)-1)
# check if item values are calculated
for d in si.doclist.get({"parentfield": "entries"}):
for d in si.get("entries"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
@ -129,7 +129,7 @@ class TestSalesInvoice(unittest.TestCase):
"_Test Account Discount - _TC": [-180.78, 1627.05]
}
for d in si.doclist.get({"parentfield": "other_charges"}):
for d in si.get("other_charges"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
@ -160,11 +160,11 @@ class TestSalesInvoice(unittest.TestCase):
}
# check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
self.assertEquals(len(si.get("entries")),
len(expected_values)-1)
# check if item values are calculated
for d in si.doclist.get({"parentfield": "entries"}):
for d in si.get("entries"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
@ -186,7 +186,7 @@ class TestSalesInvoice(unittest.TestCase):
"_Test Account Service Tax - _TC": [-18.03, -16.88, 1500]
}
for d in si.doclist.get({"parentfield": "other_charges"}):
for d in si.get("other_charges"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
@ -245,7 +245,7 @@ class TestSalesInvoice(unittest.TestCase):
def test_inclusive_rate_validations(self):
si = frappe.bean(copy=test_records[2])
for i, tax in enumerate(si.doclist.get({"parentfield": "other_charges"})):
for i, tax in enumerate(si.get("other_charges")):
tax.idx = i+1
si.doclist[1].price_list_rate = 62.5
@ -273,11 +273,11 @@ class TestSalesInvoice(unittest.TestCase):
}
# check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
self.assertEquals(len(si.get("entries")),
len(expected_values)-1)
# check if item values are calculated
for d in si.doclist.get({"parentfield": "entries"}):
for d in si.get("entries"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
@ -298,7 +298,7 @@ class TestSalesInvoice(unittest.TestCase):
"_Test Account Discount - _TC": [-180.33, 1622.98]
}
for d in si.doclist.get({"parentfield": "other_charges"}):
for d in si.get("other_charges"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
@ -326,11 +326,11 @@ class TestSalesInvoice(unittest.TestCase):
}
# check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
self.assertEquals(len(si.get("entries")),
len(expected_values)-1)
# check if item values are calculated
for d in si.doclist.get({"parentfield": "entries"}):
for d in si.get("entries"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
@ -351,7 +351,7 @@ class TestSalesInvoice(unittest.TestCase):
"_Test Account Discount - _TC": [-7245.01, 65205.16]
}
for d in si.doclist.get({"parentfield": "other_charges"}):
for d in si.get("other_charges"):
for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class SalesInvoiceAdvance(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class SalesInvoiceItem(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class SalesTaxesAndCharges(Document):
pass

View File

@ -6,7 +6,7 @@ import frappe
from frappe.utils import cint
from frappe.model.controller import DocListController
class DocType(DocListController):
class SalesTaxesAndChargesMaster(DocListController):
def validate(self):
if self.doc.is_default == 1:
frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0

View File

@ -14,13 +14,11 @@ class OverlappingConditionError(frappe.ValidationError): pass
class FromGreaterThanToError(frappe.ValidationError): pass
class ManyBlankToValuesError(frappe.ValidationError): pass
class DocType(DocListController):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
class ShippingRule(DocListController):
def validate(self):
self.validate_value("calculate_based_on", "in", ["Net Total", "Net Weight"])
self.shipping_rule_conditions = self.doclist.get({"parentfield": "shipping_rule_conditions"})
self.shipping_rule_conditions = self.get("shipping_rule_conditions")
self.validate_from_to_values()
self.sort_shipping_rule_conditions()
self.validate_overlapping_shipping_rule_conditions()

View File

@ -6,6 +6,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class ShippingRuleCondition(Document):
pass

View File

@ -5,7 +5,6 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import nowdate, cstr, flt, now, getdate, add_months
from frappe.model.doc import addchild
from frappe import msgprint, throw, _
from frappe.utils import formatdate
from erpnext.utilities import build_filter_conditions
@ -182,7 +181,7 @@ def update_against_doc(d, jv_obj):
jvd = frappe.db.sql("""select cost_center, balance, against_account, is_advance
from `tabJournal Voucher Detail` where name = %s""", d['voucher_detail_no'])
# new entry with balance amount
ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail')
ch = jv_obj.append("entries")
ch.account = d['account']
ch.cost_center = cstr(jvd[0][0])
ch.balance = cstr(jvd[0][1])

View File

@ -6,9 +6,9 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class BuyingSettings(Document):
def validate(self):
for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]:

View File

@ -11,10 +11,7 @@ from frappe import msgprint, _
from erpnext.stock.doctype.item.item import get_last_purchase_details
from erpnext.controllers.buying_controller import BuyingController
class DocType(BuyingController):
def __init__(self, doc, doclist=None):
self.doc = doc
self.doclist = doclist
class PurchaseCommon(BuyingController):
def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item"""

View File

@ -11,10 +11,7 @@ from frappe import msgprint
from erpnext.controllers.buying_controller import BuyingController
class DocType(BuyingController):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
class PurchaseOrder(BuyingController):
self.tname = 'Purchase Order Item'
self.fname = 'po_details'
self.status_updater = [{
@ -65,7 +62,7 @@ class DocType(BuyingController):
})
def get_schedule_dates(self):
for d in getlist(self.doclist, 'po_details'):
for d in self.get('po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
d.schedule_date = frappe.db.get_value("Material Request Item",
d.prevdoc_detail_docname, "schedule_date")
@ -76,7 +73,7 @@ class DocType(BuyingController):
# Check for Stopped status
def check_for_stopped_status(self, pc_obj):
check_list =[]
for d in getlist(self.doclist, 'po_details'):
for d in self.get('po_details'):
if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
check_list.append(d.prevdoc_docname)
pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
@ -85,7 +82,7 @@ class DocType(BuyingController):
def update_bin(self, is_submit, is_stopped = 0):
from erpnext.stock.utils import update_bin
pc_obj = get_obj('Purchase Common')
for d in getlist(self.doclist, 'po_details'):
for d in self.get('po_details'):
#1. Check if is_stock_item == 'Yes'
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes":
# this happens when item is changed from non-stock to stock item

View File

@ -95,7 +95,7 @@ class TestPurchaseOrder(unittest.TestCase):
def test_subcontracting(self):
po = frappe.bean(copy=test_records[0])
po.insert()
self.assertEquals(len(po.doclist.get({"parentfield": "po_raw_material_details"})), 2)
self.assertEquals(len(po.get("po_raw_material_details")), 2)
def test_warehouse_company_validation(self):
from erpnext.stock.utils import InvalidWarehouseCompany

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class PurchaseOrderItem(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class PurchaseOrderItemSupplied(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class PurchaseReceiptItemSupplied(Document):
pass

View File

@ -4,19 +4,17 @@
from __future__ import unicode_literals
import frappe
from frappe.model.doc import addchild
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class QualityInspection(Document):
def get_item_specification_details(self):
self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details')
self.set('qa_specification_details', [])
specification = frappe.db.sql("select specification, value from `tabItem Quality Inspection Parameter` \
where parent = '%s' order by idx" % (self.doc.item_code))
for d in specification:
child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist)
child = self.doc.append('qa_specification_details', {})
child.specification = d[0]
child.value = d[1]
child.status = 'Accepted'

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class QualityInspectionReading(Document):
pass

View File

@ -12,10 +12,7 @@ from erpnext.accounts.party import create_party_account
from erpnext.utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
class Supplier(TransactionBase):
def autoname(self):
supp_master_name = frappe.defaults.get_global_default('supp_master_name')

View File

@ -6,7 +6,7 @@ import frappe
from frappe.model.code import get_obj
from erpnext.controllers.buying_controller import BuyingController
class DocType(BuyingController):
class SupplierQuotation(BuyingController):
def __init__(self, doc, doclist=None):
self.doc, self.doclist = doc, doclist or []
self.tname, self.fname = "Supplier Quotation Item", "quotation_items"

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class SupplierQuotationItem(Document):
pass

View File

@ -87,7 +87,7 @@ class AccountsController(TransactionBase):
def set_missing_item_details(self):
"""set missing item values"""
from erpnext.stock.get_item_details import get_item_details
for item in self.doclist.get({"parentfield": self.fname}):
for item in self.get(self.fname):
if item.fields.get("item_code"):
args = item.fields.copy()
args.update(self.doc.fields)
@ -103,7 +103,7 @@ class AccountsController(TransactionBase):
tax_master_doctype = self.meta.get_field(tax_master_field).options
if not self.doclist.get({"parentfield": tax_parentfield}):
if not self.get(tax_parentfield):
if not self.doc.fields.get(tax_master_field):
# get the default tax master
self.doc.fields[tax_master_field] = \
@ -134,7 +134,7 @@ class AccountsController(TransactionBase):
self.doclist.append(tax)
def get_other_charges(self):
self.doclist = self.doc.clear_table(self.doclist, "other_charges")
self.set("other_charges", [])
self.set_taxes("other_charges", "taxes_and_charges")
def calculate_taxes_and_totals(self):
@ -156,8 +156,8 @@ class AccountsController(TransactionBase):
self.meta.get_label("conversion_rate"), self.doc.company)
self.doc.conversion_rate = flt(self.doc.conversion_rate)
self.item_doclist = self.doclist.get({"parentfield": self.fname})
self.tax_doclist = self.doclist.get({"parentfield": self.other_fname})
self.item_doclist = self.get(self.fname)
self.tax_doclist = self.get(self.other_fname)
self.calculate_item_values()
self.initialize_taxes()
@ -368,7 +368,7 @@ class AccountsController(TransactionBase):
def calculate_total_advance(self, parenttype, advance_parentfield):
if self.doc.doctype == parenttype and self.doc.docstatus < 2:
sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv))
for adv in self.doclist.get({"parentfield": advance_parentfield})])
for adv in self.get(advance_parentfield)])
self.doc.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance"))
@ -408,7 +408,7 @@ class AccountsController(TransactionBase):
and t1.docstatus = 1 order by t1.posting_date""" %
(dr_or_cr, '%s'), account_head, as_dict=1)
self.doclist = self.doc.clear_table(self.doclist, parentfield)
self.set(parentfield, [])
for d in res:
self.doclist.append({
"doctype": child_doctype,
@ -425,7 +425,7 @@ class AccountsController(TransactionBase):
item_tolerance = {}
global_tolerance = None
for item in self.doclist.get({"parentfield": "entries"}):
for item in self.get("entries"):
if item.fields.get(item_ref_dn):
ref_amt = flt(frappe.db.get_value(ref_dt + " Item",
item.fields[item_ref_dn], based_on), self.precision(based_on, item))
@ -467,7 +467,7 @@ class AccountsController(TransactionBase):
def get_stock_items(self):
stock_items = []
item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname})))
self.get(self.fname)))
if item_codes:
stock_items = [r[0] for r in frappe.db.sql("""select name
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \

View File

@ -58,7 +58,7 @@ class BuyingController(StockController):
def validate_stock_or_nonstock_items(self):
if not self.get_stock_items():
tax_for_valuation = [d.account_head for d in
self.doclist.get({"parentfield": "other_charges"})
self.get("other_charges")
if d.category in ["Valuation", "Valuation and Total"]]
if tax_for_valuation:
frappe.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"""), raise_exception=1)
@ -171,19 +171,19 @@ class BuyingController(StockController):
stock_items_qty, stock_items_amount = 0, 0
last_stock_item_idx = 1
for d in self.doclist.get({"parentfield": parentfield}):
for d in self.get(parentfield):
if d.item_code and d.item_code in stock_items:
stock_items_qty += flt(d.qty)
stock_items_amount += flt(d.base_amount)
last_stock_item_idx = d.idx
total_valuation_amount = sum([flt(d.tax_amount) for d in
self.doclist.get({"parentfield": "other_charges"})
self.get("other_charges")
if d.category in ["Valuation", "Valuation and Total"]])
valuation_amount_adjustment = total_valuation_amount
for i, item in enumerate(self.doclist.get({"parentfield": parentfield})):
for i, item in enumerate(self.get(parentfield)):
if item.item_code and item.qty and item.item_code in stock_items:
item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \
else flt(item.qty) / stock_items_qty
@ -218,9 +218,9 @@ class BuyingController(StockController):
raise_exception=1)
def update_raw_materials_supplied(self, raw_material_table):
self.doclist = self.doc.clear_table(self.doclist, raw_material_table)
self.set(raw_material_table, [])
if self.doc.is_subcontracted=="Yes":
for item in self.doclist.get({"parentfield": self.fname}):
for item in self.get(self.fname):
if item.item_code in self.sub_contracted_items:
self.add_bom_items(item, raw_material_table)
@ -271,7 +271,7 @@ class BuyingController(StockController):
if not hasattr(self, "_sub_contracted_items"):
self._sub_contracted_items = []
item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname})))
self.get(self.fname)))
if item_codes:
self._sub_contracted_items = [r[0] for r in frappe.db.sql("""select name
from `tabItem` where name in (%s) and is_sub_contracted_item='Yes'""" % \
@ -284,7 +284,7 @@ class BuyingController(StockController):
if not hasattr(self, "_purchase_items"):
self._purchase_items = []
item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname})))
self.get(self.fname)))
if item_codes:
self._purchase_items = [r[0] for r in frappe.db.sql("""select name
from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \
@ -294,5 +294,5 @@ class BuyingController(StockController):
def is_item_table_empty(self):
if not len(self.doclist.get({"parentfield": self.fname})):
if not len(self.get(self.fname)):
frappe.throw(_("Item table can not be blank"))

View File

@ -54,7 +54,7 @@ class SellingController(StockController):
# shipping rule calculation based on item's net weight
shipping_amount = 0.0
for condition in shipping_rule.doclist.get({"parentfield": "shipping_rule_conditions"}):
for condition in shipping_rule.get("shipping_rule_conditions"):
if not condition.to_value or (flt(condition.from_value) <= value <= flt(condition.to_value)):
shipping_amount = condition.shipping_amount
break
@ -242,7 +242,7 @@ class SellingController(StockController):
def calculate_contribution(self):
total = 0.0
sales_team = self.doclist.get({"parentfield": "sales_team"})
sales_team = self.get("sales_team")
for sales_person in sales_team:
self.round_floats_in(sales_person)
@ -279,7 +279,7 @@ class SellingController(StockController):
outstanding_including_current)
def validate_max_discount(self):
for d in self.doclist.get({"parentfield": self.fname}):
for d in self.get(self.fname):
discount = flt(frappe.db.get_value("Item", d.item_code, "max_discount"))
if discount and flt(d.discount_percentage) > discount:
@ -288,7 +288,7 @@ class SellingController(StockController):
def get_item_list(self):
il = []
for d in self.doclist.get({"parentfield": self.fname}):
for d in self.get(self.fname):
reserved_warehouse = ""
reserved_qty_for_main_item = 0
@ -315,7 +315,7 @@ class SellingController(StockController):
reserved_qty_for_main_item = -flt(d.qty)
if self.has_sales_bom(d.item_code):
for p in self.doclist.get({"parentfield": "packing_details"}):
for p in self.get("packing_details"):
if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
# the packing details table's qty is already multiplied with parent's qty
il.append(frappe._dict({
@ -362,7 +362,7 @@ class SellingController(StockController):
return so_qty, so_warehouse
def check_stop_sales_order(self, ref_fieldname):
for d in self.doclist.get({"parentfield": self.fname}):
for d in self.get(self.fname):
if d.fields.get(ref_fieldname):
status = frappe.db.get_value("Sales Order", d.fields[ref_fieldname], "status")
if status == "Stopped":

View File

@ -240,7 +240,7 @@ class StatusUpdater(DocListController):
all_zero_amount_refdoc = frappe.db.sql_list("""select name from `tab%s`
where docstatus=1 and net_total = 0""" % ref_dt)
for item in self.doclist.get({"parentfield": "entries"}):
for item in self.get("entries"):
if item.fields.get(ref_fieldname) \
and item.fields.get(ref_fieldname) in all_zero_amount_refdoc \
and item.fields.get(ref_fieldname) not in zero_amount_refdoc:

View File

@ -70,7 +70,7 @@ class StockController(AccountsController):
def get_voucher_details(self, stock_ledger, default_expense_account, default_cost_center):
if not default_expense_account:
details = self.doclist.get({"parentfield": self.fname})
details = self.get(self.fname)
for d in details:
self.check_expense_account(d)
else:
@ -129,7 +129,7 @@ class StockController(AccountsController):
future_stock_vouchers = []
if hasattr(self, "fname"):
item_list = [d.item_code for d in self.doclist.get({"parentfield": self.fname})]
item_list = [d.item_code for d in self.get(self.fname)]
condition = ''.join(['and item_code in (\'', '\', \''.join(item_list) ,'\')'])
else:
condition = ""
@ -256,8 +256,8 @@ class StockController(AccountsController):
def get_distinct_item_warehouse(self):
item_list = []
warehouse_list = []
for item in self.doclist.get({"parentfield": self.fname}) \
+ self.doclist.get({"parentfield": "packing_details"}):
for item in self.get(self.fname) \
+ self.get("packing_details"):
item_list.append(item.item_code)
warehouse_list.append(item.warehouse)

View File

@ -4,15 +4,10 @@
from __future__ import unicode_literals
import frappe
from frappe.model import db_exists
from frappe.model.bean import copy_doclist
from frappe.model.document import Document
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d, dl
class Feed(Document):
pass
def on_doctype_update():
if not frappe.db.sql("""show index from `tabFeed`

View File

@ -8,10 +8,9 @@ from frappe.utils import cstr, flt, getdate
from frappe.model.bean import getlist
from frappe import msgprint
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class Appraisal(Document):
def validate(self):
if not self.doc.status:
@ -45,7 +44,7 @@ class DocType:
def calculate_total(self):
total, total_w = 0, 0
for d in getlist(self.doclist, 'appraisal_details'):
for d in self.get('appraisal_details'):
if d.score:
d.score_earned = flt(d.score) * flt(d.per_weightage) / 100
total = total + d.score_earned

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class AppraisalGoal(Document):
pass

View File

@ -5,9 +5,9 @@ from __future__ import unicode_literals
import frappe
from frappe import _
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class AppraisalTemplate(Document):
def validate(self):
self.doc.total_points = 0

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class AppraisalTemplateGoal(Document):
pass

View File

@ -8,10 +8,9 @@ from frappe.utils import getdate, nowdate
from frappe import msgprint, _
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class Attendance(Document):
def validate_duplicate_record(self):
res = frappe.db.sql("""select name from `tabAttendance` where employee = %s and att_date = %s

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class Branch(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class DeductionType(Document):
pass

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class Department(Document):
pass

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class Designation(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class EarningType(Document):
pass

View File

@ -11,7 +11,7 @@ import frappe.permissions
from frappe.defaults import get_restrictions
from frappe.model.controller import DocListController
class DocType(DocListController):
class Employee(DocListController):
def autoname(self):
naming_method = frappe.db.get_value("HR Settings", None, "emp_created_by")
if not naming_method:
@ -57,7 +57,7 @@ class DocType(DocListController):
def restrict_leave_approver(self):
"""restrict to this employee for leave approver"""
employee_leave_approvers = [d.leave_approver for d in self.doclist.get({"parentfield": "employee_leave_approvers"})]
employee_leave_approvers = [d.leave_approver for d in self.get("employee_leave_approvers")]
if self.doc.reports_to and self.doc.reports_to not in employee_leave_approvers:
employee_leave_approvers.append(frappe.db.get_value("Employee", self.doc.reports_to, "user_id"))
@ -167,7 +167,7 @@ class DocType(DocListController):
from frappe.utils.user import User
from erpnext.hr.doctype.leave_application.leave_application import InvalidLeaveApproverError
for l in self.doclist.get({"parentfield": "employee_leave_approvers"}):
for l in self.get("employee_leave_approvers"):
if "Leave Approver" not in User(l.leave_approver).get_roles():
throw(_("Invalid Leave Approver") + ": \"" + l.leave_approver + "\"",
exc=InvalidLeaveApproverError)

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class EmployeeEducation(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class EmployeeExternalWorkHistory(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class EmployeeInternalWorkHistory(Document):
pass

View File

@ -6,6 +6,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class EmployeeLeaveApprover(Document):
pass

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class EmploymentType(Document):
pass

View File

@ -7,10 +7,9 @@ import frappe
from frappe.model.bean import getlist
from frappe import msgprint
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class ExpenseClaim(Document):
def validate(self):
self.validate_fiscal_year()
@ -26,6 +25,6 @@ class DocType:
validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, "Posting Date")
def validate_exp_details(self):
if not getlist(self.doclist, 'expense_voucher_details'):
if not self.get('expense_voucher_details'):
msgprint("Please add expense voucher details")
raise Exception

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class ExpenseClaimDetail(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class ExpenseClaimType(Document):
pass

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class Grade(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class Holiday(Document):
pass

View File

@ -5,17 +5,13 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import add_days, add_years, cint, getdate
from frappe.model import db_exists
from frappe.model.doc import addchild, make_autoname
from frappe.model.bean import copy_doclist
from frappe.model.doc import make_autoname
from frappe import msgprint, throw, _
import datetime
class DocType:
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class HolidayList(Document):
def autoname(self):
self.doc.name = make_autoname(self.doc.fiscal_year + "/" + self.doc.holiday_list_name + "/.###")
@ -29,7 +25,7 @@ class DocType:
last_idx = max([cint(d.idx) for d in self.doclist.get(
{"parentfield": "holiday_list_details"})] or [0,])
for i, d in enumerate(date_list):
ch = addchild(self.doc, 'holiday_list_details', 'Holiday', self.doclist)
ch = self.doc.append('holiday_list_details', {})
ch.description = self.doc.weekly_off
ch.holiday_date = d
ch.idx = last_idx + i + 1
@ -63,7 +59,7 @@ class DocType:
return date_list
def clear_table(self):
self.doclist = self.doc.clear_table(self.doclist, 'holiday_list_details')
self.set('holiday_list_details', [])
def update_default_holiday_list(self):
frappe.db.sql("""update `tabHoliday List` set is_default = 0

View File

@ -8,9 +8,9 @@ import frappe
from frappe.utils import cint
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class HrSettings(Document):
def validate(self):
self.update_birthday_reminders()

View File

@ -8,9 +8,7 @@ import frappe
from erpnext.utilities.transaction_base import TransactionBase
from frappe.utils import extract_email_id
class DocType(TransactionBase):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
class JobApplicant(TransactionBase):
def get_sender(self, comm):
return frappe.db.get_value('Jobs Email Settings',None,'email_id')

View File

@ -6,6 +6,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class JobOpening(Document):
pass

View File

@ -6,7 +6,9 @@ import frappe
from frappe.utils import cint, flt
from frappe import msgprint
class DocType:
from frappe.model.document import Document
class LeaveAllocation(Document):
def __init__(self, doc, doclist):
self.doc, self.doclist = doc, doclist

View File

@ -15,7 +15,7 @@ class InvalidLeaveApproverError(frappe.ValidationError): pass
class LeaveApproverIdentityError(frappe.ValidationError): pass
from frappe.model.controller import DocListController
class DocType(DocListController):
class LeaveApplication(DocListController):
def setup(self):
if frappe.db.exists(self.doc.doctype, self.doc.name):
self.previous_doc = frappe.doc(self.doc.doctype, self.doc.name)
@ -149,7 +149,7 @@ class DocType(DocListController):
def validate_leave_approver(self):
employee = frappe.bean("Employee", self.doc.employee)
leave_approvers = [l.leave_approver for l in
employee.doclist.get({"parentfield": "employee_leave_approvers"})]
employee.get("employee_leave_approvers")]
if len(leave_approvers) and self.doc.leave_approver not in leave_approvers:
msgprint(("[" + _("For Employee") + ' "' + self.doc.employee + '"] '

View File

@ -8,9 +8,9 @@ import frappe
from erpnext.accounts.utils import validate_fiscal_year
from frappe import _
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class LeaveBlockList(Document):
def validate(self):
dates = []

View File

@ -6,6 +6,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class LeaveBlockListAllow(Document):
pass

View File

@ -6,6 +6,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class LeaveBlockListDate(Document):
pass

View File

@ -12,7 +12,9 @@ from frappe import msgprint, _
class DocType:
from frappe.model.document import Document
class LeaveControlPanel(Document):
def __init__(self, doc, doclist):
self.doc = doc
self.doclist = doclist

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class LeaveType(Document):
pass

View File

@ -7,10 +7,9 @@ from frappe.utils import cint, flt
from frappe.model.code import get_obj
from frappe import msgprint
class DocType:
def __init__(self, doc, doclist):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class SalaryManager(Document):
def get_emp_list(self):
"""

View File

@ -14,11 +14,7 @@ from erpnext.setup.utils import get_company_currency
from erpnext.utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
class SalarySlip(TransactionBase):
def autoname(self):
self.doc.name = make_autoname('Sal Slip/' +self.doc.employee + '/.#####')
@ -146,8 +142,8 @@ class DocType(TransactionBase):
from frappe.utils import money_in_words
self.check_existing()
if not (len(self.doclist.get({"parentfield": "earning_details"})) or
len(self.doclist.get({"parentfield": "deduction_details"}))):
if not (len(self.get("earning_details")) or
len(self.get("deduction_details"))):
self.get_emp_and_leave_details()
else:
self.get_leave_details(self.doc.leave_without_pay)
@ -160,7 +156,7 @@ class DocType(TransactionBase):
def calculate_earning_total(self):
self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount)
for d in self.doclist.get({"parentfield": "earning_details"}):
for d in self.get("earning_details"):
if cint(d.e_depends_on_lwp) == 1:
d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days)
/ cint(self.doc.total_days_in_month), 2)
@ -172,7 +168,7 @@ class DocType(TransactionBase):
def calculate_ded_total(self):
self.doc.total_deduction = 0
for d in getlist(self.doclist, 'deduction_details'):
for d in self.get('deduction_details'):
if cint(d.d_depends_on_lwp) == 1:
d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days)
/ cint(self.doc.total_days_in_month), 2)

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class SalarySlipDeduction(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class SalarySlipEarning(Document):
pass

View File

@ -5,15 +5,13 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, flt
from frappe.model.doc import addchild, make_autoname
from frappe.model.doc import make_autoname
from frappe import msgprint, _
class DocType:
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class SalaryStructure(Document):
def autoname(self):
self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
@ -44,7 +42,7 @@ class DocType:
def make_table(self, doct_name, tab_fname, tab_name):
list1 = frappe.db.sql("select name from `tab%s` where docstatus != 2" % doct_name)
for li in list1:
child = addchild(self.doc, tab_fname, tab_name, self.doclist)
child = self.doc.append(tab_fname, {})
if(tab_fname == 'earning_details'):
child.e_type = cstr(li[0])
child.modified_value = 0

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class SalaryStructureDeduction(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class SalaryStructureEarning(Document):
pass

View File

@ -8,14 +8,13 @@ import frappe
from frappe.utils import cstr, add_days, date_diff
from frappe import msgprint, _
from frappe.utils.datautils import UnicodeWriter
from frappe.model.document import Document
# doclist = None
doclist = frappe.local('uploadattendance_doclist')
class DocType():
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
class UploadAttendance(Document):
pass
@frappe.whitelist()
def get_template():

View File

@ -4,17 +4,15 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cint, cstr, flt, now, nowdate
from frappe.model.doc import addchild
from frappe.model.bean import getlist
from frappe.model.code import get_obj
from frappe import msgprint, _
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class Bom(Document):
def autoname(self):
last_name = frappe.db.sql("""select max(name) from `tabBOM`
@ -75,7 +73,7 @@ class DocType:
msgprint("Item %s does not exist in system" % item[0]['item_code'], raise_exception = 1)
def set_bom_material_details(self):
for item in self.doclist.get({"parentfield": "bom_materials"}):
for item in self.get("bom_materials"):
ret = self.get_bom_material_detail({"item_code": item.item_code, "bom_no": item.bom_no,
"qty": item.qty})
@ -128,7 +126,7 @@ class DocType:
return rate
def update_cost(self):
for d in self.doclist.get({"parentfield": "bom_materials"}):
for d in self.get("bom_materials"):
d.rate = self.get_bom_material_detail({
'item_code': d.item_code,
'bom_no': d.bom_no,
@ -188,8 +186,8 @@ class DocType:
def clear_operations(self):
if not self.doc.with_operations:
self.doclist = self.doc.clear_table(self.doclist, 'bom_operations')
for d in self.doclist.get({"parentfield": "bom_materials"}):
self.set('bom_operations', [])
for d in self.get("bom_materials"):
d.operation_no = None
def validate_main_item(self):
@ -210,7 +208,7 @@ class DocType:
def validate_operations(self):
""" Check duplicate operation no"""
self.op = []
for d in getlist(self.doclist, 'bom_operations'):
for d in self.get('bom_operations'):
if cstr(d.operation_no) in self.op:
msgprint("Operation no: %s is repeated in Operations Table" %
d.operation_no, raise_exception=1)
@ -221,7 +219,7 @@ class DocType:
def validate_materials(self):
""" Validate raw material entries """
check_list = []
for m in getlist(self.doclist, 'bom_materials'):
for m in self.get('bom_materials'):
# check if operation no not in op table
if self.doc.with_operations and cstr(m.operation_no) not in self.op:
msgprint("""Operation no: %s against item: %s at row no: %s \
@ -315,7 +313,7 @@ class DocType:
def calculate_op_cost(self):
"""Update workstation rate and calculates totals"""
total_op_cost = 0
for d in getlist(self.doclist, 'bom_operations'):
for d in self.get('bom_operations'):
if d.workstation and not d.hour_rate:
d.hour_rate = frappe.db.get_value("Workstation", d.workstation, "hour_rate")
if d.hour_rate and d.time_in_mins:
@ -326,7 +324,7 @@ class DocType:
def calculate_rm_cost(self):
"""Fetch RM rate as per today's valuation rate and calculate totals"""
total_rm_cost = 0
for d in getlist(self.doclist, 'bom_materials'):
for d in self.get('bom_materials'):
if d.bom_no:
d.rate = self.get_bom_unitcost(d.bom_no)
d.amount = flt(d.rate) * flt(d.qty)
@ -343,7 +341,7 @@ class DocType:
def get_exploded_items(self):
""" Get all raw materials including items from child bom"""
self.cur_exploded_items = {}
for d in getlist(self.doclist, 'bom_materials'):
for d in self.get('bom_materials'):
if d.bom_no:
self.get_child_exploded_items(d.bom_no, d.qty)
else:
@ -379,9 +377,9 @@ class DocType:
def add_exploded_items(self):
"Add items to Flat BOM table"
self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
self.set('flat_bom_details', [])
for d in self.cur_exploded_items:
ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', self.doclist)
ch = self.doc.append('flat_bom_details', {})
for i in self.cur_exploded_items[d].keys():
ch.fields[i] = self.cur_exploded_items[d][i]
ch.amount = flt(ch.qty) * flt(ch.rate)

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class BomExplosionItem(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class BomItem(Document):
pass

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
from frappe.model.document import Document
class BomOperation(Document):
pass

View File

@ -7,7 +7,9 @@ from frappe.utils import cstr, flt
from frappe.model.code import get_obj
from frappe import msgprint, _
class DocType:
from frappe.model.document import Document
class BomReplaceTool(Document):
def __init__( self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist

View File

@ -10,10 +10,9 @@ from frappe import msgprint, _
class OverProductionError(frappe.ValidationError): pass
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
from frappe.model.document import Document
class ProductionOrder(Document):
def validate(self):
if self.doc.docstatus == 0:

Some files were not shown because too many files have changed in this diff Show More