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

[16.0][FIX] stock_picking_delivery_link: Test compatibility with purchase #781

Merged
Changes from all commits
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
22 changes: 22 additions & 0 deletions stock_picking_delivery_link/tests/test_delivery_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
"product_id": test_carrier_product.id,
}
)
# We need to know if purchase module is installed
cls.purchase_installed = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is cleaner to use

Suggested change
cls.purchase_installed = False
cls.purchase_installed = cls.env.ref("base.module_purchase").state == "installed"

if "purchased_product_qty" in cls.env["product.product"]._fields:
cls.purchase_installed = True
cls.vendor = cls.env["res.partner"].create({"name": "Test vendor"})
cls.product.write(

Check warning on line 34 in stock_picking_delivery_link/tests/test_delivery_link.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_delivery_link/tests/test_delivery_link.py#L32-L34

Added lines #L32 - L34 were not covered by tests
{
"seller_ids": [(0, 0, {"partner_id": cls.vendor.id})],
}
)

def test_ship_data_from_pick(self):
move1 = self._create_move(
Expand Down Expand Up @@ -123,6 +133,12 @@
)
ship_move._assign_picking()
ship_move._action_confirm()
# Confirm purchase order
if self.purchase_installed:
purchase = self.env["purchase.order"].search(

Check warning on line 138 in stock_picking_delivery_link/tests/test_delivery_link.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_delivery_link/tests/test_delivery_link.py#L138

Added line #L138 was not covered by tests
[("partner_id", "=", self.vendor.id)]
)
purchase.button_confirm()

Check warning on line 141 in stock_picking_delivery_link/tests/test_delivery_link.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_delivery_link/tests/test_delivery_link.py#L141

Added line #L141 was not covered by tests
pick_move = ship_move.move_orig_ids[0]
pick_picking = pick_move.picking_id
ship_picking = ship_move.picking_id
Expand Down Expand Up @@ -170,6 +186,12 @@
)
ship_move._assign_picking()
ship_move._action_confirm()
# Confirm purchase order
if self.purchase_installed:
purchase = self.env["purchase.order"].search(

Check warning on line 191 in stock_picking_delivery_link/tests/test_delivery_link.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_delivery_link/tests/test_delivery_link.py#L191

Added line #L191 was not covered by tests
[("partner_id", "=", self.vendor.id)]
)
purchase.button_confirm()

Check warning on line 194 in stock_picking_delivery_link/tests/test_delivery_link.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_delivery_link/tests/test_delivery_link.py#L194

Added line #L194 was not covered by tests
pick_move = ship_move.move_orig_ids[0]
pick_picking = pick_move.picking_id
ship_picking = ship_move.picking_id
Expand Down
Loading