Merge branch 'master' into staging
This commit is contained in:
commit
5171956646
@ -4,7 +4,7 @@ import inspect
|
|||||||
import frappe
|
import frappe
|
||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
|
|
||||||
__version__ = '9.0.7'
|
__version__ = '9.0.8'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
|||||||
@ -3,6 +3,12 @@
|
|||||||
|
|
||||||
frappe.ui.form.on('Subscription', {
|
frappe.ui.form.on('Subscription', {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
|
frm.fields_dict['reference_doctype'].get_query = function(doc) {
|
||||||
|
return {
|
||||||
|
query: "erpnext.accounts.doctype.subscription.subscription.subscription_doctype_query"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
frm.fields_dict['reference_document'].get_query = function() {
|
frm.fields_dict['reference_document'].get_query = function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
|
|||||||
@ -276,4 +276,20 @@ def stop_resume_subscription(subscription, status):
|
|||||||
doc.update_status(status)
|
doc.update_status(status)
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|
||||||
return doc.status
|
return doc.status
|
||||||
|
|
||||||
|
def subscription_doctype_query(doctype, txt, searchfield, start, page_len, filters):
|
||||||
|
return frappe.db.sql("""select parent from `tabDocField`
|
||||||
|
where fieldname = 'subscription'
|
||||||
|
and parent like %(txt)s
|
||||||
|
order by
|
||||||
|
if(locate(%(_txt)s, parent), locate(%(_txt)s, parent), 99999),
|
||||||
|
parent
|
||||||
|
limit %(start)s, %(page_len)s""".format(**{
|
||||||
|
'key': searchfield,
|
||||||
|
}), {
|
||||||
|
'txt': "%%%s%%" % txt,
|
||||||
|
'_txt': txt.replace("%", ""),
|
||||||
|
'start': start,
|
||||||
|
'page_len': page_len
|
||||||
|
})
|
||||||
@ -21,7 +21,7 @@ class JobOpening(WebsiteGenerator):
|
|||||||
self.route = frappe.scrub(self.job_title).replace('_', '-')
|
self.route = frappe.scrub(self.job_title).replace('_', '-')
|
||||||
|
|
||||||
def get_context(self, context):
|
def get_context(self, context):
|
||||||
context.parents = [{'name': 'jobs', 'title': _('All Jobs') }]
|
context.parents = [{'route': 'jobs', 'title': _('All Jobs') }]
|
||||||
|
|
||||||
def get_list_context(context):
|
def get_list_context(context):
|
||||||
context.title = _("Jobs")
|
context.title = _("Jobs")
|
||||||
|
|||||||
@ -370,8 +370,13 @@ class ProductionOrder(Document):
|
|||||||
self.actual_start_date = None
|
self.actual_start_date = None
|
||||||
self.actual_end_date = None
|
self.actual_end_date = None
|
||||||
if self.get("operations"):
|
if self.get("operations"):
|
||||||
self.actual_start_date = min([d.actual_start_time for d in self.get("operations") if d.actual_start_time])
|
actual_start_dates = [d.actual_start_time for d in self.get("operations") if d.actual_start_time]
|
||||||
self.actual_end_date = max([d.actual_end_time for d in self.get("operations") if d.actual_end_time])
|
if actual_start_dates:
|
||||||
|
self.actual_start_date = min(actual_start_dates)
|
||||||
|
|
||||||
|
actual_end_dates = [d.actual_end_time for d in self.get("operations") if d.actual_end_time]
|
||||||
|
if actual_end_dates:
|
||||||
|
self.actual_end_date = max(actual_end_dates)
|
||||||
|
|
||||||
def delete_timesheet(self):
|
def delete_timesheet(self):
|
||||||
for timesheet in frappe.get_all("Timesheet", ["name"], {"production_order": self.name}):
|
for timesheet in frappe.get_all("Timesheet", ["name"], {"production_order": self.name}):
|
||||||
@ -621,4 +626,4 @@ def stop_unstop(production_order, status):
|
|||||||
frappe.msgprint(_("Production Order has been {0}").format(status))
|
frappe.msgprint(_("Production Order has been {0}").format(status))
|
||||||
pro_order.notify_update()
|
pro_order.notify_update()
|
||||||
|
|
||||||
return pro_order.status
|
return pro_order.status
|
||||||
|
|||||||
@ -763,28 +763,41 @@ class POSCart {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
this.wrapper.find('.additional_discount_percentage').on('change', (e) => {
|
this.wrapper.find('.additional_discount_percentage').on('change', (e) => {
|
||||||
|
const discount_percentage = flt(e.target.value,
|
||||||
|
precision("additional_discount_percentage"));
|
||||||
|
|
||||||
frappe.model.set_value(this.frm.doctype, this.frm.docname,
|
frappe.model.set_value(this.frm.doctype, this.frm.docname,
|
||||||
'additional_discount_percentage', e.target.value)
|
'additional_discount_percentage', discount_percentage)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
let discount_wrapper = this.wrapper.find('.discount_amount');
|
let discount_wrapper = this.wrapper.find('.discount_amount');
|
||||||
discount_wrapper.val(this.frm.doc.discount_amount);
|
discount_wrapper.val(flt(this.frm.doc.discount_amount,
|
||||||
|
precision('discount_amount')));
|
||||||
discount_wrapper.trigger('change');
|
discount_wrapper.trigger('change');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find('.discount_amount').on('change', (e) => {
|
this.wrapper.find('.discount_amount').on('change', (e) => {
|
||||||
|
const discount_amount = flt(e.target.value, precision('discount_amount'));
|
||||||
frappe.model.set_value(this.frm.doctype, this.frm.docname,
|
frappe.model.set_value(this.frm.doctype, this.frm.docname,
|
||||||
'discount_amount', flt(e.target.value));
|
'discount_amount', discount_amount);
|
||||||
this.frm.trigger('discount_amount')
|
this.frm.trigger('discount_amount')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
let discount_wrapper = this.wrapper.find('.additional_discount_percentage');
|
this.update_discount_fields();
|
||||||
discount_wrapper.val(this.frm.doc.additional_discount_percentage);
|
|
||||||
this.update_taxes_and_totals();
|
this.update_taxes_and_totals();
|
||||||
this.update_grand_total();
|
this.update_grand_total();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_discount_fields() {
|
||||||
|
let discount_wrapper = this.wrapper.find('.additional_discount_percentage');
|
||||||
|
let discount_amt_wrapper = this.wrapper.find('.discount_amount');
|
||||||
|
discount_wrapper.val(flt(this.frm.doc.additional_discount_percentage,
|
||||||
|
precision('additional_discount_percentage')));
|
||||||
|
discount_amt_wrapper.val(flt(this.frm.doc.discount_amount,
|
||||||
|
precision('discount_amount')));
|
||||||
|
}
|
||||||
|
|
||||||
set_selected_item($item) {
|
set_selected_item($item) {
|
||||||
this.selected_item = $item;
|
this.selected_item = $item;
|
||||||
this.$cart_items.find('.list-item').removeClass('current-item qty disc rate');
|
this.$cart_items.find('.list-item').removeClass('current-item qty disc rate');
|
||||||
@ -848,7 +861,7 @@ class POSItems {
|
|||||||
this.search_field = frappe.ui.form.make_control({
|
this.search_field = frappe.ui.form.make_control({
|
||||||
df: {
|
df: {
|
||||||
fieldtype: 'Data',
|
fieldtype: 'Data',
|
||||||
label: 'Search Item (Ctrl + I)',
|
label: 'Search Item ( Ctrl + i )',
|
||||||
placeholder: 'Search by item code, serial number, batch no or barcode'
|
placeholder: 'Search by item code, serial number, batch no or barcode'
|
||||||
},
|
},
|
||||||
parent: this.wrapper.find('.search-field'),
|
parent: this.wrapper.find('.search-field'),
|
||||||
@ -945,16 +958,21 @@ class POSItems {
|
|||||||
if(serial_no) {
|
if(serial_no) {
|
||||||
this.events.update_cart(items[0].item_code,
|
this.events.update_cart(items[0].item_code,
|
||||||
'serial_no', serial_no);
|
'serial_no', serial_no);
|
||||||
this.search_field.set_value('');
|
this.reset_search_field();
|
||||||
}
|
}
|
||||||
if(batch_no) {
|
if(batch_no) {
|
||||||
this.events.update_cart(items[0].item_code,
|
this.events.update_cart(items[0].item_code,
|
||||||
'batch_no', batch_no);
|
'batch_no', batch_no);
|
||||||
this.search_field.set_value('');
|
this.reset_search_field();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset_search_field() {
|
||||||
|
this.search_field.set_value('');
|
||||||
|
this.search_field.$input.trigger("input");
|
||||||
|
}
|
||||||
|
|
||||||
bind_events() {
|
bind_events() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.wrapper.on('click', '.pos-item-wrapper', function() {
|
this.wrapper.on('click', '.pos-item-wrapper', function() {
|
||||||
|
|||||||
@ -24,6 +24,8 @@ def get_items(start, page_length, price_list, item_group, search_value=""):
|
|||||||
if batch_no_data:
|
if batch_no_data:
|
||||||
batch_no, item_code = batch_no_data
|
batch_no, item_code = batch_no_data
|
||||||
|
|
||||||
|
item_code, condition = get_conditions(item_code, serial_no, batch_no)
|
||||||
|
|
||||||
lft, rgt = frappe.db.get_value('Item Group', item_group, ['lft', 'rgt'])
|
lft, rgt = frappe.db.get_value('Item Group', item_group, ['lft', 'rgt'])
|
||||||
# locate function is used to sort by closest match from the beginning of the value
|
# locate function is used to sort by closest match from the beginning of the value
|
||||||
res = frappe.db.sql("""select i.name as item_code, i.item_name, i.image as item_image,
|
res = frappe.db.sql("""select i.name as item_code, i.item_name, i.image as item_image,
|
||||||
@ -36,11 +38,11 @@ def get_items(start, page_length, price_list, item_group, search_value=""):
|
|||||||
where
|
where
|
||||||
i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
|
i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
|
||||||
and i.item_group in (select name from `tabItem Group` where lft >= {lft} and rgt <= {rgt})
|
and i.item_group in (select name from `tabItem Group` where lft >= {lft} and rgt <= {rgt})
|
||||||
and (i.item_code like %(item_code)s
|
and {condition}
|
||||||
or i.item_name like %(item_code)s or i.barcode like %(item_code)s)
|
limit {start}, {page_length}""".format(start=start,
|
||||||
limit {start}, {page_length}""".format(start=start, page_length=page_length, lft=lft, rgt=rgt),
|
page_length=page_length, lft=lft, rgt=rgt, condition=condition),
|
||||||
{
|
{
|
||||||
'item_code': '%%%s%%'%(frappe.db.escape(item_code)),
|
'item_code': item_code,
|
||||||
'price_list': price_list
|
'price_list': price_list
|
||||||
} , as_dict=1)
|
} , as_dict=1)
|
||||||
|
|
||||||
@ -60,6 +62,15 @@ def get_items(start, page_length, price_list, item_group, search_value=""):
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def get_conditions(item_code, serial_no, batch_no):
|
||||||
|
if serial_no or batch_no:
|
||||||
|
return frappe.db.escape(item_code), "i.item_code = %(item_code)s"
|
||||||
|
|
||||||
|
condition = """(i.item_code like %(item_code)s
|
||||||
|
or i.item_name like %(item_code)s or i.barcode like %(item_code)s)"""
|
||||||
|
|
||||||
|
return '%%%s%%'%(frappe.db.escape(item_code)), condition
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def submit_invoice(doc):
|
def submit_invoice(doc):
|
||||||
if isinstance(doc, basestring):
|
if isinstance(doc, basestring):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user