From 47c4de21323b229162d687991afc9f7ebe215d7d Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Thu, 24 Oct 2024 14:14:46 +0200 Subject: [PATCH] Add partner_base_multicompany_default_queue --- .../__init__.py | 1 + .../__manifest__.py | 19 ++++++++++++++++ .../models/__init__.py | 2 ++ .../models/base.py | 20 +++++++++++++++++ .../models/partner.py | 22 +++++++++++++++++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 6 +++++ 7 files changed, 71 insertions(+) create mode 100644 partner_base_multicompany_default_queue/__init__.py create mode 100644 partner_base_multicompany_default_queue/__manifest__.py create mode 100644 partner_base_multicompany_default_queue/models/__init__.py create mode 100644 partner_base_multicompany_default_queue/models/base.py create mode 100644 partner_base_multicompany_default_queue/models/partner.py create mode 100644 partner_base_multicompany_default_queue/readme/CONTRIBUTORS.rst create mode 100644 partner_base_multicompany_default_queue/readme/DESCRIPTION.rst diff --git a/partner_base_multicompany_default_queue/__init__.py b/partner_base_multicompany_default_queue/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/partner_base_multicompany_default_queue/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_base_multicompany_default_queue/__manifest__.py b/partner_base_multicompany_default_queue/__manifest__.py new file mode 100644 index 00000000000..bca99bd7079 --- /dev/null +++ b/partner_base_multicompany_default_queue/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 Camptocamp SA +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +{ + "name": "Partner Base Multi-Company Default Queue", + "summary": "Glue module between partner_base_multicompany and queue_job", + "version": "16.0.0.1.0", + "development_status": "Alpha", + "category": "Technical", + "website": "https://github.com/OCA/multi-company", + "author": "Camptocamp, Odoo Community Association (OCA)", + "maintainers": ["camptocamp"], + "license": "LGPL-3", + "depends": [ + "partner_base_multicompany_default", + "queue_job", + ], + "data": [], +} diff --git a/partner_base_multicompany_default_queue/models/__init__.py b/partner_base_multicompany_default_queue/models/__init__.py new file mode 100644 index 00000000000..0649de787a2 --- /dev/null +++ b/partner_base_multicompany_default_queue/models/__init__.py @@ -0,0 +1,2 @@ +from . import base +from . import partner diff --git a/partner_base_multicompany_default_queue/models/base.py b/partner_base_multicompany_default_queue/models/base.py new file mode 100644 index 00000000000..f804828aeac --- /dev/null +++ b/partner_base_multicompany_default_queue/models/base.py @@ -0,0 +1,20 @@ +# Copyright 2024 Camptocamp +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +import functools + +from odoo import api, models + +from ..delay import Delayable +from ..job import DelayableRecordset +from ..utils import must_run_without_delay + + +class Base(models.AbstractModel): + + @api.model + def _job_prepare_context_before_enqueue_keys(self): + """Keys to keep in context of stored jobs + Empty by default for backward compatibility. + """ + return super()._job_prepare_context_before_enqueue_keys() + ("property_propagation",) diff --git a/partner_base_multicompany_default_queue/models/partner.py b/partner_base_multicompany_default_queue/models/partner.py new file mode 100644 index 00000000000..12a7620f0ea --- /dev/null +++ b/partner_base_multicompany_default_queue/models/partner.py @@ -0,0 +1,22 @@ +# Copyright 2024 Camptocamp SA +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) +import logging +from collections import defaultdict +from functools import reduce +from itertools import groupby +from operator import itemgetter, or_ + +from odoo import _, api, models +from odoo.exceptions import UserError +from odoo.osv import expression + +_logger = logging.getLogger(__name__) + + +class Partner(models.Model): + + _inherit = "res.partner" + + def _propagate_property_fields(self): + # Adding a call with_delay() make an aync propagation of the property fields + return super().with_delay()._propagate_property_fields() diff --git a/partner_base_multicompany_default_queue/readme/CONTRIBUTORS.rst b/partner_base_multicompany_default_queue/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..fcb7aaa08fb --- /dev/null +++ b/partner_base_multicompany_default_queue/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Denis Leemann diff --git a/partner_base_multicompany_default_queue/readme/DESCRIPTION.rst b/partner_base_multicompany_default_queue/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..0021a934334 --- /dev/null +++ b/partner_base_multicompany_default_queue/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +Glue module inbetween `partner_base_multicompany` and `queue_job`. + +The propagation of the fields can be costly given the amount of fields to be propagated +and the amount of companies. + +With this module, we want to make the propagation of the fields asynchronous with the creation of queue_jobs.