#322 filtra la carga de pickings en el PDV cuando hay un cliente seleccionado. Añadido módulo con página de consulta de productos en el website
This commit is contained in:
parent
6debf13f25
commit
bc5f2ab42a
17 changed files with 390 additions and 1 deletions
1
pos_picking_load_selected_partner/__init__.py
Normal file
1
pos_picking_load_selected_partner/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import models
|
||||||
21
pos_picking_load_selected_partner/__manifest__.py
Normal file
21
pos_picking_load_selected_partner/__manifest__.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Copyright 2022 Criptomart
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Pos Picking Load Selected Partner',
|
||||||
|
'description': """
|
||||||
|
If a partner is selected in the PoS Order as client, search only the pickings related to this partner.""",
|
||||||
|
'version': '12.0.1.0.0',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'author': 'Criptomart',
|
||||||
|
'website': 'https://criptomart.net',
|
||||||
|
'depends': [
|
||||||
|
"point_of_sale",
|
||||||
|
"pos_picking_load"
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'views/assets.xml'
|
||||||
|
],
|
||||||
|
'demo': [
|
||||||
|
],
|
||||||
|
}
|
||||||
1
pos_picking_load_selected_partner/models/__init__.py
Normal file
1
pos_picking_load_selected_partner/models/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import stock_picking
|
||||||
15
pos_picking_load_selected_partner/models/stock_picking.py
Normal file
15
pos_picking_load_selected_partner/models/stock_picking.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Copyright 2022 Criptomart
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import api, fields, models, _
|
||||||
|
from odoo.tools import date_utils
|
||||||
|
import json
|
||||||
|
|
||||||
|
import logging
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class StockPicking(models.Model):
|
||||||
|
|
||||||
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
20
pos_picking_load_selected_partner/static/src/js/widget.js
Normal file
20
pos_picking_load_selected_partner/static/src/js/widget.js
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
odoo.define('pos_picking_load_selected_partner.picking_partner', function (require) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var screens = require('point_of_sale.screens');
|
||||||
|
var gui = require('point_of_sale.gui');
|
||||||
|
|
||||||
|
var PickingPartner = gui.Gui.prototype.screen_classes.filter(function(el) {
|
||||||
|
return el.name == 'load_picking'
|
||||||
|
})[0].widget.include({
|
||||||
|
|
||||||
|
show: function () {
|
||||||
|
this._super();
|
||||||
|
var partner = this.pos.get_order().get_client();
|
||||||
|
var query = "";
|
||||||
|
if (partner){ query = partner.name; }
|
||||||
|
this.search_pickings(query);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return PickingPartner;
|
||||||
|
});
|
||||||
11
pos_picking_load_selected_partner/views/assets.xml
Normal file
11
pos_picking_load_selected_partner/views/assets.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<template id="assets" inherit_id="point_of_sale.assets">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script type="text/javascript" src="/pos_picking_load_selected_partner/static/src/js/widget.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
|
|
@ -23,7 +23,7 @@ class ProductTemplate(models.Model):
|
||||||
_logger.debug("Calculating price with PriceList : %s" %pricelist.name)
|
_logger.debug("Calculating price with PriceList : %s" %pricelist.name)
|
||||||
if pricelist:
|
if pricelist:
|
||||||
for template in self:
|
for template in self:
|
||||||
if template.name and template.id and template.last_purchase_price_compute_type != 'manual_update':
|
if template.name and template.id and template.product_variant_id and template.last_purchase_price_compute_type != 'manual_update':
|
||||||
partial_price = pricelist.get_product_price(template.product_variant_id, "1", partner)
|
partial_price = pricelist.get_product_price(template.product_variant_id, "1", partner)
|
||||||
_logger.debug("partial_price : %s" %partial_price)
|
_logger.debug("partial_price : %s" %partial_price)
|
||||||
# Suma el IVA
|
# Suma el IVA
|
||||||
|
|
|
||||||
3
website_search_products/__init__.py
Normal file
3
website_search_products/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from . import controllers
|
||||||
|
from . import models
|
||||||
22
website_search_products/__manifest__.py
Normal file
22
website_search_products/__manifest__.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Copyright 2022 Criptomart
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
'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",
|
||||||
|
"views/web_templates.xml"
|
||||||
|
],
|
||||||
|
'demo': [
|
||||||
|
],
|
||||||
|
}
|
||||||
3
website_search_products/controllers/__init__.py
Normal file
3
website_search_products/controllers/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import controller
|
||||||
34
website_search_products/controllers/controller.py
Normal file
34
website_search_products/controllers/controller.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# -*- 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)
|
||||||
|
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?'
|
||||||
|
return http.redirect_with_hash(redirect)
|
||||||
|
|
||||||
|
products = request.env["product.template"].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
|
||||||
|
else:
|
||||||
|
redirect = '/inventory/search'
|
||||||
|
return http.redirect_with_hash(redirect)
|
||||||
|
return response
|
||||||
11
website_search_products/data/menu.xml
Normal file
11
website_search_products/data/menu.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record id="menu_partner_form" model="website.menu">
|
||||||
|
<field name="name">Products in Shop</field>
|
||||||
|
<field name="url">/inventory/search</field>
|
||||||
|
<field name="parent_id" ref="website.main_menu"/>
|
||||||
|
<field name="sequence" type="int">22</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
63
website_search_products/i18n/es.po
Normal file
63
website_search_products/i18n/es.po
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * website_search_products
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 12.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2023-01-12 17:25+0000\n"
|
||||||
|
"PO-Revision-Date: 2023-01-12 18:26+0100\n"
|
||||||
|
"Last-Translator: <>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
"Language: es\n"
|
||||||
|
"X-Generator: Poedit 2.3\n"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Category"
|
||||||
|
msgstr "Categoría"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Displayed products"
|
||||||
|
msgstr "Productos mostrados"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Name"
|
||||||
|
msgstr "Nombre"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Price"
|
||||||
|
msgstr "Precio"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model:website.menu,name:website_search_products.menu_partner_form
|
||||||
|
msgid "Products in Shop"
|
||||||
|
msgstr "Productos en tienda"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Products not found"
|
||||||
|
msgstr "Productos no encontrados"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Quantity"
|
||||||
|
msgstr "Cantidad"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model:ir.model,name:website_search_products.model_stock_move
|
||||||
|
msgid "Stock Move"
|
||||||
|
msgstr "Movimiento de stock"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "UoM"
|
||||||
|
msgstr "UdM"
|
||||||
62
website_search_products/i18n/website_search_products.pot
Normal file
62
website_search_products/i18n/website_search_products.pot
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * website_search_products
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 12.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2023-01-12 17:24+0000\n"
|
||||||
|
"PO-Revision-Date: 2023-01-12 17:24+0000\n"
|
||||||
|
"Last-Translator: <>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: \n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Category"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Displayed products"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Name"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Price"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model:website.menu,name:website_search_products.menu_partner_form
|
||||||
|
msgid "Products in Shop"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Products not found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "Quantity"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model:ir.model,name:website_search_products.model_stock_move
|
||||||
|
msgid "Stock Move"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_search_products
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_search_products.web_list_products
|
||||||
|
msgid "UoM"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
2
website_search_products/models/__init__.py
Normal file
2
website_search_products/models/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from . import stock_move
|
||||||
59
website_search_products/models/stock_move.py
Normal file
59
website_search_products/models/stock_move.py
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
from odoo import tools
|
||||||
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
from datetime import date,datetime
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
|
import logging
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class StockMove(models.Model):
|
||||||
|
_inherit = 'stock.move'
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def get_stock_moves_by_product(self, date_begin, date_end, location):
|
||||||
|
|
||||||
|
if date_begin and date_end:
|
||||||
|
moves = self.env['stock.move'].search([
|
||||||
|
'|',
|
||||||
|
('location_id','=',int(location)),
|
||||||
|
('location_dest_id','=',int(location)),
|
||||||
|
('state', '=', 'done'),
|
||||||
|
('date','>=',date_begin),
|
||||||
|
('date','<=',date_end),
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
moves_grouped = {}
|
||||||
|
data = []
|
||||||
|
|
||||||
|
if moves:
|
||||||
|
for move in moves:
|
||||||
|
if move.product_id.id and move.product_id.type == 'product':
|
||||||
|
if not moves_grouped.get(move.product_id.id, False):
|
||||||
|
date_end_obj = datetime.strptime(date_end, '%Y-%m-%d').date() + relativedelta(days=1)
|
||||||
|
moves_grouped[move.product_id.id] = dict([])
|
||||||
|
moves_grouped[move.product_id.id]['name'] = move.product_id.name
|
||||||
|
moves_grouped[move.product_id.id]['category'] = move.product_id.categ_id.name
|
||||||
|
moves_grouped[move.product_id.id]['list_price'] = move.product_id.list_price
|
||||||
|
moves_grouped[move.product_id.id]['qty_init'] = move.product_id.with_context({
|
||||||
|
'to_date':date_begin,
|
||||||
|
'location': int(location)
|
||||||
|
}).qty_available
|
||||||
|
moves_grouped[move.product_id.id]['qty_end'] = move.product_id.with_context({
|
||||||
|
'to_date':date_end_obj,
|
||||||
|
'location': int(location)
|
||||||
|
}).qty_available
|
||||||
|
|
||||||
|
if not moves_grouped[move.product_id.id].get('in'):
|
||||||
|
moves_grouped[move.product_id.id]['in'] = 0.0
|
||||||
|
if not moves_grouped[move.product_id.id].get('out'):
|
||||||
|
moves_grouped[move.product_id.id]['out'] = 0.0
|
||||||
|
if int(move.location_id) == int(location):
|
||||||
|
moves_grouped[move.product_id.id]['out'] += move.product_qty
|
||||||
|
elif int(move.location_dest_id) == int(location):
|
||||||
|
moves_grouped[move.product_id.id]['in'] += move.product_qty
|
||||||
|
|
||||||
|
data = list(moves_grouped.values())
|
||||||
|
return data
|
||||||
61
website_search_products/views/web_templates.xml
Normal file
61
website_search_products/views/web_templates.xml
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright 2021 Criptomart <tech@criptomart.net>
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<template id="web_list_products" name="Product List">
|
||||||
|
<t t-call="website.layout">
|
||||||
|
<div id="wrap">
|
||||||
|
<div class="container">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<t t-if="products">
|
||||||
|
<div class="alert alert-success">
|
||||||
|
Displayed products
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
<t t-if="not_found">
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
Products not found
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
<div class="col-md-12" style="margin-top: 50px;">
|
||||||
|
<table id="productTable" class="table table-stripped" >
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Category</th>
|
||||||
|
<th>Price</th>
|
||||||
|
<th>Quantity</th>
|
||||||
|
<th>UoM</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<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>
|
||||||
|
</tr>
|
||||||
|
</t>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js" />
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css" />
|
||||||
|
<script>
|
||||||
|
$('#productTable').DataTable({
|
||||||
|
"pageLength": 100,
|
||||||
|
"order": [[1, "asc"], [0, "asc"], [2, "desc"]]
|
||||||
|
});
|
||||||
|
console.log("table init");
|
||||||
|
</script>
|
||||||
|
</t>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue