mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] contract: Terminate contract lines with last_date_invoiced if it is higher than terminate date from wizard
This commit is contained in:
@@ -6,6 +6,8 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 17.0\n"
|
"Project-Id-Version: Odoo Server 17.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2025-01-09 20:32+0000\n"
|
||||||
|
"PO-Revision-Date: 2025-01-09 20:32+0000\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@@ -1739,11 +1741,6 @@ msgstr ""
|
|||||||
msgid "Quarter(s)"
|
msgid "Quarter(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
|
||||||
#: model:ir.model.fields,field_description:contract.field_contract_contract__rating_ids
|
|
||||||
msgid "Ratings"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract__recurring_rule_type
|
#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract__recurring_rule_type
|
||||||
#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__recurring_rule_type
|
#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__recurring_rule_type
|
||||||
@@ -2078,6 +2075,18 @@ msgstr ""
|
|||||||
msgid "Terminate Contract Wizard"
|
msgid "Terminate Contract Wizard"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: contract
|
||||||
|
#: model:ir.model.fields,field_description:contract.field_contract_contract_terminate__terminate_with_last_date_invoiced
|
||||||
|
msgid "Terminate lines with last date invoiced"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: contract
|
||||||
|
#: model:ir.model.fields,help:contract.field_contract_contract_terminate__terminate_with_last_date_invoiced
|
||||||
|
msgid ""
|
||||||
|
"Terminate the contract lines with the last invoiced date if they cannot be "
|
||||||
|
"terminated with the date reported in the wizard."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: model:ir.model.fields,field_description:contract.field_contract_contract__is_terminated
|
#: model:ir.model.fields,field_description:contract.field_contract_contract__is_terminated
|
||||||
msgid "Terminated"
|
msgid "Terminated"
|
||||||
|
|||||||
@@ -2271,6 +2271,20 @@ msgstr "Finalizar contrato"
|
|||||||
msgid "Terminate Contract Wizard"
|
msgid "Terminate Contract Wizard"
|
||||||
msgstr "Asistente de finalización de contrato"
|
msgstr "Asistente de finalización de contrato"
|
||||||
|
|
||||||
|
#. module: contract
|
||||||
|
#: model:ir.model.fields,field_description:contract.field_contract_contract_terminate__terminate_with_last_date_invoiced
|
||||||
|
msgid "Terminate lines with last date invoiced"
|
||||||
|
msgstr "Finalizar líneas con la última fecha facturada"
|
||||||
|
|
||||||
|
#. module: contract
|
||||||
|
#: model:ir.model.fields,help:contract.field_contract_contract_terminate__terminate_with_last_date_invoiced
|
||||||
|
msgid ""
|
||||||
|
"Terminate the contract lines with the last invoiced date if they cannot be "
|
||||||
|
"terminated with the date reported in the wizard."
|
||||||
|
msgstr ""
|
||||||
|
"Terminar las lineas de los contratos con la ultima fecha facturada si no se "
|
||||||
|
"pueden terminar con la fecha informada en el asistente."
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: model:ir.model.fields,field_description:contract.field_contract_contract__is_terminated
|
#: model:ir.model.fields,field_description:contract.field_contract_contract__is_terminated
|
||||||
msgid "Terminated"
|
msgid "Terminated"
|
||||||
|
|||||||
@@ -685,12 +685,21 @@ class ContractContract(models.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _terminate_contract(
|
def _terminate_contract(
|
||||||
self, terminate_reason_id, terminate_comment, terminate_date
|
self,
|
||||||
|
terminate_reason_id,
|
||||||
|
terminate_comment,
|
||||||
|
terminate_date,
|
||||||
|
terminate_lines_with_last_date_invoiced=False,
|
||||||
):
|
):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if not self.env.user.has_group("contract.can_terminate_contract"):
|
if not self.env.user.has_group("contract.can_terminate_contract"):
|
||||||
raise UserError(_("You are not allowed to terminate contracts."))
|
raise UserError(_("You are not allowed to terminate contracts."))
|
||||||
self.contract_line_ids.filtered("is_stop_allowed").stop(terminate_date)
|
for line in self.contract_line_ids.filtered("is_stop_allowed"):
|
||||||
|
line.stop(
|
||||||
|
max(terminate_date, line.last_date_invoiced)
|
||||||
|
if terminate_lines_with_last_date_invoiced and line.last_date_invoiced
|
||||||
|
else terminate_date
|
||||||
|
)
|
||||||
self.write(
|
self.write(
|
||||||
{
|
{
|
||||||
"is_terminated": True,
|
"is_terminated": True,
|
||||||
|
|||||||
@@ -2295,6 +2295,15 @@ class TestContract(TestContractBase):
|
|||||||
"terminate_comment",
|
"terminate_comment",
|
||||||
to_date("2018-02-13"),
|
to_date("2018-02-13"),
|
||||||
)
|
)
|
||||||
|
# Try terminate contract line with last_date_invoiced allowed
|
||||||
|
self.contract._terminate_contract(
|
||||||
|
self.terminate_reason,
|
||||||
|
"terminate_comment",
|
||||||
|
to_date("2018-02-13"),
|
||||||
|
terminate_lines_with_last_date_invoiced=True,
|
||||||
|
)
|
||||||
|
self.assertTrue(self.contract.is_terminated)
|
||||||
|
self.assertEqual(self.acct_line.date_end, to_date("2018-02-14"))
|
||||||
|
|
||||||
def test_recurrency_propagation(self):
|
def test_recurrency_propagation(self):
|
||||||
# Existing contract
|
# Existing contract
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ class ContractContractTerminate(models.TransientModel):
|
|||||||
terminate_comment_required = fields.Boolean(
|
terminate_comment_required = fields.Boolean(
|
||||||
related="terminate_reason_id.terminate_comment_required"
|
related="terminate_reason_id.terminate_comment_required"
|
||||||
)
|
)
|
||||||
|
terminate_with_last_date_invoiced = fields.Boolean(
|
||||||
|
string="Terminate lines with last date invoiced",
|
||||||
|
help="Terminate the contract lines with the last invoiced date if they cannot "
|
||||||
|
"be terminated with the date reported in the wizard.",
|
||||||
|
)
|
||||||
|
|
||||||
def terminate_contract(self):
|
def terminate_contract(self):
|
||||||
for wizard in self:
|
for wizard in self:
|
||||||
@@ -32,5 +37,6 @@ class ContractContractTerminate(models.TransientModel):
|
|||||||
wizard.terminate_reason_id,
|
wizard.terminate_reason_id,
|
||||||
wizard.terminate_comment,
|
wizard.terminate_comment,
|
||||||
wizard.terminate_date,
|
wizard.terminate_date,
|
||||||
|
wizard.terminate_with_last_date_invoiced,
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
name="terminate_comment"
|
name="terminate_comment"
|
||||||
required="terminate_comment_required"
|
required="terminate_comment_required"
|
||||||
/>
|
/>
|
||||||
|
<field name="terminate_with_last_date_invoiced" />
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user