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 get_value = frappe.db.get_value
class DocType: from frappe.model.document import Document
def __init__(self,d,dl):
self.doc, self.doclist = d,dl class Account(Document):
self.nsm_parent_field = 'parent_account' nsm_parent_field = 'parent_account'
def autoname(self): def autoname(self):
self.doc.name = self.doc.account_name.strip() + ' - ' + \ self.doc.name = self.doc.account_name.strip() + ' - ' + \

View File

@ -8,9 +8,9 @@ import frappe
from frappe import _ from frappe import _
from frappe.utils import cint from frappe.utils import cint
class DocType: from frappe.model.document import Document
def __init__(self, d, dl):
self.doc, self.doclist = d, dl class AccountsSettings(Document):
def on_update(self): def on_update(self):
frappe.db.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock) 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 import frappe
from frappe.utils import cstr, flt, getdate, now, nowdate 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 import msgprint
from frappe.model.document import Document
class BankReconciliation(Document):
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def get_details(self): def get_details(self):
if not (self.doc.bank_account and self.doc.from_date and self.doc.to_date): 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)) 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 self.doc.total_amount = 0.0
for d in dl: 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.posting_date = cstr(d[5])
nl.voucher_id = cstr(d[0]) nl.voucher_id = cstr(d[0])
nl.cheque_number = cstr(d[1]) nl.cheque_number = cstr(d[1])
@ -40,7 +34,7 @@ class DocType:
def update_details(self): def update_details(self):
vouchers = [] vouchers = []
for d in getlist(self.doclist, 'entries'): for d in self.get('entries'):
if d.clearance_date: if d.clearance_date:
if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_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)" % msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,9 +8,8 @@ from frappe import msgprint, _
from frappe.utils.nestedset import DocTypeNestedSet from frappe.utils.nestedset import DocTypeNestedSet
class DocType(DocTypeNestedSet): class CostCenter(DocTypeNestedSet):
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
self.nsm_parent_field = 'parent_cost_center' self.nsm_parent_field = 'parent_cost_center'
def autoname(self): def autoname(self):
@ -54,7 +53,7 @@ class DocType(DocTypeNestedSet):
def validate_budget_details(self): def validate_budget_details(self):
check_acc_list = [] 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": if self.doc.group_or_ledger=="Group":
msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1) 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 import msgprint, _
from frappe.utils import getdate from frappe.utils import getdate
class DocType: from frappe.model.document import Document
def __init__(self, d, dl):
self.doc, self.doclist = d, dl class FiscalYear(Document):
def set_as_default(self): def set_as_default(self):
frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name) 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.utils import flt, fmt_money, getdate
from frappe import _ from frappe import _
class DocType: from frappe.model.document import Document
def __init__(self,d,dl):
self.doc, self.doclist = d, dl class GlEntry(Document):
def validate(self): def validate(self):
self.check_mandatory() self.check_mandatory()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,12 +15,10 @@ import frappe.defaults
from erpnext.controllers.buying_controller import BuyingController from erpnext.controllers.buying_controller import BuyingController
from erpnext.accounts.party import get_party_account, get_due_date from erpnext.accounts.party import get_party_account, get_due_date
class DocType(BuyingController): class PurchaseInvoice(BuyingController):
def __init__(self,d,dl): tname = 'Purchase Invoice Item'
self.doc, self.doclist = d, dl fname = 'entries'
self.tname = 'Purchase Invoice Item' status_updater = [{
self.fname = 'entries'
self.status_updater = [{
'source_dt': 'Purchase Invoice Item', 'source_dt': 'Purchase Invoice Item',
'target_dt': 'Purchase Order Item', 'target_dt': 'Purchase Order Item',
'join_field': 'po_detail', 'join_field': 'po_detail',
@ -71,7 +69,7 @@ class DocType(BuyingController):
"Purchase Invoice Advance", "advance_allocation_details", "debit") "Purchase Invoice Advance", "advance_allocation_details", "debit")
def check_active_purchase_items(self): 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 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) valid_item = frappe.db.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
if valid_item[0][0] == 2: if valid_item[0][0] == 2:
@ -125,7 +123,7 @@ class DocType(BuyingController):
# --------------------- # ---------------------
def check_for_stopped_status(self): def check_for_stopped_status(self):
check_list = [] 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: if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
check_list.append(d.purhcase_order) check_list.append(d.purhcase_order)
stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_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 = [] against_accounts = []
stock_items = self.get_stock_items() 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 auto_accounting_for_stock and item.item_code in stock_items \
and self.doc.is_opening == 'No': and self.doc.is_opening == 'No':
# in case of auto inventory accounting, against expense account is always # in case of auto inventory accounting, against expense account is always
@ -210,14 +208,14 @@ class DocType(BuyingController):
def po_required(self): def po_required(self):
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes': 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: if not d.purchase_order:
msgprint("Purchse Order No. required against item %s"%d.item_code) msgprint("Purchse Order No. required against item %s"%d.item_code)
raise Exception raise Exception
def pr_required(self): def pr_required(self):
if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes': 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: if not d.purchase_receipt:
msgprint("Purchase Receipt No. required against item %s"%d.item_code) msgprint("Purchase Receipt No. required against item %s"%d.item_code)
raise Exception raise Exception
@ -227,7 +225,7 @@ class DocType(BuyingController):
msgprint("Please enter Write Off Account", raise_exception=1) msgprint("Please enter Write Off Account", raise_exception=1)
def check_prev_docstatus(self): def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'): for d in self.get('entries'):
if d.purchase_order: if d.purchase_order:
submitted = frappe.db.sql("select name from `tabPurchase Order` where docstatus = 1 and name = %s", d.purchase_order) submitted = frappe.db.sql("select name from `tabPurchase Order` where docstatus = 1 and name = %s", d.purchase_order)
if not submitted: if not submitted:
@ -247,7 +245,7 @@ class DocType(BuyingController):
""" """
lst = [] lst = []
for d in getlist(self.doclist, 'advance_allocation_details'): for d in self.get('advance_allocation_details'):
if flt(d.allocated_amount) > 0: if flt(d.allocated_amount) > 0:
args = { args = {
'voucher_no' : d.journal_voucher, 'voucher_no' : d.journal_voucher,
@ -299,7 +297,7 @@ class DocType(BuyingController):
# tax table gl entries # tax table gl entries
valuation_tax = {} 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): if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount):
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
@ -325,7 +323,7 @@ class DocType(BuyingController):
# item gl entries # item gl entries
stock_item_and_auto_accounting_for_stock = False stock_item_and_auto_accounting_for_stock = False
stock_items = self.get_stock_items() 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 auto_accounting_for_stock and item.item_code in stock_items:
if flt(item.valuation_rate): if flt(item.valuation_rate):
# if auto inventory accounting enabled and stock item, # if auto inventory accounting enabled and stock item,
@ -404,7 +402,7 @@ class DocType(BuyingController):
def update_raw_material_cost(self): def update_raw_material_cost(self):
if self.sub_contracted_items: 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 rm_cost = frappe.db.sql("""select raw_material_cost / quantity
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1 from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
and is_active = 1 """, (d.item_code,)) 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 100", 90, 59],
["_Test Item Home Desktop 200", 135, 177] ["_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_code, expected_values[i][0])
self.assertEqual(item.item_tax_amount, expected_values[i][1]) self.assertEqual(item.item_tax_amount, expected_values[i][1])
self.assertEqual(item.valuation_rate, expected_values[i][2]) 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], ["_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.account_head, expected_values[i][0])
self.assertEqual(tax.tax_amount, expected_values[i][1]) self.assertEqual(tax.tax_amount, expected_values[i][1])
self.assertEqual(tax.total, expected_values[i][2]) self.assertEqual(tax.total, expected_values[i][2])
@ -141,7 +141,7 @@ class TestPurchaseInvoice(unittest.TestCase):
["_Test FG Item", 90, 7059], ["_Test FG Item", 90, 7059],
["_Test Item Home Desktop 200", 135, 177] ["_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_code, expected_values[i][0])
self.assertEqual(item.item_tax_amount, expected_values[i][1]) self.assertEqual(item.item_tax_amount, expected_values[i][1])
self.assertEqual(item.valuation_rate, expected_values[i][2]) 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], ["_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.account_head, expected_values[i][0])
self.assertEqual(tax.tax_amount, expected_values[i][1]) self.assertEqual(tax.tax_amount, expected_values[i][1])
self.assertEqual(tax.total, expected_values[i][2]) self.assertEqual(tax.total, expected_values[i][2])

View File

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

View File

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

View File

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

View File

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

View File

@ -20,13 +20,10 @@ month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
from erpnext.controllers.selling_controller import SellingController from erpnext.controllers.selling_controller import SellingController
class DocType(SellingController): class SalesInvoice(SellingController):
def __init__(self,d,dl): tname = 'Sales Invoice Item'
self.doc, self.doclist = d, dl fname = 'entries'
self.log = [] status_updater = [{
self.tname = 'Sales Invoice Item'
self.fname = 'entries'
self.status_updater = [{
'source_dt': 'Sales Invoice Item', 'source_dt': 'Sales Invoice Item',
'target_field': 'billed_amt', 'target_field': 'billed_amt',
'target_ref_field': 'amount', 'target_ref_field': 'amount',
@ -41,7 +38,6 @@ class DocType(SellingController):
'keyword': 'Billed' 'keyword': 'Billed'
}] }]
def validate(self): def validate(self):
super(DocType, self).validate() super(DocType, self).validate()
self.validate_posting_time() self.validate_posting_time()
@ -194,7 +190,7 @@ class DocType(SellingController):
self.doc.update_stock = cint(pos.get("update_stock")) self.doc.update_stock = cint(pos.get("update_stock"))
# set pos values in items # 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'): if item.fields.get('item_code'):
for fname, val in get_pos_settings_item_details(pos, for fname, val in get_pos_settings_item_details(pos,
frappe._dict(item.fields), pos).items(): 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") self.doc.terms = frappe.db.get_value("Terms and Conditions", self.doc.tc_name, "terms")
# fetch charges # 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") self.set_taxes("other_charges", "taxes_and_charges")
def get_advances(self): def get_advances(self):
@ -226,7 +222,7 @@ class DocType(SellingController):
""" """
lst = [] lst = []
for d in getlist(self.doclist, 'advance_adjustment_details'): for d in self.get('advance_adjustment_details'):
if flt(d.allocated_amount) > 0: if flt(d.allocated_amount) > 0:
args = { args = {
'voucher_no' : d.journal_voucher, 'voucher_no' : d.journal_voucher,
@ -262,7 +258,7 @@ class DocType(SellingController):
def validate_fixed_asset_account(self): def validate_fixed_asset_account(self):
"""Validate Fixed Asset and whether Income Account Entered Exists""" """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` 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' where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00'
or end_of_life > now())""", d.item_code) or end_of_life > now())""", d.item_code)
@ -314,7 +310,7 @@ class DocType(SellingController):
def set_against_income_account(self): def set_against_income_account(self):
"""Set against account for debit to account""" """Set against account for debit to account"""
against_acc = [] against_acc = []
for d in getlist(self.doclist, 'entries'): for d in self.get('entries'):
if d.income_account not in against_acc: if d.income_account not in against_acc:
against_acc.append(d.income_account) against_acc.append(d.income_account)
self.doc.against_income_account = ','.join(against_acc) self.doc.against_income_account = ','.join(against_acc)
@ -329,7 +325,7 @@ class DocType(SellingController):
dic = {'Sales Order':'so_required','Delivery Note':'dn_required'} dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
for i in dic: for i in dic:
if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes': 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' \ if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
and not d.fields[i.lower().replace(' ','_')]: 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) 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): def validate_item_code(self):
for d in getlist(self.doclist, 'entries'): for d in self.get('entries'):
if not d.item_code: 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), 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) raise_exception=True)
def validate_delivery_note(self): def validate_delivery_note(self):
for d in self.doclist.get({"parentfield": "entries"}): for d in self.get("entries"):
if d.delivery_note: if d.delivery_note:
msgprint("""Stock update can not be made against Delivery Note""", raise_exception=1) 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', '') frappe.db.set(self.doc, 'c_form_no', '')
def update_current_stock(self): 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: 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) 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 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) 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.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
d.projected_qty = bin and flt(bin[0]['projected_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: if cint(self.doc.is_pos) == 1:
w = self.get_warehouse() w = self.get_warehouse()
if w: if w:
for d in getlist(self.doclist, 'entries'): for d in self.get('entries'):
if not d.warehouse: if not d.warehouse:
d.warehouse = cstr(w) d.warehouse = cstr(w)
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
make_packing_list(self, 'entries') make_packing_list(self, 'entries')
else: else:
self.doclist = self.doc.clear_table(self.doclist, 'packing_details') self.set('packing_details', [])
if cint(self.doc.is_pos) == 1: if cint(self.doc.is_pos) == 1:
if flt(self.doc.paid_amount) == 0: if flt(self.doc.paid_amount) == 0:
@ -436,7 +432,7 @@ class DocType(SellingController):
frappe.db.set(self.doc,'paid_amount',0) frappe.db.set(self.doc,'paid_amount',0)
def check_prev_docstatus(self): def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'): for d in self.get('entries'):
if d.sales_order: if d.sales_order:
submitted = frappe.db.sql("""select name from `tabSales Order` submitted = frappe.db.sql("""select name from `tabSales Order`
where docstatus = 1 and name = %s""", d.sales_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): 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): if flt(tax.tax_amount_after_discount_amount):
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
@ -524,7 +520,7 @@ class DocType(SellingController):
def make_item_gl_entries(self, gl_entries): def make_item_gl_entries(self, gl_entries):
# income account 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): if flt(item.base_amount):
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({

View File

@ -54,11 +54,11 @@ class TestSalesInvoice(unittest.TestCase):
} }
# check if children are saved # check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), self.assertEquals(len(si.get("entries")),
len(expected_values)-1) len(expected_values)-1)
# check if item values are calculated # 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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) 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] "_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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) 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 # check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), self.assertEquals(len(si.get("entries")),
len(expected_values)-1) len(expected_values)-1)
# check if item values are calculated # 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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) 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] "_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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) 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 # check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), self.assertEquals(len(si.get("entries")),
len(expected_values)-1) len(expected_values)-1)
# check if item values are calculated # 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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) 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] "_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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) 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): def test_inclusive_rate_validations(self):
si = frappe.bean(copy=test_records[2]) 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 tax.idx = i+1
si.doclist[1].price_list_rate = 62.5 si.doclist[1].price_list_rate = 62.5
@ -273,11 +273,11 @@ class TestSalesInvoice(unittest.TestCase):
} }
# check if children are saved # check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), self.assertEquals(len(si.get("entries")),
len(expected_values)-1) len(expected_values)-1)
# check if item values are calculated # 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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) 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] "_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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) 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 # check if children are saved
self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), self.assertEquals(len(si.get("entries")),
len(expected_values)-1) len(expected_values)-1)
# check if item values are calculated # 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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) 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] "_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"]): for i, k in enumerate(expected_values["keys"]):
self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import frappe
from frappe.utils import cint from frappe.utils import cint
from frappe.model.controller import DocListController from frappe.model.controller import DocListController
class DocType(DocListController): class SalesTaxesAndChargesMaster(DocListController):
def validate(self): def validate(self):
if self.doc.is_default == 1: if self.doc.is_default == 1:
frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0 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 FromGreaterThanToError(frappe.ValidationError): pass
class ManyBlankToValuesError(frappe.ValidationError): pass class ManyBlankToValuesError(frappe.ValidationError): pass
class DocType(DocListController): class ShippingRule(DocListController):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self): def validate(self):
self.validate_value("calculate_based_on", "in", ["Net Total", "Net Weight"]) 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.validate_from_to_values()
self.sort_shipping_rule_conditions() self.sort_shipping_rule_conditions()
self.validate_overlapping_shipping_rule_conditions() self.validate_overlapping_shipping_rule_conditions()

View File

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

View File

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

View File

@ -6,9 +6,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
class DocType: from frappe.model.document import Document
def __init__(self, d, dl):
self.doc, self.doclist = d, dl class BuyingSettings(Document):
def validate(self): def validate(self):
for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]: 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.stock.doctype.item.item import get_last_purchase_details
from erpnext.controllers.buying_controller import BuyingController from erpnext.controllers.buying_controller import BuyingController
class DocType(BuyingController): class PurchaseCommon(BuyingController):
def __init__(self, doc, doclist=None):
self.doc = doc
self.doclist = doclist
def update_last_purchase_rate(self, obj, is_submit): def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item""" """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 from erpnext.controllers.buying_controller import BuyingController
class DocType(BuyingController): class PurchaseOrder(BuyingController):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.tname = 'Purchase Order Item' self.tname = 'Purchase Order Item'
self.fname = 'po_details' self.fname = 'po_details'
self.status_updater = [{ self.status_updater = [{
@ -65,7 +62,7 @@ class DocType(BuyingController):
}) })
def get_schedule_dates(self): 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: if d.prevdoc_detail_docname and not d.schedule_date:
d.schedule_date = frappe.db.get_value("Material Request Item", d.schedule_date = frappe.db.get_value("Material Request Item",
d.prevdoc_detail_docname, "schedule_date") d.prevdoc_detail_docname, "schedule_date")
@ -76,7 +73,7 @@ class DocType(BuyingController):
# Check for Stopped status # Check for Stopped status
def check_for_stopped_status(self, pc_obj): def check_for_stopped_status(self, pc_obj):
check_list =[] 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: 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) check_list.append(d.prevdoc_docname)
pc_obj.check_for_stopped_status( d.prevdoc_doctype, 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): def update_bin(self, is_submit, is_stopped = 0):
from erpnext.stock.utils import update_bin from erpnext.stock.utils import update_bin
pc_obj = get_obj('Purchase Common') 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' #1. Check if is_stock_item == 'Yes'
if frappe.db.get_value("Item", d.item_code, "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 # 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): def test_subcontracting(self):
po = frappe.bean(copy=test_records[0]) po = frappe.bean(copy=test_records[0])
po.insert() 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): def test_warehouse_company_validation(self):
from erpnext.stock.utils import InvalidWarehouseCompany from erpnext.stock.utils import InvalidWarehouseCompany

View File

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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
class DocType: from frappe.model.document import Document
def __init__(self, d, dl):
self.doc, self.doclist = d, dl 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 from erpnext.utilities.transaction_base import TransactionBase
class DocType(TransactionBase): class Supplier(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def autoname(self): def autoname(self):
supp_master_name = frappe.defaults.get_global_default('supp_master_name') 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 frappe.model.code import get_obj
from erpnext.controllers.buying_controller import BuyingController from erpnext.controllers.buying_controller import BuyingController
class DocType(BuyingController): class SupplierQuotation(BuyingController):
def __init__(self, doc, doclist=None): def __init__(self, doc, doclist=None):
self.doc, self.doclist = doc, doclist or [] self.doc, self.doclist = doc, doclist or []
self.tname, self.fname = "Supplier Quotation Item", "quotation_items" self.tname, self.fname = "Supplier Quotation Item", "quotation_items"

View File

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

View File

@ -87,7 +87,7 @@ class AccountsController(TransactionBase):
def set_missing_item_details(self): def set_missing_item_details(self):
"""set missing item values""" """set missing item values"""
from erpnext.stock.get_item_details import get_item_details 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"): if item.fields.get("item_code"):
args = item.fields.copy() args = item.fields.copy()
args.update(self.doc.fields) args.update(self.doc.fields)
@ -103,7 +103,7 @@ class AccountsController(TransactionBase):
tax_master_doctype = self.meta.get_field(tax_master_field).options 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): if not self.doc.fields.get(tax_master_field):
# get the default tax master # get the default tax master
self.doc.fields[tax_master_field] = \ self.doc.fields[tax_master_field] = \
@ -134,7 +134,7 @@ class AccountsController(TransactionBase):
self.doclist.append(tax) self.doclist.append(tax)
def get_other_charges(self): 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") self.set_taxes("other_charges", "taxes_and_charges")
def calculate_taxes_and_totals(self): def calculate_taxes_and_totals(self):
@ -156,8 +156,8 @@ class AccountsController(TransactionBase):
self.meta.get_label("conversion_rate"), self.doc.company) self.meta.get_label("conversion_rate"), self.doc.company)
self.doc.conversion_rate = flt(self.doc.conversion_rate) self.doc.conversion_rate = flt(self.doc.conversion_rate)
self.item_doclist = self.doclist.get({"parentfield": self.fname}) self.item_doclist = self.get(self.fname)
self.tax_doclist = self.doclist.get({"parentfield": self.other_fname}) self.tax_doclist = self.get(self.other_fname)
self.calculate_item_values() self.calculate_item_values()
self.initialize_taxes() self.initialize_taxes()
@ -368,7 +368,7 @@ class AccountsController(TransactionBase):
def calculate_total_advance(self, parenttype, advance_parentfield): def calculate_total_advance(self, parenttype, advance_parentfield):
if self.doc.doctype == parenttype and self.doc.docstatus < 2: if self.doc.doctype == parenttype and self.doc.docstatus < 2:
sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv)) 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")) 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""" % and t1.docstatus = 1 order by t1.posting_date""" %
(dr_or_cr, '%s'), account_head, as_dict=1) (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: for d in res:
self.doclist.append({ self.doclist.append({
"doctype": child_doctype, "doctype": child_doctype,
@ -425,7 +425,7 @@ class AccountsController(TransactionBase):
item_tolerance = {} item_tolerance = {}
global_tolerance = None global_tolerance = None
for item in self.doclist.get({"parentfield": "entries"}): for item in self.get("entries"):
if item.fields.get(item_ref_dn): if item.fields.get(item_ref_dn):
ref_amt = flt(frappe.db.get_value(ref_dt + " Item", ref_amt = flt(frappe.db.get_value(ref_dt + " Item",
item.fields[item_ref_dn], based_on), self.precision(based_on, 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): def get_stock_items(self):
stock_items = [] stock_items = []
item_codes = list(set(item.item_code for item in item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname}))) self.get(self.fname)))
if item_codes: if item_codes:
stock_items = [r[0] for r in frappe.db.sql("""select name stock_items = [r[0] for r in frappe.db.sql("""select name
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \ 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): def validate_stock_or_nonstock_items(self):
if not self.get_stock_items(): if not self.get_stock_items():
tax_for_valuation = [d.account_head for d in 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 d.category in ["Valuation", "Valuation and Total"]]
if tax_for_valuation: 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) 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 stock_items_qty, stock_items_amount = 0, 0
last_stock_item_idx = 1 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: if d.item_code and d.item_code in stock_items:
stock_items_qty += flt(d.qty) stock_items_qty += flt(d.qty)
stock_items_amount += flt(d.base_amount) stock_items_amount += flt(d.base_amount)
last_stock_item_idx = d.idx last_stock_item_idx = d.idx
total_valuation_amount = sum([flt(d.tax_amount) for d in 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"]]) if d.category in ["Valuation", "Valuation and Total"]])
valuation_amount_adjustment = total_valuation_amount 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: 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 \ item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \
else flt(item.qty) / stock_items_qty else flt(item.qty) / stock_items_qty
@ -218,9 +218,9 @@ class BuyingController(StockController):
raise_exception=1) raise_exception=1)
def update_raw_materials_supplied(self, raw_material_table): 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": 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: if item.item_code in self.sub_contracted_items:
self.add_bom_items(item, raw_material_table) self.add_bom_items(item, raw_material_table)
@ -271,7 +271,7 @@ class BuyingController(StockController):
if not hasattr(self, "_sub_contracted_items"): if not hasattr(self, "_sub_contracted_items"):
self._sub_contracted_items = [] self._sub_contracted_items = []
item_codes = list(set(item.item_code for item in item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname}))) self.get(self.fname)))
if item_codes: if item_codes:
self._sub_contracted_items = [r[0] for r in frappe.db.sql("""select name 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'""" % \ 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"): if not hasattr(self, "_purchase_items"):
self._purchase_items = [] self._purchase_items = []
item_codes = list(set(item.item_code for item in item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname}))) self.get(self.fname)))
if item_codes: if item_codes:
self._purchase_items = [r[0] for r in frappe.db.sql("""select name self._purchase_items = [r[0] for r in frappe.db.sql("""select name
from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \ from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \
@ -294,5 +294,5 @@ class BuyingController(StockController):
def is_item_table_empty(self): 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")) 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 rule calculation based on item's net weight
shipping_amount = 0.0 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)): if not condition.to_value or (flt(condition.from_value) <= value <= flt(condition.to_value)):
shipping_amount = condition.shipping_amount shipping_amount = condition.shipping_amount
break break
@ -242,7 +242,7 @@ class SellingController(StockController):
def calculate_contribution(self): def calculate_contribution(self):
total = 0.0 total = 0.0
sales_team = self.doclist.get({"parentfield": "sales_team"}) sales_team = self.get("sales_team")
for sales_person in sales_team: for sales_person in sales_team:
self.round_floats_in(sales_person) self.round_floats_in(sales_person)
@ -279,7 +279,7 @@ class SellingController(StockController):
outstanding_including_current) outstanding_including_current)
def validate_max_discount(self): 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")) discount = flt(frappe.db.get_value("Item", d.item_code, "max_discount"))
if discount and flt(d.discount_percentage) > discount: if discount and flt(d.discount_percentage) > discount:
@ -288,7 +288,7 @@ class SellingController(StockController):
def get_item_list(self): def get_item_list(self):
il = [] il = []
for d in self.doclist.get({"parentfield": self.fname}): for d in self.get(self.fname):
reserved_warehouse = "" reserved_warehouse = ""
reserved_qty_for_main_item = 0 reserved_qty_for_main_item = 0
@ -315,7 +315,7 @@ class SellingController(StockController):
reserved_qty_for_main_item = -flt(d.qty) reserved_qty_for_main_item = -flt(d.qty)
if self.has_sales_bom(d.item_code): 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: 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 # the packing details table's qty is already multiplied with parent's qty
il.append(frappe._dict({ il.append(frappe._dict({
@ -362,7 +362,7 @@ class SellingController(StockController):
return so_qty, so_warehouse return so_qty, so_warehouse
def check_stop_sales_order(self, ref_fieldname): 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): if d.fields.get(ref_fieldname):
status = frappe.db.get_value("Sales Order", d.fields[ref_fieldname], "status") status = frappe.db.get_value("Sales Order", d.fields[ref_fieldname], "status")
if status == "Stopped": 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` all_zero_amount_refdoc = frappe.db.sql_list("""select name from `tab%s`
where docstatus=1 and net_total = 0""" % ref_dt) 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) \ if item.fields.get(ref_fieldname) \
and item.fields.get(ref_fieldname) in all_zero_amount_refdoc \ and item.fields.get(ref_fieldname) in all_zero_amount_refdoc \
and item.fields.get(ref_fieldname) not in 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): def get_voucher_details(self, stock_ledger, default_expense_account, default_cost_center):
if not default_expense_account: if not default_expense_account:
details = self.doclist.get({"parentfield": self.fname}) details = self.get(self.fname)
for d in details: for d in details:
self.check_expense_account(d) self.check_expense_account(d)
else: else:
@ -129,7 +129,7 @@ class StockController(AccountsController):
future_stock_vouchers = [] future_stock_vouchers = []
if hasattr(self, "fname"): 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) ,'\')']) condition = ''.join(['and item_code in (\'', '\', \''.join(item_list) ,'\')'])
else: else:
condition = "" condition = ""
@ -256,8 +256,8 @@ class StockController(AccountsController):
def get_distinct_item_warehouse(self): def get_distinct_item_warehouse(self):
item_list = [] item_list = []
warehouse_list = [] warehouse_list = []
for item in self.doclist.get({"parentfield": self.fname}) \ for item in self.get(self.fname) \
+ self.doclist.get({"parentfield": "packing_details"}): + self.get("packing_details"):
item_list.append(item.item_code) item_list.append(item.item_code)
warehouse_list.append(item.warehouse) warehouse_list.append(item.warehouse)

View File

@ -4,15 +4,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.model import db_exists from frappe.model.document import Document
from frappe.model.bean import copy_doclist
class Feed(Document):
pass
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d, dl
def on_doctype_update(): def on_doctype_update():
if not frappe.db.sql("""show index from `tabFeed` 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.model.bean import getlist
from frappe import msgprint from frappe import msgprint
class DocType: from frappe.model.document import Document
def __init__(self, doc, doclist=[]):
self.doc = doc class Appraisal(Document):
self.doclist = doclist
def validate(self): def validate(self):
if not self.doc.status: if not self.doc.status:
@ -45,7 +44,7 @@ class DocType:
def calculate_total(self): def calculate_total(self):
total, total_w = 0, 0 total, total_w = 0, 0
for d in getlist(self.doclist, 'appraisal_details'): for d in self.get('appraisal_details'):
if d.score: if d.score:
d.score_earned = flt(d.score) * flt(d.per_weightage) / 100 d.score_earned = flt(d.score) * flt(d.per_weightage) / 100
total = total + d.score_earned total = total + d.score_earned

View File

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

View File

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

View File

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

View File

@ -8,10 +8,9 @@ from frappe.utils import getdate, nowdate
from frappe import msgprint, _ from frappe import msgprint, _
class DocType: from frappe.model.document import Document
def __init__(self, doc, doclist=[]):
self.doc = doc class Attendance(Document):
self.doclist = doclist
def validate_duplicate_record(self): def validate_duplicate_record(self):
res = frappe.db.sql("""select name from `tabAttendance` where employee = %s and att_date = %s 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 from __future__ import unicode_literals
import frappe import frappe
class DocType: from frappe.model.document import Document
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
class Branch(Document):
pass

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ import frappe.permissions
from frappe.defaults import get_restrictions from frappe.defaults import get_restrictions
from frappe.model.controller import DocListController from frappe.model.controller import DocListController
class DocType(DocListController): class Employee(DocListController):
def autoname(self): def autoname(self):
naming_method = frappe.db.get_value("HR Settings", None, "emp_created_by") naming_method = frappe.db.get_value("HR Settings", None, "emp_created_by")
if not naming_method: if not naming_method:
@ -57,7 +57,7 @@ class DocType(DocListController):
def restrict_leave_approver(self): def restrict_leave_approver(self):
"""restrict to this employee for leave approver""" """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: 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")) 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 frappe.utils.user import User
from erpnext.hr.doctype.leave_application.leave_application import InvalidLeaveApproverError 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(): if "Leave Approver" not in User(l.leave_approver).get_roles():
throw(_("Invalid Leave Approver") + ": \"" + l.leave_approver + "\"", throw(_("Invalid Leave Approver") + ": \"" + l.leave_approver + "\"",
exc=InvalidLeaveApproverError) exc=InvalidLeaveApproverError)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,6 +6,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
class DocType: from frappe.model.document import Document
def __init__(self, d, dl):
self.doc, self.doclist = d, dl 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): def __init__(self, doc, doclist):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
class DocType: from frappe.model.document import Document
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
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.model.code import get_obj
from frappe import msgprint from frappe import msgprint
class DocType: from frappe.model.document import Document
def __init__(self, doc, doclist):
self.doc = doc class SalaryManager(Document):
self.doclist = doclist
def get_emp_list(self): 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 from erpnext.utilities.transaction_base import TransactionBase
class DocType(TransactionBase): class SalarySlip(TransactionBase):
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
def autoname(self): def autoname(self):
self.doc.name = make_autoname('Sal Slip/' +self.doc.employee + '/.#####') self.doc.name = make_autoname('Sal Slip/' +self.doc.employee + '/.#####')
@ -146,8 +142,8 @@ class DocType(TransactionBase):
from frappe.utils import money_in_words from frappe.utils import money_in_words
self.check_existing() self.check_existing()
if not (len(self.doclist.get({"parentfield": "earning_details"})) or if not (len(self.get("earning_details")) or
len(self.doclist.get({"parentfield": "deduction_details"}))): len(self.get("deduction_details"))):
self.get_emp_and_leave_details() self.get_emp_and_leave_details()
else: else:
self.get_leave_details(self.doc.leave_without_pay) self.get_leave_details(self.doc.leave_without_pay)
@ -160,7 +156,7 @@ class DocType(TransactionBase):
def calculate_earning_total(self): def calculate_earning_total(self):
self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount) 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: if cint(d.e_depends_on_lwp) == 1:
d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days) d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days)
/ cint(self.doc.total_days_in_month), 2) / cint(self.doc.total_days_in_month), 2)
@ -172,7 +168,7 @@ class DocType(TransactionBase):
def calculate_ded_total(self): def calculate_ded_total(self):
self.doc.total_deduction = 0 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: if cint(d.d_depends_on_lwp) == 1:
d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days) d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days)
/ cint(self.doc.total_days_in_month), 2) / cint(self.doc.total_days_in_month), 2)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
class DocType: from frappe.model.document import Document
def __init__(self, d, dl):
self.doc, self.doclist = d, dl 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.model.code import get_obj
from frappe import msgprint, _ from frappe import msgprint, _
class DocType: from frappe.model.document import Document
class BomReplaceTool(Document):
def __init__( self, doc, doclist=[]): def __init__( self, doc, doclist=[]):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist

View File

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

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