mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
Steps to reproduce the problem: 1. Log in as Mitchell Admin. 2. Create contract CNT-A for company CMP-A, assigned to Marc Demo. 3. Create contract CNT-B for company CMP-B, assigned to Marc Demo. 4. Run cron to create recurring invoices. Actual results: - Odoo sends automated assignment emails to Marc Demo, which indicate the name of the company activated for `__system__` user whlie the cron was being executed. Expected results after this patch: - Odoo sends automated assignment emails to Marc Demo, which indicate the invoice company. @Tecnativa TT24657
20 lines
641 B
Python
20 lines
641 B
Python
# Copyright 2020 Tecnativa - Jairo Llopis
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo import api, models
|
|
|
|
|
|
class IrUiView(models.Model):
|
|
_inherit = "ir.ui.view"
|
|
|
|
@api.model
|
|
def _prepare_qcontext(self):
|
|
"""Patch context to use fw-compatible v13 company."""
|
|
# TODO Delete this method in v13; it's upstream there
|
|
result = super()._prepare_qcontext()
|
|
if self.env.context.get("allowed_company_ids"):
|
|
result["res_company"] = self.env["res.company"].browse(
|
|
self.env.context["allowed_company_ids"][0]
|
|
).sudo()
|
|
return result
|