Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Accessibility for E-commerce Doctypes #30578

Merged
merged 2 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions erpnext/e_commerce/doctype/website_item/website_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// For license information, please see license.txt

frappe.ui.form.on('Website Item', {
onload: function(frm) {
onload: (frm) => {
// should never check Private
frm.fields_dict["website_image"].df.is_private = 0;

Expand All @@ -13,18 +13,35 @@ frappe.ui.form.on('Website Item', {
});
},

image: function() {
refresh: (frm) => {
frm.add_custom_button(__("Prices"), function() {
frappe.set_route("List", "Item Price", {"item_code": frm.doc.item_code});
}, __("View"));

frm.add_custom_button(__("Stock"), function() {
frappe.route_options = {
"item_code": frm.doc.item_code
};
frappe.set_route("query-report", "Stock Balance");
}, __("View"));

frm.add_custom_button(__("E Commerce Settings"), function() {
frappe.set_route("Form", "E Commerce Settings");
}, __("View"));
},

image: () => {
refresh_field("image_view");
},

copy_from_item_group: function(frm) {
copy_from_item_group: (frm) => {
return frm.call({
doc: frm.doc,
method: "copy_specification_from_item_group"
});
},

set_meta_tags(frm) {
set_meta_tags: (frm) => {
frappe.utils.set_meta_tag(frm.doc.route);
}
});
18 changes: 12 additions & 6 deletions erpnext/stock/doctype/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ frappe.ui.form.on("Item", {

if (frm.doc.has_variants) {
frm.set_intro(__("This Item is a Template and cannot be used in transactions. Item attributes will be copied over into the variants unless 'No Copy' is set"), true);

frm.add_custom_button(__("Show Variants"), function() {
frappe.set_route("List", "Item", {"variant_of": frm.doc.name});
}, __("View"));

frm.add_custom_button(__("Item Variant Settings"), function() {
frappe.set_route("Form", "Item Variant Settings");
}, __("View"));

frm.add_custom_button(__("Variant Details Report"), function() {
frappe.set_route("query-report", "Item Variant Details", {"item": frm.doc.name});
}, __("View"));
Expand Down Expand Up @@ -110,6 +115,13 @@ frappe.ui.form.on("Item", {
}
});
}, __('Actions'));
} else {
frm.add_custom_button(__("Website Item"), function() {
frappe.db.get_value("Website Item", {item_code: frm.doc.name}, "name", (d) => {
if (!d.name) frappe.throw(__("Website Item not found"));
frappe.set_route("Form", "Website Item", d.name);
});
}, __("View"));
}

erpnext.item.edit_prices_button(frm);
Expand All @@ -131,12 +143,6 @@ frappe.ui.form.on("Item", {
frappe.set_route('Form', 'Item', new_item.name);
});

if(frm.doc.has_variants) {
frm.add_custom_button(__("Item Variant Settings"), function() {
frappe.set_route("Form", "Item Variant Settings");
}, __("View"));
}

const stock_exists = (frm.doc.__onload
&& frm.doc.__onload.stock_exists) ? 1 : 0;

Expand Down
1 change: 1 addition & 0 deletions erpnext/stock/doctype/item/item_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ def get_data():
{"label": _("Manufacture"), "items": ["Production Plan", "Work Order", "Item Manufacturer"]},
{"label": _("Traceability"), "items": ["Serial No", "Batch"]},
{"label": _("Move"), "items": ["Stock Entry"]},
{"label": _("E-commerce"), "items": ["Website Item"]},
],
}