[FIX] stock: be able to have infinite forecast in replenishment

Currently if you require internal transit pickings between warehouse,
it's not possible to use security days in order to plan them and
receive products on time (e.g the second warehouse need times to
manufacture them).

Also the deadline are impacted by security days, so it's hard to
do at the same time replenish on order an use the orderpoints.
(either you see them late in orderpoints or they are plan way to
early in replenish on order process)

To avoid this kind of issue this PR introduces a visibility days
global on the orderpoint. It's call `stock.visibility_days`.
It will add the number of days in the orderpoint forecast date but
it doesn't impact the documents (PO, MO) planned dates.

It could for example always show the quantity in 1 years if people
don't need the just in time feature and don't care to store for a
long period of time.

closes odoo/odoo#110303

X-original-commit: 24816bfee9825fecd60bd24a92d1496f30522b8e
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Arnold Moyaux
2023-01-19 12:30:50 +01:00
parent c40320eb15
commit fe03a58e62
3 changed files with 15 additions and 0 deletions
+7
View File
@@ -9508,3 +9508,10 @@ msgstr ""
msgid ""
"{{ object.company_id.name }} Delivery Order (Ref {{ object.name or 'n/a' }})"
msgstr ""
#. module: stock
#. odoo-python
#: code:addons/stock/models/stock_rule.py:0
#, python-format
msgid "Global Visibility Days"
msgstr ""
+3
View File
@@ -506,6 +506,9 @@ class StockWarehouseOrderpoint(models.Model):
origin = orderpoint.name
if float_compare(orderpoint.qty_to_order, 0.0, precision_rounding=orderpoint.product_uom.rounding) == 1:
date = orderpoint._get_orderpoint_procurement_date()
global_visibility_days = self.env['ir.config_parameter'].sudo().get_param('stock.visibility_days')
if global_visibility_days:
date -= relativedelta.relativedelta(days=int(global_visibility_days))
values = orderpoint._prepare_procurement_values(date=date)
procurements.append(self.env['procurement.group'].Procurement(
orderpoint.product_id, orderpoint.qty_to_order, orderpoint.product_uom,
+5
View File
@@ -355,6 +355,9 @@ class StockRule(models.Model):
:rtype: tuple[int, list[str, str]]
"""
delay = sum(self.filtered(lambda r: r.action in ['pull', 'pull_push']).mapped('delay'))
global_visibility_days = self.env['ir.config_parameter'].sudo().get_param('stock.visibility_days')
if global_visibility_days:
delay += int(global_visibility_days)
if self.env.context.get('bypass_delay_description'):
delay_description = []
else:
@@ -363,6 +366,8 @@ class StockRule(models.Model):
for rule in self
if rule.action in ['pull', 'pull_push'] and rule.delay
]
if global_visibility_days:
delay_description.append((_('Global Visibility Days'), _('+ %d day(s)') % int(global_visibility_days)))
return delay, delay_description