2024-06-11 21:26:26 -04:00
|
|
|
from odoo import api, fields, models
|
2023-06-14 15:51:20 -04:00
|
|
|
|
2023-11-16 09:01:22 -05:00
|
|
|
|
2023-06-14 15:51:20 -04:00
|
|
|
class Partner(models.Model):
|
2024-06-11 21:26:26 -04:00
|
|
|
_inherit = "res.partner"
|
2023-06-14 15:51:20 -04:00
|
|
|
|
2023-11-16 09:01:22 -05:00
|
|
|
is_site_contact = fields.Boolean(
|
2024-06-11 21:26:26 -04:00
|
|
|
string="Is a site contact",
|
2023-11-16 09:01:22 -05:00
|
|
|
compute="_compute_is_site_contact",
|
|
|
|
|
search="_search_is_site_contact",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
site_ids = fields.Many2many(
|
2024-06-11 21:26:26 -04:00
|
|
|
string="Work Sites",
|
|
|
|
|
comodel_name="res.partner",
|
|
|
|
|
relation="res_partner_site_contact_rel",
|
|
|
|
|
column1="site_contact_id",
|
|
|
|
|
column2="site_id",
|
|
|
|
|
tracking=True,
|
2023-11-16 09:01:22 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
site_contacts = fields.Many2many(
|
2024-06-11 21:26:26 -04:00
|
|
|
comodel_name="res.partner",
|
|
|
|
|
relation="res_partner_site_contact_rel",
|
|
|
|
|
column1="site_id",
|
|
|
|
|
column2="site_contact_id",
|
|
|
|
|
domain=[("is_company", "=", False)],
|
|
|
|
|
tracking=True,
|
2023-11-16 09:01:22 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
work_order_contacts = fields.Many2many(
|
2024-06-11 21:26:26 -04:00
|
|
|
string="Work Order Recipients",
|
|
|
|
|
comodel_name="res.partner",
|
|
|
|
|
relation="res_partner_work_order_contacts_rel",
|
|
|
|
|
column1="res_partner_id",
|
|
|
|
|
column2="work_order_contact_id",
|
|
|
|
|
domain=[("is_company", "=", False)],
|
|
|
|
|
tracking=True,
|
2023-11-16 09:01:22 -05:00
|
|
|
)
|
|
|
|
|
|
2024-06-11 21:26:26 -04:00
|
|
|
@api.depends("site_ids")
|
2023-06-15 13:16:37 -04:00
|
|
|
def _compute_is_site_contact(self):
|
|
|
|
|
for rec in self:
|
2024-06-19 09:47:49 -04:00
|
|
|
rec.is_site_contact = rec.site_ids
|
2023-06-14 15:51:20 -04:00
|
|
|
|
2023-06-26 11:41:07 -04:00
|
|
|
@api.model
|
|
|
|
|
def _search_is_site_contact(self, operator, value):
|
2024-06-19 09:36:57 -04:00
|
|
|
return [("site_ids", "!=", False)]
|