diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 005eecb29..99c61bdf1 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -11,7 +11,7 @@ { "name": "Recurring - Contracts Management", - "version": "13.0.2.9.0", + "version": "13.0.2.10.0", "category": "Contract Management", "license": "AGPL-3", "author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/contract/migrations/13.0.2.10.0/pre-migrate.py b/contract/migrations/13.0.2.10.0/pre-migrate.py new file mode 100644 index 000000000..ecad5784f --- /dev/null +++ b/contract/migrations/13.0.2.10.0/pre-migrate.py @@ -0,0 +1,18 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + fields_list = [ + ("date", "contract.contract", "contract_contract", "date", "date", "contract") + ] + openupgrade.add_fields(env, fields_list) + query = """ + UPDATE contract_contract + SET date = date_start + WHERE date IS NULL + """ + openupgrade.logged_query(env.cr, query) diff --git a/contract/models/abstract_contract.py b/contract/models/abstract_contract.py index 377f32f14..446ece48c 100644 --- a/contract/models/abstract_contract.py +++ b/contract/models/abstract_contract.py @@ -18,6 +18,11 @@ class ContractAbstractContract(models.AbstractModel): NO_SYNC = ["name", "partner_id", "company_id"] name = fields.Char(required=True) + date = fields.Date( + required=True, + default=lambda self: fields.Date.today(), + help="This is the date the contract is taken into account (e.g.: signature date)", + ) # Needed for avoiding errors on several inherited behaviors partner_id = fields.Many2one( comodel_name="res.partner", string="Partner", index=True diff --git a/contract/views/contract.xml b/contract/views/contract.xml index 710f080c5..e5a421f1b 100644 --- a/contract/views/contract.xml +++ b/contract/views/contract.xml @@ -103,6 +103,10 @@ +