From 586ae7a2cc6822a98426ead087acf37ae0076759 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Tue, 5 Nov 2024 12:11:08 +0100 Subject: [PATCH 1/2] IMP factor: add store attribute and filter --- account_factoring_receivable_balance/i18n/fr.po | 5 +++++ .../models/account_move.py | 1 + .../views/account_move.xml | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/account_factoring_receivable_balance/i18n/fr.po b/account_factoring_receivable_balance/i18n/fr.po index dd2b474..0582251 100644 --- a/account_factoring_receivable_balance/i18n/fr.po +++ b/account_factoring_receivable_balance/i18n/fr.po @@ -644,6 +644,11 @@ msgstr "Montant non taxé" msgid "Use Factor" msgstr "Utiliser le factor" +#. module: account_factoring_receivable_balance +#: model_terms:ir.ui.view,arch_db:account_factoring_receivable_balance.view_account_invoice_filter +msgid "Use factor" +msgstr "Utiliser le factor" + #. module: account_factoring_receivable_balance #: model:ir.model.fields,help:account_factoring_receivable_balance.field_res_company__factor_config_currency_id msgid "Use to configure account and journal" diff --git a/account_factoring_receivable_balance/models/account_move.py b/account_factoring_receivable_balance/models/account_move.py index 6424868..6a31893 100644 --- a/account_factoring_receivable_balance/models/account_move.py +++ b/account_factoring_receivable_balance/models/account_move.py @@ -13,6 +13,7 @@ class AccountMove(models.Model): use_factor = fields.Boolean( compute="_compute_use_factor", help="Depending on partner factor settings and skip factor field", + store=True, ) factor_journal_id = fields.Many2one( comodel_name="account.journal", diff --git a/account_factoring_receivable_balance/views/account_move.xml b/account_factoring_receivable_balance/views/account_move.xml index 39c3bbe..81f3fae 100644 --- a/account_factoring_receivable_balance/views/account_move.xml +++ b/account_factoring_receivable_balance/views/account_move.xml @@ -24,4 +24,20 @@ + + account.invoice.filter + account.move + + + + + + + + + From b202530c4274244cafb353c8efed9a1b3843b509 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Tue, 5 Nov 2024 15:35:28 +0100 Subject: [PATCH 2/2] 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