Skip to content

Commit

Permalink
[FIX] delivery_schenker: Do not use number_of_packages
Browse files Browse the repository at this point in the history
Otherwise in a scenario with a transfer including moves with packages
and without the wrong amount of pieces is send
Therefore also the dependency to delivery_package_number can be removed
  • Loading branch information
mt-software-de committed May 20, 2024
1 parent e54c126 commit 01d4b88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion delivery_schenker/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["delivery_package_number", "delivery_state"],
"depends": ["delivery_state"],
"external_dependencies": {"python": ["zeep"]},
"data": [
"views/delivery_schenker_view.xml",
Expand Down
17 changes: 11 additions & 6 deletions delivery_schenker/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def _schenker_shipping_information_with_packages(self, picking):
for package in picking.package_ids
]

def _schenker_shipping_information_without_packages_volume(self, picking):
def _schenker_shipping_information_without_packages_volume(self, move_lines):
# Obviously products should be well configured. This parameter is mandatory.
return sum(
[
Expand All @@ -416,13 +416,16 @@ def _schenker_shipping_information_without_packages_volume(self, picking):
ml.qty_done, ml.product_id.uom_id
),
)
for ml in picking.move_line_ids
for ml in move_lines
if not ml.result_package_id
]
)

def _schenker_shipping_information_without_packages(self, picking):
if all(move_line.result_package_id for move_line in picking.move_line_ids):
move_lines_without_package = picking.move_line_ids.filtered(
lambda ml: not ml.result_package_id
)
if not move_lines_without_package:
return []
weight = picking.shipping_weight or picking.weight
return [
Expand All @@ -432,14 +435,16 @@ def _schenker_shipping_information_without_packages(self, picking):
"cargoDesc": picking.name,
# For a more complex solution use packaging properly
"grossWeight": self._schenker_shipping_information_round_dimension(
weight / picking.number_of_packages
weight
),
"volume": self._schenker_shipping_information_round_dimension(
self._schenker_shipping_information_without_packages_volume(picking)
self._schenker_shipping_information_without_packages_volume(
move_lines_without_package
)
),
"packageType": self.schenker_default_packaging_id.shipper_package_code,
"stackable": self.schenker_default_packaging_id.schenker_stackable,
"pieces": picking.number_of_packages,
"pieces": 1,
}
]

Expand Down

0 comments on commit 01d4b88

Please sign in to comment.