mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-18 02:55:20 +00:00
refactor!: drop ecommerce in favor of webshop (#33265)
* refactor!: remove ecommerce item group field check Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove `e_commerce` directory Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove `get_context` from `item_group` https://frappeframework.com/docs/v14/user/en/guides/portal-development/context Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove related `./templates` Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(navbar): remove wishlist (ecommerce) Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(js): remove js from scripts Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove `www/all-products` Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove pages and js Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove js/customer_reviews Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(portal utils): remove shopping cart debtor account Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove e_commerce events from hooks Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(web): remove e_commerce js from bundle Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(setup): remove shopping cart setup Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove pages Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor(item): remove website item button Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(payment request): remove `on_payment_authorized` Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: @staticmethod `get_gateway_details` to avoid monkey patching, in custom apps https://discuss.erpnext.com/t/how-to-override-method-in-frappe/28786/36 Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(pages): remove product page Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(homepage): do not setup website items Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor(workspace): remove link to ecommerce settings Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(www): remove shop-by-category Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(homepage): remove featured product Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor: remove products in homepage Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor(homepage): remove explore button Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor: remove products fields from homepage Signed-off-by: Sabu Siyad <hello@ssiyad.com> * Revert "refactor!: @staticmethod `get_gateway_details`" This reverts commit 561bcd96680a930bb92627869502d9346b10611b. Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: remove payment gateway e_commerce import Signed-off-by: Sabu Siyad <hello@ssiyad.com> * chore: pre-commit Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!: pass `party` into `get_price` Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor: move `get_item_codes_by_attributes` to `utilities/product` Signed-off-by: Sabu Siyad <hello@ssiyad.com> * refactor!(quotation): input customer group Signed-off-by: Sabu Siyad <hello@ssiyad.com> * chore: pre-commit * refactor: remove custom `navbar_items.html` * refactor!(item): remove `published_in_website` * refactor: move `validate_duplicate_website_item` before rename * test: remove `test_shopping_cart_without_website_item` * chore: add doctype drop patch * refactor: removed website item related code * refactor: removed shopping_cart code * refactor: removed e-commerce related patches * refactor: removed website related fields from item group * fix: patch create_asset_depreciation_schedules_from_assets, KeyError: '0K BU64 AUY' --------- Signed-off-by: Sabu Siyad <hello@ssiyad.com> Co-authored-by: Rohit Waghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -26,7 +26,6 @@ class Quotation(SellingController):
|
||||
self.set_status()
|
||||
self.validate_uom_is_integer("stock_uom", "qty")
|
||||
self.validate_valid_till()
|
||||
self.validate_shopping_cart_items()
|
||||
self.set_customer_name()
|
||||
if self.items:
|
||||
self.with_items = 1
|
||||
@@ -42,26 +41,6 @@ class Quotation(SellingController):
|
||||
if self.valid_till and getdate(self.valid_till) < getdate(self.transaction_date):
|
||||
frappe.throw(_("Valid till date cannot be before transaction date"))
|
||||
|
||||
def validate_shopping_cart_items(self):
|
||||
if self.order_type != "Shopping Cart":
|
||||
return
|
||||
|
||||
for item in self.items:
|
||||
has_web_item = frappe.db.exists("Website Item", {"item_code": item.item_code})
|
||||
|
||||
# If variant is unpublished but template is published: valid
|
||||
template = frappe.get_cached_value("Item", item.item_code, "variant_of")
|
||||
if template and not has_web_item:
|
||||
has_web_item = frappe.db.exists("Website Item", {"item_code": template})
|
||||
|
||||
if not has_web_item:
|
||||
frappe.throw(
|
||||
_("Row #{0}: Item {1} must have a Website Item for Shopping Cart Quotations").format(
|
||||
item.idx, frappe.bold(item.item_code)
|
||||
),
|
||||
title=_("Unpublished Item"),
|
||||
)
|
||||
|
||||
def set_has_alternative_item(self):
|
||||
"""Mark 'Has Alternative Item' for rows."""
|
||||
if not any(row.is_alternative for row in self.get("items")):
|
||||
@@ -263,8 +242,8 @@ def make_sales_order(source_name: str, target_doc=None):
|
||||
return _make_sales_order(source_name, target_doc)
|
||||
|
||||
|
||||
def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
|
||||
customer = _make_customer(source_name, ignore_permissions)
|
||||
def _make_sales_order(source_name, target_doc=None, customer_group=None, ignore_permissions=False):
|
||||
customer = _make_customer(source_name, ignore_permissions, customer_group)
|
||||
ordered_items = frappe._dict(
|
||||
frappe.db.get_all(
|
||||
"Sales Order Item",
|
||||
@@ -428,7 +407,7 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
|
||||
return doclist
|
||||
|
||||
|
||||
def _make_customer(source_name, ignore_permissions=False):
|
||||
def _make_customer(source_name, ignore_permissions=False, customer_group=None):
|
||||
quotation = frappe.db.get_value(
|
||||
"Quotation", source_name, ["order_type", "party_name", "customer_name"], as_dict=1
|
||||
)
|
||||
@@ -445,10 +424,7 @@ def _make_customer(source_name, ignore_permissions=False):
|
||||
customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
|
||||
customer = frappe.get_doc(customer_doclist)
|
||||
customer.flags.ignore_permissions = ignore_permissions
|
||||
if quotation.get("party_name") == "Shopping Cart":
|
||||
customer.customer_group = frappe.db.get_value(
|
||||
"E Commerce Settings", None, "default_customer_group"
|
||||
)
|
||||
customer.customer_group = customer_group
|
||||
|
||||
try:
|
||||
customer.insert()
|
||||
|
||||
@@ -161,15 +161,6 @@ class TestQuotation(FrappeTestCase):
|
||||
|
||||
make_sales_order(quotation.name)
|
||||
|
||||
def test_shopping_cart_without_website_item(self):
|
||||
if frappe.db.exists("Website Item", {"item_code": "_Test Item Home Desktop 100"}):
|
||||
frappe.get_last_doc("Website Item", {"item_code": "_Test Item Home Desktop 100"}).delete()
|
||||
|
||||
quotation = frappe.copy_doc(test_records[0])
|
||||
quotation.order_type = "Shopping Cart"
|
||||
quotation.valid_till = getdate()
|
||||
self.assertRaises(frappe.ValidationError, quotation.validate)
|
||||
|
||||
def test_create_quotation_with_margin(self):
|
||||
from erpnext.selling.doctype.quotation.quotation import make_sales_order
|
||||
from erpnext.selling.doctype.sales_order.sales_order import (
|
||||
|
||||
Reference in New Issue
Block a user