-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA#70572 [14.0][FIX] stock_orderpoint_scheduled_date: get lead days f… (
#204)
- Loading branch information
Showing
5 changed files
with
101 additions
and
27 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
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,28 @@ | ||
# © 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models, fields, _ | ||
|
||
|
||
class StockRule(models.Model): | ||
_inherit = "stock.rule" | ||
|
||
def _get_lead_days(self, product): | ||
"""Add the delay from the manually entered scheduled date in the replenishment | ||
order to the cumulative delay and cumulative description. | ||
""" | ||
delay, delay_description = super()._get_lead_days(product) | ||
scheduled_date = self.env.context.get("scheduled_date") | ||
bypass_delay_description = self.env.context.get( | ||
"bypass_delay_description", False | ||
) | ||
if scheduled_date: | ||
# Convert the scheduled date from string to UTC datetime | ||
manual_delay = (scheduled_date - fields.Datetime.now()).days | ||
delay += manual_delay | ||
if not bypass_delay_description: | ||
delay_description += ( | ||
"<tr><td>%s</td><td class='text-right'>+ %d %s</td></tr>" | ||
% (_("Manual Lead Time"), manual_delay, _("day(s)")) | ||
) | ||
return delay, delay_description |
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