Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add partner_base_multicompany_default_queue #712

Draft
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
queue
94 changes: 94 additions & 0 deletions partner_base_multicompany_default_queue/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
========================================
Partner Base Multi-Company Default Queue
========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d875bc1184c96c1ba6c8761bfb4515baf2e75a5f1139bcd188f52740a09322e5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmulti--company-lightgray.png?logo=github
:target: https://github.com/OCA/multi-company/tree/16.0/partner_base_multicompany_default_queue
:alt: OCA/multi-company
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-partner_base_multicompany_default_queue
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/multi-company&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/multi-company/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/multi-company/issues/new?body=module:%20partner_base_multicompany_default_queue%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Denis Leemann <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-camptocamp| image:: https://github.com/camptocamp.png?size=40px
:target: https://github.com/camptocamp
:alt: camptocamp

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-camptocamp|

This module is part of the `OCA/multi-company <https://github.com/OCA/multi-company/tree/16.0/partner_base_multicompany_default_queue>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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
leemannd marked this conversation as resolved.
Show resolved Hide resolved
# 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"],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainers have to be persons

"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
18 changes: 18 additions & 0 deletions partner_base_multicompany_default_queue/models/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 Camptocamp
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from odoo import api, models


class Base(models.AbstractModel):

_inherit = "base"

@api.model
def _job_prepare_context_before_enqueue_keys(self):
"""Keys to keep in context of stored jobs
Empty by default for backward compatibility.
"""
Comment on lines +13 to +15

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Keys to keep in context of stored jobs
Empty by default for backward compatibility.
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, this override should be moved to res.partner

return super()._job_prepare_context_before_enqueue_keys() + (
"property_propagation",
)
23 changes: 23 additions & 0 deletions partner_base_multicompany_default_queue/models/partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 Camptocamp SA
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)

from odoo import models


class Partner(models.Model):

_inherit = "res.partner"

def _propagate_property_fields(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you miss a queue.job.function to be able to delay this

# Adding a call with_delay() make an aync propagation of the property fields
if (
self.env.context.get("force_property_propagation")
and not self.env.context.get("property_propagation") == "enqueued"
):
# changing the context to avoid infinite loop
self_enqueued = self.with_context(property_propagation="enqueued")
return (
super(Partner, self_enqueued).with_delay()._propagate_property_fields()
)
else:
return super()._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.
Loading
Loading