From fe39843be80ee11c33d64e3fb17a9ec64eb57d39 Mon Sep 17 00:00:00 2001 From: edescalona Date: Wed, 8 Jan 2025 18:19:19 -0500 Subject: [PATCH] [FIX] Showing in the Rental application the products marked with the can be rent check --- rental_base/models/product.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rental_base/models/product.py b/rental_base/models/product.py index b22a2ff4..a4ba36ad 100644 --- a/rental_base/models/product.py +++ b/rental_base/models/product.py @@ -1,6 +1,6 @@ # Part of rental-vertical See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import api, fields, models class ProductTemplate(models.Model): @@ -12,4 +12,15 @@ class ProductTemplate(models.Model): class ProductProduct(models.Model): _inherit = "product.product" - rental = fields.Boolean("Can be Rent", related="product_tmpl_id.rental", store=True) + rental = fields.Boolean( + "Can be Rent", compute="_compute_rental", inverse="_inverse_rental", store=True + ) + + @api.depends("product_tmpl_id.rental") + def _compute_rental(self): + for product in self: + product.rental = product.product_tmpl_id.rental + + def _inverse_rental(self): + for product in self: + product.product_tmpl_id.rental = product.rental