Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 committed Jan 17, 2025
1 parent 0ff8e28 commit f1277c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
12 changes: 7 additions & 5 deletions sale_lead_time_profile/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ def _compute_delivery_lead_time(self):
)
if not profiles:
continue
best_profile = max(
profiles,
default=None,
key=lambda r: r._get_score(rec.warehouse_id, rec.partner_shipping_id),
profile_scores = {
profile: profile._get_score(rec.warehouse_id, rec.partner_shipping_id)
for profile in profiles
}
best_profile = max(profile_scores, key=profile_scores.get, default=None)
rec.delivery_lead_time = (
best_profile.lead_time if profile_scores[best_profile] > 0 else 0.00
)
rec.delivery_lead_time = best_profile.lead_time
9 changes: 2 additions & 7 deletions sale_lead_time_profile/tests/test_sale_lead_time_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ def setUpClass(cls):
cls.partner = cls.env["res.partner"].create(
{
"name": "Partner",
}
)
cls.delivery_address = cls.env["res.partner"].create(
{
"name": "Delivery Address",
"parent_id": cls.partner.id,
"country_id": cls.env.ref("base.us").id,
}
)
cls.warehouse = cls.env["stock.warehouse"].create(
Expand Down Expand Up @@ -79,7 +74,7 @@ def test_sale_order_lead_time_profile(self):
)

# assign partner_id to profile
self.lead_time_profile_1.partner_id = self.delivery_address.id
self.lead_time_profile_1.partner_id = self.partner.id
sale_order = self.create_and_confirm_sale_order()
self.assertTrue(sale_order.picking_ids)
self.assertEqual(sale_order.delivery_lead_time, 3.0)
Expand Down

0 comments on commit f1277c7

Please sign in to comment.