Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6d6ad01ef | |||
| 846235f9ca |
4 changed files with 80 additions and 75 deletions
|
|
@ -2,22 +2,14 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Website Search Products',
|
"name": "Website Search Products",
|
||||||
'description': """
|
"description": """
|
||||||
Allows portal users to search products in a table with filters.""",
|
Allows portal users to search products in a table with filters.""",
|
||||||
'version': '12.0.1.0.0',
|
"version": "12.0.1.0.0",
|
||||||
'license': 'AGPL-3',
|
"license": "AGPL-3",
|
||||||
'author': 'Criptomart',
|
"author": "Criptomart",
|
||||||
'website': 'https://criptomart.net',
|
"website": "https://criptomart.net",
|
||||||
'depends': [
|
"depends": ["stock", "website"],
|
||||||
"stock",
|
"data": ["data/menu.xml", "views/web_templates.xml"],
|
||||||
"website"
|
"demo": [],
|
||||||
],
|
|
||||||
'data': [
|
|
||||||
"data/menu.xml",
|
|
||||||
"data/ir_rule.xml",
|
|
||||||
"views/web_templates.xml"
|
|
||||||
],
|
|
||||||
'demo': [
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,47 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
from odoo.addons.website.controllers.main import Website
|
from odoo.addons.website.controllers.main import Website
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class IntentoryForm(http.Controller):
|
class IntentoryForm(http.Controller):
|
||||||
|
|
||||||
@http.route(['/inventory/search'], type='http', auth="user", website=True)
|
@http.route(["/inventory/search"], type="http", auth="user", website=True)
|
||||||
def inventory_form(self, **post):
|
def inventory_form(self, **post):
|
||||||
if not request.env['res.users'].browse(request.uid).has_group('base.group_portal')\
|
if not request.env["res.users"].browse(request.uid).has_group(
|
||||||
and not request.env['res.users'].browse(request.uid).has_group('base.group_user'):
|
"base.group_portal"
|
||||||
redirect = b'/web?'
|
) and not request.env["res.users"].browse(request.uid).has_group(
|
||||||
|
"base.group_user"
|
||||||
|
):
|
||||||
|
redirect = b"/web?"
|
||||||
return http.redirect_with_hash(redirect)
|
return http.redirect_with_hash(redirect)
|
||||||
|
|
||||||
products = request.env["product.template"].search([('active', '=', 'True'), ('available_in_pos', '=', 'True')])
|
products = (
|
||||||
vals = {'products': products}
|
request.env["product.template"]
|
||||||
|
.sudo()
|
||||||
|
.search([("active", "=", "True"), ("available_in_pos", "=", "True")])
|
||||||
|
)
|
||||||
|
vals = {"products": products}
|
||||||
return request.render("website_search_products.web_list_products", vals)
|
return request.render("website_search_products.web_list_products", vals)
|
||||||
|
|
||||||
|
|
||||||
class Website(Website):
|
class Website(Website):
|
||||||
|
|
||||||
@http.route(website=True, auth="public")
|
@http.route(website=True, auth="public")
|
||||||
def web_login(self, redirect=None, *args, **kw):
|
def web_login(self, redirect=None, *args, **kw):
|
||||||
response = super(Website, self).web_login(redirect=redirect, *args, **kw)
|
response = super(Website, self).web_login(redirect=redirect, *args, **kw)
|
||||||
if not redirect and request.params['login_success']:
|
if not redirect and request.params["login_success"]:
|
||||||
if request.env['res.users'].browse(request.uid).has_group('base.group_user'):
|
if (
|
||||||
redirect = b'/web?' + request.httprequest.query_string
|
request.env["res.users"]
|
||||||
|
.browse(request.uid)
|
||||||
|
.has_group("base.group_user")
|
||||||
|
):
|
||||||
|
redirect = b"/web?" + request.httprequest.query_string
|
||||||
else:
|
else:
|
||||||
redirect = '/inventory/search'
|
redirect = "/inventory/search"
|
||||||
return http.redirect_with_hash(redirect)
|
return http.redirect_with_hash(redirect)
|
||||||
return response
|
return response
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<record id="member_space_consult_products" model="ir.rule">
|
|
||||||
<field name="name">Portal Consult Products</field>
|
|
||||||
<field name="model_id" ref="product.model_product_template"/>
|
|
||||||
<field eval="1" name="perm_read"/>
|
|
||||||
<field eval="0" name="perm_write"/>
|
|
||||||
<field eval="0" name="perm_create"/>
|
|
||||||
<field eval="0" name="perm_unlink"/>
|
|
||||||
<field eval="1" name="active"/>
|
|
||||||
<field name="groups" eval="[(4, ref('base.group_portal'))]"/>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -9,57 +9,70 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<t t-if="products">
|
<t t-if="products">
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success">
|
||||||
Displayed products
|
Displayed products
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="not_found">
|
<t t-if="not_found">
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
Products not found
|
Products not found
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
<div class="col-md-12" style="text-align: center;"><h2>In this table you can consult all the products available in the store</h2></div>
|
<div class="col-md-12" style="text-align: center;">
|
||||||
|
<h2>In this table you can consult all the products available in the
|
||||||
|
store</h2>
|
||||||
|
</div>
|
||||||
<div class="col-md-12" style="margin-top: 50px;">
|
<div class="col-md-12" style="margin-top: 50px;">
|
||||||
<table id="productTable" class="table stripe" >
|
<table id="productTable" class="table stripe">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Category</th>
|
<th>Category</th>
|
||||||
<th>Price</th>
|
<th>Price</th>
|
||||||
<th>Quantity</th>
|
<th>Quantity</th>
|
||||||
<th>UoM</th>
|
<th>UoM</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="stockList" >
|
<tbody id="stockList">
|
||||||
<t t-foreach="products" t-as="product">
|
<t t-foreach="products" t-as="product">
|
||||||
<tr>
|
<tr>
|
||||||
<td><span t-esc="product.name"/></td>
|
<td>
|
||||||
<td><span t-esc="product.categ_id.name"/></td>
|
<span t-esc="product.name" />
|
||||||
<td><span t-esc="product.list_price" t-options='{"widget": "monetary", "display_currency": res_company.currency_id}' /></td>
|
</td>
|
||||||
<td><span t-esc="product.sudo().qty_available" t-options='{"widget": "float", "precision": 2}' /></td>
|
<td>
|
||||||
<td><span t-esc="product.sudo().uom_id.name" /></td>
|
<span t-esc="product.categ_id.name" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span t-esc="product.list_price"
|
||||||
|
t-options='{"widget": "monetary", "display_currency": res_company.currency_id}' />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span t-esc="product.sudo().qty_available"
|
||||||
|
t-options='{"widget": "float", "precision": 2}' />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span t-esc="product.sudo().uom_id.name" />
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</t>
|
</t>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js" />
|
<link rel="stylesheet"
|
||||||
<script src="https://cdn.datatables.net/plug-ins/1.13.2/filtering/type-based/accent-neutralise.js" />
|
href="https://cdn.datatables.net/2.0.0/css/dataTables.dataTables.css" />
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.1/css/jquery.dataTables.min.css" />
|
<script src="https://cdn.datatables.net/2.0.0/js/dataTables.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$('#productTable').DataTable({
|
$('#productTable').DataTable({
|
||||||
"pageLength": 100,
|
"pageLength": 100,
|
||||||
"order": [[1, "asc"], [0, "asc"], [2, "desc"]],
|
"order": [[1, "asc"], [0, "asc"], [2, "desc"]],
|
||||||
"language": {
|
"language": {
|
||||||
"url": "https://cdn.datatables.net/plug-ins/1.13.1/i18n/es-ES.json"
|
"url": "https://cdn.datatables.net/plug-ins/1.13.1/i18n/es-ES.json"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</t>
|
</t>
|
||||||
</template>
|
</template>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue