Files
stock-logistics-warehouse/stock_orderpoint_move_link/models/stock.py
Thierry Ducrest 975cac1eae Fix stock_order_point_move_link get move values
The `order_point_id` can be set as an empty recordset by the core.
Which breaks later in a write.
2021-11-16 10:16:42 +01:00

35 lines
948 B
Python

# Copyright 2019 ForgeFlow, S.L., Ecosoft
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
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,
):
vals = super()._get_stock_move_values(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
)
if "orderpoint_id" in values and values["orderpoint_id"]:
vals["orderpoint_ids"] = [(4, values["orderpoint_id"].id)]
elif "orderpoint_ids" in values and values["orderpoint_ids"]:
vals["orderpoint_ids"] = [(4, o.id) for o in values["orderpoint_ids"]]
return vals