diff --git a/product_multi_uom_pos/__init__.py b/product_multi_uom_pos/__init__.py index 6ee5692fc..18a00a821 100644 --- a/product_multi_uom_pos/__init__.py +++ b/product_multi_uom_pos/__init__.py @@ -19,4 +19,4 @@ # If not, see . # ############################################################################# -from . import models +from . import models \ No newline at end of file diff --git a/product_multi_uom_pos/__manifest__.py b/product_multi_uom_pos/__manifest__.py index d7e982465..33d5b5bf8 100644 --- a/product_multi_uom_pos/__manifest__.py +++ b/product_multi_uom_pos/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': "POS Product Multiple UOM", - 'version': '17.0.1.0.1', + 'version': '17.0.1.0.2', 'category': 'Point of Sale', 'summary': """A module to manage multiple UoM in POS""", 'description': """Using this app, you can change unit of measure of @@ -30,10 +30,9 @@ 'company': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions', 'website': "https://www.cybrosys.com", - 'depends': ['base', 'point_of_sale'], + 'depends': ['point_of_sale', 'uom'], 'data': - [ - 'security/ir.model.access.csv', + [ 'data/uom_data.xml', 'views/res_config_settings_views.xml', 'views/product_template_views.xml', 'views/pos_order_views.xml', diff --git a/product_multi_uom_pos/data/uom_data.xml b/product_multi_uom_pos/data/uom_data.xml new file mode 100644 index 000000000..56a833573 --- /dev/null +++ b/product_multi_uom_pos/data/uom_data.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/product_multi_uom_pos/doc/RELEASE_NOTES.md b/product_multi_uom_pos/doc/RELEASE_NOTES.md index 414286d36..2864beb1a 100644 --- a/product_multi_uom_pos/doc/RELEASE_NOTES.md +++ b/product_multi_uom_pos/doc/RELEASE_NOTES.md @@ -18,4 +18,11 @@ #### 20.08.2024 #### Version 17.0.1.0.1 ##### UPDT -- Bug Fix - Resolved the issue of UOM shown in sales details report \ No newline at end of file +- Bug Fix - Resolved the issue of UOM shown in sales details report + +#### 16.10.2024 +#### Version 17.0.1.0.2 +##### UPDT +- Bug Fix - 1) Changed the workflow, Unit and price will be automatically calculated on the basis of selected UOM ratio. + 2) Resolved issue with the multiple order lines in the POS. + 3) Resolved the issue in the delivery. \ No newline at end of file diff --git a/product_multi_uom_pos/models/__init__.py b/product_multi_uom_pos/models/__init__.py index 5dcd36716..5ab7460a8 100644 --- a/product_multi_uom_pos/models/__init__.py +++ b/product_multi_uom_pos/models/__init__.py @@ -26,4 +26,3 @@ from . import stock_picking from . import pos_config from . import report_sale_details from . import res_config_settings -from . import pos_multi_uom diff --git a/product_multi_uom_pos/models/pos_multi_uom.py b/product_multi_uom_pos/models/pos_multi_uom.py deleted file mode 100644 index c2b1b42df..000000000 --- a/product_multi_uom_pos/models/pos_multi_uom.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################# -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2024-TODAY Cybrosys Technologies() -# Author: Gayathri V (Contact : odoo@cybrosys.com) -# -# You can modify it under the terms of the GNU AFFERO -# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. -# -# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE -# (AGPL v3) along with this program. -# If not, see . -# -############################################################################# -from odoo import fields, models - - -class PosMultiUom(models.Model): - """ - Model for managing Point of Sale (POS) Multi Unit of Measure (UoM). - This model represents the association between a product template and its - multiple unit of measure options for the Point of Sale module. - """ - _name = 'pos.multi.uom' - _description = 'POS Multi UoM' - - product_template_id = fields.Many2one('product.template', - string='Product Template', - help='Inverse field of one2many' - 'field POS Multiple UoM in' - 'product.template') - category_id = fields.Many2one( - related='product_template_id.uom_id.category_id', - string='UoM Category', help='Category of unit of measure') - uom_id = fields.Many2one('uom.uom', string='Unit Of Measure', - domain="[('category_id', '=', category_id)]", - help="Choose a UoM") - price = fields.Float(string='Sale Price', help="Set a price for selected " - "UoM") diff --git a/product_multi_uom_pos/models/pos_session.py b/product_multi_uom_pos/models/pos_session.py index 809a3e059..9c2023af2 100644 --- a/product_multi_uom_pos/models/pos_session.py +++ b/product_multi_uom_pos/models/pos_session.py @@ -31,20 +31,3 @@ class PosSession(models.Model): result = super()._loader_params_product_product() result['search_params']['fields'].append('pos_multi_uom_ids') return result - - def _pos_ui_models_to_load(self): - """Loading model 'pos.multi.uom' to POS""" - result = super()._pos_ui_models_to_load() - result.append('pos.multi.uom') - return result - - def _loader_params_pos_multi_uom(self): - """Loading fields of model 'pos.multi.uom' to POS""" - return { - 'search_params': { - 'fields': ['uom_id', 'price', 'product_template_id']} - } - - def _get_pos_ui_pos_multi_uom(self, params): - """Loading new model to POS""" - return self.env['pos.multi.uom'].search_read(**params['search_params']) diff --git a/product_multi_uom_pos/models/product_template.py b/product_multi_uom_pos/models/product_template.py index c46465dad..7c04ad276 100644 --- a/product_multi_uom_pos/models/product_template.py +++ b/product_multi_uom_pos/models/product_template.py @@ -27,22 +27,9 @@ class ProductTemplate(models.Model): of measure""" _inherit = 'product.template' - multi_uom = fields.Boolean(compute='_compute_multi_uom', string='Multi UoM', - help='A boolean field to show the one2many field' - 'POS Multiple UoM if the Multi UoM option' - ' is enabled in Configuration settings') - pos_multi_uom_ids = fields.One2many('pos.multi.uom', 'product_template_id', + product_uom_category_id = fields.Many2one(related='uom_id.category_id') + pos_multi_uom_ids = fields.Many2many('uom.uom', 'product_template_id', string="POS Multiple UoM", + domain="[('category_id', '=', product_uom_category_id)]", help='These UoM can be selected from ' - 'PoS') - - def _compute_multi_uom(self): - """ - Updates the 'multi_uom' field based on the configuration parameter - 'product_multi_uom_pos.pos_multi_uom'. - """ - status = self.env['ir.config_parameter'].sudo().get_param( - 'product_multi_uom_pos.pos_multi_uom') - self.write({ - 'multi_uom': status - }) + 'PoS') \ No newline at end of file diff --git a/product_multi_uom_pos/models/res_config_settings.py b/product_multi_uom_pos/models/res_config_settings.py index 4f47647de..cbf5173fb 100644 --- a/product_multi_uom_pos/models/res_config_settings.py +++ b/product_multi_uom_pos/models/res_config_settings.py @@ -19,7 +19,8 @@ # If not, see . # ############################################################################# -from odoo import fields, models +from odoo import api, fields, models +from odoo.tools import decode_message_header class ResConfigSettings(models.TransientModel): diff --git a/product_multi_uom_pos/models/stock_picking.py b/product_multi_uom_pos/models/stock_picking.py index 364d70034..bc27cdcc4 100644 --- a/product_multi_uom_pos/models/stock_picking.py +++ b/product_multi_uom_pos/models/stock_picking.py @@ -20,6 +20,8 @@ # ############################################################################# from odoo import models +from itertools import groupby + class StockPicking(models.Model): @@ -45,3 +47,18 @@ class StockPicking(models.Model): 'location_dest_id': self.location_dest_id.id, 'company_id': self.company_id.id, } + def _create_move_from_pos_order_lines(self, lines): + self.ensure_one() + lines_by_product = groupby( + sorted(lines, key=lambda l: (l.product_id.id, l.product_uom_id)), + key=lambda l: (l.product_id.id, l.product_uom_id) + ) + move_vals = [] + for dummy, olines in lines_by_product: + order_lines = self.env['pos.order.line'].concat(*olines) + move_vals.append(self._prepare_stock_move_vals(order_lines[0], order_lines)) + moves = self.env['stock.move'].create(move_vals) + confirmed_moves = moves._action_confirm() + confirmed_moves._add_mls_related_to_order(lines, are_qties_done=True) + confirmed_moves.picked = True + self._link_owner_on_return_picking(lines) diff --git a/product_multi_uom_pos/security/ir.model.access.csv b/product_multi_uom_pos/security/ir.model.access.csv deleted file mode 100644 index 459fbb366..000000000 --- a/product_multi_uom_pos/security/ir.model.access.csv +++ /dev/null @@ -1,2 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_pos_multi_uom,access.pos.multi.uom,model_pos_multi_uom,base.group_user,1,1,1,1 diff --git a/product_multi_uom_pos/static/description/assets/screenshots/10.png b/product_multi_uom_pos/static/description/assets/screenshots/10.png new file mode 100644 index 000000000..8371b45a3 Binary files /dev/null and b/product_multi_uom_pos/static/description/assets/screenshots/10.png differ diff --git a/product_multi_uom_pos/static/description/assets/screenshots/2.png b/product_multi_uom_pos/static/description/assets/screenshots/2.png index 70942aa34..ed312257a 100644 Binary files a/product_multi_uom_pos/static/description/assets/screenshots/2.png and b/product_multi_uom_pos/static/description/assets/screenshots/2.png differ diff --git a/product_multi_uom_pos/static/description/assets/screenshots/9.png b/product_multi_uom_pos/static/description/assets/screenshots/9.png new file mode 100644 index 000000000..6d88a3dcf Binary files /dev/null and b/product_multi_uom_pos/static/description/assets/screenshots/9.png differ diff --git a/product_multi_uom_pos/static/description/index.html b/product_multi_uom_pos/static/description/index.html index 1576397b0..eb61fb1f1 100644 --- a/product_multi_uom_pos/static/description/index.html +++ b/product_multi_uom_pos/static/description/index.html @@ -169,8 +169,7 @@ style=" font-weight:600 !important; color:#282F33 !important; font-size:1.3rem !important"> Form View of Product

- If 'Multiple Unit of Measure' option is - enabled, you can add + You can add multiple units of measures and its price under 'Sales' tab of Products as shown.

@@ -178,6 +177,39 @@ +
+
+
+ +
+
+

+ You can UOM in UOM categories in the Inventory module

+ +
+
+
+
+
+
+ +
+
+

+ Price and unit will be calculated based on the ratio in the UOM +

+ +
+
+
- - - + + + + + diff --git a/product_multi_uom_pos/static/src/overrides/models/orderline.js b/product_multi_uom_pos/static/src/overrides/models/orderline.js index e2673e37c..461cf87dd 100644 --- a/product_multi_uom_pos/static/src/overrides/models/orderline.js +++ b/product_multi_uom_pos/static/src/overrides/models/orderline.js @@ -43,17 +43,17 @@ patch(Orderline.prototype, { return this.product.get_unit(); }, onSelectionChangedUom(ev) { - var splitTargetValue = ev.target.value.split(',') - var price = splitTargetValue[0] - var uomId = splitTargetValue[1] - var uomName = splitTargetValue[2] - // Set the selected unit of measure on the order line - const currentOrder = this.env.services.pos.get_order(); - currentOrder.selected_orderline.set_uom({0:uomId,1:uomName}) - // Set the price_manually_set flag to indicate that the price was manually set - currentOrder.selected_orderline.price_type = "manual"; - // Set the unit price of selected UoM on the order line - currentOrder.selected_orderline.set_unit_price(price); + var uom_id = ev.target.value + var selected_uom = this.env.services.pos.units_by_id[uom_id] + var selected_product = this.props.slots['product-name'].__ctx.line + selected_product.set_uom({0:selected_uom.id,1:selected_uom.name}) + selected_product.price_type = "manual"; + if (selected_uom.uom_type == "smaller"){ + selected_product.set_unit_price(selected_product.product.lst_price * (1 / selected_uom.ratio)); + } else { + selected_product.set_unit_price(selected_product.product.lst_price * selected_uom.ratio); + } + }, getUom(self) { const currentOrder = self.env.services.pos.get_order(); @@ -74,6 +74,7 @@ patch(Orderline.prototype, { getUom: this.getUom, resetUom: this.resetUom, onSelectionChangedUom: this.onSelectionChangedUom, + multiUom: [...this.product.pos_multi_uom_ids], }; }, }); diff --git a/product_multi_uom_pos/static/src/overrides/models/store.js b/product_multi_uom_pos/static/src/overrides/models/store.js deleted file mode 100644 index 2a55bdf6e..000000000 --- a/product_multi_uom_pos/static/src/overrides/models/store.js +++ /dev/null @@ -1,12 +0,0 @@ -/** @odoo-module */ -import { PosStore } from "@point_of_sale/app/store/pos_store"; -import { patch } from "@web/core/utils/patch"; - - -patch(PosStore.prototype, { - // @Override - async _processData(loadedData) { - await super._processData(...arguments); - this.pos_multi_uom = loadedData['pos.multi.uom']; - }, -}); diff --git a/product_multi_uom_pos/views/pos_order_views.xml b/product_multi_uom_pos/views/pos_order_views.xml index d6edfd1c1..78ba573c3 100644 --- a/product_multi_uom_pos/views/pos_order_views.xml +++ b/product_multi_uom_pos/views/pos_order_views.xml @@ -1,16 +1,16 @@ - - pos.order.view.form.inherit.product.multi.uom.pos - - - pos.order - - - - - - + + + + + + + + + + + + diff --git a/product_multi_uom_pos/views/product_template_views.xml b/product_multi_uom_pos/views/product_template_views.xml index 6400a8234..349ba6c23 100644 --- a/product_multi_uom_pos/views/product_template_views.xml +++ b/product_multi_uom_pos/views/product_template_views.xml @@ -9,15 +9,8 @@ product.template - - - - - - - - + +