mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[FIX] contract: multi-company assignment notification
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
This commit is contained in:
committed by
Pedro M. Baeza
parent
1c6bfdb391
commit
4e570bd46f
@@ -74,6 +74,7 @@ Known issues / Roadmap
|
|||||||
======================
|
======================
|
||||||
|
|
||||||
* Recover states and others functional fields in Contracts.
|
* Recover states and others functional fields in Contracts.
|
||||||
|
* Remove ``models/ir_ui_view.py`` in v13, where the workaround it contains is supported upstream.
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|||||||
@@ -13,3 +13,4 @@ from . import contract_tag
|
|||||||
from . import res_company
|
from . import res_company
|
||||||
from . import res_config_settings
|
from . import res_config_settings
|
||||||
from . import contract_terminate_reason
|
from . import contract_terminate_reason
|
||||||
|
from . import ir_ui_view
|
||||||
|
|||||||
@@ -546,8 +546,15 @@ class ContractContract(models.Model):
|
|||||||
if not date_ref:
|
if not date_ref:
|
||||||
date_ref = fields.Date.context_today(self)
|
date_ref = fields.Date.context_today(self)
|
||||||
domain = self._get_contracts_to_invoice_domain(date_ref)
|
domain = self._get_contracts_to_invoice_domain(date_ref)
|
||||||
contracts_to_invoice = self.search(domain)
|
invoices = self.env["account.invoice"]
|
||||||
return contracts_to_invoice._recurring_create_invoice(date_ref)
|
# Invoice by companies, so assignation emails get correct context
|
||||||
|
companies_to_invoice = self.read_group(domain, ["company_id"], ["company_id"])
|
||||||
|
for row in companies_to_invoice:
|
||||||
|
contracts_to_invoice = self.search(row["__domain"]).with_context(
|
||||||
|
allowed_company_ids=[row["company_id"][0]]
|
||||||
|
)
|
||||||
|
invoices |= contracts_to_invoice._recurring_create_invoice(date_ref)
|
||||||
|
return invoices
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_terminate_contract(self):
|
def action_terminate_contract(self):
|
||||||
|
|||||||
19
contract/models/ir_ui_view.py
Normal file
19
contract/models/ir_ui_view.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# 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
|
||||||
@@ -1 +1,2 @@
|
|||||||
* Recover states and others functional fields in Contracts.
|
* Recover states and others functional fields in Contracts.
|
||||||
|
* Remove ``models/ir_ui_view.py`` in v13, where the workaround it contains is supported upstream.
|
||||||
|
|||||||
@@ -425,6 +425,7 @@ To use it, just select the template on the contract and fields will be filled au
|
|||||||
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
|
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Recover states and others functional fields in Contracts.</li>
|
<li>Recover states and others functional fields in Contracts.</li>
|
||||||
|
<li>Remove <tt class="docutils literal">models/ir_ui_view.py</tt> in v13, where the workaround it contains is supported upstream.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
|
|||||||
Reference in New Issue
Block a user