2021-04-13 00:39:26 +05:30
|
|
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
|
2014-10-21 16:16:30 +05:30
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
import frappe
|
2023-10-17 17:05:44 +05:30
|
|
|
from frappe.utils import cint, flt, fmt_money
|
2021-09-02 16:44:59 +05:30
|
|
|
|
2016-11-22 22:23:31 +05:30
|
|
|
from erpnext.accounts.doctype.pricing_rule.pricing_rule import get_pricing_rule_for_item
|
2014-10-21 16:16:30 +05:30
|
|
|
|
2022-02-01 00:39:14 +05:30
|
|
|
|
2023-10-17 17:05:44 +05:30
|
|
|
def get_price(item_code, price_list, customer_group, company, qty=1, party=None):
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
template_item_code = frappe.db.get_value("Item", item_code, "variant_of")
|
2016-11-22 22:23:31 +05:30
|
|
|
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
if price_list:
|
2015-10-20 17:30:02 +05:30
|
|
|
price = frappe.get_all(
|
|
|
|
"Item Price",
|
|
|
|
fields=["price_list_rate", "currency"],
|
|
|
|
filters={"price_list": price_list, "item_code": item_code},
|
|
|
|
)
|
|
|
|
|
2017-05-17 09:50:01 -04:00
|
|
|
if template_item_code and not price:
|
2015-10-20 17:30:02 +05:30
|
|
|
price = frappe.get_all(
|
|
|
|
"Item Price",
|
|
|
|
fields=["price_list_rate", "currency"],
|
|
|
|
filters={"price_list": price_list, "item_code": template_item_code},
|
|
|
|
)
|
|
|
|
|
|
|
|
if price:
|
2021-12-18 16:03:16 -05:00
|
|
|
pricing_rule_dict = frappe._dict(
|
|
|
|
{
|
2016-11-22 22:23:31 +05:30
|
|
|
"item_code": item_code,
|
|
|
|
"qty": qty,
|
2020-09-05 12:15:49 +02:00
|
|
|
"stock_qty": qty,
|
2016-11-22 22:23:31 +05:30
|
|
|
"transaction_type": "selling",
|
|
|
|
"price_list": price_list,
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
"customer_group": customer_group,
|
|
|
|
"company": company,
|
2016-11-22 22:23:31 +05:30
|
|
|
"conversion_rate": 1,
|
2018-08-06 11:12:04 +02:00
|
|
|
"for_shopping_cart": True,
|
|
|
|
"currency": frappe.db.get_value("Price List", price_list, "currency"),
|
2022-12-08 18:04:40 +05:30
|
|
|
"doctype": "Quotation",
|
2021-12-18 16:03:16 -05:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
if party and party.doctype == "Customer":
|
|
|
|
pricing_rule_dict.update({"customer": party.name})
|
|
|
|
|
|
|
|
pricing_rule = get_pricing_rule_for_item(pricing_rule_dict)
|
2021-04-13 00:39:26 +05:30
|
|
|
price_obj = price[0]
|
2016-11-22 22:23:31 +05:30
|
|
|
|
|
|
|
if pricing_rule:
|
2021-04-13 00:39:26 +05:30
|
|
|
# price without any rules applied
|
|
|
|
mrp = price_obj.price_list_rate or 0
|
|
|
|
|
2016-11-22 22:23:31 +05:30
|
|
|
if pricing_rule.pricing_rule_for == "Discount Percentage":
|
2021-04-20 21:54:52 +05:30
|
|
|
price_obj.discount_percent = pricing_rule.discount_percentage
|
2021-04-13 00:39:26 +05:30
|
|
|
price_obj.formatted_discount_percent = str(flt(pricing_rule.discount_percentage, 0)) + "%"
|
|
|
|
price_obj.price_list_rate = flt(
|
|
|
|
price_obj.price_list_rate * (1.0 - (flt(pricing_rule.discount_percentage) / 100.0))
|
2022-03-28 18:52:46 +05:30
|
|
|
)
|
2016-11-22 22:23:31 +05:30
|
|
|
|
2018-08-06 11:12:04 +02:00
|
|
|
if pricing_rule.pricing_rule_for == "Rate":
|
2021-04-13 00:39:26 +05:30
|
|
|
rate_discount = flt(mrp) - flt(pricing_rule.price_list_rate)
|
|
|
|
if rate_discount > 0:
|
|
|
|
price_obj.formatted_discount_rate = fmt_money(rate_discount, currency=price_obj["currency"])
|
|
|
|
price_obj.price_list_rate = pricing_rule.price_list_rate or 0
|
2016-11-22 22:23:31 +05:30
|
|
|
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
if price_obj:
|
|
|
|
price_obj["formatted_price"] = fmt_money(
|
|
|
|
price_obj["price_list_rate"], currency=price_obj["currency"]
|
|
|
|
)
|
2021-04-13 00:39:26 +05:30
|
|
|
if mrp != price_obj["price_list_rate"]:
|
|
|
|
price_obj["formatted_mrp"] = fmt_money(mrp, currency=price_obj["currency"])
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
|
|
|
|
price_obj["currency_symbol"] = (
|
|
|
|
not cint(frappe.db.get_default("hide_currency_symbol"))
|
2018-08-08 16:37:31 +05:30
|
|
|
and (
|
|
|
|
frappe.db.get_value("Currency", price_obj.currency, "symbol", cache=True)
|
|
|
|
or price_obj.currency
|
|
|
|
)
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
or ""
|
2022-03-28 18:52:46 +05:30
|
|
|
)
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
|
2018-03-20 09:58:44 +01:00
|
|
|
uom_conversion_factor = frappe.db.sql(
|
|
|
|
"""select C.conversion_factor
|
|
|
|
from `tabUOM Conversion Detail` C
|
2018-11-13 07:06:41 +01:00
|
|
|
inner join `tabItem` I on C.parent = I.name and C.uom = I.sales_uom
|
|
|
|
where I.name = %s""",
|
|
|
|
item_code,
|
|
|
|
)
|
2018-03-20 09:58:44 +01:00
|
|
|
|
|
|
|
uom_conversion_factor = uom_conversion_factor[0][0] if uom_conversion_factor else 1
|
|
|
|
price_obj["formatted_price_sales_uom"] = fmt_money(
|
|
|
|
price_obj["price_list_rate"] * uom_conversion_factor, currency=price_obj["currency"]
|
|
|
|
)
|
|
|
|
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
if not price_obj["price_list_rate"]:
|
|
|
|
price_obj["price_list_rate"] = 0
|
|
|
|
|
|
|
|
if not price_obj["currency"]:
|
|
|
|
price_obj["currency"] = ""
|
|
|
|
|
|
|
|
if not price_obj["formatted_price"]:
|
2021-04-13 00:39:26 +05:30
|
|
|
price_obj["formatted_price"], price_obj["formatted_mrp"] = "", ""
|
Hub (#10934)
* [WIP]Hub
* [listing] Show items, users and item_groups
* Show filters
* [start] cart, api for rfq and opp
* rfq working
* [wip] keys
* wip quotes
* [hub] register/unregister
* [hub] rename password to access_token, remove passed company field
* [hub] publishing cases, api call wrapper
* [hub] add and remove fields working
* [hub] fix flags, update on client save working
* [hub] new hub page, client item CUD at hub working
* listing, standard rate, local site hack
* item listing, item page, search, back to home
* [hub] implement hub company
* [hub] company filter
* [hub] basic rfq-ing, item page cleanup
* categories wip
* [hub] use get_doc_before_save()
* [hub] send opportunity message to hub, api to make locally
* [hub] enqueueing in hub api request wrapper
* cleanup
* [hub] refactor shopping cart's product.py to reuse
* sync dynamic item fields daily
* Scheduler heartbeat check
* [wip] hub categories
* [hub] wip enqueued callbacks
* [hub] outgoing messages, fixing callback loop
* [hub] bug: callback save after primary save
* [hub] pricing, stock, currency
* [hub] replace send_hub_request with make_and_enqueue
* add hub.less, refactor code
* Remove template html files, add styling for hub item cards
* fix paging
* add breadcrumb
* Add sidebar
* [hub] add company page, change country
* [hub] order_by filters
* [hub] make hub category a tree
* [hub] enqueue batched item enqueueing
* [hub] requested products page
* [minor]
* update hub url
* [fix] url
* [fix] more reform
* fix recursion
* [hub] data migration plans as jsons
* Hub register, create data connector, sync with run
* [add] user registration by session user
* Removed hub_message
* Remove sync code from hub_settings
* Remove hub methods from item.py
* Update Hub Sync plan
* Hub unregister
* Update Hub connector on reregister
* Dont delete Hub Connector on unregister
* Enable hub on success response
* Add new hub whitelisted methods
* [hub] list working
* Hub register from hub page
* [hub] Add hub logo in desk icon, link to page
* [hub] hide page head on empty state
* [hub] make rfq
* [hub] push opportunity doc, poll for opportunity docs
* add fields to item mapping
* update hub mappings
* Make RFQ
* [hub] item, home routing
* Make rfq and send opportunity refactor
* [hub][fix] remote lead data
* images passed as base64
* set default company on register
* Revert "images passed as base64"
This reverts commit 0b033a5fb7072b2d39a1b87a47dc41e7af707bb4.
* Add sync to hub page
* Prompt for publish items to hub
* add post process to hub document to lead
* Rename Hub document to Hub message, create opportunity in post process
2017-10-05 11:17:30 +05:30
|
|
|
|
|
|
|
return price_obj
|
2020-01-24 15:52:27 +05:30
|
|
|
|
2022-03-28 18:52:46 +05:30
|
|
|
|
2023-10-17 17:05:44 +05:30
|
|
|
def get_item_codes_by_attributes(attribute_filters, template_item_code=None):
|
|
|
|
items = []
|
|
|
|
|
|
|
|
for attribute, values in attribute_filters.items():
|
|
|
|
attribute_values = values
|
|
|
|
|
|
|
|
if not isinstance(attribute_values, list):
|
|
|
|
attribute_values = [attribute_values]
|
|
|
|
|
|
|
|
if not attribute_values:
|
|
|
|
continue
|
|
|
|
|
|
|
|
wheres = []
|
|
|
|
query_values = []
|
|
|
|
for attribute_value in attribute_values:
|
|
|
|
wheres.append("( attribute = %s and attribute_value = %s )")
|
|
|
|
query_values += [attribute, attribute_value]
|
|
|
|
|
|
|
|
attribute_query = " or ".join(wheres)
|
|
|
|
|
|
|
|
if template_item_code:
|
|
|
|
variant_of_query = "AND t2.variant_of = %s"
|
|
|
|
query_values.append(template_item_code)
|
|
|
|
else:
|
|
|
|
variant_of_query = ""
|
|
|
|
|
|
|
|
query = """
|
|
|
|
SELECT
|
|
|
|
t1.parent
|
|
|
|
FROM
|
|
|
|
`tabItem Variant Attribute` t1
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND (
|
|
|
|
{attribute_query}
|
|
|
|
)
|
|
|
|
AND EXISTS (
|
|
|
|
SELECT
|
|
|
|
1
|
|
|
|
FROM
|
|
|
|
`tabItem` t2
|
|
|
|
WHERE
|
|
|
|
t2.name = t1.parent
|
|
|
|
{variant_of_query}
|
|
|
|
)
|
|
|
|
GROUP BY
|
|
|
|
t1.parent
|
|
|
|
ORDER BY
|
|
|
|
NULL
|
|
|
|
""".format(
|
|
|
|
attribute_query=attribute_query, variant_of_query=variant_of_query
|
2021-08-25 13:09:35 +05:30
|
|
|
)
|
2023-10-17 17:05:44 +05:30
|
|
|
|
|
|
|
item_codes = set([r[0] for r in frappe.db.sql(query, query_values)])
|
|
|
|
items.append(item_codes)
|
|
|
|
|
|
|
|
res = list(set.intersection(*items))
|
|
|
|
|
|
|
|
return res
|