-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] stock_picking_report_undelivered_product: Migration to 18.0
TT54343
- Loading branch information
1 parent
6daeef9
commit 20cdb90
Showing
10 changed files
with
107 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,7 @@ Contributors | |
|
||
- Sergio Teruel <[email protected]> | ||
- Carlos Dauden <[email protected]> | ||
- Juan Carlos Oñate <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
stock_picking_report_undelivered_product/models/stock_move.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
> - Sergio Teruel \<<[email protected]>\> | ||
> - Carlos Dauden \<<[email protected]>\> | ||
> - Juan Carlos Oñate \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | ||
|
@@ -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( | ||
|
@@ -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( | ||
|
@@ -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
127
stock_picking_report_undelivered_product/views/report_deliveryslip.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="replace"> | ||
<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="o.move_line_ids and o.state=='done'"]" | ||
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="//td[@class='text-center w-auto']" position="replace"> | ||
<td class="text-center w-auto"> | ||
<span t-esc="bo_line.product_uom_qty - bo_line.quantity">3.00</span> | ||
<span t-field="bo_line.product_uom" groups="uom.group_uom">units</span> | ||
</td> | ||
</xpath> | ||
</template> | ||
</odoo> |
Oops, something went wrong.