From d2b34dc30c39a495b78f55bb02e32ef6ae657e81 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 27 Mar 2014 16:12:56 +0530 Subject: [PATCH] frappe/frappe#478 --- erpnext/accounts/doctype/account/account.py | 8 +-- .../accounts_settings/accounts_settings.py | 6 +- .../bank_reconciliation.py | 16 ++--- .../bank_reconciliation_detail.py | 7 +- .../doctype/budget_detail/budget_detail.py | 7 +- .../budget_distribution.py | 11 ++- .../budget_distribution_detail.py | 7 +- erpnext/accounts/doctype/c_form/c_form.py | 13 ++-- .../c_form_invoice_detail.py | 7 +- .../chart_of_accounts/chart_of_accounts.py | 6 +- .../doctype/cost_center/cost_center.py | 7 +- .../doctype/fiscal_year/fiscal_year.py | 6 +- erpnext/accounts/doctype/gl_entry/gl_entry.py | 6 +- .../journal_voucher/journal_voucher.py | 45 ++++++------ .../journal_voucher_detail.py | 7 +- .../mode_of_payment/mode_of_payment.py | 7 +- .../payment_to_invoice_matching_tool.py | 15 ++-- ...payment_to_invoice_matching_tool_detail.py | 7 +- .../period_closing_voucher.py | 4 +- .../doctype/pos_setting/pos_setting.py | 5 +- .../doctype/pricing_rule/pricing_rule.py | 4 +- .../purchase_invoice/purchase_invoice.py | 50 +++++++------- .../purchase_invoice/test_purchase_invoice.py | 8 +-- .../purchase_invoice_advance.py | 7 +- .../purchase_invoice_item.py | 7 +- .../purchase_taxes_and_charges.py | 7 +- .../purchase_taxes_and_charges_master.py | 14 +--- .../doctype/sales_invoice/sales_invoice.py | 68 +++++++++---------- .../sales_invoice/test_sales_invoice.py | 32 ++++----- .../sales_invoice_advance.py | 7 +- .../sales_invoice_item/sales_invoice_item.py | 7 +- .../sales_taxes_and_charges.py | 7 +- .../sales_taxes_and_charges_master.py | 2 +- .../doctype/shipping_rule/shipping_rule.py | 6 +- .../shipping_rule_condition.py | 7 +- erpnext/accounts/utils.py | 3 +- .../buying_settings/buying_settings.py | 6 +- .../purchase_common/purchase_common.py | 5 +- .../doctype/purchase_order/purchase_order.py | 11 ++- .../purchase_order/test_purchase_order.py | 2 +- .../purchase_order_item.py | 7 +- .../purchase_order_item_supplied.py | 7 +- .../purchase_receipt_item_supplied.py | 7 +- .../quality_inspection/quality_inspection.py | 12 ++-- .../quality_inspection_reading.py | 7 +- erpnext/buying/doctype/supplier/supplier.py | 5 +- .../supplier_quotation/supplier_quotation.py | 2 +- .../supplier_quotation_item.py | 7 +- erpnext/controllers/accounts_controller.py | 18 ++--- erpnext/controllers/buying_controller.py | 18 ++--- erpnext/controllers/selling_controller.py | 12 ++-- erpnext/controllers/status_updater.py | 2 +- erpnext/controllers/stock_controller.py | 8 +-- erpnext/home/doctype/feed/feed.py | 11 +-- erpnext/hr/doctype/appraisal/appraisal.py | 9 ++- .../doctype/appraisal_goal/appraisal_goal.py | 7 +- .../appraisal_template/appraisal_template.py | 6 +- .../appraisal_template_goal.py | 7 +- erpnext/hr/doctype/attendance/attendance.py | 7 +- erpnext/hr/doctype/branch/branch.py | 8 +-- .../doctype/deduction_type/deduction_type.py | 7 +- erpnext/hr/doctype/department/department.py | 8 +-- erpnext/hr/doctype/designation/designation.py | 8 +-- .../hr/doctype/earning_type/earning_type.py | 7 +- erpnext/hr/doctype/employee/employee.py | 6 +- .../employee_education/employee_education.py | 7 +- .../employee_external_work_history.py | 7 +- .../employee_internal_work_history.py | 7 +- .../employee_leave_approver.py | 7 +- .../employment_type/employment_type.py | 8 +-- .../hr/doctype/expense_claim/expense_claim.py | 9 ++- .../expense_claim_detail.py | 7 +- .../expense_claim_type/expense_claim_type.py | 7 +- erpnext/hr/doctype/grade/grade.py | 8 +-- erpnext/hr/doctype/holiday/holiday.py | 7 +- .../hr/doctype/holiday_list/holiday_list.py | 14 ++-- erpnext/hr/doctype/hr_settings/hr_settings.py | 6 +- .../hr/doctype/job_applicant/job_applicant.py | 4 +- erpnext/hr/doctype/job_opening/job_opening.py | 7 +- .../leave_allocation/leave_allocation.py | 4 +- .../leave_application/leave_application.py | 4 +- .../leave_block_list/leave_block_list.py | 6 +- .../leave_block_list_allow.py | 7 +- .../leave_block_list_date.py | 7 +- .../leave_control_panel.py | 4 +- erpnext/hr/doctype/leave_type/leave_type.py | 8 +-- .../doctype/salary_manager/salary_manager.py | 7 +- erpnext/hr/doctype/salary_slip/salary_slip.py | 14 ++-- .../salary_slip_deduction.py | 7 +- .../salary_slip_earning.py | 7 +- .../salary_structure/salary_structure.py | 10 ++- .../salary_structure_deduction.py | 7 +- .../salary_structure_earning.py | 7 +- .../upload_attendance/upload_attendance.py | 7 +- erpnext/manufacturing/doctype/bom/bom.py | 30 ++++---- .../bom_explosion_item/bom_explosion_item.py | 7 +- .../doctype/bom_item/bom_item.py | 7 +- .../doctype/bom_operation/bom_operation.py | 7 +- .../bom_replace_tool/bom_replace_tool.py | 4 +- .../production_order/production_order.py | 7 +- .../production_plan_item.py | 7 +- .../production_plan_sales_order.py | 7 +- .../production_planning_tool.py | 25 +++---- .../doctype/workstation/workstation.py | 4 +- .../doctype/activity_type/activity_type.py | 7 +- erpnext/projects/doctype/project/project.py | 9 ++- .../project_milestone/project_milestone.py | 7 +- erpnext/projects/doctype/task/task.py | 10 +-- erpnext/projects/doctype/time_log/time_log.py | 6 +- .../doctype/time_log_batch/time_log_batch.py | 6 +- .../time_log_batch_detail.py | 7 +- erpnext/selling/doctype/campaign/campaign.py | 8 +-- erpnext/selling/doctype/customer/customer.py | 5 +- .../doctype/industry_type/industry_type.py | 8 +-- .../installation_note/installation_note.py | 13 ++-- .../installation_note_item.py | 7 +- erpnext/selling/doctype/lead/lead.py | 5 +- .../doctype/opportunity/opportunity.py | 25 +++---- .../opportunity_item/opportunity_item.py | 7 +- .../selling/doctype/quotation/quotation.py | 15 ++-- .../doctype/quotation_item/quotation_item.py | 7 +- .../selling/doctype/sales_bom/sales_bom.py | 7 +- .../doctype/sales_bom_item/sales_bom_item.py | 7 +- .../doctype/sales_order/sales_order.py | 6 +- .../sales_order_item/sales_order_item.py | 7 +- .../selling/doctype/sales_team/sales_team.py | 7 +- .../selling_settings/selling_settings.py | 6 +- .../selling/doctype/sms_center/sms_center.py | 7 +- .../applicable_territory.py | 7 +- .../authorization_control.py | 4 +- .../authorization_rule/authorization_rule.py | 6 +- .../doctype/backup_manager/backup_manager.py | 6 +- erpnext/setup/doctype/brand/brand.py | 7 +- erpnext/setup/doctype/company/company.py | 7 +- .../contact_control/contact_control.py | 8 +-- erpnext/setup/doctype/country/country.py | 7 +- erpnext/setup/doctype/currency/currency.py | 6 +- .../currency_exchange/currency_exchange.py | 4 +- .../doctype/customer_group/customer_group.py | 5 +- .../doctype/email_digest/email_digest.py | 6 +- .../doctype/features_setup/features_setup.py | 6 +- .../global_defaults/global_defaults.py | 6 +- .../setup/doctype/item_group/item_group.py | 5 +- .../jobs_email_settings.py | 6 +- .../doctype/naming_series/naming_series.py | 6 +- .../notification_control.py | 7 +- .../doctype/print_heading/print_heading.py | 11 +-- .../quotation_lost_reason.py | 7 +- .../sales_email_settings.py | 6 +- .../doctype/sales_partner/sales_partner.py | 7 +- .../doctype/sales_person/sales_person.py | 7 +- .../doctype/sms_parameter/sms_parameter.py | 7 +- .../doctype/sms_settings/sms_settings.py | 7 +- .../doctype/supplier_type/supplier_type.py | 7 +- .../doctype/target_detail/target_detail.py | 7 +- .../terms_and_conditions.py | 7 +- erpnext/setup/doctype/territory/territory.py | 9 +-- erpnext/setup/doctype/uom/uom.py | 7 +- .../website_item_group/website_item_group.py | 7 +- .../setup/page/setup_wizard/setup_wizard.py | 10 ++- erpnext/stock/doctype/batch/batch.py | 7 +- erpnext/stock/doctype/bin/bin.py | 7 +- .../doctype/delivery_note/delivery_note.py | 23 +++---- .../delivery_note_item/delivery_note_item.py | 7 +- erpnext/stock/doctype/item/item.py | 15 ++-- .../item_customer_detail.py | 7 +- .../stock/doctype/item_price/item_price.py | 6 +- .../item_quality_inspection_parameter.py | 7 +- .../doctype/item_reorder/item_reorder.py | 7 +- .../doctype/item_supplier/item_supplier.py | 7 +- erpnext/stock/doctype/item_tax/item_tax.py | 7 +- .../item_website_specification.py | 7 +- .../landed_cost_item/landed_cost_item.py | 7 +- .../landed_cost_purchase_receipt.py | 7 +- .../landed_cost_wizard/landed_cost_wizard.py | 19 ++---- .../material_request/material_request.py | 17 ++--- .../material_request_item.py | 7 +- .../stock/doctype/packed_item/packed_item.py | 11 ++- .../doctype/packing_slip/packing_slip.py | 17 +++-- .../packing_slip_item/packing_slip_item.py | 7 +- .../stock/doctype/price_list/price_list.py | 4 +- .../purchase_receipt/purchase_receipt.py | 25 +++---- .../purchase_receipt/test_purchase_receipt.py | 2 +- .../purchase_receipt_item.py | 7 +- erpnext/stock/doctype/serial_no/serial_no.py | 2 +- .../stock/doctype/stock_entry/stock_entry.py | 41 +++++------ .../doctype/stock_entry/test_stock_entry.py | 12 ++-- .../stock_entry_detail/stock_entry_detail.py | 7 +- .../doctype/stock_ledger/stock_ledger.py | 7 +- .../stock_ledger_entry/stock_ledger_entry.py | 5 +- .../stock_reconciliation.py | 2 +- .../doctype/stock_settings/stock_settings.py | 6 +- .../stock_uom_replace_utility.py | 4 +- .../uom_conversion_detail.py | 7 +- erpnext/stock/doctype/warehouse/warehouse.py | 7 +- .../doctype/warehouse_user/warehouse_user.py | 7 +- erpnext/stock/get_item_details.py | 2 +- erpnext/stock/utils.py | 2 +- .../doctype/customer_issue/customer_issue.py | 5 +- .../maintenance_schedule.py | 33 ++++----- .../maintenance_schedule_detail.py | 7 +- .../maintenance_schedule_item.py | 7 +- .../maintenance_visit/maintenance_visit.py | 13 ++-- .../maintenance_visit_purpose.py | 7 +- .../support/doctype/newsletter/newsletter.py | 5 +- .../support_email_settings.py | 6 +- .../doctype/support_ticket/support_ticket.py | 5 +- erpnext/utilities/doctype/address/address.py | 7 +- erpnext/utilities/doctype/contact/contact.py | 5 +- erpnext/utilities/doctype/note/note.py | 6 +- .../utilities/doctype/note_user/note_user.py | 7 +- .../doctype/rename_tool/rename_tool.py | 6 +- .../doctype/sms_control/sms_control.py | 7 +- erpnext/utilities/doctype/sms_log/sms_log.py | 7 +- 214 files changed, 898 insertions(+), 973 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 4c3e4d1682..0c88aebd92 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -9,10 +9,10 @@ from frappe import msgprint, throw, _ get_value = frappe.db.get_value -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl - self.nsm_parent_field = 'parent_account' +from frappe.model.document import Document + +class Account(Document): + nsm_parent_field = 'parent_account' def autoname(self): self.doc.name = self.doc.account_name.strip() + ' - ' + \ diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index 3e01eea710..ab7e8ab286 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -8,9 +8,9 @@ import frappe from frappe import _ from frappe.utils import cint -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class AccountsSettings(Document): def on_update(self): frappe.db.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock) diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 859c9d00c4..5ad447cceb 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -5,17 +5,11 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, getdate, now, nowdate -from frappe.model import db_exists -from frappe.model.doc import addchild -from frappe.model.bean import getlist, copy_doclist from frappe import msgprint - +from frappe.model.document import Document - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class BankReconciliation(Document): def get_details(self): if not (self.doc.bank_account and self.doc.from_date and self.doc.to_date): @@ -24,11 +18,11 @@ class DocType: dl = frappe.db.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date)) - self.doclist = self.doc.clear_table(self.doclist, 'entries') + self.set('entries', []) self.doc.total_amount = 0.0 for d in dl: - nl = addchild(self.doc, 'entries', 'Bank Reconciliation Detail', self.doclist) + nl = self.doc.append('entries', {}) nl.posting_date = cstr(d[5]) nl.voucher_id = cstr(d[0]) nl.cheque_number = cstr(d[1]) @@ -40,7 +34,7 @@ class DocType: def update_details(self): vouchers = [] - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.clearance_date: if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date): msgprint("Clearance Date can not be before Cheque Date (Row #%s)" % diff --git a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py index 26c87f1c04..93dca1da23 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py +++ b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BankReconciliationDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_detail/budget_detail.py b/erpnext/accounts/doctype/budget_detail/budget_detail.py index 26c87f1c04..58106a06ac 100644 --- a/erpnext/accounts/doctype/budget_detail/budget_detail.py +++ b/erpnext/accounts/doctype/budget_detail/budget_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BudgetDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py index 5173097666..069c4d3390 100644 --- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py @@ -5,21 +5,18 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt -from frappe.model.doc import addchild from frappe.model.bean import getlist from frappe import msgprint, _ -class DocType: - def __init__(self,doc,doclist=[]): - self.doc,self.doclist = doc,doclist - +from frappe.model.document import Document + +class BudgetDistribution(Document): def get_months(self): month_list = ['January','February','March','April','May','June','July','August','September', 'October','November','December'] idx =1 for m in month_list: - mnth = addchild(self.doc, 'budget_distribution_details', - 'Budget Distribution Detail', self.doclist) + mnth = self.append('budget_distribution_details') mnth.month = m or '' mnth.idx = idx idx += 1 diff --git a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py index 26c87f1c04..84d8060731 100644 --- a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py +++ b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BudgetDistributionDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/c_form/c_form.py b/erpnext/accounts/doctype/c_form/c_form.py index fdf8b30ebb..b832554164 100644 --- a/erpnext/accounts/doctype/c_form/c_form.py +++ b/erpnext/accounts/doctype/c_form/c_form.py @@ -6,15 +6,16 @@ import frappe from frappe.utils import flt, getdate from frappe.model.bean import getlist -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +from frappe.model.document import Document + +class CForm(Document): + def validate(self): """Validate invoice that c-form is applicable and no other c-form is received for that""" - for d in getlist(self.doclist, 'invoice_details'): + for d in self.get('invoice_details'): if d.invoice_no: inv = frappe.db.sql("""select c_form_applicable, c_form_no from `tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no) @@ -46,7 +47,7 @@ class DocType: where c_form_no=%s""", self.doc.name) def set_cform_in_sales_invoices(self): - inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')] + inv = [d.invoice_no for d in self.get('invoice_details')] if inv: frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))), @@ -60,7 +61,7 @@ class DocType: frappe.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1) def set_total_invoiced_amount(self): - total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')]) + total = sum([flt(d.grand_total) for d in self.get('invoice_details')]) frappe.db.set(self.doc, 'total_invoiced_amount', total) def get_invoice_details(self, invoice_no): diff --git a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py index 26c87f1c04..8e3bc2974a 100644 --- a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py +++ b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class CFormInvoiceDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py index 16c6acff58..3b377fc54f 100644 --- a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py @@ -7,9 +7,9 @@ from frappe.utils import cstr from unidecode import unidecode -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class ChartOfAccounts(Document): self.no_report_type = False def create_accounts(self, company): diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index e02496ff5d..720b0bab19 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -8,9 +8,8 @@ from frappe import msgprint, _ from frappe.utils.nestedset import DocTypeNestedSet -class DocType(DocTypeNestedSet): - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +class CostCenter(DocTypeNestedSet): + self.nsm_parent_field = 'parent_cost_center' def autoname(self): @@ -54,7 +53,7 @@ class DocType(DocTypeNestedSet): def validate_budget_details(self): check_acc_list = [] - for d in getlist(self.doclist, 'budget_details'): + for d in self.get('budget_details'): if self.doc.group_or_ledger=="Group": msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1) diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index 3918751d84..34110d3386 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -6,9 +6,9 @@ import frappe from frappe import msgprint, _ from frappe.utils import getdate -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class FiscalYear(Document): def set_as_default(self): frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name) diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 9e1dbb7f58..b6a52953c5 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -7,9 +7,9 @@ import frappe from frappe.utils import flt, fmt_money, getdate from frappe import _ -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class GlEntry(Document): def validate(self): self.check_mandatory() diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index 57c14b00d6..9884b57da3 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -5,16 +5,13 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate -from frappe.model.doc import addchild -from frappe.model.bean import getlist from frappe import msgprint, _ from erpnext.setup.utils import get_company_currency from erpnext.controllers.accounts_controller import AccountsController -class DocType(AccountsController): - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +class JournalVoucher(AccountsController): + self.master_type = {} self.credit_days_for = {} self.credit_days_global = -1 @@ -57,7 +54,7 @@ class DocType(AccountsController): # frappe.delete_doc("Journal Voucher", self.doc.amended_from) def validate_debit_credit(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.debit and d.credit: msgprint("You cannot credit and debit same account at the same time.", raise_exception=1) @@ -72,7 +69,7 @@ class DocType(AccountsController): msgprint("Reference No is mandatory if you entered Reference Date", raise_exception=1) def validate_entries_for_advance(self): - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if not d.is_advance and not d.against_voucher and \ not d.against_invoice and not d.against_jv: master_type = frappe.db.get_value("Account", d.account, "master_type") @@ -82,7 +79,7 @@ class DocType(AccountsController): Account %s if this is an advance entry." % d.account) def validate_against_jv(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.against_jv: if d.against_jv == self.doc.name: msgprint("You can not enter current voucher in 'Against JV' column", @@ -96,7 +93,7 @@ class DocType(AccountsController): # Debit = Credit debit, credit = 0.0, 0.0 debit_list, credit_list = [], [] - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): debit += flt(d.debit, 2) credit += flt(d.credit, 2) if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account) @@ -110,7 +107,7 @@ class DocType(AccountsController): (self.doc.total_debit-self.doc.total_credit), raise_exception=1) # update against account - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if flt(d.debit) > 0: d.against_account = ', '.join(credit_list) if flt(d.credit) > 0: d.against_account = ', '.join(debit_list) @@ -123,7 +120,7 @@ class DocType(AccountsController): else : msgprint("Please enter Reference date", raise_exception=1) - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.against_invoice and d.credit: currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency") r.append('%s %s against Invoice: %s' % @@ -152,7 +149,7 @@ class DocType(AccountsController): else: # check account type whether supplier or customer exists = False - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): account_type = frappe.db.get_value("Account", d.account, "account_type") if account_type in ["Supplier", "Customer"]: exists = True @@ -165,7 +162,7 @@ class DocType(AccountsController): self.doc.aging_date = self.doc.posting_date def set_print_format_fields(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): account_type, master_type = frappe.db.get_value("Account", d.account, ["account_type", "master_type"]) @@ -191,7 +188,7 @@ class DocType(AccountsController): # Get List of Customer Account acc_list = filter(lambda d: frappe.db.get_value("Account", d.account, - "master_type")=='Customer', getlist(self.doclist,'entries')) + "master_type")=='Customer', self.get('entries')) for d in acc_list: credit_days = self.get_credit_days_for(d.account) @@ -228,7 +225,7 @@ class DocType(AccountsController): return self.is_approving_authority def check_account_against_entries(self): - for d in self.doclist.get({"parentfield": "entries"}): + for d in self.get("entries"): if d.against_invoice and frappe.db.get_value("Sales Invoice", d.against_invoice, "debit_to") != d.account: frappe.throw(_("Row #") + cstr(d.idx) + ": " + @@ -246,7 +243,7 @@ class DocType(AccountsController): self.check_account_against_entries() gl_map = [] - for d in self.doclist.get({"parentfield": "entries"}): + for d in self.get("entries"): if d.debit or d.credit: gl_map.append( self.get_gl_dict({ @@ -266,21 +263,21 @@ class DocType(AccountsController): make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj) def check_credit_limit(self): - for d in self.doclist.get({"parentfield": "entries"}): + for d in self.get("entries"): master_type, master_name = frappe.db.get_value("Account", d.account, ["master_type", "master_name"]) if master_type == "Customer" and master_name: super(DocType, self).check_credit_limit(d.account) def get_balance(self): - if not getlist(self.doclist,'entries'): + if not self.get('entries'): msgprint("Please enter atleast 1 entry in 'GL Entries' table") else: flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0 diff = flt(self.doc.difference, 2) # If any row without amount, set the diff on that row - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if not d.credit and not d.debit and diff != 0: if diff>0: d.credit = diff @@ -290,25 +287,25 @@ class DocType(AccountsController): # Set the diff in a new row if flag == 0 and diff != 0: - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist) + jd = self.doc.append('entries', {}) if diff>0: jd.credit = abs(diff) elif diff<0: jd.debit = abs(diff) # Set the total debit, total credit and difference - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): self.doc.total_debit += flt(d.debit, 2) self.doc.total_credit += flt(d.credit, 2) self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2) def get_outstanding_invoices(self): - self.doclist = self.doc.clear_table(self.doclist, 'entries') + self.set('entries', []) total = 0 for d in self.get_values(): total += flt(d[2]) - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist) + jd = self.doc.append('entries', {}) jd.account = cstr(d[1]) if self.doc.write_off_based_on == 'Accounts Receivable': jd.credit = flt(d[2]) @@ -317,7 +314,7 @@ class DocType(AccountsController): jd.debit = flt(d[2]) jd.against_voucher = cstr(d[0]) jd.save(1) - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist) + jd = self.doc.append('entries', {}) if self.doc.write_off_based_on == 'Accounts Receivable': jd.debit = total elif self.doc.write_off_based_on == 'Accounts Payable': diff --git a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py index 26c87f1c04..36700d2dc3 100644 --- a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py +++ b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class JournalVoucherDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py index 26c87f1c04..ddabf8973f 100644 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ModeOfPayment(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py index e0bd61d7ae..8260deadc3 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py @@ -5,14 +5,12 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt -from frappe.model.doc import addchild from frappe.model.bean import getlist from frappe import msgprint -class DocType: - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class PaymentToInvoiceMatchingTool(Document): def set_account_type(self): self.doc.account_type = "" @@ -49,7 +47,7 @@ class DocType: Payment entry will be decided based on account type (Dr/Cr) """ - self.doclist = self.doc.clear_table(self.doclist, 'ir_payment_details') + self.set('ir_payment_details', []) gle = self.get_gl_entries() self.create_payment_table(gle) @@ -79,8 +77,7 @@ class DocType: def create_payment_table(self, gle): for d in gle: - ch = addchild(self.doc, 'ir_payment_details', - 'Payment to Invoice Matching Tool Detail', self.doclist) + ch = self.doc.append('ir_payment_details', {}) ch.voucher_no = d.get('voucher_no') ch.posting_date = d.get('posting_date') ch.amt_due = self.doc.account_type == 'debit' and flt(d.get('amt_due')) \ @@ -106,7 +103,7 @@ class DocType: msgprint("Please select valid Voucher No to proceed", raise_exception=1) lst = [] - for d in getlist(self.doclist, 'ir_payment_details'): + for d in self.get('ir_payment_details'): if flt(d.amt_to_be_reconciled) > 0: args = { 'voucher_no' : d.voucher_no, diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py index 26c87f1c04..a7bf686170 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PaymentToInvoiceMatchingToolDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 100bd9562d..cdc20e85f0 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -7,9 +7,7 @@ from frappe.utils import cstr, flt from frappe import _ from erpnext.controllers.accounts_controller import AccountsController -class DocType(AccountsController): - def __init__(self,d,dl): - self.doc, self.doclist = d, dl +class PeriodClosingVoucher(AccountsController): self.year_start_date = '' def validate(self): diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.py b/erpnext/accounts/doctype/pos_setting/pos_setting.py index 29ae298b8e..61d405bccd 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.py +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.py @@ -6,10 +6,9 @@ import frappe from frappe import msgprint, _ from frappe.utils import cint -class DocType: - def __init__(self,doc,doclist): - self.doc, self.doclist = doc,doclist +from frappe.model.document import Document +class PosSetting(Document): def get_series(self): import frappe.model.doctype docfield = frappe.model.doctype.get('Sales Invoice') diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 5073718d43..831efacb9d 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -8,9 +8,7 @@ import frappe from frappe import throw, _ from frappe.model.controller import DocListController -class DocType(DocListController): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class PricingRule(DocListController): def validate(self): self.validate_mandatory() diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index c059d2d7c3..c07b2c8e29 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -15,22 +15,20 @@ import frappe.defaults from erpnext.controllers.buying_controller import BuyingController from erpnext.accounts.party import get_party_account, get_due_date -class DocType(BuyingController): - def __init__(self,d,dl): - self.doc, self.doclist = d, dl - self.tname = 'Purchase Invoice Item' - self.fname = 'entries' - self.status_updater = [{ - 'source_dt': 'Purchase Invoice Item', - 'target_dt': 'Purchase Order Item', - 'join_field': 'po_detail', - 'target_field': 'billed_amt', - 'target_parent_dt': 'Purchase Order', - 'target_parent_field': 'per_billed', - 'target_ref_field': 'amount', - 'source_field': 'amount', - 'percent_join_field': 'purchase_order', - }] +class PurchaseInvoice(BuyingController): + tname = 'Purchase Invoice Item' + fname = 'entries' + status_updater = [{ + 'source_dt': 'Purchase Invoice Item', + 'target_dt': 'Purchase Order Item', + 'join_field': 'po_detail', + 'target_field': 'billed_amt', + 'target_parent_dt': 'Purchase Order', + 'target_parent_field': 'per_billed', + 'target_ref_field': 'amount', + 'source_field': 'amount', + 'percent_join_field': 'purchase_order', + }] def validate(self): if not self.doc.is_opening: @@ -71,7 +69,7 @@ class DocType(BuyingController): "Purchase Invoice Advance", "advance_allocation_details", "debit") def check_active_purchase_items(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.item_code: # extra condn coz item_code is not mandatory in PV valid_item = frappe.db.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code) if valid_item[0][0] == 2: @@ -125,7 +123,7 @@ class DocType(BuyingController): # --------------------- def check_for_stopped_status(self): check_list = [] - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt: check_list.append(d.purhcase_order) stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_order) @@ -187,7 +185,7 @@ class DocType(BuyingController): against_accounts = [] stock_items = self.get_stock_items() - for item in self.doclist.get({"parentfield": "entries"}): + for item in self.get("entries"): if auto_accounting_for_stock and item.item_code in stock_items \ and self.doc.is_opening == 'No': # in case of auto inventory accounting, against expense account is always @@ -210,14 +208,14 @@ class DocType(BuyingController): def po_required(self): if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes': - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if not d.purchase_order: msgprint("Purchse Order No. required against item %s"%d.item_code) raise Exception def pr_required(self): if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes': - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if not d.purchase_receipt: msgprint("Purchase Receipt No. required against item %s"%d.item_code) raise Exception @@ -227,7 +225,7 @@ class DocType(BuyingController): msgprint("Please enter Write Off Account", raise_exception=1) def check_prev_docstatus(self): - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if d.purchase_order: submitted = frappe.db.sql("select name from `tabPurchase Order` where docstatus = 1 and name = %s", d.purchase_order) if not submitted: @@ -247,7 +245,7 @@ class DocType(BuyingController): """ lst = [] - for d in getlist(self.doclist, 'advance_allocation_details'): + for d in self.get('advance_allocation_details'): if flt(d.allocated_amount) > 0: args = { 'voucher_no' : d.journal_voucher, @@ -299,7 +297,7 @@ class DocType(BuyingController): # tax table gl entries valuation_tax = {} - for tax in self.doclist.get({"parentfield": "other_charges"}): + for tax in self.get("other_charges"): if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount): gl_entries.append( self.get_gl_dict({ @@ -325,7 +323,7 @@ class DocType(BuyingController): # item gl entries stock_item_and_auto_accounting_for_stock = False stock_items = self.get_stock_items() - for item in self.doclist.get({"parentfield": "entries"}): + for item in self.get("entries"): if auto_accounting_for_stock and item.item_code in stock_items: if flt(item.valuation_rate): # if auto inventory accounting enabled and stock item, @@ -404,7 +402,7 @@ class DocType(BuyingController): def update_raw_material_cost(self): if self.sub_contracted_items: - for d in self.doclist.get({"parentfield": "entries"}): + for d in self.get("entries"): rm_cost = frappe.db.sql("""select raw_material_cost / quantity from `tabBOM` where item = %s and is_default = 1 and docstatus = 1 and is_active = 1 """, (d.item_code,)) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index b5942e3ddc..28bd2d183d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -107,7 +107,7 @@ class TestPurchaseInvoice(unittest.TestCase): ["_Test Item Home Desktop 100", 90, 59], ["_Test Item Home Desktop 200", 135, 177] ] - for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})): + for i, item in enumerate(wrapper.get("entries")): self.assertEqual(item.item_code, expected_values[i][0]) self.assertEqual(item.item_tax_amount, expected_values[i][1]) self.assertEqual(item.valuation_rate, expected_values[i][2]) @@ -126,7 +126,7 @@ class TestPurchaseInvoice(unittest.TestCase): ["_Test Account Discount - _TC", 168.03, 1512.30], ] - for i, tax in enumerate(wrapper.doclist.get({"parentfield": "other_charges"})): + for i, tax in enumerate(wrapper.get("other_charges")): self.assertEqual(tax.account_head, expected_values[i][0]) self.assertEqual(tax.tax_amount, expected_values[i][1]) self.assertEqual(tax.total, expected_values[i][2]) @@ -141,7 +141,7 @@ class TestPurchaseInvoice(unittest.TestCase): ["_Test FG Item", 90, 7059], ["_Test Item Home Desktop 200", 135, 177] ] - for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})): + for i, item in enumerate(wrapper.get("entries")): self.assertEqual(item.item_code, expected_values[i][0]) self.assertEqual(item.item_tax_amount, expected_values[i][1]) self.assertEqual(item.valuation_rate, expected_values[i][2]) @@ -160,7 +160,7 @@ class TestPurchaseInvoice(unittest.TestCase): ["_Test Account Discount - _TC", 168.03, 1512.30], ] - for i, tax in enumerate(wrapper.doclist.get({"parentfield": "other_charges"})): + for i, tax in enumerate(wrapper.get("other_charges")): self.assertEqual(tax.account_head, expected_values[i][0]) self.assertEqual(tax.tax_amount, expected_values[i][1]) self.assertEqual(tax.total, expected_values[i][2]) diff --git a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py index 26c87f1c04..9dc3b16878 100644 --- a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py +++ b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseInvoiceAdvance(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py index 26c87f1c04..580d989158 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseInvoiceItem(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py index 26c87f1c04..910e380dcf 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseTaxesAndCharges(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py index eee6e9ac8c..fb9a0ab674 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py @@ -3,15 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe.model.document import Document -from frappe.model import db_exists -from frappe.model.bean import copy_doclist -from frappe.model.code import get_obj - - - - -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist \ No newline at end of file +class PurchaseTaxesAndChargesMaster(Document): + pass diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index a3302c7558..068d82ce85 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -20,27 +20,23 @@ month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12} from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self,d,dl): - self.doc, self.doclist = d, dl - self.log = [] - self.tname = 'Sales Invoice Item' - self.fname = 'entries' - self.status_updater = [{ - 'source_dt': 'Sales Invoice Item', - 'target_field': 'billed_amt', - 'target_ref_field': 'amount', - 'target_dt': 'Sales Order Item', - 'join_field': 'so_detail', - 'target_parent_dt': 'Sales Order', - 'target_parent_field': 'per_billed', - 'source_field': 'amount', - 'join_field': 'so_detail', - 'percent_join_field': 'sales_order', - 'status_field': 'billing_status', - 'keyword': 'Billed' - }] - +class SalesInvoice(SellingController): + tname = 'Sales Invoice Item' + fname = 'entries' + status_updater = [{ + 'source_dt': 'Sales Invoice Item', + 'target_field': 'billed_amt', + 'target_ref_field': 'amount', + 'target_dt': 'Sales Order Item', + 'join_field': 'so_detail', + 'target_parent_dt': 'Sales Order', + 'target_parent_field': 'per_billed', + 'source_field': 'amount', + 'join_field': 'so_detail', + 'percent_join_field': 'sales_order', + 'status_field': 'billing_status', + 'keyword': 'Billed' + }] def validate(self): super(DocType, self).validate() @@ -194,7 +190,7 @@ class DocType(SellingController): self.doc.update_stock = cint(pos.get("update_stock")) # set pos values in items - for item in self.doclist.get({"parentfield": "entries"}): + for item in self.get("entries"): if item.fields.get('item_code'): for fname, val in get_pos_settings_item_details(pos, frappe._dict(item.fields), pos).items(): @@ -207,7 +203,7 @@ class DocType(SellingController): self.doc.terms = frappe.db.get_value("Terms and Conditions", self.doc.tc_name, "terms") # fetch charges - if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})): + if self.doc.charge and not len(self.get("other_charges")): self.set_taxes("other_charges", "taxes_and_charges") def get_advances(self): @@ -226,7 +222,7 @@ class DocType(SellingController): """ lst = [] - for d in getlist(self.doclist, 'advance_adjustment_details'): + for d in self.get('advance_adjustment_details'): if flt(d.allocated_amount) > 0: args = { 'voucher_no' : d.journal_voucher, @@ -262,7 +258,7 @@ class DocType(SellingController): def validate_fixed_asset_account(self): """Validate Fixed Asset and whether Income Account Entered Exists""" - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem` where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())""", d.item_code) @@ -314,7 +310,7 @@ class DocType(SellingController): def set_against_income_account(self): """Set against account for debit to account""" against_acc = [] - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.income_account not in against_acc: against_acc.append(d.income_account) self.doc.against_income_account = ','.join(against_acc) @@ -329,7 +325,7 @@ class DocType(SellingController): dic = {'Sales Order':'so_required','Delivery Note':'dn_required'} for i in dic: if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes': - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \ and not d.fields[i.lower().replace(' ','_')]: msgprint("%s is mandatory for stock item which is not mentioed against item: %s"%(i,d.item_code), raise_exception=1) @@ -356,13 +352,13 @@ class DocType(SellingController): def validate_item_code(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if not d.item_code: msgprint("Please enter Item Code at line no : %s to update stock or remove check from Update Stock in Basic Info Tab." % (d.idx), raise_exception=True) def validate_delivery_note(self): - for d in self.doclist.get({"parentfield": "entries"}): + for d in self.get("entries"): if d.delivery_note: msgprint("""Stock update can not be made against Delivery Note""", raise_exception=1) @@ -381,12 +377,12 @@ class DocType(SellingController): frappe.db.set(self.doc, 'c_form_no', '') def update_current_stock(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.item_code and d.warehouse: bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 - for d in getlist(self.doclist, 'packing_details'): + for d in self.get('packing_details'): bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0 @@ -414,14 +410,14 @@ class DocType(SellingController): if cint(self.doc.is_pos) == 1: w = self.get_warehouse() if w: - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if not d.warehouse: d.warehouse = cstr(w) from erpnext.stock.doctype.packed_item.packed_item import make_packing_list make_packing_list(self, 'entries') else: - self.doclist = self.doc.clear_table(self.doclist, 'packing_details') + self.set('packing_details', []) if cint(self.doc.is_pos) == 1: if flt(self.doc.paid_amount) == 0: @@ -436,7 +432,7 @@ class DocType(SellingController): frappe.db.set(self.doc,'paid_amount',0) def check_prev_docstatus(self): - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if d.sales_order: submitted = frappe.db.sql("""select name from `tabSales Order` where docstatus = 1 and name = %s""", d.sales_order) @@ -510,7 +506,7 @@ class DocType(SellingController): ) def make_tax_gl_entries(self, gl_entries): - for tax in self.doclist.get({"parentfield": "other_charges"}): + for tax in self.get("other_charges"): if flt(tax.tax_amount_after_discount_amount): gl_entries.append( self.get_gl_dict({ @@ -524,7 +520,7 @@ class DocType(SellingController): def make_item_gl_entries(self, gl_entries): # income account gl entries - for item in self.doclist.get({"parentfield": "entries"}): + for item in self.get("entries"): if flt(item.base_amount): gl_entries.append( self.get_gl_dict({ diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 81d55722f9..a4a1f7ba79 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -54,11 +54,11 @@ class TestSalesInvoice(unittest.TestCase): } # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) @@ -79,7 +79,7 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account Discount - _TC": [-180.78, 1627.05] } - for d in si.doclist.get({"parentfield": "other_charges"}): + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) @@ -104,11 +104,11 @@ class TestSalesInvoice(unittest.TestCase): } # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) @@ -129,7 +129,7 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account Discount - _TC": [-180.78, 1627.05] } - for d in si.doclist.get({"parentfield": "other_charges"}): + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) @@ -160,11 +160,11 @@ class TestSalesInvoice(unittest.TestCase): } # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) @@ -186,7 +186,7 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account Service Tax - _TC": [-18.03, -16.88, 1500] } - for d in si.doclist.get({"parentfield": "other_charges"}): + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) @@ -245,7 +245,7 @@ class TestSalesInvoice(unittest.TestCase): def test_inclusive_rate_validations(self): si = frappe.bean(copy=test_records[2]) - for i, tax in enumerate(si.doclist.get({"parentfield": "other_charges"})): + for i, tax in enumerate(si.get("other_charges")): tax.idx = i+1 si.doclist[1].price_list_rate = 62.5 @@ -273,11 +273,11 @@ class TestSalesInvoice(unittest.TestCase): } # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) @@ -298,7 +298,7 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account Discount - _TC": [-180.33, 1622.98] } - for d in si.doclist.get({"parentfield": "other_charges"}): + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) @@ -326,11 +326,11 @@ class TestSalesInvoice(unittest.TestCase): } # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) @@ -351,7 +351,7 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account Discount - _TC": [-7245.01, 65205.16] } - for d in si.doclist.get({"parentfield": "other_charges"}): + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) diff --git a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py index 26c87f1c04..683ca8a00a 100644 --- a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py +++ b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesInvoiceAdvance(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index 26c87f1c04..3fa0f2e0e5 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesInvoiceItem(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py index 26c87f1c04..8f621de86d 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesTaxesAndCharges(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py index 047bbd4f11..0546ce721b 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py @@ -6,7 +6,7 @@ import frappe from frappe.utils import cint from frappe.model.controller import DocListController -class DocType(DocListController): +class SalesTaxesAndChargesMaster(DocListController): def validate(self): if self.doc.is_default == 1: frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0 diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py index fe5d7f9010..e450e70a23 100644 --- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py @@ -14,13 +14,11 @@ class OverlappingConditionError(frappe.ValidationError): pass class FromGreaterThanToError(frappe.ValidationError): pass class ManyBlankToValuesError(frappe.ValidationError): pass -class DocType(DocListController): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class ShippingRule(DocListController): def validate(self): self.validate_value("calculate_based_on", "in", ["Net Total", "Net Weight"]) - self.shipping_rule_conditions = self.doclist.get({"parentfield": "shipping_rule_conditions"}) + self.shipping_rule_conditions = self.get("shipping_rule_conditions") self.validate_from_to_values() self.sort_shipping_rule_conditions() self.validate_overlapping_shipping_rule_conditions() diff --git a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py index 968a25b613..76d0a57b69 100644 --- a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py +++ b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ShippingRuleCondition(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 1b00efce0a..3805ec3468 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import nowdate, cstr, flt, now, getdate, add_months -from frappe.model.doc import addchild from frappe import msgprint, throw, _ from frappe.utils import formatdate from erpnext.utilities import build_filter_conditions @@ -182,7 +181,7 @@ def update_against_doc(d, jv_obj): jvd = frappe.db.sql("""select cost_center, balance, against_account, is_advance from `tabJournal Voucher Detail` where name = %s""", d['voucher_detail_no']) # new entry with balance amount - ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail') + ch = jv_obj.append("entries") ch.account = d['account'] ch.cost_center = cstr(jvd[0][0]) ch.balance = cstr(jvd[0][1]) diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.py b/erpnext/buying/doctype/buying_settings/buying_settings.py index 9776fda99c..1f63798ed9 100644 --- a/erpnext/buying/doctype/buying_settings/buying_settings.py +++ b/erpnext/buying/doctype/buying_settings/buying_settings.py @@ -6,9 +6,9 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class BuyingSettings(Document): def validate(self): for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]: diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py index 3fefeba915..8ae364906c 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.py +++ b/erpnext/buying/doctype/purchase_common/purchase_common.py @@ -11,10 +11,7 @@ from frappe import msgprint, _ from erpnext.stock.doctype.item.item import get_last_purchase_details from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist +class PurchaseCommon(BuyingController): def update_last_purchase_rate(self, obj, is_submit): """updates last_purchase_rate in item table for each item""" diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index fca61e3632..587256ee89 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -11,10 +11,7 @@ from frappe import msgprint from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class PurchaseOrder(BuyingController): self.tname = 'Purchase Order Item' self.fname = 'po_details' self.status_updater = [{ @@ -65,7 +62,7 @@ class DocType(BuyingController): }) def get_schedule_dates(self): - for d in getlist(self.doclist, 'po_details'): + for d in self.get('po_details'): if d.prevdoc_detail_docname and not d.schedule_date: d.schedule_date = frappe.db.get_value("Material Request Item", d.prevdoc_detail_docname, "schedule_date") @@ -76,7 +73,7 @@ class DocType(BuyingController): # Check for Stopped status def check_for_stopped_status(self, pc_obj): check_list =[] - for d in getlist(self.doclist, 'po_details'): + for d in self.get('po_details'): if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: check_list.append(d.prevdoc_docname) pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname) @@ -85,7 +82,7 @@ class DocType(BuyingController): def update_bin(self, is_submit, is_stopped = 0): from erpnext.stock.utils import update_bin pc_obj = get_obj('Purchase Common') - for d in getlist(self.doclist, 'po_details'): + for d in self.get('po_details'): #1. Check if is_stock_item == 'Yes' if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes": # this happens when item is changed from non-stock to stock item diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index d58ce17bea..d0df0df068 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -95,7 +95,7 @@ class TestPurchaseOrder(unittest.TestCase): def test_subcontracting(self): po = frappe.bean(copy=test_records[0]) po.insert() - self.assertEquals(len(po.doclist.get({"parentfield": "po_raw_material_details"})), 2) + self.assertEquals(len(po.get("po_raw_material_details")), 2) def test_warehouse_company_validation(self): from erpnext.stock.utils import InvalidWarehouseCompany diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py index 26c87f1c04..8c7c0a8a47 100644 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseOrderItem(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py index 26c87f1c04..d1542fc7a6 100644 --- a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py +++ b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseOrderItemSupplied(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py index 26c87f1c04..1270cf0e74 100644 --- a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py +++ b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseReceiptItemSupplied(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.py b/erpnext/buying/doctype/quality_inspection/quality_inspection.py index 4222d68b49..4e289dcfcc 100644 --- a/erpnext/buying/doctype/quality_inspection/quality_inspection.py +++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.py @@ -4,19 +4,17 @@ from __future__ import unicode_literals import frappe -from frappe.model.doc import addchild -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class QualityInspection(Document): def get_item_specification_details(self): - self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details') + self.set('qa_specification_details', []) specification = frappe.db.sql("select specification, value from `tabItem Quality Inspection Parameter` \ where parent = '%s' order by idx" % (self.doc.item_code)) for d in specification: - child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist) + child = self.doc.append('qa_specification_details', {}) child.specification = d[0] child.value = d[1] child.status = 'Accepted' diff --git a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py index 26c87f1c04..1e36103dd0 100644 --- a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py +++ b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class QualityInspectionReading(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index f937958eda..44dcd5fd28 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -12,10 +12,7 @@ from erpnext.accounts.party import create_party_account from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class Supplier(TransactionBase): def autoname(self): supp_master_name = frappe.defaults.get_global_default('supp_master_name') diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index f6a3ffc516..edebfb3015 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -6,7 +6,7 @@ import frappe from frappe.model.code import get_obj from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): +class SupplierQuotation(BuyingController): def __init__(self, doc, doclist=None): self.doc, self.doclist = doc, doclist or [] self.tname, self.fname = "Supplier Quotation Item", "quotation_items" diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py index 26c87f1c04..16e6e126eb 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SupplierQuotationItem(Document): + pass \ No newline at end of file diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 7ad5d86c62..35234ce568 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -87,7 +87,7 @@ class AccountsController(TransactionBase): def set_missing_item_details(self): """set missing item values""" from erpnext.stock.get_item_details import get_item_details - for item in self.doclist.get({"parentfield": self.fname}): + for item in self.get(self.fname): if item.fields.get("item_code"): args = item.fields.copy() args.update(self.doc.fields) @@ -103,7 +103,7 @@ class AccountsController(TransactionBase): tax_master_doctype = self.meta.get_field(tax_master_field).options - if not self.doclist.get({"parentfield": tax_parentfield}): + if not self.get(tax_parentfield): if not self.doc.fields.get(tax_master_field): # get the default tax master self.doc.fields[tax_master_field] = \ @@ -134,7 +134,7 @@ class AccountsController(TransactionBase): self.doclist.append(tax) def get_other_charges(self): - self.doclist = self.doc.clear_table(self.doclist, "other_charges") + self.set("other_charges", []) self.set_taxes("other_charges", "taxes_and_charges") def calculate_taxes_and_totals(self): @@ -156,8 +156,8 @@ class AccountsController(TransactionBase): self.meta.get_label("conversion_rate"), self.doc.company) self.doc.conversion_rate = flt(self.doc.conversion_rate) - self.item_doclist = self.doclist.get({"parentfield": self.fname}) - self.tax_doclist = self.doclist.get({"parentfield": self.other_fname}) + self.item_doclist = self.get(self.fname) + self.tax_doclist = self.get(self.other_fname) self.calculate_item_values() self.initialize_taxes() @@ -368,7 +368,7 @@ class AccountsController(TransactionBase): def calculate_total_advance(self, parenttype, advance_parentfield): if self.doc.doctype == parenttype and self.doc.docstatus < 2: sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv)) - for adv in self.doclist.get({"parentfield": advance_parentfield})]) + for adv in self.get(advance_parentfield)]) self.doc.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance")) @@ -408,7 +408,7 @@ class AccountsController(TransactionBase): and t1.docstatus = 1 order by t1.posting_date""" % (dr_or_cr, '%s'), account_head, as_dict=1) - self.doclist = self.doc.clear_table(self.doclist, parentfield) + self.set(parentfield, []) for d in res: self.doclist.append({ "doctype": child_doctype, @@ -425,7 +425,7 @@ class AccountsController(TransactionBase): item_tolerance = {} global_tolerance = None - for item in self.doclist.get({"parentfield": "entries"}): + for item in self.get("entries"): if item.fields.get(item_ref_dn): ref_amt = flt(frappe.db.get_value(ref_dt + " Item", item.fields[item_ref_dn], based_on), self.precision(based_on, item)) @@ -467,7 +467,7 @@ class AccountsController(TransactionBase): def get_stock_items(self): stock_items = [] item_codes = list(set(item.item_code for item in - self.doclist.get({"parentfield": self.fname}))) + self.get(self.fname))) if item_codes: stock_items = [r[0] for r in frappe.db.sql("""select name from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \ diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 4ca6c195b4..655b101a12 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -58,7 +58,7 @@ class BuyingController(StockController): def validate_stock_or_nonstock_items(self): if not self.get_stock_items(): tax_for_valuation = [d.account_head for d in - self.doclist.get({"parentfield": "other_charges"}) + self.get("other_charges") if d.category in ["Valuation", "Valuation and Total"]] if tax_for_valuation: frappe.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"""), raise_exception=1) @@ -171,19 +171,19 @@ class BuyingController(StockController): stock_items_qty, stock_items_amount = 0, 0 last_stock_item_idx = 1 - for d in self.doclist.get({"parentfield": parentfield}): + for d in self.get(parentfield): if d.item_code and d.item_code in stock_items: stock_items_qty += flt(d.qty) stock_items_amount += flt(d.base_amount) last_stock_item_idx = d.idx total_valuation_amount = sum([flt(d.tax_amount) for d in - self.doclist.get({"parentfield": "other_charges"}) + self.get("other_charges") if d.category in ["Valuation", "Valuation and Total"]]) valuation_amount_adjustment = total_valuation_amount - for i, item in enumerate(self.doclist.get({"parentfield": parentfield})): + for i, item in enumerate(self.get(parentfield)): if item.item_code and item.qty and item.item_code in stock_items: item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \ else flt(item.qty) / stock_items_qty @@ -218,9 +218,9 @@ class BuyingController(StockController): raise_exception=1) def update_raw_materials_supplied(self, raw_material_table): - self.doclist = self.doc.clear_table(self.doclist, raw_material_table) + self.set(raw_material_table, []) if self.doc.is_subcontracted=="Yes": - for item in self.doclist.get({"parentfield": self.fname}): + for item in self.get(self.fname): if item.item_code in self.sub_contracted_items: self.add_bom_items(item, raw_material_table) @@ -271,7 +271,7 @@ class BuyingController(StockController): if not hasattr(self, "_sub_contracted_items"): self._sub_contracted_items = [] item_codes = list(set(item.item_code for item in - self.doclist.get({"parentfield": self.fname}))) + self.get(self.fname))) if item_codes: self._sub_contracted_items = [r[0] for r in frappe.db.sql("""select name from `tabItem` where name in (%s) and is_sub_contracted_item='Yes'""" % \ @@ -284,7 +284,7 @@ class BuyingController(StockController): if not hasattr(self, "_purchase_items"): self._purchase_items = [] item_codes = list(set(item.item_code for item in - self.doclist.get({"parentfield": self.fname}))) + self.get(self.fname))) if item_codes: self._purchase_items = [r[0] for r in frappe.db.sql("""select name from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \ @@ -294,5 +294,5 @@ class BuyingController(StockController): def is_item_table_empty(self): - if not len(self.doclist.get({"parentfield": self.fname})): + if not len(self.get(self.fname)): frappe.throw(_("Item table can not be blank")) \ No newline at end of file diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index f58366830c..5e0ea659f5 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -54,7 +54,7 @@ class SellingController(StockController): # shipping rule calculation based on item's net weight shipping_amount = 0.0 - for condition in shipping_rule.doclist.get({"parentfield": "shipping_rule_conditions"}): + for condition in shipping_rule.get("shipping_rule_conditions"): if not condition.to_value or (flt(condition.from_value) <= value <= flt(condition.to_value)): shipping_amount = condition.shipping_amount break @@ -242,7 +242,7 @@ class SellingController(StockController): def calculate_contribution(self): total = 0.0 - sales_team = self.doclist.get({"parentfield": "sales_team"}) + sales_team = self.get("sales_team") for sales_person in sales_team: self.round_floats_in(sales_person) @@ -279,7 +279,7 @@ class SellingController(StockController): outstanding_including_current) def validate_max_discount(self): - for d in self.doclist.get({"parentfield": self.fname}): + for d in self.get(self.fname): discount = flt(frappe.db.get_value("Item", d.item_code, "max_discount")) if discount and flt(d.discount_percentage) > discount: @@ -288,7 +288,7 @@ class SellingController(StockController): def get_item_list(self): il = [] - for d in self.doclist.get({"parentfield": self.fname}): + for d in self.get(self.fname): reserved_warehouse = "" reserved_qty_for_main_item = 0 @@ -315,7 +315,7 @@ class SellingController(StockController): reserved_qty_for_main_item = -flt(d.qty) if self.has_sales_bom(d.item_code): - for p in self.doclist.get({"parentfield": "packing_details"}): + for p in self.get("packing_details"): if p.parent_detail_docname == d.name and p.parent_item == d.item_code: # the packing details table's qty is already multiplied with parent's qty il.append(frappe._dict({ @@ -362,7 +362,7 @@ class SellingController(StockController): return so_qty, so_warehouse def check_stop_sales_order(self, ref_fieldname): - for d in self.doclist.get({"parentfield": self.fname}): + for d in self.get(self.fname): if d.fields.get(ref_fieldname): status = frappe.db.get_value("Sales Order", d.fields[ref_fieldname], "status") if status == "Stopped": diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 7411d092e2..30bc02ec23 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -240,7 +240,7 @@ class StatusUpdater(DocListController): all_zero_amount_refdoc = frappe.db.sql_list("""select name from `tab%s` where docstatus=1 and net_total = 0""" % ref_dt) - for item in self.doclist.get({"parentfield": "entries"}): + for item in self.get("entries"): if item.fields.get(ref_fieldname) \ and item.fields.get(ref_fieldname) in all_zero_amount_refdoc \ and item.fields.get(ref_fieldname) not in zero_amount_refdoc: diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 2481868abf..d87a88c331 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -70,7 +70,7 @@ class StockController(AccountsController): def get_voucher_details(self, stock_ledger, default_expense_account, default_cost_center): if not default_expense_account: - details = self.doclist.get({"parentfield": self.fname}) + details = self.get(self.fname) for d in details: self.check_expense_account(d) else: @@ -129,7 +129,7 @@ class StockController(AccountsController): future_stock_vouchers = [] if hasattr(self, "fname"): - item_list = [d.item_code for d in self.doclist.get({"parentfield": self.fname})] + item_list = [d.item_code for d in self.get(self.fname)] condition = ''.join(['and item_code in (\'', '\', \''.join(item_list) ,'\')']) else: condition = "" @@ -256,8 +256,8 @@ class StockController(AccountsController): def get_distinct_item_warehouse(self): item_list = [] warehouse_list = [] - for item in self.doclist.get({"parentfield": self.fname}) \ - + self.doclist.get({"parentfield": "packing_details"}): + for item in self.get(self.fname) \ + + self.get("packing_details"): item_list.append(item.item_code) warehouse_list.append(item.warehouse) diff --git a/erpnext/home/doctype/feed/feed.py b/erpnext/home/doctype/feed/feed.py index 0a12d26f8a..45d8ea1ac4 100644 --- a/erpnext/home/doctype/feed/feed.py +++ b/erpnext/home/doctype/feed/feed.py @@ -4,15 +4,10 @@ from __future__ import unicode_literals import frappe -from frappe.model import db_exists -from frappe.model.bean import copy_doclist +from frappe.model.document import Document - - - -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d, dl +class Feed(Document): + pass def on_doctype_update(): if not frappe.db.sql("""show index from `tabFeed` diff --git a/erpnext/hr/doctype/appraisal/appraisal.py b/erpnext/hr/doctype/appraisal/appraisal.py index 8abeab8dc6..761e38595c 100644 --- a/erpnext/hr/doctype/appraisal/appraisal.py +++ b/erpnext/hr/doctype/appraisal/appraisal.py @@ -8,10 +8,9 @@ from frappe.utils import cstr, flt, getdate from frappe.model.bean import getlist from frappe import msgprint -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Appraisal(Document): def validate(self): if not self.doc.status: @@ -45,7 +44,7 @@ class DocType: def calculate_total(self): total, total_w = 0, 0 - for d in getlist(self.doclist, 'appraisal_details'): + for d in self.get('appraisal_details'): if d.score: d.score_earned = flt(d.score) * flt(d.per_weightage) / 100 total = total + d.score_earned diff --git a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py index 26c87f1c04..c13c42bd03 100644 --- a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py +++ b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class AppraisalGoal(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_template/appraisal_template.py b/erpnext/hr/doctype/appraisal_template/appraisal_template.py index 0f78a4a76a..e4fba2cd47 100644 --- a/erpnext/hr/doctype/appraisal_template/appraisal_template.py +++ b/erpnext/hr/doctype/appraisal_template/appraisal_template.py @@ -5,9 +5,9 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class AppraisalTemplate(Document): def validate(self): self.doc.total_points = 0 diff --git a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py index 26c87f1c04..0cdd921e05 100644 --- a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py +++ b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class AppraisalTemplateGoal(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py index 9abef7677e..42cb7b0379 100644 --- a/erpnext/hr/doctype/attendance/attendance.py +++ b/erpnext/hr/doctype/attendance/attendance.py @@ -8,10 +8,9 @@ from frappe.utils import getdate, nowdate from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Attendance(Document): def validate_duplicate_record(self): res = frappe.db.sql("""select name from `tabAttendance` where employee = %s and att_date = %s diff --git a/erpnext/hr/doctype/branch/branch.py b/erpnext/hr/doctype/branch/branch.py index 58ecbe8902..f5dbe18e47 100644 --- a/erpnext/hr/doctype/branch/branch.py +++ b/erpnext/hr/doctype/branch/branch.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +from frappe.model.document import Document + +class Branch(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/deduction_type/deduction_type.py b/erpnext/hr/doctype/deduction_type/deduction_type.py index 26c87f1c04..c18f5692bb 100644 --- a/erpnext/hr/doctype/deduction_type/deduction_type.py +++ b/erpnext/hr/doctype/deduction_type/deduction_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class DeductionType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/department/department.py b/erpnext/hr/doctype/department/department.py index 5015bed79c..bf154914d7 100644 --- a/erpnext/hr/doctype/department/department.py +++ b/erpnext/hr/doctype/department/department.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class Department(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/designation/designation.py b/erpnext/hr/doctype/designation/designation.py index 58ecbe8902..fb530478c3 100644 --- a/erpnext/hr/doctype/designation/designation.py +++ b/erpnext/hr/doctype/designation/designation.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +from frappe.model.document import Document + +class Designation(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/earning_type/earning_type.py b/erpnext/hr/doctype/earning_type/earning_type.py index 26c87f1c04..8f7450ef33 100644 --- a/erpnext/hr/doctype/earning_type/earning_type.py +++ b/erpnext/hr/doctype/earning_type/earning_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EarningType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index 3ec44e66d2..aacb2aa44b 100644 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -11,7 +11,7 @@ import frappe.permissions from frappe.defaults import get_restrictions from frappe.model.controller import DocListController -class DocType(DocListController): +class Employee(DocListController): def autoname(self): naming_method = frappe.db.get_value("HR Settings", None, "emp_created_by") if not naming_method: @@ -57,7 +57,7 @@ class DocType(DocListController): def restrict_leave_approver(self): """restrict to this employee for leave approver""" - employee_leave_approvers = [d.leave_approver for d in self.doclist.get({"parentfield": "employee_leave_approvers"})] + employee_leave_approvers = [d.leave_approver for d in self.get("employee_leave_approvers")] if self.doc.reports_to and self.doc.reports_to not in employee_leave_approvers: employee_leave_approvers.append(frappe.db.get_value("Employee", self.doc.reports_to, "user_id")) @@ -167,7 +167,7 @@ class DocType(DocListController): from frappe.utils.user import User from erpnext.hr.doctype.leave_application.leave_application import InvalidLeaveApproverError - for l in self.doclist.get({"parentfield": "employee_leave_approvers"}): + for l in self.get("employee_leave_approvers"): if "Leave Approver" not in User(l.leave_approver).get_roles(): throw(_("Invalid Leave Approver") + ": \"" + l.leave_approver + "\"", exc=InvalidLeaveApproverError) diff --git a/erpnext/hr/doctype/employee_education/employee_education.py b/erpnext/hr/doctype/employee_education/employee_education.py index 26c87f1c04..2cc0f26037 100644 --- a/erpnext/hr/doctype/employee_education/employee_education.py +++ b/erpnext/hr/doctype/employee_education/employee_education.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EmployeeEducation(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py index 26c87f1c04..a99e4de8c2 100644 --- a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py +++ b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EmployeeExternalWorkHistory(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py index 26c87f1c04..65dfa44a6a 100644 --- a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py +++ b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EmployeeInternalWorkHistory(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py index 968a25b613..8736c4fe77 100644 --- a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py +++ b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EmployeeLeaveApprover(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employment_type/employment_type.py b/erpnext/hr/doctype/employment_type/employment_type.py index 5015bed79c..87a8634d66 100644 --- a/erpnext/hr/doctype/employment_type/employment_type.py +++ b/erpnext/hr/doctype/employment_type/employment_type.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class EmploymentType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py index 0fbfde5c3a..1d02e87b3a 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/expense_claim.py @@ -7,10 +7,9 @@ import frappe from frappe.model.bean import getlist from frappe import msgprint -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class ExpenseClaim(Document): def validate(self): self.validate_fiscal_year() @@ -26,6 +25,6 @@ class DocType: validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, "Posting Date") def validate_exp_details(self): - if not getlist(self.doclist, 'expense_voucher_details'): + if not self.get('expense_voucher_details'): msgprint("Please add expense voucher details") raise Exception diff --git a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.py b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.py index 26c87f1c04..fe6cb1ef22 100644 --- a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.py +++ b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ExpenseClaimDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.py b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.py index 26c87f1c04..bc0db7fc51 100644 --- a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.py +++ b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ExpenseClaimType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/grade/grade.py b/erpnext/hr/doctype/grade/grade.py index 58ecbe8902..04e3e97ed7 100644 --- a/erpnext/hr/doctype/grade/grade.py +++ b/erpnext/hr/doctype/grade/grade.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +from frappe.model.document import Document + +class Grade(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/holiday/holiday.py b/erpnext/hr/doctype/holiday/holiday.py index 26c87f1c04..2e64a10557 100644 --- a/erpnext/hr/doctype/holiday/holiday.py +++ b/erpnext/hr/doctype/holiday/holiday.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class Holiday(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/holiday_list/holiday_list.py b/erpnext/hr/doctype/holiday_list/holiday_list.py index 8fdfccc3ed..c0f1b1b83e 100644 --- a/erpnext/hr/doctype/holiday_list/holiday_list.py +++ b/erpnext/hr/doctype/holiday_list/holiday_list.py @@ -5,17 +5,13 @@ from __future__ import unicode_literals import frappe from frappe.utils import add_days, add_years, cint, getdate -from frappe.model import db_exists -from frappe.model.doc import addchild, make_autoname -from frappe.model.bean import copy_doclist +from frappe.model.doc import make_autoname from frappe import msgprint, throw, _ import datetime -class DocType: - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document +class HolidayList(Document): def autoname(self): self.doc.name = make_autoname(self.doc.fiscal_year + "/" + self.doc.holiday_list_name + "/.###") @@ -29,7 +25,7 @@ class DocType: last_idx = max([cint(d.idx) for d in self.doclist.get( {"parentfield": "holiday_list_details"})] or [0,]) for i, d in enumerate(date_list): - ch = addchild(self.doc, 'holiday_list_details', 'Holiday', self.doclist) + ch = self.doc.append('holiday_list_details', {}) ch.description = self.doc.weekly_off ch.holiday_date = d ch.idx = last_idx + i + 1 @@ -63,7 +59,7 @@ class DocType: return date_list def clear_table(self): - self.doclist = self.doc.clear_table(self.doclist, 'holiday_list_details') + self.set('holiday_list_details', []) def update_default_holiday_list(self): frappe.db.sql("""update `tabHoliday List` set is_default = 0 diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.py b/erpnext/hr/doctype/hr_settings/hr_settings.py index e9e44d4fea..6d5f8e07f3 100644 --- a/erpnext/hr/doctype/hr_settings/hr_settings.py +++ b/erpnext/hr/doctype/hr_settings/hr_settings.py @@ -8,9 +8,9 @@ import frappe from frappe.utils import cint -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class HrSettings(Document): def validate(self): self.update_birthday_reminders() diff --git a/erpnext/hr/doctype/job_applicant/job_applicant.py b/erpnext/hr/doctype/job_applicant/job_applicant.py index 41fc5f3b45..364030498a 100644 --- a/erpnext/hr/doctype/job_applicant/job_applicant.py +++ b/erpnext/hr/doctype/job_applicant/job_applicant.py @@ -8,9 +8,7 @@ import frappe from erpnext.utilities.transaction_base import TransactionBase from frappe.utils import extract_email_id -class DocType(TransactionBase): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class JobApplicant(TransactionBase): def get_sender(self, comm): return frappe.db.get_value('Jobs Email Settings',None,'email_id') diff --git a/erpnext/hr/doctype/job_opening/job_opening.py b/erpnext/hr/doctype/job_opening/job_opening.py index 968a25b613..4224207027 100644 --- a/erpnext/hr/doctype/job_opening/job_opening.py +++ b/erpnext/hr/doctype/job_opening/job_opening.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class JobOpening(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py index 7648ba5b6b..a78dc1a530 100755 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py @@ -6,7 +6,9 @@ import frappe from frappe.utils import cint, flt from frappe import msgprint -class DocType: +from frappe.model.document import Document + +class LeaveAllocation(Document): def __init__(self, doc, doclist): self.doc, self.doclist = doc, doclist diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 1630e1485e..03045a4c31 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -15,7 +15,7 @@ class InvalidLeaveApproverError(frappe.ValidationError): pass class LeaveApproverIdentityError(frappe.ValidationError): pass from frappe.model.controller import DocListController -class DocType(DocListController): +class LeaveApplication(DocListController): def setup(self): if frappe.db.exists(self.doc.doctype, self.doc.name): self.previous_doc = frappe.doc(self.doc.doctype, self.doc.name) @@ -149,7 +149,7 @@ class DocType(DocListController): def validate_leave_approver(self): employee = frappe.bean("Employee", self.doc.employee) leave_approvers = [l.leave_approver for l in - employee.doclist.get({"parentfield": "employee_leave_approvers"})] + employee.get("employee_leave_approvers")] if len(leave_approvers) and self.doc.leave_approver not in leave_approvers: msgprint(("[" + _("For Employee") + ' "' + self.doc.employee + '"] ' diff --git a/erpnext/hr/doctype/leave_block_list/leave_block_list.py b/erpnext/hr/doctype/leave_block_list/leave_block_list.py index cdbb2d0375..e1cbf1bfaf 100644 --- a/erpnext/hr/doctype/leave_block_list/leave_block_list.py +++ b/erpnext/hr/doctype/leave_block_list/leave_block_list.py @@ -8,9 +8,9 @@ import frappe from erpnext.accounts.utils import validate_fiscal_year from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class LeaveBlockList(Document): def validate(self): dates = [] diff --git a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py index 968a25b613..684e178d5b 100644 --- a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py +++ b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class LeaveBlockListAllow(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py index 968a25b613..3db479841e 100644 --- a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py +++ b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class LeaveBlockListDate(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py index 001d0d5848..f3aace2e5c 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py @@ -12,7 +12,9 @@ from frappe import msgprint, _ -class DocType: +from frappe.model.document import Document + +class LeaveControlPanel(Document): def __init__(self, doc, doclist): self.doc = doc self.doclist = doclist diff --git a/erpnext/hr/doctype/leave_type/leave_type.py b/erpnext/hr/doctype/leave_type/leave_type.py index 5015bed79c..426bc73ca5 100644 --- a/erpnext/hr/doctype/leave_type/leave_type.py +++ b/erpnext/hr/doctype/leave_type/leave_type.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class LeaveType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.py b/erpnext/hr/doctype/salary_manager/salary_manager.py index 0420f77409..d0af7beaed 100644 --- a/erpnext/hr/doctype/salary_manager/salary_manager.py +++ b/erpnext/hr/doctype/salary_manager/salary_manager.py @@ -7,10 +7,9 @@ from frappe.utils import cint, flt from frappe.model.code import get_obj from frappe import msgprint -class DocType: - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class SalaryManager(Document): def get_emp_list(self): """ diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index a264c1c2d5..a7c4f8df16 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -14,11 +14,7 @@ from erpnext.setup.utils import get_company_currency from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist - +class SalarySlip(TransactionBase): def autoname(self): self.doc.name = make_autoname('Sal Slip/' +self.doc.employee + '/.#####') @@ -146,8 +142,8 @@ class DocType(TransactionBase): from frappe.utils import money_in_words self.check_existing() - if not (len(self.doclist.get({"parentfield": "earning_details"})) or - len(self.doclist.get({"parentfield": "deduction_details"}))): + if not (len(self.get("earning_details")) or + len(self.get("deduction_details"))): self.get_emp_and_leave_details() else: self.get_leave_details(self.doc.leave_without_pay) @@ -160,7 +156,7 @@ class DocType(TransactionBase): def calculate_earning_total(self): self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount) - for d in self.doclist.get({"parentfield": "earning_details"}): + for d in self.get("earning_details"): if cint(d.e_depends_on_lwp) == 1: d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days) / cint(self.doc.total_days_in_month), 2) @@ -172,7 +168,7 @@ class DocType(TransactionBase): def calculate_ded_total(self): self.doc.total_deduction = 0 - for d in getlist(self.doclist, 'deduction_details'): + for d in self.get('deduction_details'): if cint(d.d_depends_on_lwp) == 1: d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days) / cint(self.doc.total_days_in_month), 2) diff --git a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py index 26c87f1c04..422ee28338 100644 --- a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py +++ b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalarySlipDeduction(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py index 26c87f1c04..c4a7b4e2e2 100644 --- a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py +++ b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalarySlipEarning(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index 8d59f2b926..ae103945fc 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -5,15 +5,13 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt -from frappe.model.doc import addchild, make_autoname +from frappe.model.doc import make_autoname from frappe import msgprint, _ -class DocType: - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document +class SalaryStructure(Document): def autoname(self): self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####') @@ -44,7 +42,7 @@ class DocType: def make_table(self, doct_name, tab_fname, tab_name): list1 = frappe.db.sql("select name from `tab%s` where docstatus != 2" % doct_name) for li in list1: - child = addchild(self.doc, tab_fname, tab_name, self.doclist) + child = self.doc.append(tab_fname, {}) if(tab_fname == 'earning_details'): child.e_type = cstr(li[0]) child.modified_value = 0 diff --git a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py index 26c87f1c04..95300e15e1 100644 --- a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py +++ b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalaryStructureDeduction(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py index 26c87f1c04..79f7972f81 100644 --- a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py +++ b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalaryStructureEarning(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py index 3da10786fe..844806ecb7 100644 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py @@ -8,14 +8,13 @@ import frappe from frappe.utils import cstr, add_days, date_diff from frappe import msgprint, _ from frappe.utils.datautils import UnicodeWriter +from frappe.model.document import Document # doclist = None doclist = frappe.local('uploadattendance_doclist') -class DocType(): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class UploadAttendance(Document): + pass @frappe.whitelist() def get_template(): diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 2c6d642bdf..bd5642ee6b 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -4,17 +4,15 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, flt, now, nowdate -from frappe.model.doc import addchild from frappe.model.bean import getlist from frappe.model.code import get_obj from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Bom(Document): def autoname(self): last_name = frappe.db.sql("""select max(name) from `tabBOM` @@ -75,7 +73,7 @@ class DocType: msgprint("Item %s does not exist in system" % item[0]['item_code'], raise_exception = 1) def set_bom_material_details(self): - for item in self.doclist.get({"parentfield": "bom_materials"}): + for item in self.get("bom_materials"): ret = self.get_bom_material_detail({"item_code": item.item_code, "bom_no": item.bom_no, "qty": item.qty}) @@ -128,7 +126,7 @@ class DocType: return rate def update_cost(self): - for d in self.doclist.get({"parentfield": "bom_materials"}): + for d in self.get("bom_materials"): d.rate = self.get_bom_material_detail({ 'item_code': d.item_code, 'bom_no': d.bom_no, @@ -188,8 +186,8 @@ class DocType: def clear_operations(self): if not self.doc.with_operations: - self.doclist = self.doc.clear_table(self.doclist, 'bom_operations') - for d in self.doclist.get({"parentfield": "bom_materials"}): + self.set('bom_operations', []) + for d in self.get("bom_materials"): d.operation_no = None def validate_main_item(self): @@ -210,7 +208,7 @@ class DocType: def validate_operations(self): """ Check duplicate operation no""" self.op = [] - for d in getlist(self.doclist, 'bom_operations'): + for d in self.get('bom_operations'): if cstr(d.operation_no) in self.op: msgprint("Operation no: %s is repeated in Operations Table" % d.operation_no, raise_exception=1) @@ -221,7 +219,7 @@ class DocType: def validate_materials(self): """ Validate raw material entries """ check_list = [] - for m in getlist(self.doclist, 'bom_materials'): + for m in self.get('bom_materials'): # check if operation no not in op table if self.doc.with_operations and cstr(m.operation_no) not in self.op: msgprint("""Operation no: %s against item: %s at row no: %s \ @@ -315,7 +313,7 @@ class DocType: def calculate_op_cost(self): """Update workstation rate and calculates totals""" total_op_cost = 0 - for d in getlist(self.doclist, 'bom_operations'): + for d in self.get('bom_operations'): if d.workstation and not d.hour_rate: d.hour_rate = frappe.db.get_value("Workstation", d.workstation, "hour_rate") if d.hour_rate and d.time_in_mins: @@ -326,7 +324,7 @@ class DocType: def calculate_rm_cost(self): """Fetch RM rate as per today's valuation rate and calculate totals""" total_rm_cost = 0 - for d in getlist(self.doclist, 'bom_materials'): + for d in self.get('bom_materials'): if d.bom_no: d.rate = self.get_bom_unitcost(d.bom_no) d.amount = flt(d.rate) * flt(d.qty) @@ -343,7 +341,7 @@ class DocType: def get_exploded_items(self): """ Get all raw materials including items from child bom""" self.cur_exploded_items = {} - for d in getlist(self.doclist, 'bom_materials'): + for d in self.get('bom_materials'): if d.bom_no: self.get_child_exploded_items(d.bom_no, d.qty) else: @@ -379,9 +377,9 @@ class DocType: def add_exploded_items(self): "Add items to Flat BOM table" - self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1) + self.set('flat_bom_details', []) for d in self.cur_exploded_items: - ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', self.doclist) + ch = self.doc.append('flat_bom_details', {}) for i in self.cur_exploded_items[d].keys(): ch.fields[i] = self.cur_exploded_items[d][i] ch.amount = flt(ch.qty) * flt(ch.rate) diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py index 26c87f1c04..bd1b1af43f 100644 --- a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py +++ b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BomExplosionItem(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.py b/erpnext/manufacturing/doctype/bom_item/bom_item.py index 26c87f1c04..f2bef2c7c4 100644 --- a/erpnext/manufacturing/doctype/bom_item/bom_item.py +++ b/erpnext/manufacturing/doctype/bom_item/bom_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BomItem(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_operation/bom_operation.py b/erpnext/manufacturing/doctype/bom_operation/bom_operation.py index 26c87f1c04..df55159e1c 100644 --- a/erpnext/manufacturing/doctype/bom_operation/bom_operation.py +++ b/erpnext/manufacturing/doctype/bom_operation/bom_operation.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BomOperation(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py index 598d822cd5..c406777a84 100644 --- a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py +++ b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py @@ -7,7 +7,9 @@ from frappe.utils import cstr, flt from frappe.model.code import get_obj from frappe import msgprint, _ -class DocType: +from frappe.model.document import Document + +class BomReplaceTool(Document): def __init__( self, doc, doclist=[]): self.doc = doc self.doclist = doclist diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index abc6cfd466..aeea1c0762 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -10,10 +10,9 @@ from frappe import msgprint, _ class OverProductionError(frappe.ValidationError): pass -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class ProductionOrder(Document): def validate(self): if self.doc.docstatus == 0: diff --git a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py index 26c87f1c04..a9a9c61f0d 100644 --- a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py +++ b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ProductionPlanItem(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py index 26c87f1c04..c0be09e9c5 100644 --- a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py +++ b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ProductionPlanSalesOrder(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py index 60007cd839..89fafbcab7 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -4,15 +4,13 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, cint, nowdate, add_days -from frappe.model.doc import addchild, Document from frappe.model.bean import getlist from frappe.model.code import get_obj from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class ProductionPlanningTool(Document): self.item_dict = {} def get_so_details(self, so): @@ -39,10 +37,10 @@ class DocType: return ret def clear_so_table(self): - self.doclist = self.doc.clear_table(self.doclist, 'pp_so_details') + self.set('pp_so_details', []) def clear_item_table(self): - self.doclist = self.doc.clear_table(self.doclist, 'pp_details') + self.set('pp_details', []) def validate_company(self): if not self.doc.company: @@ -84,11 +82,10 @@ class DocType: """ Add sales orders in the table""" self.clear_so_table() - so_list = [d.sales_order for d in getlist(self.doclist, 'pp_so_details')] + so_list = [d.sales_order for d in self.get('pp_so_details')] for r in open_so: if cstr(r['name']) not in so_list: - pp_so = addchild(self.doc, 'pp_so_details', - 'Production Plan Sales Order', self.doclist) + pp_so = self.doc.append('pp_so_details', {}) pp_so.sales_order = r['name'] pp_so.sales_order_date = cstr(r['transaction_date']) pp_so.customer = cstr(r['customer']) @@ -103,7 +100,7 @@ class DocType: self.add_items(items) def get_items(self): - so_list = filter(None, [d.sales_order for d in getlist(self.doclist, 'pp_so_details')]) + so_list = filter(None, [d.sales_order for d in self.get('pp_so_details')]) if not so_list: msgprint(_("Please enter sales order in the above table")) return [] @@ -138,7 +135,7 @@ class DocType: for p in items: item_details = frappe.db.sql("""select description, stock_uom, default_bom from tabItem where name=%s""", p['item_code']) - pi = addchild(self.doc, 'pp_details', 'Production Plan Item', self.doclist) + pi = self.doc.append('pp_details', {}) pi.sales_order = p['parent'] pi.warehouse = p['warehouse'] pi.item_code = p['item_code'] @@ -151,7 +148,7 @@ class DocType: def validate_data(self): self.validate_company() - for d in getlist(self.doclist, 'pp_details'): + for d in self.get('pp_details'): self.validate_bom_no(d) if not flt(d.planned_qty): frappe.throw("Please Enter Planned Qty for item: %s at row no: %s" % @@ -193,7 +190,7 @@ class DocType: } """ item_dict, bom_dict = {}, {} - for d in self.doclist.get({"parentfield": "pp_details"}): + for d in self.get("pp_details"): bom_dict.setdefault(d.bom_no, []).append([d.sales_order, flt(d.planned_qty)]) item_dict[(d.item_code, d.sales_order, d.warehouse)] = { "production_item" : d.item_code, diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py index 2829f41ed8..dd53c56429 100644 --- a/erpnext/manufacturing/doctype/workstation/workstation.py +++ b/erpnext/manufacturing/doctype/workstation/workstation.py @@ -5,7 +5,9 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt -class DocType: +from frappe.model.document import Document + +class Workstation(Document): def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist diff --git a/erpnext/projects/doctype/activity_type/activity_type.py b/erpnext/projects/doctype/activity_type/activity_type.py index 26c87f1c04..a98d8cf0ec 100644 --- a/erpnext/projects/doctype/activity_type/activity_type.py +++ b/erpnext/projects/doctype/activity_type/activity_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ActivityType(Document): + pass \ No newline at end of file diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index deac722ae9..99a9d3a394 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -8,10 +8,9 @@ from frappe.utils import flt, getdate from frappe import msgprint from erpnext.utilities.transaction_base import delete_events -class DocType: - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Project(Document): def get_gross_profit(self): pft, per_pft =0, 0 @@ -45,7 +44,7 @@ class DocType: delete_events(self.doc.doctype, self.doc.name) # add events - for milestone in self.doclist.get({"parentfield": "project_milestones"}): + for milestone in self.get("project_milestones"): if milestone.milestone_date: description = (milestone.milestone or "Milestone") + " for " + self.doc.name frappe.bean({ diff --git a/erpnext/projects/doctype/project_milestone/project_milestone.py b/erpnext/projects/doctype/project_milestone/project_milestone.py index 26c87f1c04..57bcfc4034 100644 --- a/erpnext/projects/doctype/project_milestone/project_milestone.py +++ b/erpnext/projects/doctype/project_milestone/project_milestone.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ProjectMilestone(Document): + pass \ No newline at end of file diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index 0e7678118f..289903d2c9 100644 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -5,16 +5,12 @@ from __future__ import unicode_literals import frappe, json from frappe.utils import getdate, today -from frappe.model import db_exists -from frappe.model.bean import copy_doclist from frappe import msgprint -class DocType: - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist - +from frappe.model.document import Document + +class Task(Document): def get_project_details(self): return { "project": self.doc.project diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index 690eb9270e..3dedef14c2 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -11,9 +11,9 @@ from frappe.utils import cstr class OverlapError(frappe.ValidationError): pass -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class TimeLog(Document): def validate(self): self.set_status() diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.py b/erpnext/projects/doctype/time_log_batch/time_log_batch.py index 3c3e6e06b0..89beb9d2b1 100644 --- a/erpnext/projects/doctype/time_log_batch/time_log_batch.py +++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.py @@ -7,9 +7,9 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class TimeLogBatch(Document): def validate(self): self.set_status() diff --git a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py index 968a25b613..f0c4c1b49c 100644 --- a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py +++ b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class TimeLogBatchDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/campaign/campaign.py b/erpnext/selling/doctype/campaign/campaign.py index 5015bed79c..523c62d03f 100644 --- a/erpnext/selling/doctype/campaign/campaign.py +++ b/erpnext/selling/doctype/campaign/campaign.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class Campaign(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index d8a095f7e5..1fc2613d1f 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -11,10 +11,7 @@ import frappe.defaults from erpnext.utilities.transaction_base import TransactionBase from erpnext.accounts.party import create_party_account -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class Customer(TransactionBase): def autoname(self): cust_master_name = frappe.defaults.get_global_default('cust_master_name') diff --git a/erpnext/selling/doctype/industry_type/industry_type.py b/erpnext/selling/doctype/industry_type/industry_type.py index 5015bed79c..f6bf2c8132 100644 --- a/erpnext/selling/doctype/industry_type/industry_type.py +++ b/erpnext/selling/doctype/industry_type/industry_type.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class IndustryType(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note/installation_note.py b/erpnext/selling/doctype/installation_note/installation_note.py index 3d57db734a..404ad33ae9 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.py +++ b/erpnext/selling/doctype/installation_note/installation_note.py @@ -11,10 +11,7 @@ from erpnext.stock.utils import get_valid_serial_nos from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class InstallationNote(TransactionBase): self.tname = 'Installation Note Item' self.fname = 'installed_item_details' self.status_updater = [{ @@ -78,7 +75,7 @@ class DocType(TransactionBase): def validate_serial_no(self): cur_s_no, prevdoc_s_no, sr_list = [], [], [] - for d in getlist(self.doclist, 'installed_item_details'): + for d in self.get('installed_item_details'): self.is_serial_no_added(d.item_code, d.serial_no) if d.serial_no: sr_list = get_valid_serial_nos(d.serial_no, d.qty, d.item_code) @@ -91,7 +88,7 @@ class DocType(TransactionBase): self.is_serial_no_installed(sr_list, d.item_code) def validate_installation_date(self): - for d in getlist(self.doclist, 'installed_item_details'): + for d in self.get('installed_item_details'): if d.prevdoc_docname: d_date = frappe.db.get_value("Delivery Note", d.prevdoc_docname, "posting_date") if d_date > getdate(self.doc.inst_date): @@ -99,7 +96,7 @@ class DocType(TransactionBase): " for item "+d.item_code, raise_exception=1) def check_item_table(self): - if not(getlist(self.doclist, 'installed_item_details')): + if not(self.get('installed_item_details')): msgprint("Please fetch items from Delivery Note selected", raise_exception=1) def on_update(self): @@ -111,7 +108,7 @@ class DocType(TransactionBase): frappe.db.set(self.doc, 'status', 'Submitted') def on_cancel(self): - for d in getlist(self.doclist, 'installed_item_details'): + for d in self.get('installed_item_details'): if d.serial_no: d.serial_no = d.serial_no.replace(",", "\n") for sr_no in d.serial_no.split("\n"): diff --git a/erpnext/selling/doctype/installation_note_item/installation_note_item.py b/erpnext/selling/doctype/installation_note_item/installation_note_item.py index 26c87f1c04..ac3aacfab6 100644 --- a/erpnext/selling/doctype/installation_note_item/installation_note_item.py +++ b/erpnext/selling/doctype/installation_note_item/installation_note_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class InstallationNoteItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/lead/lead.py b/erpnext/selling/doctype/lead/lead.py index 614a9c2d65..1472ff26f3 100644 --- a/erpnext/selling/doctype/lead/lead.py +++ b/erpnext/selling/doctype/lead/lead.py @@ -10,10 +10,7 @@ from frappe import session from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist +class Lead(SellingController): self._prev = frappe._dict({ "contact_date": frappe.db.get_value("Lead", self.doc.name, "contact_date") if \ diff --git a/erpnext/selling/doctype/opportunity/opportunity.py b/erpnext/selling/doctype/opportunity/opportunity.py index d2f7a2eb75..bbe9a60bb9 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.py +++ b/erpnext/selling/doctype/opportunity/opportunity.py @@ -11,19 +11,9 @@ from frappe import msgprint, _ from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self,doc,doclist): - self.doc = doc - self.doclist = doclist - self.fname = 'enq_details' - self.tname = 'Opportunity Item' - - self._prev = frappe._dict({ - "contact_date": frappe.db.get_value("Opportunity", self.doc.name, "contact_date") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - "contact_by": frappe.db.get_value("Opportunity", self.doc.name, "contact_by") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - }) +class Opportunity(TransactionBase): + fname = 'enq_details' + tname = 'Opportunity Item' def get_item_details(self, item_code): item = frappe.db.sql("""select item_name, stock_uom, description_html, description, item_group, brand @@ -91,7 +81,7 @@ class DocType(TransactionBase): super(DocType, self).add_calendar_event(opts, force) def validate_item_details(self): - if not getlist(self.doclist, 'enquiry_details'): + if not self.get('enquiry_details'): msgprint("Please select items for which enquiry needs to be made") raise Exception @@ -102,6 +92,13 @@ class DocType(TransactionBase): msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1) def validate(self): + self._prev = frappe._dict({ + "contact_date": frappe.db.get_value("Opportunity", self.doc.name, "contact_date") if \ + (not cint(self.doc.fields.get("__islocal"))) else None, + "contact_by": frappe.db.get_value("Opportunity", self.doc.name, "contact_by") if \ + (not cint(self.doc.fields.get("__islocal"))) else None, + }) + self.set_status() self.validate_item_details() self.validate_uom_is_integer("uom", "qty") diff --git a/erpnext/selling/doctype/opportunity_item/opportunity_item.py b/erpnext/selling/doctype/opportunity_item/opportunity_item.py index 26c87f1c04..26b2999ebb 100644 --- a/erpnext/selling/doctype/opportunity_item/opportunity_item.py +++ b/erpnext/selling/doctype/opportunity_item/opportunity_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class OpportunityItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 484c487548..530ad240f5 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -10,10 +10,7 @@ from frappe import _, msgprint from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class Quotation(SellingController): self.tname = 'Quotation Item' self.fname = 'quotation_details' @@ -22,7 +19,7 @@ class DocType(SellingController): def validate_for_items(self): chk_dupl_itm = [] - for d in getlist(self.doclist,'quotation_details'): + for d in self.get('quotation_details'): if [cstr(d.item_code),cstr(d.description)] in chk_dupl_itm: msgprint("Item %s has been entered twice. Please change description atleast to continue" % d.item_code) raise Exception @@ -33,7 +30,7 @@ class DocType(SellingController): super(DocType, self).validate_order_type() if self.doc.order_type in ['Maintenance', 'Service']: - for d in getlist(self.doclist, 'quotation_details'): + for d in self.get('quotation_details'): is_service_item = frappe.db.sql("select is_service_item from `tabItem` where name=%s", d.item_code) is_service_item = is_service_item and is_service_item[0][0] or 'No' @@ -41,7 +38,7 @@ class DocType(SellingController): msgprint("You can not select non service item "+d.item_code+" in Maintenance Quotation") raise Exception else: - for d in getlist(self.doclist, 'quotation_details'): + for d in self.get('quotation_details'): is_sales_item = frappe.db.sql("select is_sales_item from `tabItem` where name=%s", d.item_code) is_sales_item = is_sales_item and is_sales_item[0][0] or 'No' @@ -69,7 +66,7 @@ class DocType(SellingController): frappe.throw(_("Cannot set as Lost as Sales Order is made.")) def check_item_table(self): - if not getlist(self.doclist, 'quotation_details'): + if not self.get('quotation_details'): msgprint("Please enter item details") raise Exception @@ -89,7 +86,7 @@ class DocType(SellingController): def print_other_charges(self,docname): print_lst = [] - for d in getlist(self.doclist,'other_charges'): + for d in self.get('other_charges'): lst1 = [] lst1.append(d.description) lst1.append(d.total) diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.py b/erpnext/selling/doctype/quotation_item/quotation_item.py index 26c87f1c04..426b199a36 100644 --- a/erpnext/selling/doctype/quotation_item/quotation_item.py +++ b/erpnext/selling/doctype/quotation_item/quotation_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class QuotationItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom/sales_bom.py b/erpnext/selling/doctype/sales_bom/sales_bom.py index fb4696199c..3e97ed9f92 100644 --- a/erpnext/selling/doctype/sales_bom/sales_bom.py +++ b/erpnext/selling/doctype/sales_bom/sales_bom.py @@ -4,9 +4,10 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +from frappe.model.document import Document + +class SalesBom(Document): + def autoname(self): self.doc.name = self.doc.new_item_code diff --git a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py index 26c87f1c04..e1124d97cc 100644 --- a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py +++ b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesBomItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index fd915de7b5..25eda9ab3a 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -13,7 +13,7 @@ from frappe.model.mapper import get_mapped_doclist from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): +class SalesOrder(SellingController): def __init__(self, doc, doclist=None): self.doc = doc if not doclist: doclist = [] @@ -48,7 +48,7 @@ class DocType(SellingController): def validate_for_items(self): check_list, flag = [], 0 chk_dupl_itm = [] - for d in getlist(self.doclist, 'sales_order_details'): + for d in self.get('sales_order_details'): e = [d.item_code, d.description, d.warehouse, d.prevdoc_docname or ''] f = [d.item_code, d.description] @@ -75,7 +75,7 @@ class DocType(SellingController): d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0 def validate_sales_mntc_quotation(self): - for d in getlist(self.doclist, 'sales_order_details'): + for d in self.get('sales_order_details'): if d.prevdoc_docname: res = frappe.db.sql("select name from `tabQuotation` where name=%s and order_type = %s", (d.prevdoc_docname, self.doc.order_type)) if not res: diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.py b/erpnext/selling/doctype/sales_order_item/sales_order_item.py index 26c87f1c04..ef2ad098ec 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.py +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesOrderItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_team/sales_team.py b/erpnext/selling/doctype/sales_team/sales_team.py index 26c87f1c04..01d38d2614 100644 --- a/erpnext/selling/doctype/sales_team/sales_team.py +++ b/erpnext/selling/doctype/sales_team/sales_team.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesTeam(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.py b/erpnext/selling/doctype/selling_settings/selling_settings.py index 5b44c7b6a6..6823fa1b86 100644 --- a/erpnext/selling/doctype/selling_settings/selling_settings.py +++ b/erpnext/selling/doctype/selling_settings/selling_settings.py @@ -6,9 +6,9 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class SellingSettings(Document): def validate(self): for key in ["cust_master_name", "customer_group", "territory", "maintain_same_sales_rate", diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py index 7da6f32102..9aeb5eefef 100644 --- a/erpnext/selling/doctype/sms_center/sms_center.py +++ b/erpnext/selling/doctype/sms_center/sms_center.py @@ -8,10 +8,9 @@ from frappe.utils import cstr from frappe.model.code import get_obj from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class SmsCenter(Document): def create_receiver_list(self): rec, where_clause = '', '' diff --git a/erpnext/setup/doctype/applicable_territory/applicable_territory.py b/erpnext/setup/doctype/applicable_territory/applicable_territory.py index cb42e2eea2..25478d6aad 100644 --- a/erpnext/setup/doctype/applicable_territory/applicable_territory.py +++ b/erpnext/setup/doctype/applicable_territory/applicable_territory.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ApplicableTerritory(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.py b/erpnext/setup/doctype/authorization_control/authorization_control.py index b37686a666..9b8980cd3c 100644 --- a/erpnext/setup/doctype/authorization_control/authorization_control.py +++ b/erpnext/setup/doctype/authorization_control/authorization_control.py @@ -12,9 +12,7 @@ from erpnext.setup.utils import get_company_currency from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class AuthorizationControl(TransactionBase): # Get Names of all Approving Users and Roles diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.py b/erpnext/setup/doctype/authorization_rule/authorization_rule.py index 71f5caf6d0..5255e4cd17 100644 --- a/erpnext/setup/doctype/authorization_rule/authorization_rule.py +++ b/erpnext/setup/doctype/authorization_rule/authorization_rule.py @@ -7,9 +7,9 @@ import frappe from frappe.utils import cint, cstr, flt, has_common from frappe import msgprint -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class AuthorizationRule(Document): def check_duplicate_entry(self): diff --git a/erpnext/setup/doctype/backup_manager/backup_manager.py b/erpnext/setup/doctype/backup_manager/backup_manager.py index c3978006c8..8f7e891ad3 100644 --- a/erpnext/setup/doctype/backup_manager/backup_manager.py +++ b/erpnext/setup/doctype/backup_manager/backup_manager.py @@ -7,9 +7,9 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class BackupManager(Document): def take_backups_daily(): take_backups_if("Daily") diff --git a/erpnext/setup/doctype/brand/brand.py b/erpnext/setup/doctype/brand/brand.py index d30eab6e92..5bdc243194 100644 --- a/erpnext/setup/doctype/brand/brand.py +++ b/erpnext/setup/doctype/brand/brand.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class Brand(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 5162ffbb14..9c980684e8 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -9,9 +9,10 @@ from frappe.utils import cstr, cint import frappe.defaults -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +from frappe.model.document import Document + +class Company(Document): + def onload(self): self.doc.fields["__transactions_exist"] = self.check_if_transactions_exist() diff --git a/erpnext/setup/doctype/contact_control/contact_control.py b/erpnext/setup/doctype/contact_control/contact_control.py index 35bd61c982..96e9551c3f 100644 --- a/erpnext/setup/doctype/contact_control/contact_control.py +++ b/erpnext/setup/doctype/contact_control/contact_control.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class ContactControl(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/country/country.py b/erpnext/setup/doctype/country/country.py index d30eab6e92..5e16f51f8f 100644 --- a/erpnext/setup/doctype/country/country.py +++ b/erpnext/setup/doctype/country/country.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class Country(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/currency/currency.py b/erpnext/setup/doctype/currency/currency.py index 2f6a62af74..5541065437 100644 --- a/erpnext/setup/doctype/currency/currency.py +++ b/erpnext/setup/doctype/currency/currency.py @@ -5,9 +5,9 @@ from __future__ import unicode_literals import frappe from frappe import throw, _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class Currency(Document): def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company): """common validation for currency and price list currency""" diff --git a/erpnext/setup/doctype/currency_exchange/currency_exchange.py b/erpnext/setup/doctype/currency_exchange/currency_exchange.py index 93f44190ba..a0624de888 100644 --- a/erpnext/setup/doctype/currency_exchange/currency_exchange.py +++ b/erpnext/setup/doctype/currency_exchange/currency_exchange.py @@ -8,9 +8,7 @@ import frappe from frappe import _, msgprint from frappe.model.controller import DocListController -class DocType(DocListController): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class CurrencyExchange(DocListController): def autoname(self): self.doc.name = self.doc.from_currency + "-" + self.doc.to_currency diff --git a/erpnext/setup/doctype/customer_group/customer_group.py b/erpnext/setup/doctype/customer_group/customer_group.py index 547f19fc39..214e20c0e5 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.py +++ b/erpnext/setup/doctype/customer_group/customer_group.py @@ -7,10 +7,7 @@ from frappe import msgprint from frappe.utils.nestedset import DocTypeNestedSet -class DocType(DocTypeNestedSet): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class CustomerGroup(DocTypeNestedSet): self.nsm_parent_field = 'parent_customer_group'; def validate(self): diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index c46c43e841..1344686da6 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -45,9 +45,9 @@ row_template = """

""" from frappe.model.controller import DocListController -class DocType(DocListController): - def __init__(self, doc, doclist=[]): - self.doc, self.doclist = doc, doclist +class EmailDigest(DocListController): + def __init__(self, arg1, arg2=None): + super(EmailDigest, self).__init__(arg1, arg2) self.from_date, self.to_date = self.get_from_to_date() self.future_from_date, self.future_to_date = self.get_future_from_to_date() self.currency = frappe.db.get_value("Company", self.doc.company, diff --git a/erpnext/setup/doctype/features_setup/features_setup.py b/erpnext/setup/doctype/features_setup/features_setup.py index 0c9d6e4537..825163df9a 100644 --- a/erpnext/setup/doctype/features_setup/features_setup.py +++ b/erpnext/setup/doctype/features_setup/features_setup.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class FeaturesSetup(Document): def validate(self): """ diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py index d61ff8a00e..bfe3265b9d 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.py +++ b/erpnext/setup/doctype/global_defaults/global_defaults.py @@ -22,9 +22,9 @@ keydict = { 'disable_rounded_total': 'disable_rounded_total', } -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class GlobalDefaults(Document): def on_update(self): """update defaults""" diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index aa1002e66f..455d752452 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -6,10 +6,7 @@ import frappe from frappe.utils.nestedset import DocTypeNestedSet -class DocType(DocTypeNestedSet): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class ItemGroup(DocTypeNestedSet): self.nsm_parent_field = 'parent_item_group' def validate(self): diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py index 4d2d1ea7fa..2c928aaa7f 100644 --- a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py +++ b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py @@ -8,9 +8,9 @@ import frappe from frappe import _ from frappe.utils import cint -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class JobsEmailSettings(Document): def validate(self): if cint(self.doc.extract_emails) and not (self.doc.email_id and self.doc.host and \ diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py index 5b0c9e25e6..454b38a349 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.py +++ b/erpnext/setup/doctype/naming_series/naming_series.py @@ -8,9 +8,9 @@ from frappe.utils import cstr from frappe import msgprint, throw, _ import frappe.model.doctype -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class NamingSeries(Document): def get_transactions(self, arg=None): return { diff --git a/erpnext/setup/doctype/notification_control/notification_control.py b/erpnext/setup/doctype/notification_control/notification_control.py index c5137461c6..21bdcced93 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.py +++ b/erpnext/setup/doctype/notification_control/notification_control.py @@ -7,9 +7,10 @@ import frappe from frappe import msgprint -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +from frappe.model.document import Document + +class NotificationControl(Document): + def get_message(self, arg): fn = arg.lower().replace(' ', '_') + '_message' diff --git a/erpnext/setup/doctype/print_heading/print_heading.py b/erpnext/setup/doctype/print_heading/print_heading.py index 263c31e327..eb6d9780ff 100644 --- a/erpnext/setup/doctype/print_heading/print_heading.py +++ b/erpnext/setup/doctype/print_heading/print_heading.py @@ -4,12 +4,7 @@ from __future__ import unicode_literals import frappe -from frappe.model import db_exists -from frappe.model.bean import copy_doclist +from frappe.model.document import Document - - - -class DocType: - def __init__(self,doc,doclist=[]): - self.doc, self.doclist = doc,doclist \ No newline at end of file +class PrintHeading(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py index d30eab6e92..ea9f927856 100644 --- a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py +++ b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class QuotationLostReason(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py index 4d2d1ea7fa..01e9be41fc 100644 --- a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py +++ b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py @@ -8,9 +8,9 @@ import frappe from frappe import _ from frappe.utils import cint -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class SalesEmailSettings(Document): def validate(self): if cint(self.doc.extract_emails) and not (self.doc.email_id and self.doc.host and \ diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.py b/erpnext/setup/doctype/sales_partner/sales_partner.py index eefabf6784..5e3e569968 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/sales_partner.py @@ -4,12 +4,9 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, filter_strip_join +from frappe.model.document import Document -class DocType(): - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist - +class SalesPartner(Document): def validate(self): if self.doc.partner_website and not self.doc.partner_website.startswith("http"): self.doc.partner_website = "http://" + self.doc.partner_website diff --git a/erpnext/setup/doctype/sales_person/sales_person.py b/erpnext/setup/doctype/sales_person/sales_person.py index 58ddd13c6c..b128d2c430 100644 --- a/erpnext/setup/doctype/sales_person/sales_person.py +++ b/erpnext/setup/doctype/sales_person/sales_person.py @@ -7,14 +7,11 @@ from frappe.model.bean import getlist from frappe.utils import flt from frappe.utils.nestedset import DocTypeNestedSet -class DocType(DocTypeNestedSet): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class SalesPerson(DocTypeNestedSet): self.nsm_parent_field = 'parent_sales_person'; def validate(self): - for d in getlist(self.doclist, 'target_details'): + for d in self.get('target_details'): if not flt(d.target_qty) and not flt(d.target_amount): frappe.throw(_("Either target qty or target amount is mandatory.")) diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.py b/erpnext/setup/doctype/sms_parameter/sms_parameter.py index 26c87f1c04..4c54a4f404 100644 --- a/erpnext/setup/doctype/sms_parameter/sms_parameter.py +++ b/erpnext/setup/doctype/sms_parameter/sms_parameter.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SmsParameter(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.py b/erpnext/setup/doctype/sms_settings/sms_settings.py index 26c87f1c04..9361d3b620 100644 --- a/erpnext/setup/doctype/sms_settings/sms_settings.py +++ b/erpnext/setup/doctype/sms_settings/sms_settings.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SmsSettings(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/supplier_type/supplier_type.py b/erpnext/setup/doctype/supplier_type/supplier_type.py index d30eab6e92..70369569ce 100644 --- a/erpnext/setup/doctype/supplier_type/supplier_type.py +++ b/erpnext/setup/doctype/supplier_type/supplier_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class SupplierType(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/target_detail/target_detail.py b/erpnext/setup/doctype/target_detail/target_detail.py index 26c87f1c04..2332560b65 100644 --- a/erpnext/setup/doctype/target_detail/target_detail.py +++ b/erpnext/setup/doctype/target_detail/target_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class TargetDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py index 26c87f1c04..73ac3947b8 100644 --- a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py +++ b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class TermsAndConditions(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/territory/territory.py b/erpnext/setup/doctype/territory/territory.py index 5dfe458908..67669d9902 100644 --- a/erpnext/setup/doctype/territory/territory.py +++ b/erpnext/setup/doctype/territory/territory.py @@ -9,14 +9,11 @@ from frappe.utils import flt from frappe.utils.nestedset import DocTypeNestedSet -class DocType(DocTypeNestedSet): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.nsm_parent_field = 'parent_territory' +class Territory(DocTypeNestedSet): + nsm_parent_field = 'parent_territory' def validate(self): - for d in getlist(self.doclist, 'target_details'): + for d in self.get('target_details'): if not flt(d.target_qty) and not flt(d.target_amount): msgprint("Either target qty or target amount is mandatory.") raise Exception diff --git a/erpnext/setup/doctype/uom/uom.py b/erpnext/setup/doctype/uom/uom.py index d30eab6e92..2d076f6584 100644 --- a/erpnext/setup/doctype/uom/uom.py +++ b/erpnext/setup/doctype/uom/uom.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class Uom(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/website_item_group/website_item_group.py b/erpnext/setup/doctype/website_item_group/website_item_group.py index cb42e2eea2..4665cabef2 100644 --- a/erpnext/setup/doctype/website_item_group/website_item_group.py +++ b/erpnext/setup/doctype/website_item_group/website_item_group.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class WebsiteItemGroup(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index eba79d8432..b03eeaec07 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -334,16 +334,14 @@ def create_letter_head(args): fileurl = save_file(filename, content, "Letter Head", "Standard", decode=True).file_name frappe.db.set_value("Letter Head", "Standard", "content", "" % fileurl) - - def add_all_roles_to(name): - user = frappe.doc("User", name) + user = frappe.get_doc("User", name) for role in frappe.db.sql("""select name from tabRole"""): if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner"]: - d = user.addchild("user_roles", "UserRole") + d = user.append("user_roles") d.role = role[0] - d.insert() - + user.save() + def create_territories(): """create two default territories, one for home country and one named Rest of the World""" from frappe.utils.nestedset import get_root_of diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index 26c87f1c04..365cb38b60 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class Batch(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index 1b5e243731..0587f47160 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -9,10 +9,9 @@ from frappe import msgprint, _ import frappe.defaults -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Bin(Document): def validate(self): if self.doc.fields.get("__islocal") or not self.doc.stock_uom: diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index a7c4923125..8d91e490db 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -13,10 +13,7 @@ from frappe.model.mapper import get_mapped_doclist from erpnext.stock.utils import update_bin from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class DeliveryNote(SellingController): self.tname = 'Delivery Note Item' self.fname = 'delivery_note_details' self.status_updater = [{ @@ -37,14 +34,14 @@ class DocType(SellingController): billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabSales Invoice Item` where docstatus=1 and delivery_note=%s""", self.doc.name) if billed_qty: - total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "delivery_note_details"}))) + total_qty = sum((item.qty for item in self.get("delivery_note_details"))) self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty def get_portal_page(self): return "shipment" if self.doc.docstatus==1 else None def set_actual_qty(self): - for d in getlist(self.doclist, 'delivery_note_details'): + for d in self.get('delivery_note_details'): if d.item_code and d.warehouse: actual_qty = frappe.db.sql("""select actual_qty from `tabBin` where item_code = %s and warehouse = %s""", (d.item_code, d.warehouse)) @@ -53,7 +50,7 @@ class DocType(SellingController): def so_required(self): """check in manage account if sales order required or not""" if frappe.db.get_value("Selling Settings", None, 'so_required') == 'Yes': - for d in getlist(self.doclist,'delivery_note_details'): + for d in self.get('delivery_note_details'): if not d.against_sales_order: msgprint("Sales Order No. required against item %s"%d.item_code) raise Exception @@ -81,7 +78,7 @@ class DocType(SellingController): if not self.doc.installation_status: self.doc.installation_status = 'Not Installed' def validate_with_previous_doc(self): - items = self.doclist.get({"parentfield": "delivery_note_details"}) + items = self.get("delivery_note_details") for fn in (("Sales Order", "against_sales_order"), ("Sales Invoice", "against_sales_invoice")): if items.get_distinct_values(fn[1]): @@ -114,7 +111,7 @@ class DocType(SellingController): def validate_for_items(self): check_list, chk_dupl_itm = [], [] - for d in getlist(self.doclist,'delivery_note_details'): + for d in self.get('delivery_note_details'): e = [d.item_code, d.description, d.warehouse, d.against_sales_order or d.against_sales_invoice, d.batch_no or ''] f = [d.item_code, d.description, d.against_sales_order or d.against_sales_invoice] @@ -140,11 +137,11 @@ class DocType(SellingController): def update_current_stock(self): - for d in getlist(self.doclist, 'delivery_note_details'): + for d in self.get('delivery_note_details'): bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 - for d in getlist(self.doclist, 'packing_details'): + for d in self.get('packing_details'): bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0 @@ -268,7 +265,7 @@ class DocType(SellingController): def credit_limit(self): """check credit limit of items in DN Detail which are not fetched from sales order""" amount, total = 0, 0 - for d in getlist(self.doclist, 'delivery_note_details'): + for d in self.get('delivery_note_details'): if not (d.against_sales_order or d.against_sales_invoice): amount += d.base_amount if amount != 0: @@ -299,7 +296,7 @@ def make_sales_invoice(source_name, target_doclist=None): si.set_doclist(si.doclist.get({"parentfield": ["!=", "entries"]}) + si.doclist.get({"parentfield": "entries", "qty": [">", 0]})) - if len(si.doclist.get({"parentfield": "entries"})) == 0: + if len(si.get("entries")) == 0: frappe.msgprint(_("Hey! All these items have already been invoiced."), raise_exception=True) diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py index 26c87f1c04..3789cdaffa 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class DeliveryNoteItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 58d151a521..3a20d8cdf5 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, getdate, now_datetime, formatdate -from frappe.model.doc import addchild from frappe.model.bean import getlist from frappe import msgprint, _ @@ -13,7 +12,7 @@ from frappe.model.controller import DocListController class WarehouseNotSet(Exception): pass -class DocType(DocListController): +class Item(DocListController): def onload(self): self.doc.fields["__sle_exists"] = self.check_if_sle_exists() @@ -58,13 +57,13 @@ class DocType(DocListController): raise_exception=WarehouseNotSet) def add_default_uom_in_conversion_factor_table(self): - uom_conv_list = [d.uom for d in self.doclist.get({"parentfield": "uom_conversion_details"})] + uom_conv_list = [d.uom for d in self.get("uom_conversion_details")] if self.doc.stock_uom not in uom_conv_list: - ch = addchild(self.doc, 'uom_conversion_details', 'UOM Conversion Detail', self.doclist) + ch = self.doc.append('uom_conversion_details', {}) ch.uom = self.doc.stock_uom ch.conversion_factor = 1 - for d in self.doclist.get({"parentfield": "uom_conversion_details"}): + for d in self.get("uom_conversion_details"): if d.conversion_factor == 1 and d.uom != self.doc.stock_uom: self.doclist.remove(d) @@ -95,7 +94,7 @@ class DocType(DocListController): def validate_conversion_factor(self): check_list = [] - for d in getlist(self.doclist,'uom_conversion_details'): + for d in self.get('uom_conversion_details'): if cstr(d.uom) in check_list: msgprint(_("UOM %s has been entered more than once in Conversion Factor Table." % cstr(d.uom)), raise_exception=1) @@ -141,14 +140,14 @@ class DocType(DocListController): def fill_customer_code(self): """ Append all the customer codes and insert into "customer_code" field of item table """ cust_code=[] - for d in getlist(self.doclist,'item_customer_details'): + for d in self.get('item_customer_details'): cust_code.append(d.ref_code) self.doc.customer_code=','.join(cust_code) def check_item_tax(self): """Check whether Tax Rate is not entered twice for same Tax Type""" check_list=[] - for d in getlist(self.doclist,'item_tax'): + for d in self.get('item_tax'): if d.tax_type: account_type = frappe.db.get_value("Account", d.tax_type, "account_type") diff --git a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py index 26c87f1c04..b0bd280c7e 100644 --- a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py +++ b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemCustomerDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_price/item_price.py b/erpnext/stock/doctype/item_price/item_price.py index 879fcae4d1..3c3972bc78 100644 --- a/erpnext/stock/doctype/item_price/item_price.py +++ b/erpnext/stock/doctype/item_price/item_price.py @@ -7,9 +7,9 @@ from frappe import throw, _ class ItemPriceDuplicateItem(frappe.ValidationError): pass -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class ItemPrice(Document): def validate(self): self.validate_item() diff --git a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py index 26c87f1c04..b659bb0746 100644 --- a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py +++ b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemQualityInspectionParameter(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_reorder/item_reorder.py b/erpnext/stock/doctype/item_reorder/item_reorder.py index 968a25b613..7dcefb0e08 100644 --- a/erpnext/stock/doctype/item_reorder/item_reorder.py +++ b/erpnext/stock/doctype/item_reorder/item_reorder.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemReorder(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_supplier/item_supplier.py b/erpnext/stock/doctype/item_supplier/item_supplier.py index 26c87f1c04..68f481602f 100644 --- a/erpnext/stock/doctype/item_supplier/item_supplier.py +++ b/erpnext/stock/doctype/item_supplier/item_supplier.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemSupplier(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_tax/item_tax.py b/erpnext/stock/doctype/item_tax/item_tax.py index 26c87f1c04..96363e8115 100644 --- a/erpnext/stock/doctype/item_tax/item_tax.py +++ b/erpnext/stock/doctype/item_tax/item_tax.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemTax(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_website_specification/item_website_specification.py b/erpnext/stock/doctype/item_website_specification/item_website_specification.py index 968a25b613..ceb07275f9 100644 --- a/erpnext/stock/doctype/item_website_specification/item_website_specification.py +++ b/erpnext/stock/doctype/item_website_specification/item_website_specification.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemWebsiteSpecification(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py index 26c87f1c04..4681361d9d 100644 --- a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py +++ b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class LandedCostItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py index 26c87f1c04..090f833711 100644 --- a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py +++ b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class LandedCostPurchaseReceipt(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py index c52c820be9..34cbe3e2ea 100644 --- a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py +++ b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py @@ -4,13 +4,11 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt -from frappe.model.doc import addchild from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class LandedCostWizard(Document): def update_landed_cost(self): """ @@ -18,7 +16,7 @@ class DocType: Recalculate valuation rate in all sle after pr posting date """ purchase_receipts = [row.purchase_receipt for row in - self.doclist.get({"parentfield": "lc_pr_details"})] + self.get("lc_pr_details")] self.validate_purchase_receipts(purchase_receipts) self.cancel_pr(purchase_receipts) @@ -37,10 +35,9 @@ class DocType: for pr in purchase_receipts: pr_bean = frappe.bean('Purchase Receipt', pr) - pr_items = pr_bean.doclist.get({"parentfield": "purchase_tax_details"}) - idx = max([d.idx for d in pr_items]) if pr_items else 0 + pr_items = pr_bean.get("purchase_tax_details") - for lc in self.doclist.get({"parentfield": "landed_cost_details"}): + for lc in self.get("landed_cost_details"): amt = flt(lc.amount) * flt(pr_bean.doc.net_total)/ flt(total_amt) matched_row = pr_bean.doclist.get({ @@ -52,7 +49,7 @@ class DocType: }) if not matched_row: # add if not exists - ch = addchild(pr_bean.doc, 'other_charges', 'Purchase Taxes and Charges') + ch = pr_bean.append("other_charges") ch.category = 'Valuation' ch.add_deduct_tax = 'Add' ch.charge_type = 'Actual' @@ -62,9 +59,7 @@ class DocType: ch.rate = amt ch.tax_amount = amt ch.docstatus = 1 - ch.idx = idx + 1 ch.save(1) - idx += 1 else: # overwrite if exists matched_row[0].rate = amt matched_row[0].tax_amount = amt diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index 2fca85bbb7..c05a8d87b2 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -13,19 +13,16 @@ from frappe.model.code import get_obj from frappe import msgprint, _ from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class MaterialRequest(BuyingController): self.tname = 'Material Request Item' self.fname = 'indent_details' def check_if_already_pulled(self): - pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')] + pass#if self.[d.sales_order_no for d in self.get('indent_details')] def validate_qty_against_so(self): so_items = {} # Format --> {'SO/00001': {'Item/001': 120, 'Item/002': 24}} - for d in getlist(self.doclist, 'indent_details'): + for d in self.get('indent_details'): if d.sales_order_no: if not so_items.has_key(d.sales_order_no): so_items[d.sales_order_no] = {d.item_code: flt(d.qty)} @@ -53,7 +50,7 @@ class DocType(BuyingController): % (actual_so_qty - already_indented, item, so_no)) def validate_schedule_date(self): - for d in getlist(self.doclist, 'indent_details'): + for d in self.get('indent_details'): if d.schedule_date < self.doc.transaction_date: frappe.throw(_("Expected Date cannot be before Material Request Date")) @@ -84,7 +81,7 @@ class DocType(BuyingController): """ Update Quantity Requested for Purchase in Bin for Material Request of type 'Purchase'""" from erpnext.stock.utils import update_bin - for d in getlist(self.doclist, 'indent_details'): + for d in self.get('indent_details'): if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes": if not d.warehouse: frappe.throw("Please Enter Warehouse for Item %s as it is stock item" @@ -146,7 +143,7 @@ class DocType(BuyingController): if self.doc.material_request_type != "Transfer": return - item_doclist = self.doclist.get({"parentfield": "indent_details"}) + item_doclist = self.get("indent_details") if not mr_items: mr_items = [d.name for d in item_doclist] @@ -174,7 +171,7 @@ def update_completed_qty(bean, method): if bean.doc.doctype == "Stock Entry": material_request_map = {} - for d in bean.doclist.get({"parentfield": "mtn_details"}): + for d in bean.get("mtn_details"): if d.material_request: material_request_map.setdefault(d.material_request, []).append(d.material_request_item) diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.py b/erpnext/stock/doctype/material_request_item/material_request_item.py index 968a25b613..30101f3a88 100644 --- a/erpnext/stock/doctype/material_request_item/material_request_item.py +++ b/erpnext/stock/doctype/material_request_item/material_request_item.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class MaterialRequestItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index b01307d7a2..b7a15b7c89 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -6,12 +6,11 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt -from frappe.model.doc import addchild from frappe.model.bean import getlist -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class PackedItem(Document): def get_sales_bom_items(item_code): return frappe.db.sql("""select t1.item_code, t1.qty, t1.uom @@ -39,7 +38,7 @@ def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packi break if not exists: - pi = addchild(obj.doc, 'packing_details', 'Packed Item', obj.doclist) + pi = obj.doc.append('packing_details', {}) pi.parent_item = line.item_code pi.item_code = packing_item_code @@ -81,7 +80,7 @@ def make_packing_list(obj, item_table_fieldname): def cleanup_packing_list(obj, parent_items): """Remove all those child items which are no longer present in main item table""" delete_list = [] - for d in obj.doclist.get({"parentfield": "packing_details"}): + for d in obj.get("packing_details"): if [d.parent_item, d.parent_detail_docname] not in parent_items: # mark for deletion from doclist delete_list.append([d.parent_item, d.parent_detail_docname]) diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.py b/erpnext/stock/doctype/packing_slip/packing_slip.py index b7b6473203..99a6ee3ee6 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.py +++ b/erpnext/stock/doctype/packing_slip/packing_slip.py @@ -5,11 +5,10 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt, cint from frappe import msgprint, _ -from frappe.model.doc import addchild -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class PackingSlip(Document): def validate(self): """ @@ -36,7 +35,7 @@ class DocType: msgprint(_("""Invalid Delivery Note. Delivery Note should exist and should be in draft state. Please rectify and try again."""), raise_exception=1) def validate_items_mandatory(self): - rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})] + rows = [d.item_code for d in self.get("item_details")] if not rows: frappe.msgprint(_("No Items to Pack"), raise_exception=1) @@ -87,7 +86,7 @@ class DocType: * No. of Cases of this packing slip """ - rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})] + rows = [d.item_code for d in self.get("item_details")] condition = "" if rows: @@ -132,7 +131,7 @@ class DocType: if not self.doc.from_case_no: self.doc.from_case_no = self.get_recommended_case_no() - for d in self.doclist.get({"parentfield": "item_details"}): + for d in self.get("item_details"): res = frappe.db.get_value("Item", d.item_code, ["net_weight", "weight_uom"], as_dict=True) @@ -151,12 +150,12 @@ class DocType: return cint(recommended_case_no[0][0]) + 1 def get_items(self): - self.doclist = self.doc.clear_table(self.doclist, "item_details", 1) + self.set("item_details", []) dn_details = self.get_details_for_packing()[0] for item in dn_details: if flt(item.qty) > flt(item.packed_qty): - ch = addchild(self.doc, 'item_details', 'Packing Slip Item', self.doclist) + ch = self.doc.append('item_details', {}) ch.item_code = item.item_code ch.item_name = item.item_name ch.stock_uom = item.stock_uom diff --git a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py index 968a25b613..033e44b13c 100644 --- a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py +++ b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PackingSlipItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py index 37b956763e..420c6c5ffc 100644 --- a/erpnext/stock/doctype/price_list/price_list.py +++ b/erpnext/stock/doctype/price_list/price_list.py @@ -8,12 +8,12 @@ from frappe.utils import cint from frappe.model.controller import DocListController import frappe.defaults -class DocType(DocListController): +class PriceList(DocListController): def validate(self): if not cint(self.doc.buying) and not cint(self.doc.selling): throw(_("Price List must be applicable for Buying or Selling")) - if not self.doclist.get({"parentfield": "valid_for_territories"}): + if not self.get("valid_for_territories"): # if no territory, set default territory if frappe.defaults.get_user_default("territory"): self.doclist.append({ diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index d1e86a8521..bad59a6d86 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -12,10 +12,7 @@ import frappe.defaults from erpnext.stock.utils import update_bin from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class PurchaseReceipt(BuyingController): self.tname = 'Purchase Receipt Item' self.fname = 'purchase_receipt_details' self.count = 0 @@ -35,7 +32,7 @@ class DocType(BuyingController): billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabPurchase Invoice Item` where purchase_receipt=%s""", self.doc.name) if billed_qty: - total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "purchase_receipt_details"}))) + total_qty = sum((item.qty for item in self.get("purchase_receipt_details"))) self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty def validate(self): @@ -68,7 +65,7 @@ class DocType(BuyingController): self.update_valuation_rate("purchase_receipt_details") def validate_rejected_warehouse(self): - for d in self.doclist.get({"parentfield": "purchase_receipt_details"}): + for d in self.get("purchase_receipt_details"): if flt(d.rejected_qty) and not d.rejected_warehouse: d.rejected_warehouse = self.doc.rejected_warehouse if not d.rejected_warehouse: @@ -76,7 +73,7 @@ class DocType(BuyingController): # validate accepted and rejected qty def validate_accepted_rejected_qty(self): - for d in getlist(self.doclist, "purchase_receipt_details"): + for d in self.get("purchase_receipt_details"): if not flt(d.received_qty) and flt(d.qty): d.received_qty = flt(d.qty) - flt(d.rejected_qty) @@ -129,7 +126,7 @@ class DocType(BuyingController): def po_required(self): if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes': - for d in getlist(self.doclist,'purchase_receipt_details'): + for d in self.get('purchase_receipt_details'): if not d.prevdoc_docname: msgprint("Purchse Order No. required against item %s"%d.item_code) raise Exception @@ -138,7 +135,7 @@ class DocType(BuyingController): sl_entries = [] stock_items = self.get_stock_items() - for d in getlist(self.doclist, 'purchase_receipt_details'): + for d in self.get('purchase_receipt_details'): if d.item_code in stock_items and d.warehouse: pr_qty = flt(d.qty) * flt(d.conversion_factor) @@ -162,7 +159,7 @@ class DocType(BuyingController): def update_ordered_qty(self): stock_items = self.get_stock_items() - for d in self.doclist.get({"parentfield": "purchase_receipt_details"}): + for d in self.get("purchase_receipt_details"): if d.item_code in stock_items and d.warehouse \ and cstr(d.prevdoc_doctype) == 'Purchase Order': @@ -198,7 +195,7 @@ class DocType(BuyingController): return po_qty, po_warehouse def bk_flush_supp_wh(self, sl_entries): - for d in getlist(self.doclist, 'pr_raw_material_details'): + for d in self.get('pr_raw_material_details'): # negative quantity is passed as raw material qty has to be decreased # when PR is submitted and it has to be increased when PR is cancelled sl_entries.append(self.get_sl_entries(d, { @@ -209,7 +206,7 @@ class DocType(BuyingController): })) def validate_inspection(self): - for d in getlist(self.doclist, 'purchase_receipt_details'): #Enter inspection date for all items that require inspection + for d in self.get('purchase_receipt_details'): #Enter inspection date for all items that require inspection ins_reqd = frappe.db.sql("select inspection_required from `tabItem` where name = %s", (d.item_code,), as_dict = 1) ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No' @@ -219,7 +216,7 @@ class DocType(BuyingController): # Check for Stopped status def check_for_stopped_status(self, pc_obj): check_list =[] - for d in getlist(self.doclist, 'purchase_receipt_details'): + for d in self.get('purchase_receipt_details'): if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: check_list.append(d.prevdoc_docname) pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname) @@ -282,7 +279,7 @@ class DocType(BuyingController): self.make_cancel_gl_entries() def get_current_stock(self): - for d in getlist(self.doclist, 'pr_raw_material_details'): + for d in self.get('pr_raw_material_details'): if self.doc.supplier_warehouse: bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.doc.supplier_warehouse), as_dict = 1) d.current_stock = bin and flt(bin[0]['actual_qty']) or 0 diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 862bd846f8..2a2e821745 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -95,7 +95,7 @@ class TestPurchaseReceipt(unittest.TestCase): pr.insert() self.assertEquals(pr.doclist[1].rm_supp_cost, 70000.0) - self.assertEquals(len(pr.doclist.get({"parentfield": "pr_raw_material_details"})), 2) + self.assertEquals(len(pr.get("pr_raw_material_details")), 2) def test_serial_no_supplier(self): pr = frappe.bean(copy=test_records[0]) diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py index 26c87f1c04..35fca0d6c5 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseReceiptItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index d52d48dd8d..d8bdb77142 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -20,7 +20,7 @@ class SerialNoStatusError(ValidationError): pass class SerialNoNotExistsError(ValidationError): pass class SerialNoDuplicateError(ValidationError): pass -class DocType(StockController): +class SerialNo(StockController): def __init__(self, doc, doclist=None): self.doc = doc self.doclist = doclist or [] diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 3aeb507873..785ad9787b 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -6,7 +6,6 @@ import frappe import frappe.defaults from frappe.utils import cstr, cint, flt, comma_or, nowdate -from frappe.model.doc import addchild from frappe.model.bean import getlist from frappe.model.code import get_obj from frappe import msgprint, _ @@ -24,10 +23,7 @@ class StockOverProductionError(frappe.ValidationError): pass from erpnext.controllers.stock_controller import StockController -class DocType(StockController): - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist +class StockEntry(StockController): self.fname = 'mtn_details' def validate(self): @@ -77,7 +73,7 @@ class DocType(StockController): def validate_item(self): stock_items = self.get_stock_items() - for item in self.doclist.get({"parentfield": "mtn_details"}): + for item in self.get("mtn_details"): if item.item_code not in stock_items: msgprint(_("""Only Stock Items are allowed for Stock Entry"""), raise_exception=True) @@ -93,14 +89,14 @@ class DocType(StockController): if self.doc.purpose in source_mandatory and self.doc.purpose not in target_mandatory: self.doc.to_warehouse = None - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): d.t_warehouse = None elif self.doc.purpose in target_mandatory and self.doc.purpose not in source_mandatory: self.doc.from_warehouse = None - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): d.s_warehouse = None - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): if not d.s_warehouse and not d.t_warehouse: d.s_warehouse = self.doc.from_warehouse d.t_warehouse = self.doc.to_warehouse @@ -176,11 +172,11 @@ class DocType(StockController): + self.doc.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError) def set_total_amount(self): - self.doc.total_amount = sum([flt(item.amount) for item in self.doclist.get({"parentfield": "mtn_details"})]) + self.doc.total_amount = sum([flt(item.amount) for item in self.get("mtn_details")]) def get_stock_and_rate(self): """get stock and incoming rate on posting date""" - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): args = frappe._dict({ "item_code": d.item_code, "warehouse": d.s_warehouse or d.t_warehouse, @@ -225,12 +221,12 @@ class DocType(StockController): return incoming_rate def validate_incoming_rate(self): - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): if d.t_warehouse: self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError) def validate_bom(self): - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): if d.bom_no and not frappe.db.sql("""select name from `tabBOM` where item = %s and name = %s and docstatus = 1 and is_active = 1""", (d.item_code, d.bom_no)): @@ -240,7 +236,7 @@ class DocType(StockController): def validate_finished_goods(self): """validation: finished good quantity should be same as manufacturing quantity""" - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): if d.bom_no and flt(d.transfer_qty) != flt(self.doc.fg_completed_qty): msgprint(_("Row #") + " %s: " % d.idx + _("Quantity should be equal to Manufacturing Quantity. To fetch items again, click on 'Get Items' button or update the Quantity manually."), raise_exception=1) @@ -275,7 +271,7 @@ class DocType(StockController): stock_items = get_stock_items_for_return(ref.doclist, ref.parentfields) already_returned_item_qty = self.get_already_returned_item_qty(ref.fieldname) - for item in self.doclist.get({"parentfield": "mtn_details"}): + for item in self.get("mtn_details"): # validate if item exists in the ref doclist and that it is a stock item if item.item_code not in stock_items: msgprint(_("Item") + ': "' + item.item_code + _("\" does not exist in ") + @@ -303,7 +299,7 @@ class DocType(StockController): def update_stock_ledger(self): sl_entries = [] - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): if cstr(d.s_warehouse) and self.doc.docstatus == 1: sl_entries.append(self.get_sl_entries(d, { "warehouse": cstr(d.s_warehouse), @@ -431,7 +427,7 @@ class DocType(StockController): def get_items(self): self.doclist = filter(lambda d: d.parentfield!="mtn_details", self.doclist) - # self.doclist = self.doc.clear_table(self.doclist, 'mtn_details') + # self.set('mtn_details', []) pro_obj = None if self.doc.production_order: @@ -566,8 +562,7 @@ class DocType(StockController): ["default_expense_account", "cost_center"])[0] for d in item_dict: - se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', - self.doclist) + se_child = self.doc.append('mtn_details', {}) se_child.idx = idx se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse) se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse) @@ -592,7 +587,7 @@ class DocType(StockController): return idx def validate_with_material_request(self): - for item in self.doclist.get({"parentfield": "mtn_details"}): + for item in self.get("mtn_details"): if item.material_request: mreq_item = frappe.db.get_value("Material Request Item", {"name": item.material_request_item, "parent": item.material_request}, @@ -801,7 +796,7 @@ def make_return_jv_from_sales_invoice(se, ref): # income account entries children = [] - for se_item in se.doclist.get({"parentfield": "mtn_details"}): + for se_item in se.get("mtn_details"): # find item in ref.doclist ref_item = ref.doclist.getone({"item_code": se_item.item_code}) @@ -843,7 +838,7 @@ def make_return_jv_from_delivery_note(se, ref): parent = {} children = [] - for se_item in se.doclist.get({"parentfield": "mtn_details"}): + for se_item in se.get("mtn_details"): for sales_invoice in invoices_against_delivery: si = frappe.bean("Sales Invoice", sales_invoice) @@ -900,7 +895,7 @@ def make_return_jv_from_purchase_receipt(se, ref): parent = {} children = [] - for se_item in se.doclist.get({"parentfield": "mtn_details"}): + for se_item in se.get("mtn_details"): for purchase_invoice in invoice_against_receipt: pi = frappe.bean("Purchase Invoice", purchase_invoice) ref_item = pi.doclist.get({"item_code": se_item.item_code}) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index d14e896fb0..dc27cc9fcc 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -335,7 +335,7 @@ class TestStockEntry(unittest.TestCase): si = frappe.bean(si_doclist) si.doc.posting_date = dn.doc.posting_date si.doc.debit_to = "_Test Customer - _TC" - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): d.income_account = "Sales - _TC" d.cost_center = "_Test Cost Center - _TC" si.insert() @@ -433,7 +433,7 @@ class TestStockEntry(unittest.TestCase): si = frappe.bean(si_doclist) si.doc.posting_date = dn.doc.posting_date si.doc.debit_to = "_Test Customer - _TC" - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): d.income_account = "Sales - _TC" d.cost_center = "_Test Cost Center - _TC" si.insert() @@ -479,11 +479,11 @@ class TestStockEntry(unittest.TestCase): pi = frappe.bean(pi_doclist) pi.doc.posting_date = pr.doc.posting_date pi.doc.credit_to = "_Test Supplier - _TC" - for d in pi.doclist.get({"parentfield": "entries"}): + for d in pi.get("entries"): d.expense_account = "_Test Account Cost for Goods Sold - _TC" d.cost_center = "_Test Cost Center - _TC" - for d in pi.doclist.get({"parentfield": "other_charges"}): + for d in pi.get("other_charges"): d.cost_center = "_Test Cost Center - _TC" pi.run_method("calculate_taxes_and_totals") @@ -582,10 +582,10 @@ class TestStockEntry(unittest.TestCase): pi = frappe.bean(pi_doclist) pi.doc.posting_date = pr.doc.posting_date pi.doc.credit_to = "_Test Supplier - _TC" - for d in pi.doclist.get({"parentfield": "entries"}): + for d in pi.get("entries"): d.expense_account = "_Test Account Cost for Goods Sold - _TC" d.cost_center = "_Test Cost Center - _TC" - for d in pi.doclist.get({"parentfield": "other_charges"}): + for d in pi.get("other_charges"): d.cost_center = "_Test Cost Center - _TC" pi.run_method("calculate_taxes_and_totals") diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py index 26c87f1c04..2570b68018 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class StockEntryDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_ledger/stock_ledger.py b/erpnext/stock/doctype/stock_ledger/stock_ledger.py index 664eadbd81..452ad35879 100644 --- a/erpnext/stock/doctype/stock_ledger/stock_ledger.py +++ b/erpnext/stock/doctype/stock_ledger/stock_ledger.py @@ -12,10 +12,9 @@ from frappe import session, msgprint from erpnext.stock.utils import get_valid_serial_nos -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class StockLedger(Document): def update_stock(self, values, is_amended = 'No'): for v in values: diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 9bb991175a..dfc75d5b1a 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -11,10 +11,7 @@ from datetime import date class StockFreezeError(frappe.ValidationError): pass -class DocType(DocListController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class StockLedgerEntry(DocListController): def validate(self): from erpnext.stock.utils import validate_warehouse_company diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 7eef0a43e7..c4195c61d5 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -10,7 +10,7 @@ from frappe.utils import cstr, flt, cint from erpnext.stock.stock_ledger import update_entries_after from erpnext.controllers.stock_controller import StockController -class DocType(StockController): +class StockReconciliation(StockController): def setup(self): self.head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"] self.entries = [] diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py index 7f03bb1b1e..cb266ed434 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/stock_settings.py @@ -7,9 +7,9 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class StockSettings(Document): def validate(self): for key in ["item_naming_by", "item_group", "stock_uom", diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py index 8ff893872c..62c80d2e60 100644 --- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py +++ b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py @@ -7,7 +7,9 @@ from frappe.utils import cstr, flt, cint from frappe import msgprint, _ -class DocType: +from frappe.model.document import Document + +class StockUomReplaceUtility(Document): def __init__(self, d, dl=[]): self.doc, self.doclist = d,dl diff --git a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py index 26c87f1c04..00cd84765a 100644 --- a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py +++ b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class UomConversionDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py index 8ec62351a0..d098cfe576 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.py +++ b/erpnext/stock/doctype/warehouse/warehouse.py @@ -6,10 +6,9 @@ import frappe from frappe.utils import cint, validate_email_add from frappe import throw, msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Warehouse(Document): def autoname(self): suffix = " - " + frappe.db.get_value("Company", self.doc.company, "abbr") diff --git a/erpnext/stock/doctype/warehouse_user/warehouse_user.py b/erpnext/stock/doctype/warehouse_user/warehouse_user.py index 968a25b613..59bfefe3b1 100644 --- a/erpnext/stock/doctype/warehouse_user/warehouse_user.py +++ b/erpnext/stock/doctype/warehouse_user/warehouse_user.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class WarehouseUser(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 39d494c69a..8bfc083629 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -138,7 +138,7 @@ def get_basic_details(args, item_bean): if args.transaction_type == "selling" else item.buying_cost_center, "batch_no": None, "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in - item_bean.doclist.get({"parentfield": "item_tax"})))), + item_bean.get("item_tax")))), "uom": item.stock_uom, "min_order_qty": flt(item.min_order_qty) if args.doctype == "Material Request" else "", "conversion_factor": 1.0, diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 3a0766aca8..e5099c46e2 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -299,7 +299,7 @@ def send_email_notification(mr_list): for mr in mr_list: msg += "

" + mr.doc.name + """

""" - for item in mr.doclist.get({"parentfield": "indent_details"}): + for item in mr.get("indent_details"): msg += "" msg += "
Item CodeWarehouseQtyUOM
" + item.item_code + "" + item.warehouse + "" + \ cstr(item.qty) + "" + cstr(item.uom) + "
" diff --git a/erpnext/support/doctype/customer_issue/customer_issue.py b/erpnext/support/doctype/customer_issue/customer_issue.py index 128accd144..406ea61529 100644 --- a/erpnext/support/doctype/customer_issue/customer_issue.py +++ b/erpnext/support/doctype/customer_issue/customer_issue.py @@ -11,10 +11,7 @@ from frappe.utils import today from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class CustomerIssue(TransactionBase): def validate(self): if session['user'] != 'Guest' and not self.doc.customer: diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py index 2fcd200493..9f7aef13c1 100644 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py @@ -5,16 +5,12 @@ from __future__ import unicode_literals import frappe from frappe.utils import add_days, cstr, getdate, cint -from frappe.model.doc import addchild from frappe.model.bean import getlist from frappe import throw, _ from erpnext.utilities.transaction_base import TransactionBase, delete_events from erpnext.stock.utils import get_valid_serial_nos -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class MaintenanceSchedule(TransactionBase): def get_item_details(self, item_code): item = frappe.db.sql("""select item_name, description from `tabItem` @@ -26,17 +22,16 @@ class DocType(TransactionBase): return ret def generate_schedule(self): - self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail') + self.set('maintenance_schedule_detail', []) frappe.db.sql("""delete from `tabMaintenance Schedule Detail` where parent=%s""", (self.doc.name)) count = 1 - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): self.validate_maintenance_detail() s_list = [] s_list = self.create_schedule_list(d.start_date, d.end_date, d.no_of_visits, d.sales_person) for i in range(d.no_of_visits): - child = addchild(self.doc, 'maintenance_schedule_detail', - 'Maintenance Schedule Detail', self.doclist) + child = self.append('maintenance_schedule_detail') child.item_code = d.item_code child.item_name = d.item_name child.scheduled_date = s_list[i].strftime('%Y-%m-%d') @@ -50,13 +45,13 @@ class DocType(TransactionBase): self.on_update() def on_submit(self): - if not getlist(self.doclist, 'maintenance_schedule_detail'): + if not self.get('maintenance_schedule_detail'): throw("Please click on 'Generate Schedule' to get schedule") self.check_serial_no_added() self.validate_schedule() email_map = {} - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.serial_no: serial_nos = get_valid_serial_nos(d.serial_no) self.validate_serial_no(serial_nos, d.start_date) @@ -174,10 +169,10 @@ class DocType(TransactionBase): return ret def validate_maintenance_detail(self): - if not getlist(self.doclist, 'item_maintenance_detail'): + if not self.get('item_maintenance_detail'): throw(_("Please enter Maintaince Details first")) - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if not d.item_code: throw(_("Please select item code")) elif not d.start_date or not d.end_date: @@ -191,7 +186,7 @@ class DocType(TransactionBase): throw(_("Start date should be less than end date for item") + " " + d.item_code) def validate_sales_order(self): - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.prevdoc_docname: chk = frappe.db.sql("""select ms.name from `tabMaintenance Schedule` ms, `tabMaintenance Schedule Item` msi where msi.parent=ms.name and @@ -233,11 +228,11 @@ class DocType(TransactionBase): def validate_schedule(self): item_lst1 =[] item_lst2 =[] - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.item_code not in item_lst1: item_lst1.append(d.item_code) - for m in getlist(self.doclist, 'maintenance_schedule_detail'): + for m in self.get('maintenance_schedule_detail'): if m.item_code not in item_lst2: item_lst2.append(m.item_code) @@ -252,17 +247,17 @@ class DocType(TransactionBase): def check_serial_no_added(self): serial_present =[] - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.serial_no: serial_present.append(d.item_code) - for m in getlist(self.doclist, 'maintenance_schedule_detail'): + for m in self.get('maintenance_schedule_detail'): if serial_present: if m.item_code in serial_present and not m.serial_no: throw("Please click on 'Generate Schedule' to fetch serial no added for item "+m.item_code) def on_cancel(self): - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.serial_no: serial_nos = get_valid_serial_nos(d.serial_no) self.update_amc_date(serial_nos) diff --git a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py index 26c87f1c04..8c15d32c83 100644 --- a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py +++ b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class MaintenanceScheduleDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py index 26c87f1c04..47000c126a 100644 --- a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py +++ b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class MaintenanceScheduleItem(Document): + pass \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py index 1ddf67be6c..234756bf9a 100644 --- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py +++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py @@ -12,29 +12,26 @@ from frappe import msgprint from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class MaintenanceVisit(TransactionBase): def get_item_details(self, item_code): return frappe.db.get_value("Item", item_code, ["item_name", "description"], as_dict=1) def validate_serial_no(self): - for d in getlist(self.doclist, 'maintenance_visit_details'): + for d in self.get('maintenance_visit_details'): if d.serial_no and not frappe.db.exists("Serial No", d.serial_no): frappe.throw("Serial No: "+ d.serial_no + " not exists in the system") def validate(self): - if not getlist(self.doclist, 'maintenance_visit_details'): + if not self.get('maintenance_visit_details'): msgprint("Please enter maintenance details") raise Exception self.validate_serial_no() def update_customer_issue(self, flag): - for d in getlist(self.doclist, 'maintenance_visit_details'): + for d in self.get('maintenance_visit_details'): if d.prevdoc_docname and d.prevdoc_doctype == 'Customer Issue' : if flag==1: mntc_date = self.doc.mntc_date @@ -64,7 +61,7 @@ class DocType(TransactionBase): def check_if_last_visit(self): """check if last maintenance visit against same sales order/ customer issue""" check_for_docname = check_for_doctype = None - for d in getlist(self.doclist, 'maintenance_visit_details'): + for d in self.get('maintenance_visit_details'): if d.prevdoc_docname: check_for_docname = d.prevdoc_docname check_for_doctype = d.prevdoc_doctype diff --git a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py index 26c87f1c04..ac30b7a90e 100644 --- a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py +++ b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class MaintenanceVisitPurpose(Document): + pass \ No newline at end of file diff --git a/erpnext/support/doctype/newsletter/newsletter.py b/erpnext/support/doctype/newsletter/newsletter.py index 72d05aff28..7ede45c035 100644 --- a/erpnext/support/doctype/newsletter/newsletter.py +++ b/erpnext/support/doctype/newsletter/newsletter.py @@ -7,10 +7,9 @@ import frappe import frappe.utils from frappe.utils import cstr from frappe import msgprint, throw, _ +from frappe.model.document import Document -class DocType(): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class Newsletter(Document): def onload(self): if self.doc.email_sent: diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.py b/erpnext/support/doctype/support_email_settings/support_email_settings.py index 203bf72d51..65edf23940 100644 --- a/erpnext/support/doctype/support_email_settings/support_email_settings.py +++ b/erpnext/support/doctype/support_email_settings/support_email_settings.py @@ -6,9 +6,9 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class SupportEmailSettings(Document): def validate(self): """ diff --git a/erpnext/support/doctype/support_ticket/support_ticket.py b/erpnext/support/doctype/support_ticket/support_ticket.py index 57d141ea01..a01dad3814 100644 --- a/erpnext/support/doctype/support_ticket/support_ticket.py +++ b/erpnext/support/doctype/support_ticket/support_ticket.py @@ -7,10 +7,7 @@ import frappe from erpnext.utilities.transaction_base import TransactionBase from frappe.utils import now, extract_email_id -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class SupportTicket(TransactionBase): def get_sender(self, comm): return frappe.db.get_value('Support Email Settings',None,'support_email') diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py index b80f13a337..b698658eac 100644 --- a/erpnext/utilities/doctype/address/address.py +++ b/erpnext/utilities/doctype/address/address.py @@ -7,10 +7,9 @@ import frappe from frappe import msgprint, throw, _ from frappe.utils import cstr, cint -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Address(Document): def autoname(self): if not self.doc.address_title: diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py index 948b753fcd..16522a85eb 100644 --- a/erpnext/utilities/doctype/contact/contact.py +++ b/erpnext/utilities/doctype/contact/contact.py @@ -7,10 +7,7 @@ from frappe.utils import cstr, extract_email_id from erpnext.controllers.status_updater import StatusUpdater -class DocType(StatusUpdater): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class Contact(StatusUpdater): def autoname(self): # concat first and last name diff --git a/erpnext/utilities/doctype/note/note.py b/erpnext/utilities/doctype/note/note.py index 99846d9f9b..8936da77a9 100644 --- a/erpnext/utilities/doctype/note/note.py +++ b/erpnext/utilities/doctype/note/note.py @@ -6,9 +6,9 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class Note(Document): def autoname(self): # replace forbidden characters diff --git a/erpnext/utilities/doctype/note_user/note_user.py b/erpnext/utilities/doctype/note_user/note_user.py index 968a25b613..1594f787ca 100644 --- a/erpnext/utilities/doctype/note_user/note_user.py +++ b/erpnext/utilities/doctype/note_user/note_user.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class NoteUser(Document): + pass \ No newline at end of file diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.py b/erpnext/utilities/doctype/rename_tool/rename_tool.py index 835e6471e7..7ee46df645 100644 --- a/erpnext/utilities/doctype/rename_tool/rename_tool.py +++ b/erpnext/utilities/doctype/rename_tool/rename_tool.py @@ -7,9 +7,9 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class RenameTool(Document): @frappe.whitelist() def get_doctypes(): diff --git a/erpnext/utilities/doctype/sms_control/sms_control.py b/erpnext/utilities/doctype/sms_control/sms_control.py index 832c443a8d..b160ad9139 100644 --- a/erpnext/utilities/doctype/sms_control/sms_control.py +++ b/erpnext/utilities/doctype/sms_control/sms_control.py @@ -10,10 +10,9 @@ from frappe.model.doc import Document from frappe import msgprint, throw, _ from frappe.model.bean import getlist -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class SmsControl(Document): def validate_receiver_nos(self,receiver_list): validated_receiver_list = [] diff --git a/erpnext/utilities/doctype/sms_log/sms_log.py b/erpnext/utilities/doctype/sms_log/sms_log.py index 26c87f1c04..573054e66e 100644 --- a/erpnext/utilities/doctype/sms_log/sms_log.py +++ b/erpnext/utilities/doctype/sms_log/sms_log.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SmsLog(Document): + pass