Skip to content

Commit

Permalink
[FIX] Showing in the Rental application the products marked with the …
Browse files Browse the repository at this point in the history
…can be rent check
  • Loading branch information
edescalona committed Jan 8, 2025
1 parent f2a47ca commit fe39843
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions rental_base/models/product.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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

Check warning on line 26 in rental_base/models/product.py

View check run for this annotation

Codecov / codecov/patch

rental_base/models/product.py#L26

Added line #L26 was not covered by tests

0 comments on commit fe39843

Please sign in to comment.