Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] stock_picking_report_undelivered_product: Migration to 18.0 #367

Open
wants to merge 13 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stock_picking_report_undelivered_product/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Contributors

- Sergio Teruel <[email protected]>
- Carlos Dauden <[email protected]>
- Juan Carlos Oñate <[email protected]>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion stock_picking_report_undelivered_product/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Stock picking report undelivered products",
"summary": "Display on picking report delivery slip undelivered products",
"version": "15.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Tecnativa,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-reporting",
"category": "Warehouse",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from . import product_template
from . import res_config_settings
from . import res_partner
from . import stock_move
from . import stock_move_line
20 changes: 0 additions & 20 deletions stock_picking_report_undelivered_product/models/stock_move.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _get_aggregated_product_quantities(self, **kwargs):
aggregated_move_lines = super()._get_aggregated_product_quantities(**kwargs)
keys_to_remove = set()
for aggregated_move_line in aggregated_move_lines:
if not aggregated_move_lines[aggregated_move_line]["qty_done"]:
if not aggregated_move_lines[aggregated_move_line]["quantity"]:
keys_to_remove.add(aggregated_move_line)
# To avoid change dict size on iteration
for key_to_remmove in keys_to_remove:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

> - Sergio Teruel \<<[email protected]>\>
> - Carlos Dauden \<<[email protected]>\>
> - Juan Carlos Oñate \<<[email protected]>\>
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Sergio Teruel &lt;<a class="reference external" href="mailto:sergio.teruel&#64;tecnativa.com">sergio.teruel&#64;tecnativa.com</a>&gt;</li>
<li>Carlos Dauden &lt;<a class="reference external" href="mailto:carlos.dauden&#64;tecnativa.com">carlos.dauden&#64;tecnativa.com</a>&gt;</li>
<li>Juan Carlos Oñate &lt;<a class="reference external" href="mailto:juancarlos.onate&#64;tecnativa.com">juancarlos.onate&#64;tecnativa.com</a>&gt;</li>
</ul>
</blockquote>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright 2020 Sergio Teruel - Tecnativa <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests import common
from odoo.tests.common import Form
from odoo.tests import Form, common


class TestStockPickingReportUndeliveredProduct(common.TransactionCase):
Expand Down Expand Up @@ -31,21 +30,24 @@ def setUp(self):
{
"name": "Test product undelivered display",
"display_undelivered_in_picking": True,
"type": "product",
"type": "consu",
"is_storable": True,
}
)
self.product_no_display = self.ProductProduct.create(
{
"name": "Test product undelivered no display",
"display_undelivered_in_picking": False,
"type": "product",
"type": "consu",
"is_storable": True,
}
)
self.product_no_display_wo_stock = self.ProductProduct.create(
{
"name": "Test product undelivered no display without stock",
"display_undelivered_in_picking": False,
"type": "product",
"type": "consu",
"is_storable": True,
}
)
self.StockQuant.create(
Expand Down Expand Up @@ -83,57 +85,53 @@ def test_displayed_customer(self):
picking = self._create_picking(self.partner_display)
picking.action_confirm()
picking.action_assign()
picking.move_line_ids.qty_done = 10.00
picking.move_line_ids.quantity = 10.00
self._transfer_picking_no_backorder(picking)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
._render_qweb_html(picking.ids)
res = self.env["ir.actions.report"]._render_qweb_html(
"stock.report_deliveryslip", picking.ids
)
self.assertIn("undelivered_product", str(res[0]))
self.assertIn("Remaining quantities not yet delivered", str(res[0]))

def test_no_displayed_customer(self):
picking = self._create_picking(self.partner_no_display)
picking.action_confirm()
picking.action_assign()
picking.move_line_ids.qty_done = 10.00
picking.move_line_ids.quantity = 10.00
self._transfer_picking_no_backorder(picking)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
._render_qweb_html(picking.ids)
res = self.env["ir.actions.report"]._render_qweb_html(
"stock.report_deliveryslip", picking.ids
)
self.assertNotIn("undelivered_product", str(res[0]))
self.assertNotIn("Remaining quantities not yet delivered", str(res[0]))

def test_no_displayed_product(self):
picking = self._create_picking(self.partner_display)
picking.move_lines.filtered(
lambda l: l.product_id == self.product_display
picking.move_ids.filtered(
lambda move_line: move_line.product_id == self.product_display
).unlink()
picking.action_confirm()
picking.action_assign()
picking.move_line_ids.qty_done = 10.00
picking.move_line_ids.quantity = 10.00
self._transfer_picking_no_backorder(picking)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
._render_qweb_html(picking.ids)
res = self.env["ir.actions.report"]._render_qweb_html(
"stock.report_deliveryslip", picking.ids
)
self.assertNotIn("undelivered_product", str(res[0]))
self.assertNotIn("Remaining quantities not yet delivered", str(res[0]))

def test_picking_report_method(self):
product = self.ProductProduct.create(
{
"name": "test01",
"display_undelivered_in_picking": True,
"type": "product",
"type": "consu",
"is_storable": True,
}
)
product2 = self.ProductProduct.create(
{
"name": "test02",
"display_undelivered_in_picking": True,
"type": "product",
"type": "consu",
"is_storable": True,
}
)
self.StockQuant.create(
Expand All @@ -156,45 +154,37 @@ def test_picking_report_method(self):

picking.action_confirm()
picking.action_assign()
picking.move_line_ids.qty_done = 10.00
picking.move_line_ids.quantity = 10.00
self._transfer_picking_no_backorder(picking)

# Empty setting method field
picking.company_id.undelivered_product_slip_report_method = False
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
._render_qweb_html(picking.ids)
picking.company_id.undelivered_product_slip_report_method = "all"
res = self.env["ir.actions.report"]._render_qweb_html(
"stock.report_deliveryslip", picking.ids
)
self.assertIn("test02", str(res[0]))

# Print all undelivered lines, partial and completely lines
picking.company_id.undelivered_product_slip_report_method = "all"
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
._render_qweb_html(picking.ids)
res = self.env["ir.actions.report"]._render_qweb_html(
"stock.report_deliveryslip", picking.ids
)
self.assertIn("test02", str(res[0]))

# Print only partial undelivered lines
picking.company_id.undelivered_product_slip_report_method = (
"partially_undelivered"
)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
._render_qweb_html(picking.ids)
res = self.env["ir.actions.report"]._render_qweb_html(
"stock.report_deliveryslip", picking.ids
)
self.assertNotIn("test02", str(res[0]))

# Print only completely undelivered lines
picking.company_id.undelivered_product_slip_report_method = (
"completely_undelivered"
)
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
._render_qweb_html(picking.ids)
res = self.env["ir.actions.report"]._render_qweb_html(
"stock.report_deliveryslip", picking.ids
)
self.assertNotIn("partially_undelivered_line", str(res[0]))
127 changes: 44 additions & 83 deletions stock_picking_report_undelivered_product/views/report_deliveryslip.xml
Original file line number Diff line number Diff line change
@@ -1,95 +1,56 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="undeliverd_product">
<t t-if="o.partner_id.display_undelivered_in_picking and o.state == 'done'">
<!-- Get stock moves from backorder according to setting values -->
<t
t-if="not o.company_id.undelivered_product_slip_report_method or o.company_id.undelivered_product_slip_report_method == 'all'"
>
<template
id="undeliverd_product"
inherit_id="stock.report_delivery_document"
priority="200"
>
<xpath expr="//*[@t-set='backorders']" position="after">
<t t-if="o.partner_id.display_undelivered_in_picking and o.state == 'done'">
<t
t-set="undelivered_moves"
t-value="o.mapped('move_lines').filtered(lambda l: l.quantity_done == 0.0 and l.state == 'cancel' and l.product_id.display_undelivered_in_picking)"
t-set="all_moves"
t-value="o.mapped('move_ids') + o.mapped('backorder_ids').mapped('move_ids')"
/>
</t>
<t
t-if="o.company_id.undelivered_product_slip_report_method == 'partially_undelivered'"
>
<t t-if="o.company_id.undelivered_product_slip_report_method == 'all'">
<t
t-set="undelivered_moves"
t-value="all_moves.filtered(lambda l: (l.product_uom_qty - l.quantity) > 0.0 and l.product_id.display_undelivered_in_picking)"
/>
</t>
<t
t-set="undelivered_moves"
t-value="o.mapped('move_lines').filtered(lambda l: l.state == 'cancel' and l.product_id.display_undelivered_in_picking and l.splitted_stock_move_orig_id)"
/>
</t>
<t
t-if="o.company_id.undelivered_product_slip_report_method == 'completely_undelivered'"
>
t-if="o.company_id.undelivered_product_slip_report_method == 'partially_undelivered'"
>
<t
t-set="undelivered_moves"
t-value="all_moves.filtered(lambda l: l.state != 'cancel' and (l.product_uom_qty - l.quantity) > 0.0 and (l.product_uom_qty - l.quantity) != l.product_uom_qty and l.product_id.display_undelivered_in_picking)"
/>
</t>
<t
t-set="undelivered_moves"
t-value="o.mapped('move_lines').filtered(lambda l: l.state == 'cancel' and l.product_id.display_undelivered_in_picking and not l.splitted_stock_move_orig_id)"
/>
</t>
<table
t-if="undelivered_moves"
class="table table-sm table-bordered mt0"
id="undelivered_product"
>
<thead>
<tr>
<th colspan="7">
<strong>Remaining products (not delivered yet)</strong>
</th>
</tr>
<tr>
<th>
<strong>Reference</strong>
</th>
<th>
<strong>Product</strong>
</th>
<th class="text-right">
<strong>Quantity</strong>
</th>
</tr>
</thead>
<tbody>
t-if="o.company_id.undelivered_product_slip_report_method == 'completely_undelivered'"
>
<t
t-foreach="undelivered_moves.sorted(key=lambda l: (l.product_id.default_code, l.product_id.name))"
t-as="undelivered_move"
>
<tr
t-att-class="'partially_undelivered_line' if undelivered_move.splitted_stock_move_orig_id else 'completely_undelivered_line'"
>
<td>
<span
t-field="undelivered_move.product_id.default_code"
/>
</td>
<td>
<span t-field="undelivered_move.product_id.name" />
</td>
<td class="text-right">
<span t-field="undelivered_move.product_uom_qty" />
<span
groups="uom.group_uom"
t-field="undelivered_move.product_uom"
/>
</td>
</tr>
</t>
</tbody>
</table>
</t>
</template>
t-set="undelivered_moves"
t-value="all_moves.filtered(lambda l: l.state == 'cancel' and l.product_id.display_undelivered_in_picking and l.product_uom_qty > 0.0)"
/>
</t>
</t>
</xpath>

<template
id="report_delivery_document"
inherit_id="stock.report_delivery_document"
priority="200"
>
<xpath
expr="//table[@t-if=&quot;o.move_line_ids and o.state=='done'&quot;]"
position="after"
expr="//*[@t-if='not (o.backorder_ids and backorders)']"
position="attributes"
>
<t t-call="stock_picking_report_undelivered_product.undeliverd_product" />
<attribute name="t-if">not undelivered_moves</attribute>
</xpath>

<xpath expr="//tr[contains(@t-foreach, 'backorders')]" position="attributes">
<attribute name="t-foreach">undelivered_moves</attribute>
</xpath>

<xpath expr="//span[@t-field='bo_line.product_uom_qty']" position="attributes">
<attribute name="t-field" />
<attribute
name="t-esc"
>bo_line.product_uom_qty - bo_line.quantity</attribute>
</xpath>
</template>
</odoo>
Loading
Loading