This commit is contained in:
parent
f78d1aee28
commit
81ba0b29da
@ -62,7 +62,7 @@ class CForm(Document):
|
||||
|
||||
def set_total_invoiced_amount(self):
|
||||
total = sum([flt(d.grand_total) for d in self.get('invoice_details')])
|
||||
frappe.db.set(self.doc, 'total_invoiced_amount', total)
|
||||
frappe.db.set(self, 'total_invoiced_amount', total)
|
||||
|
||||
def get_invoice_details(self, invoice_no):
|
||||
""" Pull details from invoices for referrence """
|
||||
|
@ -374,7 +374,7 @@ class SalesInvoice(SellingController):
|
||||
frappe.db.sql("""delete from `tabC-Form Invoice Detail` where invoice_no = %s
|
||||
and parent = %s""", (self.amended_from, self.c_form_no))
|
||||
|
||||
frappe.db.set(self.doc, 'c_form_no', '')
|
||||
frappe.db.set(self, 'c_form_no', '')
|
||||
|
||||
def update_current_stock(self):
|
||||
for d in self.get('entries'):
|
||||
@ -422,14 +422,14 @@ class SalesInvoice(SellingController):
|
||||
if cint(self.is_pos) == 1:
|
||||
if flt(self.paid_amount) == 0:
|
||||
if self.cash_bank_account:
|
||||
frappe.db.set(self.doc, 'paid_amount',
|
||||
frappe.db.set(self, 'paid_amount',
|
||||
(flt(self.grand_total) - flt(self.write_off_amount)))
|
||||
else:
|
||||
# show message that the amount is not paid
|
||||
frappe.db.set(self.doc,'paid_amount',0)
|
||||
frappe.db.set(self,'paid_amount',0)
|
||||
frappe.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
|
||||
else:
|
||||
frappe.db.set(self.doc,'paid_amount',0)
|
||||
frappe.db.set(self,'paid_amount',0)
|
||||
|
||||
def check_prev_docstatus(self):
|
||||
for d in self.get('entries'):
|
||||
@ -609,7 +609,7 @@ class SalesInvoice(SellingController):
|
||||
def convert_to_recurring(self):
|
||||
if self.convert_into_recurring_invoice:
|
||||
if not self.recurring_id:
|
||||
frappe.db.set(self.doc, "recurring_id",
|
||||
frappe.db.set(self, "recurring_id",
|
||||
make_autoname("RECINV/.#####"))
|
||||
|
||||
self.set_next_date()
|
||||
@ -645,7 +645,7 @@ class SalesInvoice(SellingController):
|
||||
next_date = get_next_date(self.posting_date,
|
||||
month_map[self.recurring_type], cint(self.repeat_on_day_of_month))
|
||||
|
||||
frappe.db.set(self.doc, 'next_date', next_date)
|
||||
frappe.db.set(self, 'next_date', next_date)
|
||||
|
||||
def get_next_date(dt, mcount, day=None):
|
||||
dt = getdate(dt)
|
||||
@ -794,8 +794,8 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_delivery_note(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_delivery_note(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def set_missing_values(source, target):
|
||||
bean = frappe.bean(target)
|
||||
@ -808,7 +808,7 @@ def make_delivery_note(source_name, target_doclist=None):
|
||||
flt(source_doc.rate)
|
||||
target_doc.qty = flt(source_doc.qty) - flt(source_doc.delivered_qty)
|
||||
|
||||
doclist = get_mapped_doclist("Sales Invoice", source_name, {
|
||||
doclist = get_mapped_doc("Sales Invoice", source_name, {
|
||||
"Sales Invoice": {
|
||||
"doctype": "Delivery Note",
|
||||
"validation": {
|
||||
@ -835,6 +835,6 @@ def make_delivery_note(source_name, target_doclist=None):
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
@ -135,7 +135,7 @@ class PurchaseOrder(BuyingController):
|
||||
def update_status(self, status):
|
||||
self.check_modified_date()
|
||||
# step 1:=> Set Status
|
||||
frappe.db.set(self.doc,'status',cstr(status))
|
||||
frappe.db.set(self,'status',cstr(status))
|
||||
|
||||
# step 2:=> Update Bin
|
||||
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
|
||||
@ -154,7 +154,7 @@ class PurchaseOrder(BuyingController):
|
||||
|
||||
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
||||
|
||||
frappe.db.set(self.doc,'status','Submitted')
|
||||
frappe.db.set(self,'status','Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
pc_obj = get_obj(dt = 'Purchase Common')
|
||||
@ -172,7 +172,7 @@ class PurchaseOrder(BuyingController):
|
||||
msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
|
||||
raise Exception
|
||||
|
||||
frappe.db.set(self.doc,'status','Cancelled')
|
||||
frappe.db.set(self,'status','Cancelled')
|
||||
self.update_prevdoc_status()
|
||||
self.update_bin( is_submit = 0, is_stopped = 0)
|
||||
pc_obj.update_last_purchase_rate(self, is_submit = 0)
|
||||
@ -181,8 +181,8 @@ class PurchaseOrder(BuyingController):
|
||||
pass
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_purchase_receipt(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_purchase_receipt(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def set_missing_values(source, target):
|
||||
bean = frappe.bean(target)
|
||||
@ -194,7 +194,7 @@ def make_purchase_receipt(source_name, target_doclist=None):
|
||||
target.amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.rate)
|
||||
target.base_amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.base_rate)
|
||||
|
||||
doclist = get_mapped_doclist("Purchase Order", source_name, {
|
||||
doclist = get_mapped_doc("Purchase Order", source_name, {
|
||||
"Purchase Order": {
|
||||
"doctype": "Purchase Receipt",
|
||||
"validation": {
|
||||
@ -215,13 +215,13 @@ def make_purchase_receipt(source_name, target_doclist=None):
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_purchase_invoice(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_purchase_invoice(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def set_missing_values(source, target):
|
||||
bean = frappe.bean(target)
|
||||
@ -233,7 +233,7 @@ def make_purchase_invoice(source_name, target_doclist=None):
|
||||
if flt(obj.base_rate):
|
||||
target.qty = target.base_amount / flt(obj.base_rate)
|
||||
|
||||
doclist = get_mapped_doclist("Purchase Order", source_name, {
|
||||
doclist = get_mapped_doc("Purchase Order", source_name, {
|
||||
"Purchase Order": {
|
||||
"doctype": "Purchase Invoice",
|
||||
"validation": {
|
||||
@ -253,6 +253,6 @@ def make_purchase_invoice(source_name, target_doclist=None):
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
@ -94,7 +94,7 @@ class Supplier(TransactionBase):
|
||||
def after_rename(self, olddn, newdn, merge=False):
|
||||
set_field = ''
|
||||
if frappe.defaults.get_global_default('supp_master_name') == 'Supplier Name':
|
||||
frappe.db.set(self.doc, "supplier_name", newdn)
|
||||
frappe.db.set(self, "supplier_name", newdn)
|
||||
self.update_contact()
|
||||
set_field = ", supplier_name=%(newdn)s"
|
||||
self.update_supplier_address(newdn, set_field)
|
||||
|
@ -7,9 +7,8 @@ from frappe.model.code import get_obj
|
||||
|
||||
from erpnext.controllers.buying_controller import 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"
|
||||
tname = "Supplier Quotation Item"
|
||||
fname = "quotation_items"
|
||||
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
@ -26,10 +25,10 @@ class SupplierQuotation(BuyingController):
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
|
||||
def on_submit(self):
|
||||
frappe.db.set(self.doc, "status", "Submitted")
|
||||
frappe.db.set(self, "status", "Submitted")
|
||||
|
||||
def on_cancel(self):
|
||||
frappe.db.set(self.doc, "status", "Cancelled")
|
||||
frappe.db.set(self, "status", "Cancelled")
|
||||
|
||||
def on_trash(self):
|
||||
pass
|
||||
@ -53,8 +52,8 @@ class SupplierQuotation(BuyingController):
|
||||
pc.validate_for_items(self)
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_purchase_order(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_purchase_order(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def set_missing_values(source, target):
|
||||
bean = frappe.bean(target)
|
||||
@ -64,7 +63,7 @@ def make_purchase_order(source_name, target_doclist=None):
|
||||
def update_item(obj, target, source_parent):
|
||||
target.conversion_factor = 1
|
||||
|
||||
doclist = get_mapped_doclist("Supplier Quotation", source_name, {
|
||||
doclist = get_mapped_doc("Supplier Quotation", source_name, {
|
||||
"Supplier Quotation": {
|
||||
"doctype": "Purchase Order",
|
||||
"validation": {
|
||||
@ -88,6 +87,6 @@ def make_purchase_order(source_name, target_doclist=None):
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
},
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
@ -103,7 +103,7 @@ class BuyingController(StockController):
|
||||
self.net_total += item.base_amount
|
||||
self.net_total_import += item.amount
|
||||
|
||||
self.round_floats_in(self.doc, ["net_total", "net_total_import"])
|
||||
self.round_floats_in(self, ["net_total", "net_total_import"])
|
||||
|
||||
def calculate_totals(self):
|
||||
self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist
|
||||
|
@ -172,7 +172,7 @@ class SellingController(StockController):
|
||||
self.net_total += item.base_amount
|
||||
self.net_total_export += item.amount
|
||||
|
||||
self.round_floats_in(self.doc, ["net_total", "net_total_export"])
|
||||
self.round_floats_in(self, ["net_total", "net_total_export"])
|
||||
|
||||
def calculate_totals(self):
|
||||
self.grand_total = flt(self.tax_doclist and \
|
||||
@ -223,7 +223,7 @@ class SellingController(StockController):
|
||||
# write_off_amount is only for POS Invoice
|
||||
# total_advance is only for non POS Invoice
|
||||
if self.doctype == "Sales Invoice" and self.docstatus == 0:
|
||||
self.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount",
|
||||
self.round_floats_in(self, ["grand_total", "total_advance", "write_off_amount",
|
||||
"paid_amount"])
|
||||
total_amount_to_pay = self.grand_total - self.write_off_amount
|
||||
self.outstanding_amount = flt(total_amount_to_pay - self.total_advance \
|
||||
@ -231,7 +231,7 @@ class SellingController(StockController):
|
||||
|
||||
def calculate_commission(self):
|
||||
if self.meta.get_field("commission_rate"):
|
||||
self.round_floats_in(self.doc, ["net_total", "commission_rate"])
|
||||
self.round_floats_in(self, ["net_total", "commission_rate"])
|
||||
if self.commission_rate > 100.0:
|
||||
msgprint(_(self.meta.get_label("commission_rate")) + " " +
|
||||
_("cannot be greater than 100"), raise_exception=True)
|
||||
|
@ -6,12 +6,11 @@ import frappe
|
||||
|
||||
from frappe.utils import cstr, flt, getdate
|
||||
from frappe.model.bean import getlist
|
||||
from frappe import msgprint
|
||||
|
||||
from frappe import msgprint, _
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.model.document import Document
|
||||
|
||||
class Appraisal(Document):
|
||||
|
||||
def validate(self):
|
||||
if not self.status:
|
||||
self.status = "Draft"
|
||||
@ -21,26 +20,23 @@ class Appraisal(Document):
|
||||
self.calculate_total()
|
||||
|
||||
def get_employee_name(self):
|
||||
emp_nm = frappe.db.sql("select employee_name from `tabEmployee` where name=%s", self.employee)
|
||||
emp_nm= emp_nm and emp_nm[0][0] or ''
|
||||
self.employee_name = emp_nm
|
||||
return emp_nm
|
||||
self.employee_name = frappe.db.get_value("Employee", self.employee, "employee_name")
|
||||
return self.employee_name
|
||||
|
||||
def validate_dates(self):
|
||||
if getdate(self.start_date) > getdate(self.end_date):
|
||||
msgprint("End Date can not be less than Start Date")
|
||||
raise Exception
|
||||
frappe.throw(_("End Date can not be less than Start Date"))
|
||||
|
||||
def validate_existing_appraisal(self):
|
||||
chk = frappe.db.sql("""select name from `tabAppraisal` where employee=%s
|
||||
and (status='Submitted' or status='Completed')
|
||||
and ((start_date>=%s and start_date<=%s)
|
||||
or (end_date>=%s and end_date<=%s))""",(self.employee,self.start_date,self.end_date,self.start_date,self.end_date))
|
||||
or (end_date>=%s and end_date<=%s))""",
|
||||
(self.employee,self.start_date,self.end_date,self.start_date,self.end_date))
|
||||
if chk:
|
||||
msgprint("You have already created Appraisal "\
|
||||
frappe.throw("You have already created Appraisal "\
|
||||
+cstr(chk[0][0])+" in the current date range for employee "\
|
||||
+cstr(self.employee_name))
|
||||
raise Exception
|
||||
|
||||
def calculate_total(self):
|
||||
total, total_w = 0, 0
|
||||
@ -61,22 +57,20 @@ class Appraisal(Document):
|
||||
self.total_score = total
|
||||
|
||||
def on_submit(self):
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
frappe.db.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.db.set(self, 'status', 'Cancelled')
|
||||
|
||||
@frappe.whitelist()
|
||||
def fetch_appraisal_template(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
|
||||
doclist = get_mapped_doclist("Appraisal Template", source_name, {
|
||||
def fetch_appraisal_template(source_name, target_doc=None):
|
||||
target_doc = get_mapped_doc("Appraisal Template", source_name, {
|
||||
"Appraisal Template": {
|
||||
"doctype": "Appraisal",
|
||||
},
|
||||
"Appraisal Template Goal": {
|
||||
"doctype": "Appraisal Goal",
|
||||
}
|
||||
}, target_doclist)
|
||||
}, target_doc)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
return target_doc
|
@ -8,10 +8,9 @@ from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class AppraisalTemplate(Document):
|
||||
|
||||
def validate(self):
|
||||
self.total_points = 0
|
||||
for d in self.doclist.get({"doctype":"Appraisal Template Goal"}):
|
||||
for d in self.get("kra_sheet"):
|
||||
self.total_points += int(d.per_weightage or 0)
|
||||
|
||||
if int(self.total_points) != 100:
|
||||
|
@ -6,8 +6,6 @@ import frappe
|
||||
|
||||
from frappe.utils import getdate, nowdate
|
||||
from frappe import msgprint, _
|
||||
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
class Attendance(Document):
|
||||
@ -58,4 +56,4 @@ class Attendance(Document):
|
||||
# this is done because sometimes user entered wrong employee name
|
||||
# while uploading employee attendance
|
||||
employee_name = frappe.db.get_value("Employee", self.employee, "employee_name")
|
||||
frappe.db.set(self.doc, 'employee_name', employee_name)
|
||||
frappe.db.set(self, 'employee_name', employee_name)
|
@ -9,9 +9,6 @@ from frappe import msgprint
|
||||
from frappe.model.document import Document
|
||||
|
||||
class LeaveAllocation(Document):
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc, self.doclist = doc, doclist
|
||||
|
||||
def validate(self):
|
||||
self.validate_new_leaves_allocated_value()
|
||||
self.check_existing_leave_allocation()
|
||||
@ -84,7 +81,7 @@ class LeaveAllocation(Document):
|
||||
self.leave_type)
|
||||
cf = cf and cint(cf[0][0]) or 0
|
||||
if not cf:
|
||||
frappe.db.set(self.doc,'carry_forward',0)
|
||||
frappe.db.set(self,'carry_forward',0)
|
||||
msgprint("Sorry! You cannot carry forward %s" % (self.leave_type),
|
||||
raise_exception=1)
|
||||
|
||||
@ -107,8 +104,8 @@ class LeaveAllocation(Document):
|
||||
|
||||
def get_total_allocated_leaves(self):
|
||||
leave_det = self.get_carry_forwarded_leaves()
|
||||
frappe.db.set(self.doc,'carry_forwarded_leaves',flt(leave_det['carry_forwarded_leaves']))
|
||||
frappe.db.set(self.doc,'total_leaves_allocated',flt(leave_det['total_leaves_allocated']))
|
||||
frappe.db.set(self,'carry_forwarded_leaves',flt(leave_det['carry_forwarded_leaves']))
|
||||
frappe.db.set(self,'total_leaves_allocated',flt(leave_det['total_leaves_allocated']))
|
||||
|
||||
def check_for_leave_application(self):
|
||||
exists = frappe.db.sql("""select name from `tabLeave Application`
|
||||
|
@ -14,11 +14,6 @@ from frappe import msgprint, _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class LeaveControlPanel(Document):
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
|
||||
def get_employees(self):
|
||||
lst1 = [[self.employee_type,"employment_type"],[self.branch,"branch"],[self.designation,"designation"],[self.department, "department"],[self.grade,"grade"]]
|
||||
condition = "where "
|
||||
|
@ -34,8 +34,8 @@ class SalarySlip(TransactionBase):
|
||||
return struct and struct[0][0] or ''
|
||||
|
||||
def pull_sal_struct(self, struct):
|
||||
from erpnext.hr.doctype.salary_structure.salary_structure import get_mapped_doclist
|
||||
self.doclist = get_mapped_doclist(struct, self.doclist)
|
||||
from erpnext.hr.doctype.salary_structure.salary_structure import get_mapped_doc
|
||||
self.doclist = get_mapped_doc(struct, self.doclist)
|
||||
|
||||
def pull_emp_details(self):
|
||||
emp = frappe.db.get_value("Employee", self.employee,
|
||||
|
@ -70,11 +70,11 @@ class SalaryStructure(Document):
|
||||
self.validate_amount()
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_salary_slip(source_name, target_doclist=None):
|
||||
return [d.fields for d in get_mapped_doclist(source_name, target_doclist)]
|
||||
def make_salary_slip(source_name, target_doc=None):
|
||||
return [d.fields for d in get_mapped_doc(source_name, target_doc)]
|
||||
|
||||
def get_mapped_doclist(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def get_mapped_doc(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def postprocess(source, target):
|
||||
sal_slip = frappe.bean(target)
|
||||
@ -82,7 +82,7 @@ def get_mapped_doclist(source_name, target_doclist=None):
|
||||
sal_slip.run_method("get_leave_details")
|
||||
sal_slip.run_method("calculate_net_pay")
|
||||
|
||||
doclist = get_mapped_doclist("Salary Structure", source_name, {
|
||||
doclist = get_mapped_doc("Salary Structure", source_name, {
|
||||
"Salary Structure": {
|
||||
"doctype": "Salary Slip",
|
||||
"field_map": {
|
||||
@ -107,6 +107,6 @@ def get_mapped_doclist(source_name, target_doclist=None):
|
||||
],
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, postprocess)
|
||||
}, target_doc, postprocess)
|
||||
|
||||
return doclist
|
||||
|
@ -45,8 +45,8 @@ class Bom(Document):
|
||||
self.manage_default_bom()
|
||||
|
||||
def on_cancel(self):
|
||||
frappe.db.set(self.doc, "is_active", 0)
|
||||
frappe.db.set(self.doc, "is_default", 0)
|
||||
frappe.db.set(self, "is_active", 0)
|
||||
frappe.db.set(self, "is_default", 0)
|
||||
|
||||
# check if used in any other bom
|
||||
self.validate_bom_links()
|
||||
@ -174,12 +174,12 @@ class Bom(Document):
|
||||
"""
|
||||
if self.is_default and self.is_active:
|
||||
from frappe.model.utils import set_default
|
||||
set_default(self.doc, "item")
|
||||
set_default(self, "item")
|
||||
frappe.db.set_value("Item", self.item, "default_bom", self.name)
|
||||
|
||||
else:
|
||||
if not self.is_active:
|
||||
frappe.db.set(self.doc, "is_default", 0)
|
||||
frappe.db.set(self, "is_default", 0)
|
||||
|
||||
frappe.db.sql("update `tabItem` set default_bom = null where name = %s and default_bom = %s",
|
||||
(self.item, self.name))
|
||||
|
@ -10,10 +10,6 @@ from frappe import msgprint, _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class BomReplaceTool(Document):
|
||||
def __init__( self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def replace_bom(self):
|
||||
self.validate_bom()
|
||||
self.update_new_bom()
|
||||
|
@ -94,20 +94,20 @@ class ProductionOrder(Document):
|
||||
|
||||
def update_status(self, status):
|
||||
if status == 'Stopped':
|
||||
frappe.db.set(self.doc, 'status', cstr(status))
|
||||
frappe.db.set(self, 'status', cstr(status))
|
||||
else:
|
||||
if flt(self.qty) == flt(self.produced_qty):
|
||||
frappe.db.set(self.doc, 'status', 'Completed')
|
||||
frappe.db.set(self, 'status', 'Completed')
|
||||
if flt(self.qty) > flt(self.produced_qty):
|
||||
frappe.db.set(self.doc, 'status', 'In Process')
|
||||
frappe.db.set(self, 'status', 'In Process')
|
||||
if flt(self.produced_qty) == 0:
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
|
||||
|
||||
def on_submit(self):
|
||||
if not self.wip_warehouse:
|
||||
frappe.throw(_("WIP Warehouse required before Submit"))
|
||||
frappe.db.set(self.doc,'status', 'Submitted')
|
||||
frappe.db.set(self,'status', 'Submitted')
|
||||
self.update_planned_qty(self.qty)
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ class ProductionOrder(Document):
|
||||
frappe.throw("""Submitted Stock Entry %s exists against this production order.
|
||||
Hence can not be cancelled.""" % stock_entry[0][0])
|
||||
|
||||
frappe.db.set(self.doc,'status', 'Cancelled')
|
||||
frappe.db.set(self,'status', 'Cancelled')
|
||||
self.update_planned_qty(-self.qty)
|
||||
|
||||
def update_planned_qty(self, qty):
|
||||
|
@ -8,20 +8,16 @@ from frappe.utils import flt
|
||||
from frappe.model.document import Document
|
||||
|
||||
class Workstation(Document):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def update_bom_operation(self):
|
||||
bom_list = frappe.db.sql("""select DISTINCT parent from `tabBOM Operation`
|
||||
where workstation = %s""", self.name)
|
||||
for bom_no in bom_list:
|
||||
frappe.db.sql("""update `tabBOM Operation` set hour_rate = %s
|
||||
where parent = %s and workstation = %s""",
|
||||
(self.hour_rate, bom_no[0], self.name))
|
||||
|
||||
def on_update(self):
|
||||
frappe.db.set(self.doc, 'overhead', flt(self.hour_rate_electricity) +
|
||||
def update_bom_operation(self):
|
||||
bom_list = frappe.db.sql("""select DISTINCT parent from `tabBOM Operation`
|
||||
where workstation = %s""", self.name)
|
||||
for bom_no in bom_list:
|
||||
frappe.db.sql("""update `tabBOM Operation` set hour_rate = %s
|
||||
where parent = %s and workstation = %s""",
|
||||
(self.hour_rate, bom_no[0], self.name))
|
||||
|
||||
def on_update(self):
|
||||
frappe.db.set(self, 'overhead', flt(self.hour_rate_electricity) +
|
||||
flt(self.hour_rate_consumable) + flt(self.hour_rate_rent))
|
||||
frappe.db.set(self.doc, 'hour_rate', flt(self.hour_rate_labour) + flt(self.overhead))
|
||||
self.update_bom_operation()
|
||||
frappe.db.set(self, 'hour_rate', flt(self.hour_rate_labour) + flt(self.overhead))
|
||||
self.update_bom_operation()
|
@ -128,7 +128,7 @@ class Customer(TransactionBase):
|
||||
def after_rename(self, olddn, newdn, merge=False):
|
||||
set_field = ''
|
||||
if frappe.defaults.get_global_default('cust_master_name') == 'Customer Name':
|
||||
frappe.db.set(self.doc, "customer_name", newdn)
|
||||
frappe.db.set(self, "customer_name", newdn)
|
||||
self.update_contact()
|
||||
set_field = ", customer_name=%(newdn)s"
|
||||
self.update_customer_address(newdn, set_field)
|
||||
|
@ -100,12 +100,12 @@ class InstallationNote(TransactionBase):
|
||||
msgprint("Please fetch items from Delivery Note selected", raise_exception=1)
|
||||
|
||||
def on_update(self):
|
||||
frappe.db.set(self.doc, 'status', 'Draft')
|
||||
frappe.db.set(self, 'status', 'Draft')
|
||||
|
||||
def on_submit(self):
|
||||
self.validate_serial_no()
|
||||
self.update_prevdoc_status()
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
for d in self.get('installed_item_details'):
|
||||
@ -115,4 +115,4 @@ class InstallationNote(TransactionBase):
|
||||
frappe.db.set_value("Serial No", sr_no, "status", "Delivered")
|
||||
|
||||
self.update_prevdoc_status()
|
||||
frappe.db.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.db.set(self, 'status', 'Cancelled')
|
||||
|
@ -71,11 +71,11 @@ class Lead(SellingController):
|
||||
"status": ["!=", "Lost"]})
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_customer(source_name, target_doclist=None):
|
||||
return _make_customer(source_name, target_doclist)
|
||||
def make_customer(source_name, target_doc=None):
|
||||
return _make_customer(source_name, target_doc)
|
||||
|
||||
def _make_customer(source_name, target_doclist=None, ignore_permissions=False):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def _make_customer(source_name, target_doc=None, ignore_permissions=False):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def set_missing_values(source, target):
|
||||
if source.company_name:
|
||||
@ -87,7 +87,7 @@ def _make_customer(source_name, target_doclist=None, ignore_permissions=False):
|
||||
|
||||
target[0].customer_group = frappe.db.get_default("customer_group")
|
||||
|
||||
doclist = get_mapped_doclist("Lead", source_name,
|
||||
doclist = get_mapped_doc("Lead", source_name,
|
||||
{"Lead": {
|
||||
"doctype": "Customer",
|
||||
"field_map": {
|
||||
@ -96,15 +96,15 @@ def _make_customer(source_name, target_doclist=None, ignore_permissions=False):
|
||||
"contact_no": "phone_1",
|
||||
"fax": "fax_1"
|
||||
}
|
||||
}}, target_doclist, set_missing_values, ignore_permissions=ignore_permissions)
|
||||
}}, target_doc, set_missing_values, ignore_permissions=ignore_permissions)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_opportunity(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_opportunity(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
doclist = get_mapped_doclist("Lead", source_name,
|
||||
doclist = get_mapped_doc("Lead", source_name,
|
||||
{"Lead": {
|
||||
"doctype": "Opportunity",
|
||||
"field_map": {
|
||||
@ -116,7 +116,7 @@ def make_opportunity(source_name, target_doclist=None):
|
||||
"email_id": "contact_email",
|
||||
"mobile_no": "contact_mobile"
|
||||
}
|
||||
}}, target_doclist)
|
||||
}}, target_doc)
|
||||
|
||||
return [d if isinstance(d, dict) else d.fields for d in doclist]
|
||||
|
||||
|
@ -118,8 +118,8 @@ class Opportunity(TransactionBase):
|
||||
|
||||
def declare_enquiry_lost(self,arg):
|
||||
if not self.has_quotation():
|
||||
frappe.db.set(self.doc, 'status', 'Lost')
|
||||
frappe.db.set(self.doc, 'order_lost_reason', arg)
|
||||
frappe.db.set(self, 'status', 'Lost')
|
||||
frappe.db.set(self, 'order_lost_reason', arg)
|
||||
else:
|
||||
frappe.throw(_("Cannot declare as lost, because Quotation has been made."))
|
||||
|
||||
@ -130,15 +130,15 @@ class Opportunity(TransactionBase):
|
||||
return frappe.db.get_value("Quotation Item", {"prevdoc_docname": self.name, "docstatus": 1})
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_quotation(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_quotation(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def set_missing_values(source, target):
|
||||
quotation = frappe.bean(target)
|
||||
quotation.run_method("onload_post_render")
|
||||
quotation.run_method("calculate_taxes_and_totals")
|
||||
|
||||
doclist = get_mapped_doclist("Opportunity", source_name, {
|
||||
doclist = get_mapped_doc("Opportunity", source_name, {
|
||||
"Opportunity": {
|
||||
"doctype": "Quotation",
|
||||
"field_map": {
|
||||
@ -159,6 +159,6 @@ def make_quotation(source_name, target_doclist=None):
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
@ -59,8 +59,8 @@ class Quotation(SellingController):
|
||||
|
||||
def declare_order_lost(self, arg):
|
||||
if not self.has_sales_order():
|
||||
frappe.db.set(self.doc, 'status', 'Lost')
|
||||
frappe.db.set(self.doc, 'order_lost_reason', arg)
|
||||
frappe.db.set(self, 'status', 'Lost')
|
||||
frappe.db.set(self, 'order_lost_reason', arg)
|
||||
self.update_opportunity()
|
||||
else:
|
||||
frappe.throw(_("Cannot set as Lost as Sales Order is made."))
|
||||
@ -95,11 +95,11 @@ class Quotation(SellingController):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_sales_order(source_name, target_doclist=None):
|
||||
return _make_sales_order(source_name, target_doclist)
|
||||
def make_sales_order(source_name, target_doc=None):
|
||||
return _make_sales_order(source_name, target_doc)
|
||||
|
||||
def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
customer = _make_customer(source_name, ignore_permissions)
|
||||
|
||||
@ -112,7 +112,7 @@ def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False
|
||||
si.ignore_permissions = ignore_permissions
|
||||
si.run_method("onload_post_render")
|
||||
|
||||
doclist = get_mapped_doclist("Quotation", source_name, {
|
||||
doclist = get_mapped_doc("Quotation", source_name, {
|
||||
"Quotation": {
|
||||
"doctype": "Sales Order",
|
||||
"validation": {
|
||||
@ -133,7 +133,7 @@ def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False
|
||||
"doctype": "Sales Team",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values, ignore_permissions=ignore_permissions)
|
||||
}, target_doc, set_missing_values, ignore_permissions=ignore_permissions)
|
||||
|
||||
# postprocess: fetch shipping address, set missing values
|
||||
|
||||
|
@ -9,20 +9,16 @@ from frappe.utils import cstr, flt, getdate
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
from erpnext.controllers.selling_controller import SellingController
|
||||
|
||||
class SalesOrder(SellingController):
|
||||
def __init__(self, doc, doclist=None):
|
||||
self.doc = doc
|
||||
if not doclist: doclist = []
|
||||
self.doclist = doclist
|
||||
self.tname = 'Sales Order Item'
|
||||
self.fname = 'sales_order_details'
|
||||
self.person_tname = 'Target Detail'
|
||||
self.partner_tname = 'Partner Target Detail'
|
||||
self.territory_tname = 'Territory Target Detail'
|
||||
tname = 'Sales Order Item'
|
||||
fname = 'sales_order_details'
|
||||
person_tname = 'Target Detail'
|
||||
partner_tname = 'Partner Target Detail'
|
||||
territory_tname = 'Territory Target Detail'
|
||||
|
||||
def validate_mandatory(self):
|
||||
# validate transaction date v/s delivery date
|
||||
@ -168,7 +164,7 @@ class SalesOrder(SellingController):
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doctype, self.grand_total, self)
|
||||
|
||||
self.update_prevdoc_status('submit')
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
# Cannot cancel stopped SO
|
||||
@ -180,7 +176,7 @@ class SalesOrder(SellingController):
|
||||
|
||||
self.update_prevdoc_status('cancel')
|
||||
|
||||
frappe.db.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.db.set(self, 'status', 'Cancelled')
|
||||
|
||||
def check_nextdoc_docstatus(self):
|
||||
# Checks Delivery Note
|
||||
@ -224,14 +220,14 @@ class SalesOrder(SellingController):
|
||||
def stop_sales_order(self):
|
||||
self.check_modified_date()
|
||||
self.update_stock_ledger(-1)
|
||||
frappe.db.set(self.doc, 'status', 'Stopped')
|
||||
frappe.db.set(self, 'status', 'Stopped')
|
||||
msgprint("""%s: %s has been Stopped. To make transactions against this Sales Order
|
||||
you need to Unstop it.""" % (self.doctype, self.name))
|
||||
|
||||
def unstop_sales_order(self):
|
||||
self.check_modified_date()
|
||||
self.update_stock_ledger(1)
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
msgprint("%s: %s has been Unstopped" % (self.doctype, self.name))
|
||||
|
||||
|
||||
@ -261,11 +257,11 @@ def set_missing_values(source, target):
|
||||
bean.run_method("onload_post_render")
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_material_request(source_name, target_doclist=None):
|
||||
def make_material_request(source_name, target_doc=None):
|
||||
def postprocess(source, doclist):
|
||||
doclist[0].material_request_type = "Purchase"
|
||||
|
||||
doclist = get_mapped_doclist("Sales Order", source_name, {
|
||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
"doctype": "Material Request",
|
||||
"validation": {
|
||||
@ -279,18 +275,18 @@ def make_material_request(source_name, target_doclist=None):
|
||||
"stock_uom": "uom"
|
||||
}
|
||||
}
|
||||
}, target_doclist, postprocess)
|
||||
}, target_doc, postprocess)
|
||||
|
||||
return [(d if isinstance(d, dict) else d.fields) for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_delivery_note(source_name, target_doclist=None):
|
||||
def make_delivery_note(source_name, target_doc=None):
|
||||
def update_item(obj, target, source_parent):
|
||||
target.base_amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.base_rate)
|
||||
target.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.rate)
|
||||
target.qty = flt(obj.qty) - flt(obj.delivered_qty)
|
||||
|
||||
doclist = get_mapped_doclist("Sales Order", source_name, {
|
||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
"doctype": "Delivery Note",
|
||||
"field_map": {
|
||||
@ -319,12 +315,12 @@ def make_delivery_note(source_name, target_doclist=None):
|
||||
"doctype": "Sales Team",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_sales_invoice(source_name, target_doclist=None):
|
||||
def make_sales_invoice(source_name, target_doc=None):
|
||||
def set_missing_values(source, target):
|
||||
bean = frappe.bean(target)
|
||||
bean.is_pos = 0
|
||||
@ -335,7 +331,7 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
target.base_amount = target.amount * flt(source_parent.conversion_rate)
|
||||
target.qty = obj.rate and target.amount / flt(obj.rate) or obj.qty
|
||||
|
||||
doclist = get_mapped_doclist("Sales Order", source_name, {
|
||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
"doctype": "Sales Invoice",
|
||||
"validation": {
|
||||
@ -359,18 +355,18 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
"doctype": "Sales Team",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_maintenance_schedule(source_name, target_doclist=None):
|
||||
def make_maintenance_schedule(source_name, target_doc=None):
|
||||
maint_schedule = frappe.db.sql("""select t1.name
|
||||
from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2
|
||||
where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1""", source_name)
|
||||
|
||||
if not maint_schedule:
|
||||
doclist = get_mapped_doclist("Sales Order", source_name, {
|
||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
"doctype": "Maintenance Schedule",
|
||||
"field_map": {
|
||||
@ -387,19 +383,19 @@ def make_maintenance_schedule(source_name, target_doclist=None):
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist)
|
||||
}, target_doc)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_maintenance_visit(source_name, target_doclist=None):
|
||||
def make_maintenance_visit(source_name, target_doc=None):
|
||||
visit = frappe.db.sql("""select t1.name
|
||||
from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2
|
||||
where t2.parent=t1.name and t2.prevdoc_docname=%s
|
||||
and t1.docstatus=1 and t1.completion_status='Fully Completed'""", source_name)
|
||||
|
||||
if not visit:
|
||||
doclist = get_mapped_doclist("Sales Order", source_name, {
|
||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
"doctype": "Maintenance Visit",
|
||||
"field_map": {
|
||||
@ -417,6 +413,6 @@ def make_maintenance_visit(source_name, target_doclist=None):
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist)
|
||||
}, target_doc)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
@ -107,8 +107,8 @@ class Company(Document):
|
||||
self.import_chart_of_account()
|
||||
else:
|
||||
self.create_standard_accounts()
|
||||
frappe.db.set(self.doc, "receivables_group", "Accounts Receivable - " + self.abbr)
|
||||
frappe.db.set(self.doc, "payables_group", "Accounts Payable - " + self.abbr)
|
||||
frappe.db.set(self, "receivables_group", "Accounts Receivable - " + self.abbr)
|
||||
frappe.db.set(self, "payables_group", "Accounts Payable - " + self.abbr)
|
||||
|
||||
def import_chart_of_account(self):
|
||||
chart = frappe.bean("Chart of Accounts", self.chart_of_accounts)
|
||||
@ -132,7 +132,7 @@ class Company(Document):
|
||||
"group_or_ledger": "Ledger", "company": self.name})
|
||||
|
||||
if account and not self.get(field):
|
||||
frappe.db.set(self.doc, field, account)
|
||||
frappe.db.set(self, field, account)
|
||||
|
||||
_set_default_accounts({
|
||||
"default_cash_account": "Cash",
|
||||
@ -170,7 +170,7 @@ class Company(Document):
|
||||
cc_bean.ignore_mandatory = True
|
||||
cc_bean.insert()
|
||||
|
||||
frappe.db.set(self.doc, "cost_center", "Main - " + self.abbr)
|
||||
frappe.db.set(self, "cost_center", "Main - " + self.abbr)
|
||||
|
||||
def on_trash(self):
|
||||
"""
|
||||
@ -200,7 +200,7 @@ class Company(Document):
|
||||
frappe.throw(_("Sorry, companies cannot be merged"))
|
||||
|
||||
def after_rename(self, olddn, newdn, merge=False):
|
||||
frappe.db.set(self.doc, "company_name", newdn)
|
||||
frappe.db.set(self, "company_name", newdn)
|
||||
|
||||
frappe.db.sql("""update `tabDefaultValue` set defvalue=%s
|
||||
where defkey='Company' and defvalue=%s""", (newdn, olddn))
|
||||
|
@ -19,6 +19,6 @@ class NotificationControl(Document):
|
||||
|
||||
def set_message(self, arg = ''):
|
||||
fn = self.select_transaction.lower().replace(' ', '_') + '_message'
|
||||
frappe.db.set(self.doc, fn, self.custom_message)
|
||||
frappe.db.set(self, fn, self.custom_message)
|
||||
msgprint("Custom Message for %s updated!" % self.select_transaction)
|
||||
|
||||
|
@ -9,7 +9,7 @@ from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
import frappe.defaults
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from erpnext.stock.utils import update_bin
|
||||
from erpnext.controllers.selling_controller import SellingController
|
||||
|
||||
@ -163,7 +163,7 @@ class DeliveryNote(SellingController):
|
||||
self.make_gl_entries()
|
||||
|
||||
# set DN status
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
|
||||
|
||||
def on_cancel(self):
|
||||
@ -174,7 +174,7 @@ class DeliveryNote(SellingController):
|
||||
|
||||
self.update_stock_ledger()
|
||||
|
||||
frappe.db.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.db.set(self, 'status', 'Cancelled')
|
||||
self.cancel_packing_slips()
|
||||
|
||||
self.make_cancel_gl_entries()
|
||||
@ -285,7 +285,7 @@ def get_invoiced_qty_map(delivery_note):
|
||||
return invoiced_qty_map
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_sales_invoice(source_name, target_doclist=None):
|
||||
def make_sales_invoice(source_name, target_doc=None):
|
||||
invoiced_qty_map = get_invoiced_qty_map(source_name)
|
||||
|
||||
def update_accounts(source, target):
|
||||
@ -305,7 +305,7 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
def update_item(source_doc, target_doc, source_parent):
|
||||
target_doc.qty = source_doc.qty - invoiced_qty_map.get(source_doc.name, 0)
|
||||
|
||||
doclist = get_mapped_doclist("Delivery Note", source_name, {
|
||||
doclist = get_mapped_doc("Delivery Note", source_name, {
|
||||
"Delivery Note": {
|
||||
"doctype": "Sales Invoice",
|
||||
"validation": {
|
||||
@ -334,17 +334,17 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, update_accounts)
|
||||
}, target_doc, update_accounts)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_installation_note(source_name, target_doclist=None):
|
||||
def make_installation_note(source_name, target_doc=None):
|
||||
def update_item(obj, target, source_parent):
|
||||
target.qty = flt(obj.qty) - flt(obj.installed_qty)
|
||||
target.serial_no = obj.serial_no
|
||||
|
||||
doclist = get_mapped_doclist("Delivery Note", source_name, {
|
||||
doclist = get_mapped_doc("Delivery Note", source_name, {
|
||||
"Delivery Note": {
|
||||
"doctype": "Installation Note",
|
||||
"validation": {
|
||||
@ -361,6 +361,6 @@ def make_installation_note(source_name, target_doclist=None):
|
||||
"postprocess": update_item,
|
||||
"condition": lambda doc: doc.installed_qty < doc.qty
|
||||
}
|
||||
}, target_doclist)
|
||||
}, target_doc)
|
||||
|
||||
return [d.fields for d in doclist]
|
@ -100,7 +100,7 @@ class MaterialRequest(BuyingController):
|
||||
update_bin(args)
|
||||
|
||||
def on_submit(self):
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
self.update_bin(is_submit = 1, is_stopped = 0)
|
||||
|
||||
def check_modified_date(self):
|
||||
@ -118,7 +118,7 @@ class MaterialRequest(BuyingController):
|
||||
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
|
||||
|
||||
# Step 2:=> Set status
|
||||
frappe.db.set(self.doc, 'status', cstr(status))
|
||||
frappe.db.set(self, 'status', cstr(status))
|
||||
|
||||
# Step 3:=> Acknowledge User
|
||||
msgprint(self.doctype + ": " + self.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)))
|
||||
@ -137,7 +137,7 @@ class MaterialRequest(BuyingController):
|
||||
self.update_bin(is_submit = 0, is_stopped = (cstr(self.status) == 'Stopped') and 1 or 0)
|
||||
|
||||
# Step 5:=> Set Status
|
||||
frappe.db.set(self.doc,'status','Cancelled')
|
||||
frappe.db.set(self,'status','Cancelled')
|
||||
|
||||
def update_completed_qty(self, mr_items=None):
|
||||
if self.material_request_type != "Transfer":
|
||||
@ -217,8 +217,8 @@ def _update_requested_qty(bean, mr_obj, mr_items):
|
||||
"posting_date": bean.posting_date,
|
||||
})
|
||||
|
||||
def set_missing_values(source, target_doclist):
|
||||
po = frappe.bean(target_doclist)
|
||||
def set_missing_values(source, target_doc):
|
||||
po = frappe.bean(target_doc)
|
||||
po.run_method("set_missing_values")
|
||||
|
||||
def update_item(obj, target, source_parent):
|
||||
@ -226,10 +226,10 @@ def update_item(obj, target, source_parent):
|
||||
target.qty = flt(obj.qty) - flt(obj.ordered_qty)
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_purchase_order(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_purchase_order(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
doclist = get_mapped_doclist("Material Request", source_name, {
|
||||
doclist = get_mapped_doc("Material Request", source_name, {
|
||||
"Material Request": {
|
||||
"doctype": "Purchase Order",
|
||||
"validation": {
|
||||
@ -248,34 +248,34 @@ def make_purchase_order(source_name, target_doclist=None):
|
||||
],
|
||||
"postprocess": update_item
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_purchase_order_based_on_supplier(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
if target_doclist:
|
||||
if isinstance(target_doclist, basestring):
|
||||
def make_purchase_order_based_on_supplier(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
if target_doc:
|
||||
if isinstance(target_doc, basestring):
|
||||
import json
|
||||
target_doclist = frappe.doclist(json.loads(target_doclist))
|
||||
target_doclist = target_doclist.get({"parentfield": ["!=", "po_details"]})
|
||||
target_doc = frappe.doclist(json.loads(target_doc))
|
||||
target_doc = target_doc.get({"parentfield": ["!=", "po_details"]})
|
||||
|
||||
material_requests, supplier_items = get_material_requests_based_on_supplier(source_name)
|
||||
|
||||
def postprocess(source, target_doclist):
|
||||
target_doclist[0].supplier = source_name
|
||||
set_missing_values(source, target_doclist)
|
||||
def postprocess(source, target_doc):
|
||||
target_doc[0].supplier = source_name
|
||||
set_missing_values(source, target_doc)
|
||||
|
||||
po_items = target_doclist.get({"parentfield": "po_details"})
|
||||
target_doclist = target_doclist.get({"parentfield": ["!=", "po_details"]}) + \
|
||||
po_items = target_doc.get({"parentfield": "po_details"})
|
||||
target_doc = target_doc.get({"parentfield": ["!=", "po_details"]}) + \
|
||||
[d for d in po_items
|
||||
if d.get("item_code") in supplier_items and d.get("qty") > 0]
|
||||
|
||||
return target_doclist
|
||||
return target_doc
|
||||
|
||||
for mr in material_requests:
|
||||
target_doclist = get_mapped_doclist("Material Request", mr, {
|
||||
target_doc = get_mapped_doc("Material Request", mr, {
|
||||
"Material Request": {
|
||||
"doctype": "Purchase Order",
|
||||
},
|
||||
@ -290,9 +290,9 @@ def make_purchase_order_based_on_supplier(source_name, target_doclist=None):
|
||||
],
|
||||
"postprocess": update_item
|
||||
}
|
||||
}, target_doclist, postprocess)
|
||||
}, target_doc, postprocess)
|
||||
|
||||
return [d.fields for d in target_doclist]
|
||||
return [d.fields for d in target_doc]
|
||||
|
||||
def get_material_requests_based_on_supplier(supplier):
|
||||
supplier_items = [d[0] for d in frappe.db.get_values("Item",
|
||||
@ -309,10 +309,10 @@ def get_material_requests_based_on_supplier(supplier):
|
||||
return material_requests, supplier_items
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_supplier_quotation(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_supplier_quotation(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
doclist = get_mapped_doclist("Material Request", source_name, {
|
||||
doclist = get_mapped_doc("Material Request", source_name, {
|
||||
"Material Request": {
|
||||
"doctype": "Supplier Quotation",
|
||||
"validation": {
|
||||
@ -328,13 +328,13 @@ def make_supplier_quotation(source_name, target_doclist=None):
|
||||
"parenttype": "prevdoc_doctype"
|
||||
}
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_stock_entry(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_stock_entry(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def update_item(obj, target, source_parent):
|
||||
target.conversion_factor = 1
|
||||
@ -346,7 +346,7 @@ def make_stock_entry(source_name, target_doclist=None):
|
||||
se = frappe.bean(target)
|
||||
se.run_method("get_stock_and_rate")
|
||||
|
||||
doclist = get_mapped_doclist("Material Request", source_name, {
|
||||
doclist = get_mapped_doc("Material Request", source_name, {
|
||||
"Material Request": {
|
||||
"doctype": "Stock Entry",
|
||||
"validation": {
|
||||
@ -364,6 +364,6 @@ def make_stock_entry(source_name, target_doclist=None):
|
||||
},
|
||||
"postprocess": update_item
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
@ -229,7 +229,7 @@ class PurchaseReceipt(BuyingController):
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total)
|
||||
|
||||
# Set status as Submitted
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
|
||||
self.update_prevdoc_status()
|
||||
|
||||
@ -267,7 +267,7 @@ class PurchaseReceipt(BuyingController):
|
||||
frappe.throw("Purchase Invoice : " + cstr(submitted[0][0]) +
|
||||
" has already been submitted !")
|
||||
|
||||
frappe.db.set(self.doc,'status','Cancelled')
|
||||
frappe.db.set(self,'status','Cancelled')
|
||||
|
||||
self.update_ordered_qty()
|
||||
|
||||
@ -295,14 +295,14 @@ class PurchaseReceipt(BuyingController):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_purchase_invoice(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_purchase_invoice(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def set_missing_values(source, target):
|
||||
bean = frappe.bean(target)
|
||||
bean.run_method("set_missing_values")
|
||||
|
||||
doclist = get_mapped_doclist("Purchase Receipt", source_name, {
|
||||
doclist = get_mapped_doc("Purchase Receipt", source_name, {
|
||||
"Purchase Receipt": {
|
||||
"doctype": "Purchase Invoice",
|
||||
"validation": {
|
||||
@ -322,6 +322,6 @@ def make_purchase_invoice(source_name, target_doclist=None):
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
@ -21,9 +21,8 @@ class SerialNoNotExistsError(ValidationError): pass
|
||||
class SerialNoDuplicateError(ValidationError): pass
|
||||
|
||||
class SerialNo(StockController):
|
||||
def __init__(self, doc, doclist=None):
|
||||
self.doc = doc
|
||||
self.doclist = doclist or []
|
||||
def __init__(self, arg1, arg2=None):
|
||||
super(SerialNo, self).__init__(arg1, arg2)
|
||||
self.via_stock_ledger = False
|
||||
|
||||
def validate(self):
|
||||
|
@ -29,7 +29,7 @@ class StockLedgerEntry(DocListController):
|
||||
self.actual_amt_check()
|
||||
|
||||
from erpnext.stock.doctype.serial_no.serial_no import process_serial_no
|
||||
process_serial_no(self.doc)
|
||||
process_serial_no(self)
|
||||
|
||||
#check for item quantity available in stock
|
||||
def actual_amt_check(self):
|
||||
|
@ -10,9 +10,6 @@ from frappe import msgprint, _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class StockUomReplaceUtility(Document):
|
||||
def __init__(self, d, dl=[]):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
def validate_mandatory(self):
|
||||
if not cstr(self.item_code):
|
||||
msgprint("Please Enter an Item.")
|
||||
|
@ -33,14 +33,14 @@ class CustomerIssue(TransactionBase):
|
||||
msgprint("Maintenance Visit No. "+lst1+" already created against this customer issue. So can not be Cancelled")
|
||||
raise Exception
|
||||
else:
|
||||
frappe.db.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.db.set(self, 'status', 'Cancelled')
|
||||
|
||||
def on_update(self):
|
||||
pass
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_maintenance_visit(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_maintenance_visit(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
visit = frappe.db.sql("""select t1.name
|
||||
from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2
|
||||
@ -48,7 +48,7 @@ def make_maintenance_visit(source_name, target_doclist=None):
|
||||
and t1.docstatus=1 and t1.completion_status='Fully Completed'""", source_name)
|
||||
|
||||
if not visit:
|
||||
doclist = get_mapped_doclist("Customer Issue", source_name, {
|
||||
doclist = get_mapped_doc("Customer Issue", source_name, {
|
||||
"Customer Issue": {
|
||||
"doctype": "Maintenance Visit",
|
||||
"field_map": {
|
||||
@ -57,6 +57,6 @@ def make_maintenance_visit(source_name, target_doclist=None):
|
||||
"name": "prevdoc_docname"
|
||||
}
|
||||
}
|
||||
}, target_doclist)
|
||||
}, target_doc)
|
||||
|
||||
return [d.fields for d in doclist]
|
@ -80,7 +80,7 @@ class MaintenanceSchedule(TransactionBase):
|
||||
"ref_name": self.name
|
||||
}).insert(ignore_permissions=1)
|
||||
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
|
||||
def create_schedule_list(self, start_date, end_date, no_of_visit, sales_person):
|
||||
schedule_list = []
|
||||
@ -199,7 +199,7 @@ class MaintenanceSchedule(TransactionBase):
|
||||
self.validate_sales_order()
|
||||
|
||||
def on_update(self):
|
||||
frappe.db.set(self.doc, 'status', 'Draft')
|
||||
frappe.db.set(self, 'status', 'Draft')
|
||||
|
||||
def update_amc_date(self, serial_nos, amc_expiry_date=None):
|
||||
for serial_no in serial_nos:
|
||||
@ -261,20 +261,20 @@ class MaintenanceSchedule(TransactionBase):
|
||||
if d.serial_no:
|
||||
serial_nos = get_valid_serial_nos(d.serial_no)
|
||||
self.update_amc_date(serial_nos)
|
||||
frappe.db.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.db.set(self, 'status', 'Cancelled')
|
||||
delete_events(self.doctype, self.name)
|
||||
|
||||
def on_trash(self):
|
||||
delete_events(self.doctype, self.name)
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_maintenance_visit(source_name, target_doclist=None):
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
def make_maintenance_visit(source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
def update_status(source, target, parent):
|
||||
target.maintenance_type = "Scheduled"
|
||||
|
||||
doclist = get_mapped_doclist("Maintenance Schedule", source_name, {
|
||||
doclist = get_mapped_doc("Maintenance Schedule", source_name, {
|
||||
"Maintenance Schedule": {
|
||||
"doctype": "Maintenance Visit",
|
||||
"field_map": {
|
||||
@ -293,6 +293,6 @@ def make_maintenance_visit(source_name, target_doclist=None):
|
||||
"sales_person": "service_person"
|
||||
}
|
||||
}
|
||||
}, target_doclist)
|
||||
}, target_doc)
|
||||
|
||||
return [d.fields for d in doclist]
|
@ -79,11 +79,11 @@ class MaintenanceVisit(TransactionBase):
|
||||
|
||||
def on_submit(self):
|
||||
self.update_customer_issue(1)
|
||||
frappe.db.set(self.doc, 'status', 'Submitted')
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
self.check_if_last_visit()
|
||||
frappe.db.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.db.set(self, 'status', 'Cancelled')
|
||||
|
||||
def on_update(self):
|
||||
pass
|
@ -40,7 +40,7 @@ class Newsletter(Document):
|
||||
"doctype": self.send_to_doctype
|
||||
}))
|
||||
|
||||
frappe.db.set(self.doc, "email_sent", 1)
|
||||
frappe.db.set(self, "email_sent", 1)
|
||||
|
||||
def get_recipients(self):
|
||||
self.email_field = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user