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 9e962a22c..8abb08f6f 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": "16.0.1.0.0", + "version": "16.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,11 +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.png", "static/description/icon.png", @@ -48,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 fc7becbcf..955b462d7 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 16.0.1.0.0 #### ADD - Initial commit for Company Dependent Outgoing Mail Server + +#### 17.02.2025 +#### Version 16.0.1.1.1 +#### UPDATE +- Updated the code and removed the usage of js in it. \ 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 36abb3b30..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/core/utils/patch"; -import { useService } from "@web/core/utils/hooks"; -const rpc = require('web.rpc') -import { useState } from "@odoo/owl"; - -/**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