Files
contract/contract/models/contract_modification.py
Jean-Charles Drubay 119b5b6700 [MIG] contract: Migration to 15.0
Most changes are related to the switch from jinja to qweb in mail templates.

Also included:
- convert deprecated onchange that returns a domain and other deprecation warnings
  (see below)
- Add migration scripts from version 14.0 (force the update of the mail templates)
- Fix warnings from pre-commit checks

Fixes depreciation warnings:

- onchange method ContractAbstractContractLine._onchange_product_id returned
  a domain, this is deprecated
- SavepointCase is deprecated:
  https://github.com/odoo/odoo/blob/15.0/odoo/tests/common.py#L742
- assertDictContainsSubset: According to:
  https://stackoverflow.com/questions/20050913/python-unittests-assertdictcontainssubset-recommended-alternative
2021-11-09 10:08:29 +07:00

39 lines
1.1 KiB
Python

# Copyright 2020 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class ContractModification(models.Model):
_name = "contract.modification"
_description = "Contract Modification"
_order = "date desc"
date = fields.Date(required=True)
description = fields.Text(required=True)
contract_id = fields.Many2one(
string="Contract",
comodel_name="contract.contract",
required=True,
ondelete="cascade",
index=True,
)
sent = fields.Boolean(default=False)
@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
if not self.env.context.get("bypass_modification_send"):
records.check_modification_ids_need_sent()
return records
def write(self, vals):
res = super().write(vals)
if not self.env.context.get("bypass_modification_send"):
self.check_modification_ids_need_sent()
return res
def check_modification_ids_need_sent(self):
self.mapped("contract_id")._modification_mail_send()