Skip to content

Commit

Permalink
[IMP] rma: Calculate expected date in pickings based on the customer …
Browse files Browse the repository at this point in the history
…lead time
  • Loading branch information
JordiBForgeFlow committed Dec 2, 2024
1 parent 29787d9 commit 748d019
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rma/wizards/rma_make_picking.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (C) 2017-20 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

import time
from datetime import timedelta

from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT, float_compare
from odoo.tools import float_compare


class RmaMakePicking(models.TransientModel):
Expand Down Expand Up @@ -102,6 +102,7 @@ def _get_address_location(self, delivery_address_id, a_type):
def _get_procurement_data(self, item, group, qty, picking_type):
line = item.line_id
delivery_address_id = self._get_address(item)
date_planned = fields.Datetime.now()
location, warehouse, route = False, False, False
if picking_type == "incoming":
if line.customer_to_supplier:
Expand All @@ -117,6 +118,8 @@ def _get_procurement_data(self, item, group, qty, picking_type):
location = self._get_address_location(delivery_address_id, line.type)
warehouse = line.out_warehouse_id
route = line.out_route_id
if line.product_id.sale_delay:
date_planned = date_planned + timedelta(days=line.product_id.sale_delay)
if not route:
raise ValidationError(_("No route specified"))
if not warehouse:
Expand All @@ -126,7 +129,7 @@ def _get_procurement_data(self, item, group, qty, picking_type):
"group_id": group,
"origin": group and group.name or line.name,
"warehouse_id": warehouse,
"date_planned": time.strftime(DT_FORMAT),
"date_planned": date_planned,
"product_id": item.product_id,
"product_qty": qty,
"partner_id": delivery_address_id.id,
Expand Down

0 comments on commit 748d019

Please sign in to comment.