Merge pull request #3300 from rmehta/pos-setting-rename

[rename] POS Setting > POS Profile #3271
This commit is contained in:
Nabin Hait 2015-05-21 13:14:59 +05:30
commit 9e38d29df7
18 changed files with 316 additions and 311 deletions

View File

@ -1,13 +1,13 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
frappe.ui.form.on("POS Setting", "onload", function(frm) { frappe.ui.form.on("POS Profile", "onload", function(frm) {
frm.set_query("selling_price_list", function() { frm.set_query("selling_price_list", function() {
return { filter: { selling: 1 } }; return { filter: { selling: 1 } };
}); });
frm.call({ frm.call({
method: "erpnext.accounts.doctype.pos_setting.pos_setting.get_series", method: "erpnext.accounts.doctype.pos_profile.pos_profile.get_series",
callback: function(r) { callback: function(r) {
if(!r.exc) { if(!r.exc) {
set_field_options("naming_series", r.message); set_field_options("naming_series", r.message);

View File

@ -0,0 +1,263 @@
{
"allow_rename": 0,
"autoname": "hash",
"creation": "2013-05-24 12:15:51",
"docstatus": 0,
"doctype": "DocType",
"fields": [
{
"fieldname": "user",
"fieldtype": "Link",
"in_list_view": 1,
"label": "User",
"oldfieldname": "user",
"oldfieldtype": "Link",
"options": "User",
"permlevel": 0,
"read_only": 0
},
{
"description": "",
"fieldname": "territory",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Territory",
"oldfieldname": "territory",
"oldfieldtype": "Link",
"options": "Territory",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "naming_series",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",
"options": "[Select]",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "currency",
"fieldtype": "Link",
"in_list_view": 0,
"label": "Currency",
"oldfieldname": "currency",
"oldfieldtype": "Select",
"options": "Currency",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "selling_price_list",
"fieldtype": "Link",
"label": "Price List",
"oldfieldname": "price_list_name",
"oldfieldtype": "Select",
"options": "Price List",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "company",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Company",
"oldfieldname": "company",
"oldfieldtype": "Link",
"options": "Company",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0
},
{
"default": "1",
"description": "Create Stock Ledger Entries when you submit a Sales Invoice",
"fieldname": "update_stock",
"fieldtype": "Check",
"label": "Update Stock",
"permlevel": 0,
"reqd": 0
},
{
"fieldname": "customer",
"fieldtype": "Link",
"in_list_view": 0,
"label": "Customer",
"oldfieldname": "customer_account",
"oldfieldtype": "Link",
"options": "Customer",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "cash_bank_account",
"fieldtype": "Link",
"label": "Cash/Bank Account",
"oldfieldname": "cash_bank_account",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "income_account",
"fieldtype": "Link",
"label": "Income Account",
"oldfieldname": "income_account",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
"fieldname": "expense_account",
"fieldtype": "Link",
"hidden": 0,
"label": "Expense Account",
"options": "Account",
"permlevel": 0,
"print_hide": 1,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "warehouse",
"fieldtype": "Link",
"label": "Warehouse",
"oldfieldname": "warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"oldfieldname": "cost_center",
"oldfieldtype": "Link",
"options": "Cost Center",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "taxes_and_charges",
"fieldtype": "Link",
"label": "Taxes and Charges",
"oldfieldname": "charge",
"oldfieldtype": "Link",
"options": "Sales Taxes and Charges Template",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "write_off_account",
"fieldtype": "Link",
"label": "Write Off Account",
"options": "Account",
"permlevel": 0,
"precision": "",
"reqd": 1
},
{
"fieldname": "write_off_cost_center",
"fieldtype": "Link",
"label": "Write Off Cost Center",
"options": "Cost Center",
"permlevel": 0,
"precision": "",
"reqd": 1
},
{
"allow_on_submit": 1,
"fieldname": "letter_head",
"fieldtype": "Link",
"label": "Letter Head",
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "Letter Head",
"permlevel": 0,
"print_hide": 1,
"read_only": 0
},
{
"fieldname": "tc_name",
"fieldtype": "Link",
"label": "Terms and Conditions",
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
"permlevel": 0,
"read_only": 0
},
{
"allow_on_submit": 1,
"fieldname": "select_print_heading",
"fieldtype": "Link",
"in_filter": 0,
"label": "Print Heading",
"oldfieldname": "select_print_heading",
"oldfieldtype": "Select",
"options": "Print Heading",
"permlevel": 0,
"read_only": 0
}
],
"icon": "icon-cog",
"idx": 1,
"modified": "2015-05-20 05:38:44.482696",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Profile",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts Manager",
"share": 1,
"submit": 0,
"write": 1
},
{
"apply_user_permissions": 1,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts User",
"submit": 0
}
],
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "user"
}

View File

@ -8,22 +8,22 @@ from frappe.utils import cint
from frappe.model.document import Document from frappe.model.document import Document
class POSSetting(Document): class POSProfile(Document):
def validate(self): def validate(self):
self.check_for_duplicate() self.check_for_duplicate()
self.validate_expense_account() self.validate_expense_account()
self.validate_all_link_fields() self.validate_all_link_fields()
def check_for_duplicate(self): def check_for_duplicate(self):
res = frappe.db.sql("""select name, user from `tabPOS Setting` res = frappe.db.sql("""select name, user from `tabPOS Profile`
where ifnull(user, '') = %s and name != %s and company = %s""", where ifnull(user, '') = %s and name != %s and company = %s""",
(self.user, self.name, self.company)) (self.user, self.name, self.company))
if res: if res:
if res[0][1]: if res[0][1]:
msgprint(_("POS Setting {0} already created for user: {1} and company {2}").format(res[0][0], msgprint(_("POS Profile {0} already created for user: {1} and company {2}").format(res[0][0],
res[0][1], self.company), raise_exception=1) res[0][1], self.company), raise_exception=1)
else: else:
msgprint(_("Global POS Setting {0} already created for company {1}").format(res[0][0], msgprint(_("Global POS Profile {0} already created for company {1}").format(res[0][0],
self.company), raise_exception=1) self.company), raise_exception=1)
def validate_expense_account(self): def validate_expense_account(self):
@ -57,7 +57,7 @@ class POSSetting(Document):
condition = "" condition = ""
pos_view_users = frappe.db.sql_list("""select user pos_view_users = frappe.db.sql_list("""select user
from `tabPOS Setting` {0}""".format(condition)) from `tabPOS Profile` {0}""".format(condition))
for user in pos_view_users: for user in pos_view_users:
if user: if user:

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals from __future__ import unicode_literals
@ -5,7 +6,7 @@ from __future__ import unicode_literals
import frappe import frappe
import unittest import unittest
test_records = frappe.get_test_records('POS Setting') # test_records = frappe.get_test_records('POS Profile')
class TestPOSSetting(unittest.TestCase): class TestPOSProfile(unittest.TestCase):
pass pass

View File

@ -1 +0,0 @@
Standard settings for Point of Sales (POS) type of Sales Invoice.

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,263 +0,0 @@
{
"allow_rename": 0,
"autoname": "hash",
"creation": "2013-05-24 12:15:51",
"docstatus": 0,
"doctype": "DocType",
"fields": [
{
"fieldname": "user",
"fieldtype": "Link",
"in_list_view": 1,
"label": "User",
"oldfieldname": "user",
"oldfieldtype": "Link",
"options": "User",
"permlevel": 0,
"read_only": 0
},
{
"description": "",
"fieldname": "territory",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Territory",
"oldfieldname": "territory",
"oldfieldtype": "Link",
"options": "Territory",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "naming_series",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",
"options": "[Select]",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "currency",
"fieldtype": "Link",
"in_list_view": 0,
"label": "Currency",
"oldfieldname": "currency",
"oldfieldtype": "Select",
"options": "Currency",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "selling_price_list",
"fieldtype": "Link",
"label": "Price List",
"oldfieldname": "price_list_name",
"oldfieldtype": "Select",
"options": "Price List",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "company",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Company",
"oldfieldname": "company",
"oldfieldtype": "Link",
"options": "Company",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0
},
{
"default": "1",
"description": "Create Stock Ledger Entries when you submit a Sales Invoice",
"fieldname": "update_stock",
"fieldtype": "Check",
"label": "Update Stock",
"permlevel": 0,
"reqd": 0
},
{
"fieldname": "customer",
"fieldtype": "Link",
"in_list_view": 0,
"label": "Customer",
"oldfieldname": "customer_account",
"oldfieldtype": "Link",
"options": "Customer",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "cash_bank_account",
"fieldtype": "Link",
"label": "Cash/Bank Account",
"oldfieldname": "cash_bank_account",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "income_account",
"fieldtype": "Link",
"label": "Income Account",
"oldfieldname": "income_account",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
"fieldname": "expense_account",
"fieldtype": "Link",
"hidden": 0,
"label": "Expense Account",
"options": "Account",
"permlevel": 0,
"print_hide": 1,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "warehouse",
"fieldtype": "Link",
"label": "Warehouse",
"oldfieldname": "warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"oldfieldname": "cost_center",
"oldfieldtype": "Link",
"options": "Cost Center",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "taxes_and_charges",
"fieldtype": "Link",
"label": "Taxes and Charges",
"oldfieldname": "charge",
"oldfieldtype": "Link",
"options": "Sales Taxes and Charges Template",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "write_off_account",
"fieldtype": "Link",
"label": "Write Off Account",
"options": "Account",
"permlevel": 0,
"precision": "",
"reqd": 1
},
{
"fieldname": "write_off_cost_center",
"fieldtype": "Link",
"label": "Write Off Cost Center",
"options": "Cost Center",
"permlevel": 0,
"precision": "",
"reqd": 1
},
{
"allow_on_submit": 1,
"fieldname": "letter_head",
"fieldtype": "Link",
"label": "Letter Head",
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "Letter Head",
"permlevel": 0,
"print_hide": 1,
"read_only": 0
},
{
"fieldname": "tc_name",
"fieldtype": "Link",
"label": "Terms and Conditions",
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
"permlevel": 0,
"read_only": 0
},
{
"allow_on_submit": 1,
"fieldname": "select_print_heading",
"fieldtype": "Link",
"in_filter": 0,
"label": "Print Heading",
"oldfieldname": "select_print_heading",
"oldfieldtype": "Select",
"options": "Print Heading",
"permlevel": 0,
"read_only": 0
}
],
"icon": "icon-cog",
"idx": 1,
"modified": "2015-02-05 05:11:42.344181",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Setting",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts Manager",
"share": 1,
"submit": 0,
"write": 1
},
{
"apply_user_permissions": 1,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts User",
"submit": 0
}
],
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "user"
}

View File

@ -160,12 +160,12 @@ class SalesInvoice(SellingController):
frappe.throw(_("Time Log Batch {0} must be 'Submitted'").format(d.time_log_batch)) frappe.throw(_("Time Log Batch {0} must be 'Submitted'").format(d.time_log_batch))
def set_pos_fields(self, for_validate=False): def set_pos_fields(self, for_validate=False):
"""Set retail related fields from pos settings""" """Set retail related fields from POS Profiles"""
if cint(self.is_pos) != 1: if cint(self.is_pos) != 1:
return return
from erpnext.stock.get_item_details import get_pos_settings_item_details, get_pos_settings from erpnext.stock.get_item_details import get_pos_profiles_item_details, get_pos_profiles
pos = get_pos_settings(self.company) pos = get_pos_profiles(self.company)
if pos: if pos:
if not for_validate and not self.customer: if not for_validate and not self.customer:
@ -184,7 +184,7 @@ class SalesInvoice(SellingController):
# set pos values in items # set pos values in items
for item in self.get("items"): for item in self.get("items"):
if item.get('item_code'): if item.get('item_code'):
for fname, val in get_pos_settings_item_details(pos, for fname, val in get_pos_profiles_item_details(pos,
frappe._dict(item.as_dict()), pos).items(): frappe._dict(item.as_dict()), pos).items():
if (not for_validate) or (for_validate and not item.get(fname)): if (not for_validate) or (for_validate and not item.get(fname)):
@ -371,24 +371,24 @@ class SalesInvoice(SellingController):
def get_warehouse(self): def get_warehouse(self):
user_pos_setting = frappe.db.sql("""select name, warehouse from `tabPOS Setting` user_pos_profile = frappe.db.sql("""select name, warehouse from `tabPOS Profile`
where ifnull(user,'') = %s and company = %s""", (frappe.session['user'], self.company)) where ifnull(user,'') = %s and company = %s""", (frappe.session['user'], self.company))
warehouse = user_pos_setting[0][1] if user_pos_setting else None warehouse = user_pos_profile[0][1] if user_pos_profile else None
if not warehouse: if not warehouse:
global_pos_setting = frappe.db.sql("""select name, warehouse from `tabPOS Setting` global_pos_profile = frappe.db.sql("""select name, warehouse from `tabPOS Profile`
where ifnull(user,'') = '' and company = %s""", self.company) where ifnull(user,'') = '' and company = %s""", self.company)
if global_pos_setting: if global_pos_profile:
warehouse = global_pos_setting[0][1] warehouse = global_pos_profile[0][1]
elif not user_pos_setting: elif not user_pos_profile:
msgprint(_("POS Setting required to make POS Entry"), raise_exception=True) msgprint(_("POS Profile required to make POS Entry"), raise_exception=True)
return warehouse return warehouse
def on_update(self): def on_update(self):
if cint(self.update_stock) == 1: if cint(self.update_stock) == 1:
# Set default warehouse from pos setting # Set default warehouse from POS Profile
if cint(self.is_pos) == 1: if cint(self.is_pos) == 1:
w = self.get_warehouse() w = self.get_warehouse()
if w: if w:

View File

@ -462,7 +462,7 @@ class TestSalesInvoice(unittest.TestCase):
def test_pos_gl_entry_with_aii(self): def test_pos_gl_entry_with_aii(self):
set_perpetual_inventory() set_perpetual_inventory()
self.make_pos_setting() self.make_pos_profile()
self._insert_purchase_receipt() self._insert_purchase_receipt()
@ -517,19 +517,19 @@ class TestSalesInvoice(unittest.TestCase):
set_perpetual_inventory(0) set_perpetual_inventory(0)
frappe.db.sql("delete from `tabPOS Setting`") frappe.db.sql("delete from `tabPOS Profile`")
def make_pos_setting(self): def make_pos_profile(self):
pos_setting = frappe.get_doc({ pos_profile = frappe.get_doc({
"cash_bank_account": "_Test Account Bank Account - _TC", "cash_bank_account": "_Test Account Bank Account - _TC",
"company": "_Test Company", "company": "_Test Company",
"cost_center": "_Test Cost Center - _TC", "cost_center": "_Test Cost Center - _TC",
"currency": "INR", "currency": "INR",
"doctype": "POS Setting", "doctype": "POS Profile",
"expense_account": "_Test Account Cost for Goods Sold - _TC", "expense_account": "_Test Account Cost for Goods Sold - _TC",
"income_account": "Sales - _TC", "income_account": "Sales - _TC",
"name": "_Test POS Setting", "name": "_Test POS Profile",
"naming_series": "_T-POS Setting-", "naming_series": "_T-POS Profile-",
"selling_price_list": "_Test Price List", "selling_price_list": "_Test Price List",
"territory": "_Test Territory", "territory": "_Test Territory",
"warehouse": "_Test Warehouse - _TC", "warehouse": "_Test Warehouse - _TC",
@ -537,8 +537,8 @@ class TestSalesInvoice(unittest.TestCase):
"write_off_cost_center": "_Test Write Off Cost Center - _TC" "write_off_cost_center": "_Test Write Off Cost Center - _TC"
}) })
if not frappe.db.exists("POS Setting", "_Test POS Setting"): if not frappe.db.exists("POS Profile", "_Test POS Profile"):
pos_setting.insert() pos_profile.insert()
def test_si_gl_entry_with_aii_and_update_stock_with_warehouse_but_no_account(self): def test_si_gl_entry_with_aii_and_update_stock_with_warehouse_but_no_account(self):
set_perpetual_inventory() set_perpetual_inventory()

View File

@ -35,7 +35,7 @@ frappe.pages['pos'].on_page_load = function(wrapper) {
}); });
$.ajax({ $.ajax({
url: "/api/resource/POS Setting", url: "/api/resource/POS Profile",
success: function(data) { success: function(data) {
if(!data.data.length) { if(!data.data.length) {
page.main.find(".pos-setting-message").removeClass('hide'); page.main.find(".pos-setting-message").removeClass('hide');

View File

@ -0,0 +1 @@
- POS Setting is renamed to POS Profile

View File

@ -113,7 +113,7 @@ def get_data():
}, },
{ {
"type": "doctype", "type": "doctype",
"name": "POS Setting", "name": "POS Profile",
"label": _("Point-of-Sale Setting"), "label": _("Point-of-Sale Setting"),
"description": _("Rules to calculate shipping amount for a sale") "description": _("Rules to calculate shipping amount for a sale")
}, },

View File

@ -155,3 +155,4 @@ erpnext.patches.v5_0.reclculate_planned_operating_cost_in_production_order
erpnext.patches.v5_0.repost_requested_qty erpnext.patches.v5_0.repost_requested_qty
erpnext.patches.v5_0.fix_taxes_and_totals_in_party_currency erpnext.patches.v5_0.fix_taxes_and_totals_in_party_currency
erpnext.patches.v5_0.update_tax_amount_after_discount_in_purchase_cycle erpnext.patches.v5_0.update_tax_amount_after_discount_in_purchase_cycle
erpnext.patches.v5_0.rename_pos_setting

View File

@ -0,0 +1,5 @@
import frappe
def execute():
if frappe.db.table_exists("POS Setting"):
frappe.rename_doc("DocType", "POS Setting", "POS Profile")

View File

@ -117,7 +117,7 @@ erpnext.feature_setup.feature_dict = {
'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'], 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount'] 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
}, },
'POS Setting': {'fields':['conversion_rate','currency']}, 'POS Profile': {'fields':['conversion_rate','currency']},
'Quotation': { 'Quotation': {
'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total', 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'], 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],

View File

@ -51,7 +51,7 @@ def get_item_details(args):
get_price_list_rate(args, item_doc, out) get_price_list_rate(args, item_doc, out)
if args.transaction_type == "selling" and cint(args.is_pos): if args.transaction_type == "selling" and cint(args.is_pos):
out.update(get_pos_settings_item_details(args.company, args)) out.update(get_pos_profiles_item_details(args.company, args))
# update args with out, if key or value not exists # update args with out, if key or value not exists
for key, value in out.iteritems(): for key, value in out.iteritems():
@ -267,16 +267,16 @@ def get_party_item_code(args, item_doc, out):
item_supplier = item_doc.get("supplier_items", {"supplier": args.supplier}) item_supplier = item_doc.get("supplier_items", {"supplier": args.supplier})
out.supplier_part_no = item_supplier[0].supplier_part_no if item_supplier else None out.supplier_part_no = item_supplier[0].supplier_part_no if item_supplier else None
def get_pos_settings_item_details(company, args, pos_settings=None): def get_pos_profiles_item_details(company, args, pos_profiles=None):
res = frappe._dict() res = frappe._dict()
if not pos_settings: if not pos_profiles:
pos_settings = get_pos_settings(company) pos_profiles = get_pos_profiles(company)
if pos_settings: if pos_profiles:
for fieldname in ("income_account", "cost_center", "warehouse", "expense_account"): for fieldname in ("income_account", "cost_center", "warehouse", "expense_account"):
if not args.get(fieldname) and pos_settings.get(fieldname): if not args.get(fieldname) and pos_profiles.get(fieldname):
res[fieldname] = pos_settings.get(fieldname) res[fieldname] = pos_profiles.get(fieldname)
if res.get("warehouse"): if res.get("warehouse"):
res.actual_qty = get_available_qty(args.item_code, res.actual_qty = get_available_qty(args.item_code,
@ -284,15 +284,15 @@ def get_pos_settings_item_details(company, args, pos_settings=None):
return res return res
def get_pos_settings(company): def get_pos_profiles(company):
pos_settings = frappe.db.sql("""select * from `tabPOS Setting` where user = %s pos_profiles = frappe.db.sql("""select * from `tabPOS Profile` where user = %s
and company = %s""", (frappe.session['user'], company), as_dict=1) and company = %s""", (frappe.session['user'], company), as_dict=1)
if not pos_settings: if not pos_profiles:
pos_settings = frappe.db.sql("""select * from `tabPOS Setting` pos_profiles = frappe.db.sql("""select * from `tabPOS Profile`
where ifnull(user,'') = '' and company = %s""", company, as_dict=1) where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
return pos_settings and pos_settings[0] or None return pos_profiles and pos_profiles[0] or None
def get_serial_nos_by_fifo(args, item_doc): def get_serial_nos_by_fifo(args, item_doc):