From 4fa05cacfe87d6f14c8b3cb3ef9921a7436767bf Mon Sep 17 00:00:00 2001 From: Iryna Vyshnevska Date: Mon, 30 May 2022 11:22:31 +0300 Subject: [PATCH 1/6] [IMP] add names to tags add names to facilitate cusotom modifications --- .../report/stock_picking_report_valued.xml | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/stock_picking_report_valued/report/stock_picking_report_valued.xml b/stock_picking_report_valued/report/stock_picking_report_valued.xml index ae29d14..2722ad5 100644 --- a/stock_picking_report_valued/report/stock_picking_report_valued.xml +++ b/stock_picking_report_valued/report/stock_picking_report_valued.xml @@ -10,12 +10,13 @@ Qty Reserved - Unit Price - + Unit Price + Discount - Subtotal - Taxes + Subtotal + Taxes + - +
- - - + + + - - - @@ -90,14 +91,14 @@ - - + - - From c34780eac8ec5c8fff8a4ee9e05cf3551a45367e Mon Sep 17 00:00:00 2001 From: Iryna Vyshnevska Date: Mon, 30 May 2022 11:26:34 +0300 Subject: [PATCH 2/6] [IMP] add printing option for outgoing docs printing option is breaking for picking type, make it available only for outgoing docs --- .../report/stock_picking_report_valued.xml | 116 ++++++++++-------- 1 file changed, 68 insertions(+), 48 deletions(-) diff --git a/stock_picking_report_valued/report/stock_picking_report_valued.xml b/stock_picking_report_valued/report/stock_picking_report_valued.xml index 2722ad5..b65a507 100644 --- a/stock_picking_report_valued/report/stock_picking_report_valued.xml +++ b/stock_picking_report_valued/report/stock_picking_report_valued.xml @@ -6,17 +6,24 @@ expr="//table[@t-if="o.move_line_ids and o.state=='done'"]/thead/tr" position="inside" > - - - + + + + + + + + + - - - - - - -
Untaxed AmountTaxesTotalUntaxed AmountTaxesTotal
+ + +
+ Qty ReservedQty ReservedUnit Price + Discount + SubtotalTaxes Unit Price - Discount - SubtotalTaxes
- - - - - - - - - - - - - - -
Untaxed AmountTaxesTotal
- - - - - -
+ + + + + + + + + + + + + + + + + +
Untaxed AmountTaxesTotal
+ + + + + +
+
@@ -85,22 +97,30 @@ inherit_id="stock.stock_report_delivery_has_serial_move_line" > - - - - - + + + + + + + + + + + + + - - - - - - From 7a89078b90bbd88fd58247806848bd3e41f31352 Mon Sep 17 00:00:00 2001 From: Iryna Vyshnevska Date: Mon, 30 May 2022 11:33:26 +0300 Subject: [PATCH 3/6] [DOC] notes for readme --- stock_picking_report_valued/readme/ROADMAP.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/stock_picking_report_valued/readme/ROADMAP.rst b/stock_picking_report_valued/readme/ROADMAP.rst index 2ef668b..43dd5ff 100644 --- a/stock_picking_report_valued/readme/ROADMAP.rst +++ b/stock_picking_report_valued/readme/ROADMAP.rst @@ -1 +1,2 @@ * If the picking is not reserved, values aren't computed. +* Add tax printing by group From 66f566f617735d6a5848f49ae6dbb869f035b120 Mon Sep 17 00:00:00 2001 From: Iryna Vyshnevska Date: Tue, 31 May 2022 01:41:51 +0300 Subject: [PATCH 4/6] [IMP] add posibility to print grouped lines --- .../models/stock_move_line.py | 50 +++++++++++++++++++ .../report/stock_picking_report_valued.xml | 28 +++++++++++ 2 files changed, 78 insertions(+) diff --git a/stock_picking_report_valued/models/stock_move_line.py b/stock_picking_report_valued/models/stock_move_line.py index d55ab44..7f96c7f 100644 --- a/stock_picking_report_valued/models/stock_move_line.py +++ b/stock_picking_report_valued/models/stock_move_line.py @@ -4,8 +4,11 @@ # Copyright 2016-2022 Tecnativa - Carlos Dauden # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from functools import partial + from odoo import fields, models from odoo.tools import float_compare +from odoo.tools.misc import formatLang class StockMoveLine(models.Model): @@ -78,3 +81,50 @@ class StockMoveLine(models.Model): "sale_price_total": valued_line.price_total, } ) + + def _get_aggregated_product_quantities(self, **kwargs): + result = super()._get_aggregated_product_quantities(**kwargs) + if self.env.context.get("bypass_modification"): + return result + result = self._get_aggregated_product_quantities_delivery_price(result) + return result + + def _get_aggregated_product_quantities_delivery_price(self, aggregated_move_lines): + # sale order can have sold products under different prices + # currently lines on stock.picking will conceder only first price + # so total on sale.order and stock.picking will differ + # consider riding of aggregating of lines for stock.picking + fmt = partial( + formatLang, + self.with_context(lang=self.picking_id.partner_id.lang).env, + currency_obj=self.picking_id.currency_id, + ) + + for line in aggregated_move_lines: + product = aggregated_move_lines[line]["product"] + uom = aggregated_move_lines[line]["product_uom"] + sml = self._find_sml(product, uom) + qty = aggregated_move_lines[line]["qty_done"] or sml.move_id.product_uom_qty + aggregated_move_lines[line].update( + { + "unit_price": fmt(sml.sale_price_unit), + "tax": ", ".join( + map( + lambda x: (x.description or x.name), + sml.sale_tax_id, + ) + ), + "total": (sml.sale_price_unit * qty), + } + ) + return aggregated_move_lines + + def _find_sml(self, product, uom_name): + line = fields.first( + self.filtered( + lambda sml: sml.product_id == product + and sml.product_uom_id.name == uom_name + ) + ) + + return line diff --git a/stock_picking_report_valued/report/stock_picking_report_valued.xml b/stock_picking_report_valued/report/stock_picking_report_valued.xml index b65a507..04fe022 100644 --- a/stock_picking_report_valued/report/stock_picking_report_valued.xml +++ b/stock_picking_report_valued/report/stock_picking_report_valued.xml @@ -125,4 +125,32 @@ + + + + From f37a24d70c80cfa3d9852ea9f51ad8f29966e44b Mon Sep 17 00:00:00 2001 From: Iryna Vyshnevska Date: Tue, 31 May 2022 01:43:03 +0300 Subject: [PATCH 5/6] [FIX] restore posibility to print agrregated table adding 'or' condition leads to that that table for serial moves is always printed --- .../report/stock_picking_report_valued.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock_picking_report_valued/report/stock_picking_report_valued.xml b/stock_picking_report_valued/report/stock_picking_report_valued.xml index 04fe022..68c4030 100644 --- a/stock_picking_report_valued/report/stock_picking_report_valued.xml +++ b/stock_picking_report_valued/report/stock_picking_report_valued.xml @@ -26,7 +26,7 @@ - @@ -55,7 +55,7 @@ add="or (o.valued and o.sale_id and o.move_line_ids)" separator=" " /> - + --> Date: Wed, 8 Jun 2022 14:36:45 +0300 Subject: [PATCH 6/6] fixup! [FIX] restore posibility to print agrregated table --- stock_picking_report_valued/models/stock_move_line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock_picking_report_valued/models/stock_move_line.py b/stock_picking_report_valued/models/stock_move_line.py index 7f96c7f..bec699a 100644 --- a/stock_picking_report_valued/models/stock_move_line.py +++ b/stock_picking_report_valued/models/stock_move_line.py @@ -84,14 +84,14 @@ class StockMoveLine(models.Model): def _get_aggregated_product_quantities(self, **kwargs): result = super()._get_aggregated_product_quantities(**kwargs) - if self.env.context.get("bypass_modification"): + if self.env.context.get("bypass_modification_valued_report"): return result result = self._get_aggregated_product_quantities_delivery_price(result) return result def _get_aggregated_product_quantities_delivery_price(self, aggregated_move_lines): # sale order can have sold products under different prices - # currently lines on stock.picking will conceder only first price + # currently lines on stock.picking will consider only first price # so total on sale.order and stock.picking will differ # consider riding of aggregating of lines for stock.picking fmt = partial(