From b202530c4274244cafb353c8efed9a1b3843b509 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Tue, 5 Nov 2024 15:35:28 +0100 Subject: [PATCH] UPD _compute_use_factor --- .../models/account_move.py | 12 ++++++++---- .../views/account_move.xml | 10 ++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/account_factoring_receivable_balance/models/account_move.py b/account_factoring_receivable_balance/models/account_move.py index 6a31893..3074221 100644 --- a/account_factoring_receivable_balance/models/account_move.py +++ b/account_factoring_receivable_balance/models/account_move.py @@ -1,7 +1,7 @@ # © 2023 David BEAL @ Akretion # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import api, fields, models class AccountMove(models.Model): @@ -21,14 +21,18 @@ class AccountMove(models.Model): store=False, ) + @api.depends( + "factor_journal_id", + "factor_journal_id.factor_start_date", + "factor_journal_id.factor_invoice_journal_ids", + ) def _compute_use_factor(self): for rec in self: use_factor = False rec = rec.with_company(rec.company_id.id) - factor_journal = rec.commercial_partner_id.factor_journal_id - if factor_journal: + if rec.factor_journal_id: # TODO replace by adhoc odoo method : domain to python expression - domain = factor_journal._get_domain_for_factor() + domain = rec.factor_journal_id._get_domain_for_factor() domain.extend([("id", "=", rec.id), ("skip_factor", "=", False)]) if rec.search(domain): use_factor = True diff --git a/account_factoring_receivable_balance/views/account_move.xml b/account_factoring_receivable_balance/views/account_move.xml index 81f3fae..f07c546 100644 --- a/account_factoring_receivable_balance/views/account_move.xml +++ b/account_factoring_receivable_balance/views/account_move.xml @@ -24,6 +24,16 @@ + + account.move + + + + + + + + account.invoice.filter account.move