diff --git a/pos_picking_load_selected_partner/__init__.py b/pos_picking_load_selected_partner/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/pos_picking_load_selected_partner/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_picking_load_selected_partner/__manifest__.py b/pos_picking_load_selected_partner/__manifest__.py new file mode 100644 index 0000000..5b466d0 --- /dev/null +++ b/pos_picking_load_selected_partner/__manifest__.py @@ -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': [ + ], +} diff --git a/pos_picking_load_selected_partner/models/__init__.py b/pos_picking_load_selected_partner/models/__init__.py new file mode 100644 index 0000000..ae4c272 --- /dev/null +++ b/pos_picking_load_selected_partner/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/pos_picking_load_selected_partner/models/stock_picking.py b/pos_picking_load_selected_partner/models/stock_picking.py new file mode 100644 index 0000000..5d77546 --- /dev/null +++ b/pos_picking_load_selected_partner/models/stock_picking.py @@ -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' + diff --git a/pos_picking_load_selected_partner/static/src/js/widget.js b/pos_picking_load_selected_partner/static/src/js/widget.js new file mode 100644 index 0000000..70a4d6f --- /dev/null +++ b/pos_picking_load_selected_partner/static/src/js/widget.js @@ -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; +}); \ No newline at end of file diff --git a/pos_picking_load_selected_partner/views/assets.xml b/pos_picking_load_selected_partner/views/assets.xml new file mode 100644 index 0000000..d705648 --- /dev/null +++ b/pos_picking_load_selected_partner/views/assets.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/product_update_price_last_purchase/models/product_template.py b/product_update_price_last_purchase/models/product_template.py index 0f7b163..f89e7d2 100644 --- a/product_update_price_last_purchase/models/product_template.py +++ b/product_update_price_last_purchase/models/product_template.py @@ -23,7 +23,7 @@ class ProductTemplate(models.Model): _logger.debug("Calculating price with PriceList : %s" %pricelist.name) if pricelist: 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) _logger.debug("partial_price : %s" %partial_price) # Suma el IVA diff --git a/website_search_products/__init__.py b/website_search_products/__init__.py new file mode 100644 index 0000000..a19d6da --- /dev/null +++ b/website_search_products/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import controllers +from . import models diff --git a/website_search_products/__manifest__.py b/website_search_products/__manifest__.py new file mode 100644 index 0000000..c1df593 --- /dev/null +++ b/website_search_products/__manifest__.py @@ -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': [ + ], +} diff --git a/website_search_products/controllers/__init__.py b/website_search_products/controllers/__init__.py new file mode 100644 index 0000000..2f34e6e --- /dev/null +++ b/website_search_products/controllers/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import controller diff --git a/website_search_products/controllers/controller.py b/website_search_products/controllers/controller.py new file mode 100644 index 0000000..463cb5e --- /dev/null +++ b/website_search_products/controllers/controller.py @@ -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 diff --git a/website_search_products/data/menu.xml b/website_search_products/data/menu.xml new file mode 100644 index 0000000..397e0c8 --- /dev/null +++ b/website_search_products/data/menu.xml @@ -0,0 +1,11 @@ + + + + + Products in Shop + /inventory/search + + 22 + + + diff --git a/website_search_products/i18n/es.po b/website_search_products/i18n/es.po new file mode 100644 index 0000000..bcc0b85 --- /dev/null +++ b/website_search_products/i18n/es.po @@ -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" diff --git a/website_search_products/i18n/website_search_products.pot b/website_search_products/i18n/website_search_products.pot new file mode 100644 index 0000000..3752b58 --- /dev/null +++ b/website_search_products/i18n/website_search_products.pot @@ -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 "" + diff --git a/website_search_products/models/__init__.py b/website_search_products/models/__init__.py new file mode 100644 index 0000000..c6fcb2f --- /dev/null +++ b/website_search_products/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import stock_move diff --git a/website_search_products/models/stock_move.py b/website_search_products/models/stock_move.py new file mode 100644 index 0000000..81f9b07 --- /dev/null +++ b/website_search_products/models/stock_move.py @@ -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 diff --git a/website_search_products/views/web_templates.xml b/website_search_products/views/web_templates.xml new file mode 100644 index 0000000..bb534e2 --- /dev/null +++ b/website_search_products/views/web_templates.xml @@ -0,0 +1,61 @@ + + + + + + + +