[REF] stock: remove lead days and type on RR

- lead_days: number of days to add from today in order to define the
procurement request date.
- lead_type purpose is to define if supplier delays should be added
to procurement request date.

Those fields are problematic with the onboarding. The purpose is to
replace them with an automatic computation.

Task 1849912
This commit is contained in:
Arnold Moyaux
2020-01-09 12:17:38 +00:00
parent d81d12daaa
commit bc7d644049
2 changed files with 2 additions and 23 deletions
+2 -18
View File
@@ -6,7 +6,6 @@ from dateutil import relativedelta
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.osv import expression
@@ -63,12 +62,6 @@ class StockWarehouseOrderpoint(models.Model):
company_id = fields.Many2one(
'res.company', 'Company', required=True, index=True,
default=lambda self: self.env.company)
lead_days = fields.Integer(
'Lead Time', default=1,
help="Number of days after the orderpoint is triggered to receive the products or to order to the vendor")
lead_type = fields.Selection(
[('net', 'Days to get the products'), ('supplier', 'Days to purchase')], 'Lead Type',
required=True, default='supplier')
allowed_location_ids = fields.One2many(comodel_name='stock.location', compute='_compute_allowed_location_ids')
_sql_constraints = [
@@ -124,24 +117,15 @@ class StockWarehouseOrderpoint(models.Model):
raise UserError(_("Changing the company of this record is forbidden at this point, you should rather archive it and create a new one."))
return super().write(vals)
def _get_date_planned(self, product_qty, start_date):
days = self.lead_days or 0.0
if self.lead_type == 'supplier':
# These days will be substracted when creating the PO
days += self.product_id._select_seller(
quantity=product_qty,
date=fields.Date.context_today(self,start_date),
uom_id=self.product_uom).delay or 0.0
date_planned = start_date + relativedelta.relativedelta(days=days)
return date_planned.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
def _prepare_procurement_values(self, product_qty, date=False, group=False):
""" Prepare specific key for moves or other components that will be created from a stock rule
comming from an orderpoint. This method could be override in order to add other custom key that could
be used in move/po creation.
"""
date_planned = date or fields.Date.today()
return {
'date_planned': date or self._get_date_planned(product_qty, datetime.today()),
'date_planned': date_planned,
'warehouse_id': self.warehouse_id,
'orderpoint_id': self,
'group_id': group or self.group_id,
@@ -242,11 +242,6 @@
<field name="group_id" groups="stock.group_adv_location"/>
</div>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<label for="lead_days"/>
<div class="o_row">
<field name="lead_days"/>
<field name="lead_type"/>
</div>
</group>
</group>
</sheet>