This commit is contained in:
parent
dd32d6eb1f
commit
5b552b51f1
@ -11,7 +11,8 @@ from erpnext.setup.utils import get_company_currency
|
||||
from erpnext.controllers.accounts_controller import AccountsController
|
||||
|
||||
class JournalVoucher(AccountsController):
|
||||
|
||||
def __init__(self, arg1, arg2=None):
|
||||
super(JournalVoucher, self).__init__(arg1, arg2)
|
||||
self.master_type = {}
|
||||
self.credit_days_for = {}
|
||||
self.credit_days_global = -1
|
||||
|
@ -8,8 +8,6 @@ from frappe import _
|
||||
from erpnext.controllers.accounts_controller import AccountsController
|
||||
|
||||
class PeriodClosingVoucher(AccountsController):
|
||||
self.year_start_date = ''
|
||||
|
||||
def validate(self):
|
||||
self.validate_account_head()
|
||||
self.validate_posting_date()
|
||||
@ -47,7 +45,7 @@ class PeriodClosingVoucher(AccountsController):
|
||||
and t2.docstatus < 2 and t2.company = %s
|
||||
and t1.posting_date between %s and %s
|
||||
group by t1.account
|
||||
""", (self.company, self.year_start_date, self.posting_date), as_dict=1)
|
||||
""", (self.company, self.get("year_start_date"), self.posting_date), as_dict=1)
|
||||
|
||||
def make_gl_entries(self):
|
||||
gl_entries = []
|
||||
|
@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe.model.utils import getlist
|
||||
from frappe import msgprint, _
|
||||
|
||||
from erpnext.stock.doctype.item.item import get_last_purchase_details
|
||||
@ -19,7 +18,7 @@ class PurchaseCommon(BuyingController):
|
||||
import frappe.utils
|
||||
this_purchase_date = frappe.utils.getdate(obj.get('posting_date') or obj.get('transaction_date'))
|
||||
|
||||
for d in getlist(obj.doclist,obj.fname):
|
||||
for d in obj.get(obj.fname):
|
||||
# get last purchase details
|
||||
last_purchase_details = get_last_purchase_details(d.item_code, obj.name)
|
||||
|
||||
@ -47,7 +46,7 @@ class PurchaseCommon(BuyingController):
|
||||
doc_name = obj.name
|
||||
conversion_rate = flt(obj.get('conversion_rate')) or 1.0
|
||||
|
||||
for d in getlist(obj.doclist, obj.fname):
|
||||
for d in obj.get(obj.fname):
|
||||
if d.item_code:
|
||||
last_purchase_details = get_last_purchase_details(d.item_code, doc_name)
|
||||
|
||||
@ -69,7 +68,7 @@ class PurchaseCommon(BuyingController):
|
||||
|
||||
def validate_for_items(self, obj):
|
||||
check_list, chk_dupl_itm=[],[]
|
||||
for d in getlist( obj.doclist, obj.fname):
|
||||
for d in obj.get(obj.fname):
|
||||
# validation for valid qty
|
||||
if flt(d.qty) < 0 or (d.parenttype != 'Purchase Receipt' and not flt(d.qty)):
|
||||
frappe.throw("Please enter valid qty for item %s" % cstr(d.item_code))
|
||||
|
@ -11,19 +11,19 @@ from frappe import msgprint
|
||||
|
||||
from erpnext.controllers.buying_controller import BuyingController
|
||||
class PurchaseOrder(BuyingController):
|
||||
self.tname = 'Purchase Order Item'
|
||||
self.fname = 'po_details'
|
||||
self.status_updater = [{
|
||||
'source_dt': 'Purchase Order Item',
|
||||
'target_dt': 'Material Request Item',
|
||||
'join_field': 'prevdoc_detail_docname',
|
||||
'target_field': 'ordered_qty',
|
||||
'target_parent_dt': 'Material Request',
|
||||
'target_parent_field': 'per_ordered',
|
||||
'target_ref_field': 'qty',
|
||||
'source_field': 'qty',
|
||||
'percent_join_field': 'prevdoc_docname',
|
||||
}]
|
||||
tname = 'Purchase Order Item'
|
||||
fname = 'po_details'
|
||||
status_updater = [{
|
||||
'source_dt': 'Purchase Order Item',
|
||||
'target_dt': 'Material Request Item',
|
||||
'join_field': 'prevdoc_detail_docname',
|
||||
'target_field': 'ordered_qty',
|
||||
'target_parent_dt': 'Material Request',
|
||||
'target_parent_field': 'per_ordered',
|
||||
'target_ref_field': 'qty',
|
||||
'source_field': 'qty',
|
||||
'percent_join_field': 'prevdoc_docname',
|
||||
}]
|
||||
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
|
@ -342,20 +342,14 @@ class AccountsController(TransactionBase):
|
||||
|
||||
def _cleanup(self):
|
||||
for tax in self.tax_doclist:
|
||||
for fieldname in ("grand_total_for_current_item",
|
||||
"tax_amount_for_current_item",
|
||||
"tax_fraction_for_current_item",
|
||||
"grand_total_fraction_for_current_item"):
|
||||
if fieldname in tax.fields:
|
||||
del tax.get(fieldname)
|
||||
|
||||
tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail)
|
||||
|
||||
def _set_in_company_currency(self, item, print_field, base_field):
|
||||
"""set values in base currency"""
|
||||
item.set(base_field, flt((flt(item.get(print_field),)
|
||||
self.precision(print_field, item)) * self.conversion_rate),
|
||||
value_in_company_currency = flt(self.conversion_rate *
|
||||
flt(item.get(print_field), self.precision(print_field, item)),
|
||||
self.precision(base_field, item))
|
||||
item.set(base_field, value_in_company_currency)
|
||||
|
||||
def calculate_total_advance(self, parenttype, advance_parentfield):
|
||||
if self.doctype == parenttype and self.docstatus < 2:
|
||||
|
@ -147,18 +147,6 @@ class BuyingController(StockController):
|
||||
self.outstanding_amount = flt(self.total_amount_to_pay - self.total_advance,
|
||||
self.precision("outstanding_amount"))
|
||||
|
||||
def _cleanup(self):
|
||||
super(BuyingController, self)._cleanup()
|
||||
|
||||
if not self.meta.get_field("item_tax_amount", parentfield=self.fname):
|
||||
for item in self.item_doclist:
|
||||
del item.get("item_tax_amount")
|
||||
|
||||
if not self.meta.get_field("tax_amount_after_discount_amount",
|
||||
parentfield=self.other_fname):
|
||||
for tax in self.tax_doclist:
|
||||
del tax.get("tax_amount_after_discount_amount")
|
||||
|
||||
# update valuation rate
|
||||
def update_valuation_rate(self, parentfield):
|
||||
"""
|
||||
|
@ -10,6 +10,8 @@ from frappe import msgprint, _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class ProductionPlanningTool(Document):
|
||||
def __init__(self, arg1, arg2=None):
|
||||
super(ProductionPlanningTool, self).__init__(arg1, arg2)
|
||||
self.item_dict = {}
|
||||
|
||||
def get_so_details(self, so):
|
||||
|
@ -12,21 +12,21 @@ from erpnext.stock.utils import get_valid_serial_nos
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
|
||||
class InstallationNote(TransactionBase):
|
||||
self.tname = 'Installation Note Item'
|
||||
self.fname = 'installed_item_details'
|
||||
self.status_updater = [{
|
||||
'source_dt': 'Installation Note Item',
|
||||
'target_dt': 'Delivery Note Item',
|
||||
'target_field': 'installed_qty',
|
||||
'target_ref_field': 'qty',
|
||||
'join_field': 'prevdoc_detail_docname',
|
||||
'target_parent_dt': 'Delivery Note',
|
||||
'target_parent_field': 'per_installed',
|
||||
'source_field': 'qty',
|
||||
'percent_join_field': 'prevdoc_docname',
|
||||
'status_field': 'installation_status',
|
||||
'keyword': 'Installed'
|
||||
}]
|
||||
tname = 'Installation Note Item'
|
||||
fname = 'installed_item_details'
|
||||
status_updater = [{
|
||||
'source_dt': 'Installation Note Item',
|
||||
'target_dt': 'Delivery Note Item',
|
||||
'target_field': 'installed_qty',
|
||||
'target_ref_field': 'qty',
|
||||
'join_field': 'prevdoc_detail_docname',
|
||||
'target_parent_dt': 'Delivery Note',
|
||||
'target_parent_field': 'per_installed',
|
||||
'source_field': 'qty',
|
||||
'percent_join_field': 'prevdoc_docname',
|
||||
'status_field': 'installation_status',
|
||||
'keyword': 'Installed'
|
||||
}]
|
||||
|
||||
def validate(self):
|
||||
self.validate_fiscal_year()
|
||||
|
@ -11,20 +11,19 @@ from frappe import session
|
||||
from erpnext.controllers.selling_controller import SellingController
|
||||
|
||||
class Lead(SellingController):
|
||||
|
||||
self._prev = frappe._dict({
|
||||
"contact_date": frappe.db.get_value("Lead", self.name, "contact_date") if \
|
||||
(not cint(self.get("__islocal"))) else None,
|
||||
"contact_by": frappe.db.get_value("Lead", self.name, "contact_by") if \
|
||||
(not cint(self.get("__islocal"))) else None,
|
||||
})
|
||||
|
||||
def onload(self):
|
||||
customer = frappe.db.get_value("Customer", {"lead_name": self.name})
|
||||
if customer:
|
||||
self.set("__is_customer", customer)
|
||||
|
||||
def validate(self):
|
||||
self._prev = frappe._dict({
|
||||
"contact_date": frappe.db.get_value("Lead", self.name, "contact_date") if \
|
||||
(not cint(self.get("__islocal"))) else None,
|
||||
"contact_by": frappe.db.get_value("Lead", self.name, "contact_by") if \
|
||||
(not cint(self.get("__islocal"))) else None,
|
||||
})
|
||||
|
||||
self.set_status()
|
||||
|
||||
if self.source == 'Campaign' and not self.campaign_name and session['user'] != 'Guest':
|
||||
|
@ -86,7 +86,7 @@ class AuthorizationControl(TransactionBase):
|
||||
add_cond = " and master_name = '"+make_esc("'")(cstr(customer))+"'"
|
||||
if based_on == 'Itemwise Discount':
|
||||
if doc_obj:
|
||||
for t in getlist(doc_obj.doclist, doc_obj.fname):
|
||||
for t in doc_obj.get(doc_obj.fname):
|
||||
self.validate_auth_rule(doctype_name, t.discount_percentage, based_on, add_cond, company,t.item_code )
|
||||
else:
|
||||
self.validate_auth_rule(doctype_name, auth_value, based_on, add_cond, company)
|
||||
@ -98,7 +98,7 @@ class AuthorizationControl(TransactionBase):
|
||||
av_dis = 0
|
||||
if doc_obj:
|
||||
price_list_rate, base_rate = 0, 0
|
||||
for d in getlist(doc_obj.doclist, doc_obj.fname):
|
||||
for d in doc_obj.get(doc_obj.fname):
|
||||
if d.base_price_list_rate and d.base_rate:
|
||||
price_list_rate += flt(d.base_price_list_rate)
|
||||
base_rate += flt(d.base_rate)
|
||||
|
@ -7,7 +7,7 @@ import frappe
|
||||
from frappe.utils.nestedset import DocTypeNestedSet
|
||||
|
||||
class ItemGroup(DocTypeNestedSet):
|
||||
self.nsm_parent_field = 'parent_item_group'
|
||||
nsm_parent_field = 'parent_item_group'
|
||||
|
||||
def validate(self):
|
||||
if not self.parent_website_route:
|
||||
|
@ -8,7 +8,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe.model.utils import getlist
|
||||
from frappe import msgprint, _
|
||||
|
||||
from erpnext.controllers.buying_controller import BuyingController
|
||||
|
@ -32,7 +32,7 @@ def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packi
|
||||
|
||||
# check if exists
|
||||
exists = 0
|
||||
for d in getlist(obj.doclist, 'packing_details'):
|
||||
for d in obj.get("packing_details"):
|
||||
if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name:
|
||||
pi, exists = d, 1
|
||||
break
|
||||
|
@ -70,7 +70,7 @@ class SmsControl(Document):
|
||||
def send_via_gateway(self, arg):
|
||||
ss = frappe.get_doc('SMS Settings', 'SMS Settings')
|
||||
args = {ss.message_parameter : arg.get('message')}
|
||||
for d in getlist(ss.doclist, 'static_parameter_details'):
|
||||
for d in ss.get("static_parameter_details"):
|
||||
args[d.parameter] = d.value
|
||||
|
||||
resp = []
|
||||
|
@ -13,8 +13,8 @@ class TransactionBase(StatusUpdater):
|
||||
def load_notification_message(self):
|
||||
dt = self.doctype.lower().replace(" ", "_")
|
||||
if int(frappe.db.get_value("Notification Control", None, dt) or 0):
|
||||
self.set("__notification_message", \)
|
||||
frappe.db.get_value("Notification Control", None, dt + "_message")
|
||||
self.set("__notification_message",
|
||||
frappe.db.get_value("Notification Control", None, dt + "_message"))
|
||||
|
||||
def validate_posting_time(self):
|
||||
if not self.posting_time:
|
||||
|
Loading…
Reference in New Issue
Block a user