Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed May 30, 2017
2 parents 465d835 + 93b5367 commit f6c396f
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 47 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe

__version__ = '8.0.40'
__version__ = '8.0.41'


def get_default_company(user=None):
Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
this.calculate_write_off_amount()
}else {
this.frm.set_value("change_amount", 0.0)
this.frm.set_value("base_change_amount", 0.0)
}

this.frm.refresh_fields();
Expand Down
4 changes: 2 additions & 2 deletions erpnext/controllers/status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def validate_status(status, options):
["Converted", "has_customer"],
],
"Opportunity": [
["Quotation", "has_active_quotation"],
["Converted", "has_ordered_quotation"],
["Lost", "eval:self.status=='Lost'"],
["Lost", "has_lost_quotation"],
["Quotation", "has_active_quotation"],
["Converted", "has_ordered_quotation"],
["Closed", "eval:self.status=='Closed'"]
],
"Quotation": [
Expand Down
14 changes: 8 additions & 6 deletions erpnext/controllers/taxes_and_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,17 @@ def calculate_outstanding_amount(self):
self.doc.conversion_rate, self.doc.precision("grand_total")) - self.doc.total_advance
- flt(self.doc.base_write_off_amount), self.doc.precision("grand_total"))

if self.doc.doctype == "Sales Invoice":
if self.doc.doctype == "Sales Invoice":
self.doc.round_floats_in(self.doc, ["paid_amount"])
self.calculate_write_off_amount()
self.calculate_change_amount()

paid_amount = self.doc.paid_amount \
if self.doc.party_account_currency == self.doc.currency else self.doc.base_paid_amount

change_amount = self.doc.change_amount \
if self.doc.party_account_currency == self.doc.currency else self.doc.base_change_amount

self.calculate_write_off_amount()
self.calculate_change_amount()

self.doc.outstanding_amount = flt(total_amount_to_pay - flt(paid_amount) +
flt(change_amount), self.doc.precision("outstanding_amount"))

Expand All @@ -475,7 +475,9 @@ def calculate_paid_amount(self):
def calculate_change_amount(self):
self.doc.change_amount = 0.0
self.doc.base_change_amount = 0.0
if self.doc.paid_amount > self.doc.grand_total:
if self.doc.paid_amount > self.doc.grand_total and not self.doc.is_return \
and any([d.type == "Cash" for d in self.doc.payments]):

self.doc.change_amount = flt(self.doc.paid_amount - self.doc.grand_total +
self.doc.write_off_amount, self.doc.precision("change_amount"))

Expand Down
34 changes: 15 additions & 19 deletions erpnext/crm/doctype/opportunity/opportunity.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ frappe.ui.form.on("Opportunity", {
var doc = frm.doc;
frm.events.enquiry_from(frm);
frm.trigger('set_contact_link');
erpnext.toggle_naming_series();

if(!doc.__islocal && doc.status!=="Lost") {
if(doc.with_items){
Expand All @@ -53,6 +54,20 @@ frappe.ui.form.on("Opportunity", {
frm.add_custom_button(__('Lost'),
cur_frm.cscript['Declare Opportunity Lost']);
}
},

if(!frm.doc.__islocal && frm.perm[0].write && frm.doc.docstatus==0) {
if(frm.doc.status==="Open") {
frm.add_custom_button(__("Close"), function() {
frm.set_value("status", "Closed");
frm.save();
});
} else {
frm.add_custom_button(__("Reopen"), function() {
frm.set_value("status", "Open");
frm.save();
});
}
}
},

Expand Down Expand Up @@ -122,25 +137,6 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({

$.extend(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm}));

cur_frm.cscript.refresh = function(doc, cdt, cdn) {
erpnext.toggle_naming_series();

var frm = cur_frm;
if(!doc.__islocal && frm.perm[0].write && doc.docstatus==0) {
if(frm.doc.status==="Open") {
frm.add_custom_button(__("Close"), function() {
frm.set_value("status", "Closed");
frm.save();
});
} else {
frm.add_custom_button(__("Reopen"), function() {
frm.set_value("status", "Open");
frm.save();
});
}
}
}

cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
if(doc.enquiry_from == 'Lead' && doc.lead)
cur_frm.cscript.lead(doc, cdt, cdn);
Expand Down
1 change: 0 additions & 1 deletion erpnext/crm/doctype/opportunity/opportunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def validate(self):
if not self.enquiry_from:
frappe.throw(_("Opportunity From field is mandatory"))

self.set_status()
self.validate_item_details()
self.validate_uom_is_integer("uom", "qty")
self.validate_lead_cust()
Expand Down
3 changes: 2 additions & 1 deletion erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@
"erpnext.hr.doctype.employee.employee.send_birthday_reminders",
"erpnext.projects.doctype.task.task.set_tasks_as_overdue",
"erpnext.accounts.doctype.asset.depreciation.post_depreciation_entries",
'erpnext.hr.doctype.daily_work_summary_settings.daily_work_summary_settings.send_summary'
"erpnext.hr.doctype.daily_work_summary_settings.daily_work_summary_settings.send_summary",
"erpnext.stock.doctype.serial_no.serial_no.update_maintenance_status"
]
}

Expand Down
3 changes: 2 additions & 1 deletion erpnext/hr/doctype/expense_claim/expense_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from erpnext.accounts.general_ledger import make_gl_entries
from erpnext.accounts.doctype.sales_invoice.sales_invoice import get_bank_cash_account
from erpnext.controllers.accounts_controller import AccountsController
from frappe.utils.csvutils import getlink

class InvalidExpenseApproverError(frappe.ValidationError): pass

Expand Down Expand Up @@ -146,7 +147,7 @@ def validate_account_details(self):
frappe.throw(_("Cost center is required to book an expense claim"))

if not self.payable_account:
frappe.throw(_("Please set default payable account in the employee {0}").format(self.employee))
frappe.throw(_("Please set default payable account for the company {0}").format(getlink("Company",self.company)))

if self.is_paid:
if not self.mode_of_payment:
Expand Down
29 changes: 26 additions & 3 deletions erpnext/hr/doctype/training_event/training_event.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:event_name",
Expand All @@ -12,6 +13,7 @@
"editable_grid": 1,
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand All @@ -27,7 +29,7 @@
"in_standard_filter": 0,
"label": "Event Name",
"length": 0,
"no_copy": 0,
"no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 0,
Expand All @@ -41,6 +43,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -71,6 +74,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -99,6 +103,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -129,6 +134,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -157,6 +163,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -186,6 +193,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -216,6 +224,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -244,6 +253,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -274,6 +284,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -303,6 +314,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -331,6 +343,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -361,6 +374,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -390,6 +404,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -418,6 +433,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -447,6 +463,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -476,6 +493,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -504,6 +522,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -533,6 +552,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -562,6 +582,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -592,6 +613,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -622,6 +644,7 @@
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
Expand Down Expand Up @@ -651,17 +674,17 @@
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-02-17 16:51:35.141403",
"modified": "2017-05-29 06:13:38.411039",
"modified_by": "Administrator",
"module": "HR",
"name": "Training Event",
Expand Down
4 changes: 3 additions & 1 deletion erpnext/hr/doctype/training_result/training_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def on_submit(self):

def send_result(self):
for emp in self.employees:
message = "Thank You for attending {0}. You grade is {1}".format(self.training_event, emp.grade)
message = "Thank You for attending {0}.".format(self.training_event)
if emp.grade:
message = message + "Your grade: {0}".format(emp.grade)
frappe.sendmail(frappe.db.get_value("Employee", emp.employee, "company_email"), \
subject=_("{0} Results".format(self.training_event)), \
content=message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from erpnext.stock.stock_balance import get_planned_qty, update_bin_qty
from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict
from erpnext.stock.utils import get_bin
from frappe.utils.csvutils import getlink

class OverProductionError(frappe.ValidationError): pass
class StockOverProductionError(frappe.ValidationError): pass
Expand Down Expand Up @@ -311,7 +312,7 @@ def make_time_logs(self, open_new=False):

if timesheet and timesheet.get("time_logs"):
timesheet.save()
timesheets.append(timesheet.name)
timesheets.append(getlink("Timesheet", timesheet.name))

self.planned_end_date = self.operations[-1].planned_end_time
if timesheets:
Expand Down
Loading

0 comments on commit f6c396f

Please sign in to comment.