From 77940493a828e80a87bd0ec92ddf1b177d7b3aee Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sat, 18 Nov 2017 16:58:58 +0530 Subject: [PATCH 1/7] [fix] Price list not loaded from pos profile, auto set outstanding amount in the mode of payment --- .../doctype/pos_profile/pos_profile.js | 4 +- .../doctype/sales_invoice/sales_invoice.py | 2 +- .../page/point_of_sale/point_of_sale.js | 60 +++++++++++++------ 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.js b/erpnext/accounts/doctype/pos_profile/pos_profile.js index cb52627cf0..25aff13693 100755 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.js +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.js @@ -24,11 +24,11 @@ frappe.ui.form.on("POS Profile", "onload", function(frm) { frappe.ui.form.on('POS Profile', { setup: function(frm) { - frm.set_query("online_print_format", function() { + frm.set_query("print_format_for_online", function() { return { filters: [ ['Print Format', 'doc_type', '=', 'Sales Invoice'], - ['Print Format', 'print_format_type', '!=', 'Js'], + ['Print Format', 'print_format_type', '=', 'Server'], ] }; }); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index db9969d133..83d5103020 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -247,7 +247,7 @@ class SalesInvoice(SellingController): super(SalesInvoice, self).set_missing_values(for_validate) if pos: - return {"print_format": pos.get("print_format") } + return {"print_format": pos.get("print_format_for_online") } def update_time_sheet(self, sales_invoice): for d in self.timesheets: diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index b167bcda6c..0a70bb905a 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -53,8 +53,6 @@ erpnext.pos.PointOfSale = class PointOfSale { () => this.setup_pos_profile(), () => this.make_new_invoice(), () => { - frappe.timeout(1); - this.make_items(); this.bind_events(); frappe.dom.unfreeze(); }, @@ -323,16 +321,20 @@ erpnext.pos.PointOfSale = class PointOfSale { make_new_invoice() { return frappe.run_serially([ - () => this.make_sales_invoice_frm(), () => { - if (this.cart) { - this.cart.frm = this.frm; - this.cart.reset(); - } else { - this.make_cart(); - } - this.toggle_editing(true); - } + this.make_sales_invoice_frm() + .then(() => this.set_pos_profile_data()) + .then(() => { + if (this.cart) { + this.cart.frm = this.frm; + this.cart.reset(); + } else { + this.make_items(); + this.make_cart(); + } + this.toggle_editing(true); + }) + }, ]); } @@ -359,12 +361,29 @@ erpnext.pos.PointOfSale = class PointOfSale { if(!frm.doc.company) { frm.set_value('company', pos_profile.company); } - frm.set_value('is_pos', 1); - frm.meta.default_print_format = 'POS Invoice'; + frm.doc.is_pos = 1; return frm; } } + set_pos_profile_data() { + return new Promise(resolve => { + return this.frm.call({ + doc: this.frm.doc, + method: "set_missing_values", + }).then((r) => { + if(!r.exc) { + this.frm.script_manager.trigger("update_stock"); + frappe.model.set_default_values(this.frm.doc); + this.frm.cscript.calculate_taxes_and_totals(); + this.frm.meta.default_print_format = r.message.print_format || 'POS Invoice'; + } + + resolve(); + }) + }) + } + prepare_menu() { var me = this; this.page.clear_menu(); @@ -392,9 +411,6 @@ erpnext.pos.PointOfSale = class PointOfSale { if(this.frm.doc.docstatus !== 1) return; this.page.set_secondary_action(__("Print"), () => { - if (this.pos_profile && this.pos_profile.print_format_for_online) { - this.frm.meta.default_print_format = this.pos_profile.print_format_for_online; - } this.frm.print_preview.printit(true); }); @@ -1264,6 +1280,16 @@ class Payment { $(this.dialog.body).find('.input-with-feedback').focusin(function() { me.numpad.reset_value(); me.fieldname = $(this).prop('dataset').fieldname; + if (me.frm.doc.outstanding_amount > 0 && + !in_list(['write_off_amount', 'change_amount'], me.fieldname)) { + me.frm.doc.payments.forEach((data) => { + if (data.mode_of_payment == me.fieldname && !data.amount) { + me.dialog.set_value(me.fieldname, + me.frm.doc.outstanding_amount / me.frm.doc.conversion_rate); + return; + } + }) + } }); } @@ -1403,4 +1429,4 @@ class Payment { this.dialog.set_value("paid_amount", this.frm.doc.paid_amount); this.dialog.set_value("outstanding_amount", this.frm.doc.outstanding_amount); } -} +} \ No newline at end of file From 179e0c1d8da0b8eefaa2b51f545f2de818aa69c0 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Mon, 20 Nov 2017 11:18:55 +0530 Subject: [PATCH 2/7] Added party name in accounts receivable/payable report (#11656) --- .../accounts_receivable/accounts_receivable.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html index 8fafce6781..9d872a49f0 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html @@ -36,8 +36,14 @@
{%= data[i][__("Voucher No")] %} {% if(!(filters.customer || filters.supplier)) { %} - {%= data[i][__("Customer Name")] || data[i][__("Customer")] || data[i][__("Supplier Name")] || data[i][__("Supplier")] %}
{%= __("Remarks") %}: + {%= data[i][__("Customer")] || data[i][__("Supplier")] %} + {% if(data[i][__("Customer Name")] && data[i][__("Customer Name")] != data[i][__("Customer")]) { %} +
{%= data[i][__("Customer Name")] %} + {% } else if(data[i][__("Supplier Name")] != data[i][__("Supplier")]) { %} +
{%= data[i][__("Supplier Name")] %} + {% } %} {% } %} +
{%= __("Remarks") %}: {%= data[i][__("Remarks")] %} @@ -66,8 +72,13 @@ {% if(!(filters.customer || filters.supplier)) { %} {%= data[i][__("Customer")] || data[i][__("Supplier")] %} -
{%= __("Remarks") %}: + {% if(data[i][__("Customer Name")] && data[i][__("Customer Name")] != data[i][__("Customer")]) { %} +
{%= data[i][__("Customer Name")] %} + {% } else if(data[i][__("Supplier Name")] != data[i][__("Supplier")]) { %} +
{%= data[i][__("Supplier Name")] %} + {% } %} {% } %} +
{%= __("Remarks") %}: {%= data[i][__("Remarks")] %} {% } else { %} From cc884578b5f3e45551282ba3476c7732a5313be6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 21 Nov 2017 12:24:03 +0530 Subject: [PATCH 3/7] Update sales_order.py --- erpnext/selling/doctype/sales_order/sales_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 747a3c062c..51e6c61ea3 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -103,7 +103,7 @@ class SalesOrder(SellingController): def validate_delivery_date(self): if self.order_type == 'Sales': if not self.delivery_date: - self.delivery_date = max([d.delivery_date for d in self.get("items")]) + self.delivery_date = max([d.delivery_date for d in self.get("items") if d.delivery_date]) if self.delivery_date: for d in self.get("items"): From 75443a94ee05db66916aabced04af33bcf4f9a18 Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Tue, 21 Nov 2017 16:12:40 +0530 Subject: [PATCH 4/7] [minor] set the pos profile name while creating demo (#11664) --- erpnext/demo/setup/setup_data.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py index 34e9a3e572..d395493c47 100644 --- a/erpnext/demo/setup/setup_data.py +++ b/erpnext/demo/setup/setup_data.py @@ -348,8 +348,10 @@ def setup_budget(): budget.action_if_annual_budget_exceeded = "Warn" expense_ledger_count = frappe.db.count("Account", {"is_group": "0", "root_type": "Expense"}) - add_random_children(budget, "accounts", rows=random.randint(10, expense_ledger_count), randomize = { "account": ("Account", {"is_group": "0", "root_type": "Expense"}) - }, unique="account") + add_random_children(budget, "accounts", rows=random.randint(10, expense_ledger_count), + randomize = { + "account": ("Account", {"is_group": "0", "root_type": "Expense"}) + }, unique="account") for d in budget.accounts: d.budget_amount = random.randint(5, 100) * 10000 @@ -361,6 +363,7 @@ def setup_pos_profile(): company_abbr = frappe.db.get_value("Company", erpnext.get_default_company(), "abbr") pos = frappe.new_doc('POS Profile') pos.user = frappe.db.get_global('demo_accounts_user') + pos.pos_profile_name = "Demo POS Profile" pos.naming_series = 'SINV-' pos.update_stock = 0 pos.write_off_account = 'Cost of Goods Sold - '+ company_abbr From 96abfd2ab9fd6b5511c81aac06202032ea6fdc99 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 22 Nov 2017 15:13:16 +0530 Subject: [PATCH 5/7] [fix] In payment entry, run some events serially to avoid async issue --- .../doctype/payment_entry/payment_entry.js | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index c5e0306486..d8995a9d98 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -253,20 +253,24 @@ frappe.ui.form.on('Payment Entry', { }, callback: function(r, rt) { if(r.message) { - if(frm.doc.payment_type == "Receive") { - frm.set_value("paid_from", r.message.party_account); - frm.set_value("paid_from_account_currency", r.message.party_account_currency); - frm.set_value("paid_from_account_balance", r.message.account_balance); - } else if (frm.doc.payment_type == "Pay"){ - frm.set_value("paid_to", r.message.party_account); - frm.set_value("paid_to_account_currency", r.message.party_account_currency); - frm.set_value("paid_to_account_balance", r.message.account_balance); - } - frm.set_value("party_balance", r.message.party_balance); - frm.events.get_outstanding_documents(frm); - frm.events.hide_unhide_fields(frm); - frm.events.set_dynamic_labels(frm); - frm.set_party_account_based_on_party = false; + frappe.run_serially([ + () => { + if(frm.doc.payment_type == "Receive") { + frm.set_value("paid_from", r.message.party_account); + frm.set_value("paid_from_account_currency", r.message.party_account_currency); + frm.set_value("paid_from_account_balance", r.message.account_balance); + } else if (frm.doc.payment_type == "Pay"){ + frm.set_value("paid_to", r.message.party_account); + frm.set_value("paid_to_account_currency", r.message.party_account_currency); + frm.set_value("paid_to_account_balance", r.message.account_balance); + } + }, + () => frm.set_value("party_balance", r.message.party_balance), + () => frm.events.get_outstanding_documents(frm), + () => frm.events.hide_unhide_fields(frm), + () => frm.events.set_dynamic_labels(frm), + () => { frm.set_party_account_based_on_party = false; } + ]); } } }); From 4dc5f0efaf0cbcd404672e56f04bc17f76a35664 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 22 Nov 2017 15:21:47 +0530 Subject: [PATCH 6/7] [Fix] Item details not fetching if item has no default bom (#11688) --- erpnext/controllers/buying_controller.py | 2 +- erpnext/stock/get_item_details.py | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index d3010818e5..e5987359d0 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -171,7 +171,7 @@ class BuyingController(StockController): for item in self.get("items"): if self.doctype in ["Purchase Receipt", "Purchase Invoice"]: item.rm_supp_cost = 0.0 - if item.item_code in self.sub_contracted_items: + if item.bom and item.item_code in self.sub_contracted_items: self.update_raw_materials_supplied(item, raw_material_table) if [item.item_code, item.name] not in parent_items: diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 539e8a5667..9ec5d195be 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -96,16 +96,6 @@ def get_item_details(args): return out - # print(frappe._dict({ - # 'has_serial_no' : out.has_serial_no, - # 'has_batch_no' : out.has_batch_no - # })) - - # return frappe._dict({ - # 'has_serial_no' : out.has_serial_no, - # 'has_batch_no' : out.has_batch_no - # }) - def process_args(args): if isinstance(args, basestring): args = json.loads(args) @@ -532,8 +522,6 @@ def get_default_bom(item_code=None): bom = frappe.db.get_value("BOM", {"docstatus": 1, "is_default": 1, "is_active": 1, "item": item_code}) if bom: return bom - else: - frappe.throw(_("No default BOM exists for Item {0}").format(item_code)) def get_valuation_rate(item_code, warehouse=None): item = frappe.get_doc("Item", item_code) From 4bc12b68e45adfab84d3bedb62740aa8d72232f2 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 22 Nov 2017 18:24:18 +0600 Subject: [PATCH 7/7] bumped to version 9.2.16 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 30b021e090..b16e299dc4 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -4,7 +4,7 @@ import inspect import frappe from erpnext.hooks import regional_overrides -__version__ = '9.2.15' +__version__ = '9.2.16' def get_default_company(user=None): '''Get default company for user'''