Skip to content

Commit

Permalink
Add partner_base_multicompany_default_queue
Browse files Browse the repository at this point in the history
  • Loading branch information
leemannd committed Oct 24, 2024
1 parent 565b007 commit 47c4de2
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions partner_base_multicompany_default_queue/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions partner_base_multicompany_default_queue/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [],
}
2 changes: 2 additions & 0 deletions partner_base_multicompany_default_queue/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import base
from . import partner
20 changes: 20 additions & 0 deletions partner_base_multicompany_default_queue/models/base.py
Original file line number Diff line number Diff line change
@@ -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",)
22 changes: 22 additions & 0 deletions partner_base_multicompany_default_queue/models/partner.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Denis Leemann <[email protected]>
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 47c4de2

Please sign in to comment.