Error can not find group "All Item Groups" when configuring woocommerce in erpnext v11 when using the language is different from English

Test in:
WordPress 4.9.3
Woocomerce Versión 3.2.5
ERPNext v11

After entering the API data (url, password, secret) of woocomerce in ERPNEXT, show an indicated error that it is not possible to find the group of articles: “All Item Groups”.

I have reviewed in BD and I realize that the groups of articles are translated, therefore there is a validation in ERPNEXT code that compares with “All Item Groups” and as it does not find it can not save the configuration.

See current groups:
select name, parent, parentfield, parenttype, is_group, parenttype, idx, item_group_name, parent_item_group from tabItem Group;

SQL script to update the article group name for woocomerce for the Spanish language(In the case of other languages, check according to name of the group of the selection of the previous point):

update tabItem Group set name = “All Item Groups” where name = “Todos los Grupos de Artículos”;

update tabItem Group set parent_item_group = “All Item Groups” where name != “All Item Groups”;

With this script I managed to configure Woocommerce where ERP provided me with a secret key which I used to add the webhook in woocommercer for new orders, but when creating an order from woocoommerce it was not sent to ERPNEXT.

In the log of the woocommerce webhook, it shows:

Result:

Estado: HTTP 403 Forbidden: Not Permitted
window.frappe = {}; frappe.ready_events = []; frappe.ready = function(fn) { frappe.ready_events.push(fn); } window.dev_server = 0; Flex <a

Not Permitted You do not have enough permissions to complete the action

Home Status: 403 frappe.ready(function() { if(window.location.hash) {

This same error is reported in: ERPNext Integration with WordPress WooCommerce - #106 by Erick_Rojas_Figueroa

PLEASE HELP

THANK YOU

Complete error response from webhook woocomerce LOG

Estado: HTTP 403 Forbidden: <!-- Built on Frappe. https://frappe.io/ --> Not Permitted window.frappe = {}; frappe.ready_events = []; frappe.ready = function(fn) { frappe.ready_events.push(fn); } window.dev_server = 0; <a href="/" rel="nofollow"> Flex </a> <i></i> <a href="/contact" rel="nofollow"> Contact</a> <a href="/blog" rel="nofollow"> Blog</a> <a href="/products" rel="nofollow"> Products</a> <!-- post login tools --> <a href="/me" rel="nofollow"> My Account </a><a href="/?cmd=web_logout" rel="nofollow"> Logout </a> <a href="/login" rel="nofollow">Login</a> <a href="/contact" rel="nofollow"> Contact</a> <a href="/blog" rel="nofollow"> Blog</a> <a href="/products" rel="nofollow"> Products</a> <a href="#" rel="nofollow"> Cart </a> <!-- post login tools --> <a href="#" rel="nofollow"> <b></b> </a> <a href="/me" rel="nofollow"> My Account </a><a href="/?cmd=web_logout" rel="nofollow"> Logout </a><a href="/desk" rel="nofollow">Switch To Desk</a> <a href="/login" rel="nofollow">Login</a> .hero-and-content { background-color: #f5f7fa; } .page-card { max-width: 360px; padding: 15px; margin: 70px auto; border: 1px solid #d1d8dd; border-radius: 4px; background-color: #fff; box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.1); } .page-card .page-card-head { padding: 10px 15px; margin: -15px; margin-bottom: 15px; border-bottom: 1px solid #d1d8dd; } .page-card .page-card-head .indicator { color: #36414C; font-size: 14px; } .page-card .page-card-head .indicator::before { margin: 0 6px 0.5px 0px; } .page-card .btn { margin-top: 30px; } .page-card p { font-size: 14px; } Not Permitted You do not have enough permissions to complete the action <a href='/' rel="nofollow"> Home</a> Status: 403 frappe.ready(function() { if(window.location.hash) { localStorage.setItem('session_last_route', window.location.hash.substr(1)); } $('.btn-primary').focus(); }); <!-- sidebar ends --> Get Updates frappe.ready(function() { $("#footer-subscribe-button").click(function() { if($("#footer-subscribe-email").val() && validate_email($("#footer-subscribe-email").val())) { $("#footer-subscribe-email").attr('disabled', true); $("#footer-subscribe-button").html("Sending...") .attr("disabled", true); erpnext.subscribe_to_newsletter({ email: $("#footer-subscribe-email").val(), callback: function(r) { if(!r.exc) { $("#footer-subscribe-button").html(__("Added")) .attr("disabled", true); } else { $("#footer-subscribe-button").html(__("Error: Not a valid id?")) .addClass("btn-danger").attr("disabled", false); $("#footer-subscribe-email").val("").attr('disabled', false); } } }); } else frappe.msgprint(frappe._("Please enter valid email address")) }); }); © Flex <a href="https://erpnext.com?source=website_footer" rel="nofollow"> Powered by ERPNext</a> <!-- js should be loaded in body! --> <a href="/assets/frappe/js/lib/jquery/jquery.min.js" rel="nofollow">/assets/frappe/js/lib/jquery/jquery.min.js</a> <a href="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.slim.js" rel="nofollow">https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.slim.js</a> <a href="/assets/js/frappe-web.min.js" rel="nofollow">/assets/js/frappe-web.min.js</a> <a href="/assets/frappe/js/lib/bootstrap.min.js" rel="nofollow">/assets/frappe/js/lib/bootstrap.min.js</a> <a href="/website_script.js" rel="nofollow">/website_script.js</a> <a href="/assets/js/erpnext-web.min.js" rel="nofollow">/assets/js/erpnext-web.min.js</a> frappe.csrf_token = "None";

Headers:

server: nginx
date: Fri, 09 Nov 2018 13:40:45 GMT
content-type: text/html; charset=utf-8
vary: Accept-Encoding
x-page-name: message
x-from-cache: False
set-cookie: Array
content-encoding: gzip

Content:

<!DOCTYPE html> <!-- Built on Frappe. https://frappe.io/ --> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Not Permitted</title> <meta name="generator" content="frappe"> <link rel="shortcut icon" href="/assets/erpnext/images/favicon.png" type="image/x-icon"> <link rel="icon" href="/assets/erpnext/images/favicon.png" type="image/x-icon"> <link type="text/css" rel="stylesheet" href="/assets/frappe/css/bootstrap.css"> <link type="text/css" rel="stylesheet" href="/assets/css/frappe-web.css"> <link type="text/css" rel="stylesheet" href="/assets/css/erpnext-web.css"> <link type="text/css" rel="stylesheet" href="/website_theme.css"><script> window.frappe = {}; frappe.ready_events = []; frappe.ready = function(fn) { frappe.ready_events.push(fn); } window.dev_server = 0; </script> </head> <body data-path="api/method/erpnext.erpnext_integrations.connectors.woocommerce_connection.order"> <div class="main-section"> <div> <header> <nav class="navbar navbar-default navbar-main" role="navigation"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand ellipsis" href="/"> <span>Flex</span> </a> <div class="dropdown"> <button class="btn btn-default navbar-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <i class="octicon octicon-three-bars"></i> </button> <ul class="dropdown-menu dropdown-menu-right"> <li data-label='Contact' > <a href="/contact" > Contact</a></li><li data-label='Blog' > <a href="/blog" > Blog</a></li><li data-label='Products' > <a href="/products" > Products</a></li> <li class="divider"></li> <!-- post login tools --> <li data-label="My Account" class=" logged-in" ><a href="/me" rel="nofollow"> My Account </a></li><li data-label="Logout" class=" logged-in" ><a href="/?cmd=web_logout" rel="nofollow"> Logout </a></li> <li class="btn-login-area"><a href="/login">Login</a></li> </ul> </div> </div> <div class="hidden-xs"> <ul class="nav navbar-nav navbar-left"><li data-label='Contact' > <a href="/contact" > Contact</a></li><li data-label='Blog' > <a href="/blog" > Blog</a></li><li data-label='Products' > <a href="/products" > Products</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li class="shopping-cart hidden"> <div class="cart-icon"> <a class="dropdown-toggle" href="#" data-toggle="dropdown" id="navLogin"> Cart <span class="badge-wrapper" id="cart-count"></span> </a> <div id="cart-overlay" class="dropdown-menu shopping-cart-menu"></div> </div> </li> <!-- post login tools --> <li class="dropdown logged-in" id="website-post-login" data-label="website-post-login" style="display: none"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <span class="user-image-wrapper"></span> <span class="full-name"></span> <b class="caret"></b> </a> <ul class="dropdown-menu" role="menu"><li data-label="My Account" ><a href="/me" rel="nofollow"> My Account </a></li><li data-label="Logout" ><a href="/?cmd=web_logout" rel="nofollow"> Logout </a></li><li class='switch-to-desk hidden'><a href="/desk">Switch To Desk</a></li> </ul> </li> <li class="btn-login-area"><a href="/login">Login</a></li> </ul> </div> </div> </nav></header> <div class="hero-and-content"> <div data-html-block="hero"></div> <div class="container"> <div class="page-container" id="page-message" data-path="message" > <div class="page-content without-sidebar"> <div class="page-content-wrapper"> <div class="row page-head"> <div class='col-sm-12'> </div> <div class="col-sm-8 col-xs-6"> </div> <div class="col-sm-4 col-xs-6"> </div> </div> <div class="page_content"> <style> .hero-and-content { background-color: #f5f7fa; } .page-card { max-width: 360px; padding: 15px; margin: 70px auto; border: 1px solid #d1d8dd; border-radius: 4px; background-color: #fff; box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.1); } .page-card .page-card-head { padding: 10px 15px; margin: -15px; margin-bottom: 15px; border-bottom: 1px solid #d1d8dd; } .page-card .page-card-head .indicator { color: #36414C; font-size: 14px; } .page-card .page-card-head .indicator::before { margin: 0 6px 0.5px 0px; } .page-card .btn { margin-top: 30px; } .page-card p { font-size: 14px; } </style> <div class='page-card'> <h5 class='page-card-head'> <span class='indicator red'> Not Permitted</span> </h5> <div class="page-card-body"> <p>You do not have enough permissions to complete the action</p> <div><a href='/' class='btn btn-primary btn-sm'> Home</a></div> </div> </div> <p class='text-muted text-center small' style='margin-top: -20px;'>Status: 403</p> <script> frappe.ready(function() { if(window.location.hash) { localStorage.setItem('session_last_route', window.location.hash.substr(1)); } $('.btn-primary').focus(); }); </script> </div> </div> <!-- sidebar ends --> </div> </div> </div> </div></div> <div><footer class="web-footer"> <section class="footer-links"> <div class="container"> <div class="row"> <div class="col-sm-6 text-left"> </div> <div class="col-sm-6 text-right"> <div class='input-group input-group-sm pull-right footer-subscribe'> <input class="form-control" type="text" id="footer-subscribe-email" placeholder="Your email address..."> <span class='input-group-btn'> <button class="btn btn-default" type="button" id="footer-subscribe-button">Get Updates</button> </span> </div> <script> frappe.ready(function() { $("#footer-subscribe-button").click(function() { if($("#footer-subscribe-email").val() && validate_email($("#footer-subscribe-email").val())) { $("#footer-subscribe-email").attr('disabled', true); $("#footer-subscribe-button").html("Sending...") .attr("disabled", true); erpnext.subscribe_to_newsletter({ email: $("#footer-subscribe-email").val(), callback: function(r) { if(!r.exc) { $("#footer-subscribe-button").html(__("Added")) .attr("disabled", true); } else { $("#footer-subscribe-button").html(__("Error: Not a valid id?")) .addClass("btn-danger").attr("disabled", false); $("#footer-subscribe-email").val("").attr('disabled', false); } } }); } else frappe.msgprint(frappe._("Please enter valid email address")) }); }); </script> </div> </div> <div class="row footer-bottom-line"> <div class="text-muted small col-sm-6 col-xs-12"> © Flex </div> <div class="text-muted small col-sm-6 col-xs-12 text-right footer-powered"> <a href="https://erpnext.com?source=website_footer" target="_blank" class="text-muted"> Powered by ERPNext</a> </div> </div> </div> </section> </footer></div> </div> <!-- js should be loaded in body! --> <script type="text/javascript" src="/assets/frappe/js/lib/jquery/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.slim.js"></script> <script type="text/javascript" src="/assets/js/frappe-web.min.js"></script> <script type="text/javascript" src="/assets/frappe/js/lib/bootstrap.min.js"></script> <script type="text/javascript" src="/website_script.js"></script> <script type="text/javascript" src="/assets/js/erpnext-web.min.js"></script> <script>frappe.csrf_token = "None";</script></body> </html>

Cc @revant_one @gaurav

The Woocommerce Configuration module has several errors:

1.- If ERPNext is installed in another language it produces an error when saving the configuration because the code is in hard the following variables

-Warehouse

-Group of Articles

Temporary solution for Spanish language: Correct by BD:

See Items Groups:

select name, parent, parentfield, parenttype, is_group, parenttype, idx, item_group_name, parent_item_group from `tabItem Group`;

Update for woocomerce

update `tabItem Group` set name =" All Item Groups "where name =" All Article Groups ";
update `tabItem Group` set parent_item_group =" All Item Groups "where name! =" All Item Groups ";

2.- Never validate the Token in the file, because it never validates correctly:
…\erpnext\erpnext_integrations\connectors\woocommerce_connection.py

Current:

@frappe.whitelist(allow_guest=True)
def order(data=None):

	if not data:
		verify_request()

Solution for any language: Remove the “if not data:”

@frappe.whitelist(allow_guest=True)
def order(data=None):


	verify_request()

If it is in English it works, but if it is in another language it will show another error point 3

3.- At the moment that Woocomerce invokes the Webhook, ERPNext’s EndPoint will produce error in the following file

…\erpnext\erpnext_integrations\connectors\woocommerce_connection.py

-In the method def order (data = None) it is assumed that the name of the company is the same as the woocomerce that the ERPnext,

Current

company = raw_billing_data.get("company") or default_set_company.default_company

Solution, consider the Erpnext company

company = default_set_company.default_company

Current:

new_sales_order.append("items",{
				"item_code": found_item.item_code,
				"item_name": found_item.item_name,
				"description": found_item.item_name,
				"delivery_date":order_delivery_date,
				"uom": "Nos",

Solution for Spanish language:

new_sales_order.append("items",{
				"item_code": found_item.item_code,
				"item_name": found_item.item_name,
				"description": found_item.item_name,
				"delivery_date":order_delivery_date,
				"uom": "Unidad",

Current:

new_sales_order.append("items",{
				"item_code": found_item.item_code,
				"item_name": found_item.item_name,
				"description": found_item.item_name,
				"delivery_date":order_delivery_date,
				"uom": "Unidad",
				"qty": item.get("quantity"),
				"rate": item.get("price"),
				"warehouse": "Stores" + " - " + company_abbr
				})

Solution for Spanish language:

new_sales_order.append("items",{
				"item_code": found_item.item_code,
				"item_name": found_item.item_name,
				"description": found_item.item_name,
				"delivery_date":order_delivery_date,
				"uom": "Unidad",
				"qty": item.get("quantity"),
				"rate": item.get("price"),
				"warehouse": "Tiendas" + " - " + company_abbr
				})

For now, this little analysis so that integration can work in a language other than English.

1 Like