Files
stock-logistics-warehouse/stock_warehouse_calendar/models/stock_rule.py
2021-02-12 13:10:46 +01:00

39 lines
998 B
Python

# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from datetime import datetime
from odoo import models
class StockRule(models.Model):
_inherit = "stock.rule"
def _get_stock_move_values(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
):
res = super(StockRule, self)._get_stock_move_values(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
)
warehouse = self.propagate_warehouse_id or self.warehouse_id
if warehouse.calendar_id and self.delay:
date = warehouse.wh_plan_days(values["date_planned"], -1 * self.delay)
if date > datetime.now():
res["date"] = date
return res