Skip to content
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
24 changes: 18 additions & 6 deletions contract_line_successor/models/contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,29 @@ def _delay(self, delay_delta):
}
)

def _prepare_value_for_stop(self, date_end, manual_renew_needed):
def _prepare_value_for_stop_base(self, date_end, manual_renew_needed):
"""
Values that must always be applied when a line is stopped, whether
or not date_end itself is being pushed earlier.

This is the extension point for any module that needs to set values
on stop() even when the line's date_end doesn't move.
Modules should override this method to add their own
fields here rather , so those fields
are set in every case, not only when date_end is shortened.
"""
self.ensure_one()
return {
"date_end": date_end,
"is_auto_renew": False,
"manual_renew_needed": manual_renew_needed,
}

def _prepare_value_for_stop(self, date_end, manual_renew_needed):
self.ensure_one()
vals = self._prepare_value_for_stop_base(date_end, manual_renew_needed)
vals["date_end"] = date_end
return vals

def stop(self, date_end, manual_renew_needed=False, post_message=True):
"""
Put date_end on contract line
Expand Down Expand Up @@ -441,10 +456,7 @@ def stop(self, date_end, manual_renew_needed=False, post_message=True):
rec.contract_id.message_post(body=msg)
else:
rec.write(
{
"is_auto_renew": False,
"manual_renew_needed": manual_renew_needed,
}
rec._prepare_value_for_stop(rec.date_end, manual_renew_needed)
)
return True

Expand Down
Loading