diff --git a/posnext/doc_events/sales_invoice.py b/posnext/doc_events/sales_invoice.py index 7b882b7..798bd14 100644 --- a/posnext/doc_events/sales_invoice.py +++ b/posnext/doc_events/sales_invoice.py @@ -2,6 +2,8 @@ def validate_si(doc,method): + if 'branch' not in doc.__dict__: + frappe.throw("Create Branch Accounting Dimensions.") if doc.is_return and doc.is_pos: doc.update_outstanding_for_self = 0 if doc.payments: diff --git a/posnext/public/js/pos_item_cart.js b/posnext/public/js/pos_item_cart.js index 0bef29d..0fd1799 100644 --- a/posnext/public/js/pos_item_cart.js +++ b/posnext/public/js/pos_item_cart.js @@ -165,19 +165,6 @@ posnext.PointOfSale.ItemCart = class { ${this.get_branch_icon()} ${__('Add Branch')} `); - - // Apply styles - this.$branch_section.find('.add-branch-wrapper').css({ - "display": "flex", - "align-items": "center", - "gap": "8px", - "border": "2px dashed #ccc", - "padding": "10px", - "border-radius": "6px", - "cursor": "pointer", - "font-weight": "bold" - }); - // Change cursor on hover this.$branch_section.find('.add-branch-wrapper').hover( function () { @@ -523,51 +510,39 @@ this.highlight_checkout_btn(true); if(!this.discount_field || can_edit_discount) this.show_discount_control(); }); - this.$component.on('click', '.add-branch-wrapper', function () { - const $wrapper = $(this); - const posProfileName = me.settings.name; - - const branchFieldWrapper = $('
'); - $wrapper.replaceWith(branchFieldWrapper); - frappe.call({ - method: "posnext.doc_events.pos_profile.get_pos_profile_branch", - args: { - pos_profile_name: posProfileName - }, - callback: function (r) { - const branch_name = r.message && r.message.branch; - - console.log(branch_name) - - - if (!branch_name) { - frappe.msgprint(__('Create Branch Accounting Dimensions')); - return; - } - - - let branchField = new frappe.ui.form.ControlLink({ - df: { - fieldtype: 'Link', - options: 'Branch', - fieldname: 'branch', - label: 'Branch', - placeholder: 'Select Branch', - default: branch_name, - reqd: 1, - get_query: () => ({ - filters: { disabled: 0 } - }) - }, - parent: branchFieldWrapper - }); - - branchField.make(); - branchField.set_value(branch_name); - branchField.refresh(); - }, - }); + const $wrapper = $('.add-branch-wrapper'); + const posProfileName = me.settings.name; + const branchFieldWrapper = $(''); + $wrapper.replaceWith(branchFieldWrapper); + + frappe.call({ + method: "posnext.doc_events.pos_profile.get_pos_profile_branch", + args: { + pos_profile_name: posProfileName + }, + callback: function (r) { + const branch_name = r.message && r.message.branch; + console.log(branch_name); + + let branchField = new frappe.ui.form.ControlLink({ + df: { + fieldtype: 'Link', + options: 'Branch', + fieldname: 'branch', + label: 'Branch', + placeholder: 'Select Branch', + default: branch_name, + reqd: 1, + + }, + parent: branchFieldWrapper + }); + + branchField.make(); + branchField.set_value(branch_name); + branchField.refresh(); + }, }); frappe.ui.form.on("Sales Invoice", "paid_amount", frm => { @@ -1327,7 +1302,6 @@ this.highlight_checkout_btn(true); } }); if (item_data.description && response.message.custom_show_item_discription==1) { - console.log(`