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_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). # 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': [
],
} }

View file

@ -4,19 +4,28 @@ 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)
@ -25,10 +34,14 @@ 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

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

@ -18,7 +18,10 @@
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>
@ -33,11 +36,23 @@
<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>
@ -46,9 +61,9 @@
</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,
@ -61,5 +76,3 @@
</t> </t>
</template> </template>
</odoo> </odoo>