Compare commits

...
Sign in to create a new pull request.

3 commits
16.0 ... test

Author SHA1 Message Date
snt
abd3d560d9 prueba push 2025-02-24 18:05:57 +01:00
e6d6ad01ef website_search_products: Fix manifest 2024-02-20 10:50:37 +01:00
846235f9ca website_search_products: Fix permissions 2024-02-20 10:27:45 +01:00
5 changed files with 82 additions and 76 deletions

View file

@ -1,3 +1,4 @@
# addons_cm
addons personalizados por Criptomart
addons personalizados por Criptomart
prueba push

View file

@ -2,22 +2,14 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Website Search Products',
'description': """
"name": "Website Search Products",
"description": """
Allows portal users to search products in a table with filters.""",
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'author': 'Criptomart',
'website': 'https://criptomart.net',
'depends': [
"stock",
"website"
],
'data': [
"data/menu.xml",
"data/ir_rule.xml",
"views/web_templates.xml"
],
'demo': [
],
"version": "12.0.1.0.0",
"license": "AGPL-3",
"author": "Criptomart",
"website": "https://criptomart.net",
"depends": ["stock", "website"],
"data": ["data/menu.xml", "views/web_templates.xml"],
"demo": [],
}

View file

@ -1,34 +1,47 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
from odoo.addons.website.controllers.main import Website
import logging
_logger = logging.getLogger(__name__)
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):
if not request.env['res.users'].browse(request.uid).has_group('base.group_portal')\
and not request.env['res.users'].browse(request.uid).has_group('base.group_user'):
redirect = b'/web?'
if not request.env["res.users"].browse(request.uid).has_group(
"base.group_portal"
) and not request.env["res.users"].browse(request.uid).has_group(
"base.group_user"
):
redirect = b"/web?"
return http.redirect_with_hash(redirect)
products = request.env["product.template"].search([('active', '=', 'True'), ('available_in_pos', '=', 'True')])
vals = {'products': 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)
class Website(Website):
@http.route(website=True, auth="public")
def web_login(self, redirect=None, *args, **kw):
response = super(Website, self).web_login(redirect=redirect, *args, **kw)
if not redirect and request.params['login_success']:
if request.env['res.users'].browse(request.uid).has_group('base.group_user'):
redirect = b'/web?' + request.httprequest.query_string
if not redirect and request.params["login_success"]:
if (
request.env["res.users"]
.browse(request.uid)
.has_group("base.group_user")
):
redirect = b"/web?" + request.httprequest.query_string
else:
redirect = '/inventory/search'
redirect = "/inventory/search"
return http.redirect_with_hash(redirect)
return response

View file

@ -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>

View file

@ -9,57 +9,70 @@
<div class="container">
<div class="col-md-12">
<t t-if="products">
<div class="alert alert-success">
Displayed products
</div>
<div class="alert alert-success">
Displayed products
</div>
</t>
<t t-if="not_found">
<div class="alert alert-danger">
Products not found
</div>
<div class="alert alert-danger">
Products not found
</div>
</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;">
<table id="productTable" class="table stripe" >
<table id="productTable" class="table stripe">
<thead>
<tr>
<th>Name</th>
<th>Category</th>
<th>Category</th>
<th>Price</th>
<th>Quantity</th>
<th>UoM</th>
</tr>
</thead>
<tbody id="stockList" >
<tbody id="stockList">
<t t-foreach="products" t-as="product">
<tr>
<td><span t-esc="product.name"/></td>
<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>
<td>
<span t-esc="product.name" />
</td>
<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>
</t>
</t>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js" />
<script src="https://cdn.datatables.net/plug-ins/1.13.2/filtering/type-based/accent-neutralise.js" />
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.1/css/jquery.dataTables.min.css" />
<script>
$('#productTable').DataTable({
"pageLength": 100,
"order": [[1, "asc"], [0, "asc"], [2, "desc"]],
"language": {
"url": "https://cdn.datatables.net/plug-ins/1.13.1/i18n/es-ES.json"
}
});
</script>
</t>
</div>
<link rel="stylesheet"
href="https://cdn.datatables.net/2.0.0/css/dataTables.dataTables.css" />
<script src="https://cdn.datatables.net/2.0.0/js/dataTables.js"></script>
<script>
$('#productTable').DataTable({
"pageLength": 100,
"order": [[1, "asc"], [0, "asc"], [2, "desc"]],
"language": {
"url": "https://cdn.datatables.net/plug-ins/1.13.1/i18n/es-ES.json"
}
});
</script>
</t>
</template>
</odoo>
</odoo>