Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion subscription_oca/models/sale_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ def write(self, values):
if record.stage_id.type == "in_progress":
record.in_progress = True
today = date.today()
record.date_start = today
Comment thread
cvinh marked this conversation as resolved.
if not record.date_start:
record.date_start = today
record.calculate_recurring_next_date(today)
elif record.stage_id.type == "post":
record.close_reason_id = values.get("close_reason_id", False)
Expand Down
12 changes: 12 additions & 0 deletions subscription_oca/tests/test_subscription_oca.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ def setUpClass(cls):
"type": "pre",
}
)
cls.stage_3 = cls.env["sale.subscription.stage"].create(
{
"name": "Test Sub Stage 3 in progress",
"type": "in_progress",
}
)
cls.tag = cls.env["sale.subscription.tag"].create(
{
"name": "Test Tag",
Expand Down Expand Up @@ -631,6 +637,12 @@ def test_open_subscription(self):
action = invoice.action_open_subscription()
self.assertEqual(action["res_id"], self.sub1.id)

def test_subscription_oca_date_start(self):
self.sub6.write({"stage_id": self.stage_3})
self.assertEqual(fields.Date.to_string(self.sub6.date_start), "2099-01-01")
self.sub3.write({"stage_id": self.stage_3})
self.assertEqual(self.sub3.date_start, fields.Date.today())

def _collect_all_sub_test_results(self, subscription):
"""Creates the invoice of a subscription and returns its data
:param subscription: subscription to invoice
Expand Down
Loading