Sélectionner une révision Git
Bifurcation depuis
Le Filament / Confédération Générale des SCOP / cgscop_tantiemo
Le projet source a une visibilité limitée.
account_invoice.py 1,52 Kio
# Copyright 2022 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class AccountInvoice(models.Model):
_inherit = "account.invoice"
with_detail = fields.Boolean("Facture avec détail", default=False)
employee_allocation_ids = fields.One2many(
comodel_name="account.invoice.employee.assign",
inverse_name="invoice_id",
string="Ventilation facture",
)
is_allocated = fields.Boolean(
string="Facture ventilée",
compute="_compute_allocation",
store=True,
default=False,
)
is_allocation_error = fields.Boolean(
string="Erreur de ventilation",
compute="_compute_allocation",
store=True,
default=False,
)
# ------------------------------------------------------
# Computed field
# ------------------------------------------------------
@api.depends("employee_allocation_ids", "employee_allocation_ids.percentage")
@api.multi
def _compute_allocation(self):
for invoice in self:
if invoice.employee_allocation_ids:
invoice.is_allocated = True
if sum(invoice.employee_allocation_ids.mapped("percentage")) != 100:
invoice.is_allocation_error = True
else:
invoice.is_allocation_error = False
else:
invoice.is_allocated = False
invoice.is_allocation_error = False