Skip to content

Commit

Permalink
[IMP] repair_sale_order: Update link from stock move to repair order
Browse files Browse the repository at this point in the history
  • Loading branch information
BernatPForgeFlow committed Aug 21, 2023
1 parent d9fe990 commit f21207c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions repair_sale_order/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import repair_order
from . import sale_order
from . import repair_type
from . import stock_rule
9 changes: 9 additions & 0 deletions repair_sale_order/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,12 @@ class SaleOrderLine(models.Model):
string="Repair lines",
required=False,
)

def _prepare_procurement_values(self, group_id=False):
res = super()._prepare_procurement_values(group_id)
res.update(
{
"repair_ids": self.repair_line_ids.mapped("repair_id.id"),
}
)
return res
38 changes: 38 additions & 0 deletions repair_sale_order/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 ForgeFlow S.L. (https://forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.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_dest_id,
name,
origin,
company_id,
values,
):
res = super()._get_stock_move_values(
product_id,
product_qty,
product_uom,
location_dest_id,
name,
origin,
company_id,
values,
)
repair_ids = values.get("repair_ids", False)
if repair_ids:
res.update(
{
"repair_id": repair_ids[0],
}
)
return res

0 comments on commit f21207c

Please sign in to comment.