[Fix] Pos bugs (#16256)
* Remove hard-coded values * Fix change pos profile + add campaign * Test case for coveralls * Remove unnecessary method
This commit is contained in:
parent
4265c5a772
commit
052033a76e
@ -324,7 +324,8 @@ class SalesInvoice(SellingController):
|
|||||||
return {
|
return {
|
||||||
"print_format": print_format,
|
"print_format": print_format,
|
||||||
"allow_edit_rate": pos.get("allow_user_to_edit_rate"),
|
"allow_edit_rate": pos.get("allow_user_to_edit_rate"),
|
||||||
"allow_edit_discount": pos.get("allow_user_to_edit_discount")
|
"allow_edit_discount": pos.get("allow_user_to_edit_discount"),
|
||||||
|
"campaign": pos.get("campaign")
|
||||||
}
|
}
|
||||||
|
|
||||||
def update_time_sheet(self, sales_invoice):
|
def update_time_sheet(self, sales_invoice):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
@ -762,6 +762,20 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
|
|
||||||
frappe.db.sql("delete from `tabPOS Profile`")
|
frappe.db.sql("delete from `tabPOS Profile`")
|
||||||
|
|
||||||
|
def test_pos_si_without_payment(self):
|
||||||
|
set_perpetual_inventory()
|
||||||
|
make_pos_profile()
|
||||||
|
|
||||||
|
pos = copy.deepcopy(test_records[1])
|
||||||
|
pos["is_pos"] = 1
|
||||||
|
pos["update_stock"] = 1
|
||||||
|
|
||||||
|
si = frappe.copy_doc(pos)
|
||||||
|
si.insert()
|
||||||
|
|
||||||
|
# Check that the invoice cannot be submitted without payments
|
||||||
|
self.assertRaises(frappe.ValidationError, si.submit)
|
||||||
|
|
||||||
def test_sales_invoice_gl_entry_with_perpetual_inventory_no_item_code(self):
|
def test_sales_invoice_gl_entry_with_perpetual_inventory_no_item_code(self):
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
|
@ -1135,16 +1135,18 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
apply_category: function() {
|
apply_category: function() {
|
||||||
var me = this;
|
frappe.db.get_value("Item Group", {lft: 1, is_group: 1}, "name", (r) => {
|
||||||
category = this.selected_item_group || "All Item Groups";
|
category = this.selected_item_group || r.name;
|
||||||
|
|
||||||
if(category == 'All Item Groups') {
|
if(category == r.name) {
|
||||||
return this.item_data
|
return this.item_data
|
||||||
} else {
|
} else {
|
||||||
return this.item_data.filter(function(element, index, array){
|
return this.item_data.filter(function(element, index, array){
|
||||||
return element.item_group == category;
|
return element.item_group == category;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
bind_items_event: function() {
|
bind_items_event: function() {
|
||||||
|
@ -394,7 +394,7 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.prompt(this.get_promopt_fields(),
|
frappe.prompt(this.get_prompt_fields(),
|
||||||
on_submit,
|
on_submit,
|
||||||
__('Select POS Profile')
|
__('Select POS Profile')
|
||||||
);
|
);
|
||||||
@ -417,11 +417,12 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_promopt_fields() {
|
get_prompt_fields() {
|
||||||
return [{
|
return [{
|
||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
label: __('POS Profile'),
|
label: __('POS Profile'),
|
||||||
options: 'POS Profile',
|
options: 'POS Profile',
|
||||||
|
fieldname: 'pos_profile',
|
||||||
reqd: 1,
|
reqd: 1,
|
||||||
get_query: () => {
|
get_query: () => {
|
||||||
return {
|
return {
|
||||||
@ -433,7 +434,8 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
fieldtype: 'Check',
|
fieldtype: 'Check',
|
||||||
label: __('Set as default')
|
label: __('Set as default'),
|
||||||
|
fieldname: 'set_as_default'
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,6 +524,7 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
this.frm.meta.default_print_format = r.message.print_format || "";
|
this.frm.meta.default_print_format = r.message.print_format || "";
|
||||||
this.frm.allow_edit_rate = r.message.allow_edit_rate;
|
this.frm.allow_edit_rate = r.message.allow_edit_rate;
|
||||||
this.frm.allow_edit_discount = r.message.allow_edit_discount;
|
this.frm.allow_edit_discount = r.message.allow_edit_discount;
|
||||||
|
this.frm.doc.campaign = r.message.campaign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1128,12 +1131,15 @@ class POSItems {
|
|||||||
this.events = events;
|
this.events = events;
|
||||||
this.currency = this.frm.doc.currency;
|
this.currency = this.frm.doc.currency;
|
||||||
|
|
||||||
this.make_dom();
|
frappe.db.get_value("Item Group", {lft: 1, is_group: 1}, "name", (r) => {
|
||||||
this.make_fields();
|
this.parent_item_group = r.name;
|
||||||
|
this.make_dom();
|
||||||
|
this.make_fields();
|
||||||
|
|
||||||
this.init_clusterize();
|
this.init_clusterize();
|
||||||
this.bind_events();
|
this.bind_events();
|
||||||
this.load_items_data();
|
this.load_items_data();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
load_items_data() {
|
load_items_data() {
|
||||||
@ -1175,6 +1181,7 @@ class POSItems {
|
|||||||
|
|
||||||
make_fields() {
|
make_fields() {
|
||||||
// Search field
|
// Search field
|
||||||
|
const me = this;
|
||||||
this.search_field = frappe.ui.form.make_control({
|
this.search_field = frappe.ui.form.make_control({
|
||||||
df: {
|
df: {
|
||||||
fieldtype: 'Data',
|
fieldtype: 'Data',
|
||||||
@ -1202,7 +1209,7 @@ class POSItems {
|
|||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
label: 'Item Group',
|
label: 'Item Group',
|
||||||
options: 'Item Group',
|
options: 'Item Group',
|
||||||
default: 'All Item Groups',
|
default: me.parent_item_group,
|
||||||
onchange: () => {
|
onchange: () => {
|
||||||
const item_group = this.item_group_field.get_value();
|
const item_group = this.item_group_field.get_value();
|
||||||
if (item_group) {
|
if (item_group) {
|
||||||
@ -1258,7 +1265,7 @@ class POSItems {
|
|||||||
this.clusterize.update(row_items);
|
this.clusterize.update(row_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_items({ search_term='', item_group='All Item Groups' }={}) {
|
filter_items({ search_term='', item_group=this.parent_item_group }={}) {
|
||||||
if (search_term) {
|
if (search_term) {
|
||||||
search_term = search_term.toLowerCase();
|
search_term = search_term.toLowerCase();
|
||||||
|
|
||||||
@ -1271,7 +1278,7 @@ class POSItems {
|
|||||||
this.set_item_in_the_cart(items);
|
this.set_item_in_the_cart(items);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (item_group == "All Item Groups") {
|
} else if (item_group == this.parent_item_group) {
|
||||||
this.items = this.all_items;
|
this.items = this.all_items;
|
||||||
return this.render_items(this.all_items);
|
return this.render_items(this.all_items);
|
||||||
}
|
}
|
||||||
@ -1376,7 +1383,7 @@ class POSItems {
|
|||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_items({start = 0, page_length = 40, search_value='', item_group="All Item Groups"}={}) {
|
get_items({start = 0, page_length = 40, search_value='', item_group=this.parent_item_group}={}) {
|
||||||
return new Promise(res => {
|
return new Promise(res => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.selling.page.point_of_sale.point_of_sale.get_items",
|
method: "erpnext.selling.page.point_of_sale.point_of_sale.get_items",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user