From 1bd9044e85d17c708b1c320b2843831d4b7188a1 Mon Sep 17 00:00:00 2001 From: Cybrosys Technologies Date: Thu, 20 Mar 2025 21:49:42 +0530 Subject: [PATCH] MAR 20: [FIX] Bug Fixed 'company_dependent_outgoing_mail_server' --- .../__init__.py | 8 ------- .../__manifest__.py | 9 +------ .../doc/RELEASE_NOTES.md | 5 ++++ .../models/ir_mail_server.py | 24 +++++++------------ .../static/src/js/get_company.js | 20 ---------------- 5 files changed, 14 insertions(+), 52 deletions(-) delete mode 100644 company_dependent_outgoing_mail_server/static/src/js/get_company.js diff --git a/company_dependent_outgoing_mail_server/__init__.py b/company_dependent_outgoing_mail_server/__init__.py index 3b09ac3f3..097bdb395 100644 --- a/company_dependent_outgoing_mail_server/__init__.py +++ b/company_dependent_outgoing_mail_server/__init__.py @@ -20,11 +20,3 @@ # ############################################################################# from . import models -from odoo import api, SUPERUSER_ID - - -def _post_init_check_company(cr, registry): - """Set current company id to current.company.id key""" - env = api.Environment(cr, SUPERUSER_ID, {}) - env['ir.config_parameter'].sudo().set_param('current.company.id', - env.company.id) diff --git a/company_dependent_outgoing_mail_server/__manifest__.py b/company_dependent_outgoing_mail_server/__manifest__.py index 9f3230f4b..6a6449c5c 100644 --- a/company_dependent_outgoing_mail_server/__manifest__.py +++ b/company_dependent_outgoing_mail_server/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': 'Company Dependent Outgoing Mail Server', - 'version': '15.0.1.0.0', + 'version': '15.0.1.1.1', 'category': 'Extra Tools', 'summary': 'Send outgoing mails from company depend outgoing mail server', 'description': 'Configure multiple outgoing mail server and set each ' @@ -35,12 +35,6 @@ 'data': [ 'views/ir_mail_server_views.xml', ], - 'assets': { - 'web.assets_backend': [ - 'company_dependent_outgoing_mail_server/static/src/js/get_company' - '.js', - ], - }, 'images': [ 'static/description/banner.jpg', 'static/description/icon.png', @@ -49,5 +43,4 @@ 'installable': True, 'auto_install': False, 'application': False, - 'post_init_hook': '_post_init_check_company', } diff --git a/company_dependent_outgoing_mail_server/doc/RELEASE_NOTES.md b/company_dependent_outgoing_mail_server/doc/RELEASE_NOTES.md index 5791b2e71..cbf061533 100644 --- a/company_dependent_outgoing_mail_server/doc/RELEASE_NOTES.md +++ b/company_dependent_outgoing_mail_server/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 15.0.1.0.0 #### ADD - Initial commit for Company Dependent Outgoing Mail Server + +#### 17.02.2025 +#### Version 15.0.1.1.1 +#### UPDATE +- Updated the python code and removed the usage of the js file. \ No newline at end of file diff --git a/company_dependent_outgoing_mail_server/models/ir_mail_server.py b/company_dependent_outgoing_mail_server/models/ir_mail_server.py index 17d3faf1d..1b1ed4f36 100644 --- a/company_dependent_outgoing_mail_server/models/ir_mail_server.py +++ b/company_dependent_outgoing_mail_server/models/ir_mail_server.py @@ -19,7 +19,7 @@ # If not, see . # ############################################################################# -from odoo import api, fields, models +from odoo import fields, models class IrMailServer(models.Model): @@ -36,20 +36,12 @@ class IrMailServer(models.Model): company""" mail_server = self.env['ir.mail_server'].search([ ( - 'company_id.id', '=', - self.env['ir.config_parameter'].sudo().get_param( - 'current.company.id')) - ], - order='sequence asc', limit=1) + 'company_id', '=', + self.env.company.id) + ],order='sequence asc', limit=1) res = super()._find_mail_server(email_from) - lst = list(res) - lst[0] = mail_server - res = tuple(lst) + if mail_server: + lst = list(res) + lst[0] = mail_server + res = tuple(lst) return res - - @api.model - def get_company_id(self, current_company): - """Function called from orm and has current company id in argument""" - self.env['ir.config_parameter'].sudo().set_param('current.company.id', - current_company.get( - 'id')) diff --git a/company_dependent_outgoing_mail_server/static/src/js/get_company.js b/company_dependent_outgoing_mail_server/static/src/js/get_company.js deleted file mode 100644 index 057f289a8..000000000 --- a/company_dependent_outgoing_mail_server/static/src/js/get_company.js +++ /dev/null @@ -1,20 +0,0 @@ -/** @odoo-module **/ -import { SwitchCompanyMenu } from "@web/webclient/switch_company_menu/switch_company_menu"; -import { patch } from 'web.utils'; -import { useService } from "@web/core/utils/hooks"; -const rpc = require('web.rpc') -const { hooks } = owl; -const { useState } = hooks; -/**Returns the current company id to function get_company_id through rpc call**/ -patch(SwitchCompanyMenu.prototype, "logIntoCompany", { - setup() { - this.companyService = useService("company"); - this.currentCompany = this.companyService.currentCompany; - this.state = useState({ companiesToToggle: [] }); - rpc.query({ - model: "ir.mail_server", - method: "get_company_id", - args: [this.currentCompany] - }); - }, -}); \ No newline at end of file