Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] rma: Calculate expected date in pickings based on the customer lead time #563

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading