From 4160e3511207132eb11a1a1850b9a13d4eb991e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Wed, 4 Jun 2025 18:20:59 +0200 Subject: [PATCH] [IMP] donation_base: compute is_donation Add a new field 'is_donation' so that we can easily filter which products are donation and which are not without listing all the values for 'detailed_type'. --- donation_base/models/product.py | 6 ++++++ donation_base/views/product.xml | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/donation_base/models/product.py b/donation_base/models/product.py index 6bce84c23..e6b0f33cf 100644 --- a/donation_base/models/product.py +++ b/donation_base/models/product.py @@ -10,6 +10,7 @@ class ProductTemplate(models.Model): _inherit = "product.template" + is_donation = fields.Boolean(compute="_compute_is_donation", store=True) detailed_type = fields.Selection( selection_add=[ ("donation", "Donation"), @@ -32,6 +33,11 @@ class ProductTemplate(models.Model): help="Specify if the product is eligible for a tax receipt", ) + @api.depends("detailed_type") + def _compute_is_donation(self): + for product in self: + product.is_donation = product.detailed_type.startswith("donation") + @api.depends("detailed_type") def _compute_tax_receipt_ok(self): for product in self: diff --git a/donation_base/views/product.xml b/donation_base/views/product.xml index d2c0c3cde..dcc7b6c0d 100644 --- a/donation_base/views/product.xml +++ b/donation_base/views/product.xml @@ -15,7 +15,7 @@ @@ -33,10 +33,10 @@ - +