Permalink
Browse files

[IMP] stock: propagation of scheduled date based on general settings …

…and not depending on stock rules

Task ID : 1913401
  • Loading branch information...
hsh-odoo committed Dec 17, 2018
1 parent 4e14a6e commit 5ac44edb86b1950f93f0f9587a3606581447ec7c
@@ -8,6 +8,9 @@ class Company(models.Model):
_inherit = "res.company"

propagation_minimum_delta = fields.Integer('Minimum Delta for Propagation of a Date Change on moves linked together', default=1)
use_propagation_minimum_delta = fields.Boolean(
string="No Rescheduling Propagation",
help="Rescheduling applies to any chain of operations (e.g. Make To Order, Pick Pack Ship). In the case of MTO sales, a vendor delay (updated incoming date) impacts the expected delivery date to the customer. \n This option allows to not propagate the rescheduling if the change is not critical.")
internal_transit_location_id = fields.Many2one(
'stock.location', 'Internal Transit Location', on_delete="restrict",
help="Technical field used for resupply routes between warehouses that belong to this company")
@@ -28,6 +28,8 @@ class ResConfigSettings(models.TransientModel):
group_warning_stock = fields.Boolean("Warnings for Stock", implied_group='stock.group_warning_stock')
propagation_minimum_delta = fields.Integer(related='company_id.propagation_minimum_delta', string="Minimum Delta for Propagation", readonly=False)
use_propagation_minimum_delta = fields.Boolean(
related='company_id.use_propagation_minimum_delta',
readonly=False,
string="No Rescheduling Propagation",
oldname='default_new_propagation_minimum_delta',
config_parameter='stock.use_propagation_minimum_delta',
@@ -423,7 +423,8 @@ def write(self, vals):
current_date = move.date_expected
new_date = fields.Datetime.from_string(vals.get(propagated_date_field))
delta_days = (new_date - current_date).total_seconds() / 86400
if abs(delta_days) >= move.company_id.propagation_minimum_delta:
use_propagation_minimum_delta = move.company_id.use_propagation_minimum_delta
if use_propagation_minimum_delta and abs(delta_days) >= move.company_id.propagation_minimum_delta:
old_move_date = move.move_dest_ids[0].date_expected
new_move_date = (old_move_date + relativedelta.relativedelta(days=delta_days or 0)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
propagated_changes_dict['date_expected'] = new_move_date

0 comments on commit 5ac44ed

Please sign in to comment.