From 424c0333954b15d3788aaa4ad1aab11fab8c6633 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 21 Apr 2014 15:06:56 +0530 Subject: [PATCH] Removed controller.py --- .../accounts/doctype/pricing_rule/pricing_rule.py | 4 ++-- .../sales_taxes_and_charges_master.py | 12 ++++++------ .../accounts/doctype/shipping_rule/shipping_rule.py | 5 ++--- erpnext/controllers/status_updater.py | 5 ++--- erpnext/hr/doctype/employee/employee.py | 4 ++-- .../doctype/leave_application/leave_application.py | 7 +++---- erpnext/setup/doctype/item_group/item_group.py | 4 ++-- .../stock_reconciliation/stock_reconciliation.py | 3 +-- 8 files changed, 20 insertions(+), 24 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 3374e4a50ed..a96614292c1 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -6,9 +6,9 @@ from __future__ import unicode_literals import frappe from frappe import throw, _ -from frappe.model.controller import DocListController +from frappe.model.document import Document -class PricingRule(DocListController): +class PricingRule(Document): def validate(self): self.validate_mandatory() self.cleanup_fields_value() 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 f63a767ba55..8dd27592210 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 @@ -4,14 +4,14 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint -from frappe.model.controller import DocListController +from frappe.model.document import Document -class SalesTaxesandChargesMaster(DocListController): +class SalesTaxesandChargesMaster(Document): def validate(self): if self.is_default == 1: - frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0 - where ifnull(is_default,0) = 1 and name != %s and company = %s""", + frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0 + where ifnull(is_default,0) = 1 and name != %s and company = %s""", (self.name, self.company)) - + # at least one territory - self.validate_table_has_rows("valid_for_territories") \ No newline at end of file + self.validate_table_has_rows("valid_for_territories") diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py index 55b7ed639de..f9f64e4677f 100644 --- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py @@ -7,15 +7,14 @@ from __future__ import unicode_literals import frappe from frappe import _, msgprint, throw from frappe.utils import flt, fmt_money -from frappe.model.controller import DocListController +from frappe.model.document import Document from erpnext.setup.utils import get_company_currency class OverlappingConditionError(frappe.ValidationError): pass class FromGreaterThanToError(frappe.ValidationError): pass class ManyBlankToValuesError(frappe.ValidationError): pass -class ShippingRule(DocListController): - +class ShippingRule(Document): def validate(self): self.validate_value("calculate_based_on", "in", ["Net Total", "Net Weight"]) self.shipping_rule_conditions = self.get("shipping_rule_conditions") diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 4ccdbda359d..2f655bae9b3 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -5,8 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt from frappe import msgprint, _, throw - -from frappe.model.controller import DocListController +from frappe.model.document import Document status_map = { "Contact": [ @@ -53,7 +52,7 @@ status_map = { ], } -class StatusUpdater(DocListController): +class StatusUpdater(Document): """ Updates the status of the calling records Delivery Note: Update Delivered Qty, Update Percent and Validate over delivery diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index 45500074959..e1a060b7f42 100644 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -9,9 +9,9 @@ from frappe.model.naming import make_autoname from frappe import throw, _ import frappe.permissions from frappe.defaults import get_restrictions -from frappe.model.controller import DocListController +from frappe.model.document import Document -class Employee(DocListController): +class Employee(Document): def autoname(self): naming_method = frappe.db.get_value("HR Settings", None, "emp_created_by") if not naming_method: diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index d74e930febd..dd24463ec5a 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -14,15 +14,14 @@ class OverlapError(frappe.ValidationError): pass class InvalidLeaveApproverError(frappe.ValidationError): pass class LeaveApproverIdentityError(frappe.ValidationError): pass -from frappe.model.controller import DocListController -class LeaveApplication(DocListController): - def setup(self): +from frappe.model.document import Document +class LeaveApplication(Document): + def validate(self): if not getattr(self, "__islocal", None) and frappe.db.exists(self.doctype, self.name): self.previous_doc = frappe.db.get_value(self.doctype, self.name, "*", as_dict=True) else: self.previous_doc = None - def validate(self): self.validate_to_date() self.validate_balance_leaves() self.validate_leave_overlap() diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index df42bb575b1..e29297c6dd7 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -27,8 +27,8 @@ class ItemGroup(NestedSet, WebsiteGenerator): self.validate_one_root() def after_rename(self, olddn, newdn, merge=False): - NestedSet.after_rename(self) - WebsiteGenerator.after_rename(self) + NestedSet.after_rename(self, olddn, newdn, merge) + WebsiteGenerator.after_rename(self, olddn, newdn, merge) def on_trash(self): NestedSet.on_trash(self) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 62842f1f2cb..870fcd0bb28 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -11,11 +11,10 @@ from erpnext.stock.stock_ledger import update_entries_after from erpnext.controllers.stock_controller import StockController class StockReconciliation(StockController): - def setup(self): + def validate(self): self.head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"] self.entries = [] - def validate(self): self.validate_data() self.validate_expense_account()