From fe6326a210fc486a8399f4fd1e8d13b1e3152384 Mon Sep 17 00:00:00 2001 From: Emilio Pascual Date: Thu, 25 Apr 2024 11:21:53 +0200 Subject: [PATCH] [FIX] stock_move_packaging_qty: add packaging qty reserved - Add packaging qty reserved in stock move line with compute to know packaging reserved when reserved. MT-5861 @moduon Co-authored-by: Emilio Pascual <53056345+EmilioPascual@users.noreply.github.com> --- stock_move_packaging_qty/README.rst | 6 ++--- .../i18n/stock_move_packaging_qty.pot | 14 +++++++++- .../models/stock_move_line.py | 21 ++++++++++++++- .../readme/CONTRIBUTORS.rst | 2 ++ stock_move_packaging_qty/readme/ROADMAP.rst | 2 -- .../static/description/index.html | 17 +++++++----- .../views/stock_move_line_view.xml | 26 +++++++++++++++++++ 7 files changed, 75 insertions(+), 13 deletions(-) diff --git a/stock_move_packaging_qty/README.rst b/stock_move_packaging_qty/README.rst index 5512435b2..323528438 100644 --- a/stock_move_packaging_qty/README.rst +++ b/stock_move_packaging_qty/README.rst @@ -7,7 +7,7 @@ Stock Packaging Qty !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:0647041df888b4720a5e1b3f04ebab2f3f73052200569f6ba7d963104c308e1f + !! source digest: sha256:cdc1ef5bdc2e95d07b6b1cdd1df18cb6a7957b142cdf59a226f1305e7cabc5c8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -38,8 +38,6 @@ Add packaging fields in the stock moves, their lines and their reports. Known issues / Roadmap ====================== -* Maybe we should track also reserved packaging quantities? - * Since we store done product packaging quantities in the stock move lines, we should be able to use this information in quants to provide real packaging-based stock data. @@ -68,6 +66,8 @@ Contributors * Mateu Griful * Lois Rilo * Jairo Llopis (`Moduon `__) +* Emilio Pascual (`Moduon `__) +* Eduardo de Miguel (`Moduon `__) Maintainers ~~~~~~~~~~~ diff --git a/stock_move_packaging_qty/i18n/stock_move_packaging_qty.pot b/stock_move_packaging_qty/i18n/stock_move_packaging_qty.pot index 5735f87c0..b817d3409 100644 --- a/stock_move_packaging_qty/i18n/stock_move_packaging_qty.pot +++ b/stock_move_packaging_qty/i18n/stock_move_packaging_qty.pot @@ -4,8 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" +"Project-Id-Version: Odoo Server 16.0+e\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-04-25 09:26+0000\n" +"PO-Revision-Date: 2024-04-25 09:26+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -68,6 +70,16 @@ msgstr "" msgid "Product packaging quantity done." msgstr "" +#. module: stock_move_packaging_qty +#: model:ir.model.fields,help:stock_move_packaging_qty.field_stock_move_line__product_packaging_qty_reserved +msgid "Product packaging quantity reserved." +msgstr "" + +#. module: stock_move_packaging_qty +#: model:ir.model.fields,field_description:stock_move_packaging_qty.field_stock_move_line__product_packaging_qty_reserved +msgid "Reserved Pkg. Qty." +msgstr "" + #. module: stock_move_packaging_qty #: model:ir.model,name:stock_move_packaging_qty.model_stock_move msgid "Stock Move" diff --git a/stock_move_packaging_qty/models/stock_move_line.py b/stock_move_packaging_qty/models/stock_move_line.py index b953ead6a..273d7db66 100644 --- a/stock_move_packaging_qty/models/stock_move_line.py +++ b/stock_move_packaging_qty/models/stock_move_line.py @@ -1,6 +1,7 @@ # Copyright 2024 Moduon Team S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) -from odoo import fields, models +from odoo import api, fields, models +from odoo.tools import float_round class StockMoveLine(models.Model): @@ -9,11 +10,29 @@ class StockMoveLine(models.Model): product_packaging_id = fields.Many2one( related="move_id.product_packaging_id", readonly=True ) + product_packaging_qty_reserved = fields.Float( + string="Reserved Pkg. Qty.", + help="Product packaging quantity reserved.", + compute="_compute_product_packaging_qty_reserved", + store=True, + ) product_packaging_qty_done = fields.Float( string="Done Pkg. Qty.", help="Product packaging quantity done.", ) + @api.depends("product_packaging_id", "reserved_qty") + def _compute_product_packaging_qty_reserved(self): + """Get the quantity done in product packaging.""" + self.product_packaging_qty_reserved = False + for line in self: + if not line.product_packaging_id.qty: + continue + line.product_packaging_qty_reserved = float_round( + line.reserved_qty / line.product_packaging_id.qty, + precision_rounding=line.product_packaging_id.product_uom_id.rounding, + ) + def _get_aggregated_properties(self, move_line=False, move=False): """Aggregate by product packaging too.""" result = super()._get_aggregated_properties(move_line, move) diff --git a/stock_move_packaging_qty/readme/CONTRIBUTORS.rst b/stock_move_packaging_qty/readme/CONTRIBUTORS.rst index 430ace9f1..2e582e212 100644 --- a/stock_move_packaging_qty/readme/CONTRIBUTORS.rst +++ b/stock_move_packaging_qty/readme/CONTRIBUTORS.rst @@ -1,3 +1,5 @@ * Mateu Griful * Lois Rilo * Jairo Llopis (`Moduon `__) +* Emilio Pascual (`Moduon `__) +* Eduardo de Miguel (`Moduon `__) diff --git a/stock_move_packaging_qty/readme/ROADMAP.rst b/stock_move_packaging_qty/readme/ROADMAP.rst index a3737366b..1b6ec2dfe 100644 --- a/stock_move_packaging_qty/readme/ROADMAP.rst +++ b/stock_move_packaging_qty/readme/ROADMAP.rst @@ -1,5 +1,3 @@ -* Maybe we should track also reserved packaging quantities? - * Since we store done product packaging quantities in the stock move lines, we should be able to use this information in quants to provide real packaging-based stock data. diff --git a/stock_move_packaging_qty/static/description/index.html b/stock_move_packaging_qty/static/description/index.html index 333cbfa46..730d7a973 100644 --- a/stock_move_packaging_qty/static/description/index.html +++ b/stock_move_packaging_qty/static/description/index.html @@ -1,3 +1,4 @@ + @@ -8,10 +9,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +276,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +302,7 @@ span.option { span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -366,7 +368,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:0647041df888b4720a5e1b3f04ebab2f3f73052200569f6ba7d963104c308e1f +!! source digest: sha256:cdc1ef5bdc2e95d07b6b1cdd1df18cb6a7957b142cdf59a226f1305e7cabc5c8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: LGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runboat

Add packaging fields in the stock moves, their lines and their reports.

@@ -386,7 +388,6 @@ ul.auto-toc {

Known issues / Roadmap

    -
  • Maybe we should track also reserved packaging quantities?
  • Since we store done product packaging quantities in the stock move lines, we should be able to use this information in quants to provide real packaging-based stock data.
  • @@ -414,12 +415,16 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Mateu Griful <mateu.griful@forgeflow.com>
  • Lois Rilo <lois.rilo@forgeflow.com>
  • Jairo Llopis (Moduon)
  • +
  • Emilio Pascual (Moduon)
  • +
  • Eduardo de Miguel (Moduon)

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

diff --git a/stock_move_packaging_qty/views/stock_move_line_view.xml b/stock_move_packaging_qty/views/stock_move_line_view.xml index f8f95e4f9..195ba777e 100644 --- a/stock_move_packaging_qty/views/stock_move_line_view.xml +++ b/stock_move_packaging_qty/views/stock_move_line_view.xml @@ -23,6 +23,24 @@ stock.move.line + +