Files
Denis Roussel 897ff24882 [14.0][IMP] contract_sale_generation
Use the generation_type field defined now in contract base module.

Improve tests
2022-01-26 15:23:33 +01:00

25 lines
832 B
Python

# Copyright 2021 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class SaleOrder(models.Model):
_inherit = "sale.order"
contract_auto_confirm = fields.Boolean(
compute="_compute_contract_auto_confirm",
help="This is a technical field in order to know if the order should"
"be automatically confirmed if generated by contract.",
)
def _compute_contract_auto_confirm(self):
sale_auto_confirm = self.filtered(
lambda sale: any(
line.contract_line_id.contract_id.sale_autoconfirm
for line in sale.order_line
)
)
sale_auto_confirm.contract_auto_confirm = True
(self - sale_auto_confirm).contract_auto_confirm = False