mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 02:52:08 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
# Copyright 2024 Akretion (http://www.akretion.com).
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# @author Florian Mounier <florian.mounier@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
auth_partner_ids = fields.One2many("auth.partner", "partner_id", "Partner Auth")
|
||||
auth_partner_count = fields.Integer(
|
||||
compute="_compute_auth_partner_count", compute_sudo=True
|
||||
)
|
||||
|
||||
def _compute_auth_partner_count(self):
|
||||
data = self.env["auth.partner"].read_group(
|
||||
[
|
||||
("partner_id", "in", self.ids),
|
||||
],
|
||||
["partner_id"],
|
||||
groupby=["partner_id"],
|
||||
lazy=False,
|
||||
)
|
||||
res = {item["partner_id"][0]: item["__count"] for item in data}
|
||||
|
||||
for record in self:
|
||||
record.auth_partner_count = res.get(record.id, 0)
|
||||
|
||||
def _get_auth_partner_for_directory(self, directory):
|
||||
return self.sudo().auth_partner_ids.filtered(
|
||||
lambda r: r.directory_id == directory
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue