-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP]delivery_postlogistics:Migrated to 18.0
- Loading branch information
KAG
authored and
RUS
committed
Feb 5, 2025
1 parent
f9389fe
commit d6702a9
Showing
7 changed files
with
205 additions
and
28 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 |
---|---|---|
|
@@ -56,14 +56,13 @@ See `Log in <https://account.post.ch/selfadmin/?login&lang=en>`__ | |
|
||
To configure: | ||
|
||
- Go to Inventory -> Configuration -> Delivery -> Shipping Methods | ||
- Create new shipping methods for PostLogistics and set your login | ||
informations in the "PostLogistics" tab | ||
- Go to Inventory -> Configuration -> Delivery -> Delivery Packages to | ||
create the PostLogistics delivery packaging with the relevant Package | ||
Code (see section 8.10 of | ||
https://developer.post.ch/en/digital-commerce-api for available | ||
codes) | ||
- Go to Inventory -> Configuration -> Delivery -> Shipping Methods | ||
- Create new shipping methods for PostLogistics and set your login | ||
informations in the "PostLogistics" tab | ||
- Go to Inventory -> Configuration -> Delivery -> Delivery Packages to | ||
create the PostLogistics delivery packaging with the relevant Package | ||
Code (see section 8.10 of | ||
https://developer.post.ch/en/digital-commerce-api for available codes) | ||
|
||
Technical references | ||
-------------------- | ||
|
@@ -74,11 +73,11 @@ documentation <https://www.post.ch/en/business/a-z-of-subjects/dropping-off-mail | |
Known issues / Roadmap | ||
====================== | ||
|
||
- Integration of price webservice : | ||
https://www.post.ch/en/customer-center/all-online-services/preise-berechnen/info | ||
- Not sure if the recursive patch of suds is still needed as there's no | ||
need to use the integration WS anymore. However we still want to | ||
patch open to get meaningful error messages. | ||
- Integration of price webservice : | ||
https://www.post.ch/en/customer-center/all-online-services/preise-berechnen/info | ||
- Not sure if the recursive patch of suds is still needed as there's no | ||
need to use the integration WS anymore. However we still want to patch | ||
open to get meaningful error messages. | ||
|
||
Bug Tracker | ||
=========== | ||
|
@@ -101,31 +100,31 @@ Authors | |
Contributors | ||
------------ | ||
|
||
- Yannick Vaucher <[email protected]> | ||
- Yannick Vaucher <[email protected]> | ||
|
||
- Guewen Baconnier <[email protected]> | ||
- Guewen Baconnier <[email protected]> | ||
|
||
- Akim Juillerat <[email protected]> | ||
- Akim Juillerat <[email protected]> | ||
|
||
- Julien Coux <[email protected]> | ||
- Julien Coux <[email protected]> | ||
|
||
- Dung Tran <[email protected]> | ||
- Dung Tran <[email protected]> | ||
|
||
- Phuc Tran <[email protected]> | ||
- Phuc Tran <[email protected]> | ||
|
||
- Jacques-Etienne Baudoux <[email protected]> | ||
- Jacques-Etienne Baudoux <[email protected]> | ||
|
||
- `Trobz <https://trobz.com>`__: | ||
- `Trobz <https://trobz.com>`__: | ||
|
||
- Jack Le <[email protected]> | ||
- Jack Le <[email protected]> | ||
|
||
Other credits | ||
------------- | ||
|
||
The development of this module in version 14.0 and its migration from | ||
14.0 to 16.0 has been financially supported by: | ||
|
||
- Camptocamp | ||
- Camptocamp | ||
|
||
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,3 +1,5 @@ | ||
from . import test_postlogistics | ||
from . import test_sanitize_values | ||
from . import test_packaging_code | ||
from . import test_stock_picking | ||
from . import test_stock_move |
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
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 |
---|---|---|
@@ -0,0 +1,118 @@ | ||
from odoo import fields | ||
|
||
from .common import TestPostlogisticsCommon | ||
|
||
|
||
class TestStockMove(TestPostlogisticsCommon): | ||
@classmethod | ||
def setUpClass(self): | ||
super().setUpClass() | ||
|
||
res_partner_env = self.env["res.partner"] | ||
product_env = self.env["product.product"] | ||
sale_order_env = self.env["sale.order"] | ||
sale_order_line_env = self.env["sale.order.line"] | ||
stock_picking_env = self.env["stock.picking"] | ||
stock_move_env = self.env["stock.move"] | ||
self.partner = res_partner_env.create( | ||
{ | ||
"name": "Test Partner", | ||
"type": "delivery", | ||
"street": "123 Test St.", | ||
"city": "Test City", | ||
"zip": 234567, | ||
"country_id": self.env.ref("base.us").id, | ||
} | ||
) | ||
|
||
self.product = product_env.create( | ||
{ | ||
"name": "Test Product", | ||
"uom_id": self.env.ref("uom.product_uom_unit").id, | ||
} | ||
) | ||
|
||
self.sale_order = sale_order_env.create( | ||
{ | ||
"partner_id": self.partner.id, | ||
"commitment_date": fields.Datetime.now(), | ||
"order_line": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"product_id": self.env.ref("product.product_product_1").id, | ||
"product_uom_qty": 1, | ||
"price_unit": 100, | ||
}, | ||
) | ||
], | ||
} | ||
) | ||
|
||
self.sale_order_line = sale_order_line_env.create( | ||
{ | ||
"order_id": self.sale_order.id, | ||
"product_id": self.product.id, | ||
"product_uom_qty": 1, | ||
"price_unit": 100, | ||
} | ||
) | ||
|
||
self.picking = stock_picking_env.create( | ||
{ | ||
"name": "Test Picking", | ||
"sale_id": self.sale_order.id, | ||
"partner_id": self.partner.id, | ||
"picking_type_id": self.env.ref("stock.picking_type_out").id, | ||
"delivery_type": "postlogistics", | ||
} | ||
) | ||
|
||
self.stock_move = stock_move_env.create( | ||
{ | ||
"name": "Test Stock Move", | ||
"product_id": self.product.id, | ||
"product_uom_qty": 1, | ||
"product_uom": self.product.uom_id.id, | ||
"sale_line_id": self.sale_order_line.id, | ||
"picking_id": self.picking.id, | ||
"location_id": self.env.ref("stock.stock_location_stock").id, | ||
"location_dest_id": self.env.ref("stock.stock_location_customers").id, | ||
} | ||
) | ||
|
||
def test_get_new_picking_values(self): | ||
"""Test if 'delivery_fixed_date' is included in the stock move values for a | ||
new picking.""" | ||
stock_move_vals = self.stock_move._get_new_picking_values() | ||
self.assertIn( | ||
"delivery_fixed_date", | ||
stock_move_vals, | ||
"The 'delivery_fixed_date' should be present in the returned values.", | ||
) | ||
|
||
def test_cod_amount_no_sale_order(self): | ||
"""Test COD amount when picking has no linked sale order.""" | ||
picking = self.picking.create( | ||
{ | ||
"partner_id": self.env.ref("base.res_partner_1").id, | ||
"location_id": self.env.ref("stock.stock_location_stock").id, | ||
"location_dest_id": self.env.ref("stock.stock_location_customers").id, | ||
"picking_type_id": self.env.ref("stock.picking_type_out").id, | ||
} | ||
) | ||
self.assertEqual( | ||
picking.postlogistics_cod_amount(), | ||
0.0, | ||
"COD amount should be 0.0 when no sale order is linked to the picking.", | ||
) | ||
|
||
def test_cod_amount_single_order_and_picking(self): | ||
"""Test COD amount for a single sale order and picking.""" | ||
self.picking.sale_id = self.sale_order | ||
self.assertEqual( | ||
self.picking.postlogistics_cod_amount(), | ||
self.sale_order.amount_total, | ||
"The COD amount should match the total amount of the sale order.", | ||
) |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from odoo.exceptions import UserError | ||
|
||
from .common import TestPostlogisticsCommon | ||
|
||
|
||
class TestStockPicking(TestPostlogisticsCommon): | ||
@classmethod | ||
def setUpClass(self): | ||
super().setUpClass() | ||
|
||
res_partner_env = self.env["res.partner"] | ||
stock_picking_env = self.env["stock.picking"] | ||
product_env = self.env["product.product"] | ||
delivery_carrier_env = self.env["delivery.carrier"] | ||
|
||
self.partner = res_partner_env.create( | ||
{ | ||
"name": "Test Partner", | ||
"street": "123 Test St.", | ||
"city": "Test City", | ||
"zip": 234567, | ||
"country_id": self.env.ref("base.us").id, | ||
} | ||
) | ||
self.picking = stock_picking_env.create( | ||
{ | ||
"name": "Test Picking", | ||
"delivery_type": "postlogistics", | ||
"picking_type_id": self.env.ref("stock.picking_type_out").id, | ||
"partner_id": self.partner.id, | ||
} | ||
) | ||
self.product = product_env.create({"name": "Test Product"}) | ||
self.carrier = delivery_carrier_env.create( | ||
{ | ||
"name": "PostLogistics", | ||
"delivery_type": "postlogistics", | ||
"product_id": self.product.id, | ||
} | ||
) | ||
|
||
def test_action_generate_carrier_label_no_carrier(self): | ||
"""Test that an error is raised when generating a carrier label without a | ||
carrier.""" | ||
with self.assertRaisesRegex(UserError, "Please, set a carrier."): | ||
self.picking.action_generate_carrier_label() |