Skip to content

Commit

Permalink
Merge PR #134 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jul 10, 2024
2 parents 7f3875e + d97ee4b commit 9c357f1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions resource_booking/migrations/15.0.1.4.0/noupdate_changes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='utf-8' ?>
<odoo>
<record id="rule_resource_booking_portal" model="ir.rule">
<field
name="domain_force"
>['|', ('partner_ids', 'child_of', user.partner_id.ids), ('message_partner_ids', 'child_of', user.partner_id.ids)]</field>
</record>
<record id="rule_resource_booking_user" model="ir.rule">
<field
name="domain_force"
>['|', '|', ('partner_ids', 'child_of', user.partner_id.ids), ('message_partner_ids', 'child_of', user.partner_id.ids), ('combination_id.resource_ids.user_id', 'in', user.ids)]</field>
</record>
</odoo>
3 changes: 3 additions & 0 deletions resource_booking/migrations/15.0.1.4.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ def convert_resource_booking_partners(env):
def migrate(env, version):
"""Put partner_id in partner_ids"""
convert_resource_booking_partners(env)
openupgrade.load_data(
env.cr, "resource_booking", "migrations/15.0.1.4.0/noupdate_changes.xml"
)
9 changes: 9 additions & 0 deletions resource_booking/models/resource_booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class ResourceBooking(models.Model):
comodel_name="res.partner",
compute="_compute_partner_id",
inverse="_inverse_partner_id",
search="_search_partner_id",
readonly=False,
string="Requester",
)
Expand Down Expand Up @@ -228,6 +229,14 @@ def _inverse_partner_id(self):
for one in self:
one.partner_ids = one.partner_id

@api.model
def _search_partner_id(self, operator, value):
"""Overwrite this for security, partner_id field is not stored and if we search
for it by mistake (or out of ignorance) we will get all the records.
To avoid this behavior, we search for the correct field: partner_ids
"""
return [("partner_ids", operator, value)]

@api.model
def _default_user_id(self):
return self.env.user
Expand Down

0 comments on commit 9c357f1

Please sign in to comment.