-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] resource_booking: Button (partner -> booking)
- Loading branch information
1 parent
c480d0f
commit c3a89da
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
resource_booking_count = fields.Integer( | ||
compute="_compute_resource_booking_count", string="Resource Booking Count" | ||
) | ||
resource_booking_ids = fields.One2many( | ||
"resource.booking", "partner_id", string="Bookings" | ||
) | ||
|
||
def _compute_resource_booking_count(self): | ||
for p in self: | ||
p.resource_booking_count = len(p.resource_booking_ids) | ||
|
||
def action_view_resource_booking(self): | ||
self.ensure_one() | ||
action = self.env["ir.actions.actions"]._for_xml_id( | ||
"resource_booking.resource_booking_action" | ||
) | ||
action["context"] = { | ||
"default_partner_id": self.id, | ||
} | ||
return action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="view_partner_form" model="ir.ui.view"> | ||
<field name="model">res.partner</field> | ||
<field name="type">form</field> | ||
<field name="inherit_id" ref="base.view_partner_form" /> | ||
<field name="arch" type="xml"> | ||
<div name="button_box" position="inside"> | ||
<button | ||
class="oe_stat_button" | ||
type="object" | ||
name="action_view_resource_booking" | ||
groups="resource_booking.group_user" | ||
icon="fa-calendar" | ||
> | ||
<field | ||
string="Bookings" | ||
name="resource_booking_count" | ||
widget="statinfo" | ||
/> | ||
</button> | ||
</div> | ||
</field> | ||
</record> | ||
</odoo> |