Browse Source

FEB 18: [FIX] Bug Fixed 'company_dependent_outgoing_mail_server'

pull/231/merge
Cybrosys Technologies 2 months ago
parent
commit
0060b6363c
  1. 8
      company_dependent_outgoing_mail_server/__init__.py
  2. 8
      company_dependent_outgoing_mail_server/__manifest__.py
  3. 5
      company_dependent_outgoing_mail_server/doc/RELEASE_NOTES.md
  4. 24
      company_dependent_outgoing_mail_server/models/ir_mail_server.py
  5. 20
      company_dependent_outgoing_mail_server/static/src/js/get_company.js

8
company_dependent_outgoing_mail_server/__init__.py

@ -20,11 +20,3 @@
# #
############################################################################# #############################################################################
from . import models 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)

8
company_dependent_outgoing_mail_server/__manifest__.py

@ -21,7 +21,7 @@
############################################################################# #############################################################################
{ {
"name": "Company Dependent Outgoing Mail Server", "name": "Company Dependent Outgoing Mail Server",
"version": "16.0.1.0.0", "version": "16.0.1.1.1",
"category": "Extra Tools", "category": "Extra Tools",
"summary": "Send outgoing mails from company depend outgoing mail server", "summary": "Send outgoing mails from company depend outgoing mail server",
"description": "Configure multiple outgoing mail server and set each " "description": "Configure multiple outgoing mail server and set each "
@ -35,11 +35,6 @@
"data": [ "data": [
"views/ir_mail_server_views.xml", "views/ir_mail_server_views.xml",
], ],
"assets": {
"web.assets_backend": [
"company_dependent_outgoing_mail_server/static/src/js/get_company" ".js",
],
},
"images": [ "images": [
"static/description/banner.png", "static/description/banner.png",
"static/description/icon.png", "static/description/icon.png",
@ -48,5 +43,4 @@
"installable": True, "installable": True,
"auto_install": False, "auto_install": False,
"application": False, "application": False,
"post_init_hook": "_post_init_check_company",
} }

5
company_dependent_outgoing_mail_server/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD
- Initial commit for Company Dependent Outgoing Mail Server - 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.

24
company_dependent_outgoing_mail_server/models/ir_mail_server.py

@ -19,7 +19,7 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from odoo import api, fields, models from odoo import fields, models
class IrMailServer(models.Model): class IrMailServer(models.Model):
@ -36,20 +36,12 @@ class IrMailServer(models.Model):
company""" company"""
mail_server = self.env['ir.mail_server'].search([ mail_server = self.env['ir.mail_server'].search([
( (
'company_id.id', '=', 'company_id', '=',
self.env['ir.config_parameter'].sudo().get_param( self.env.company.id)
'current.company.id')) ],order='sequence asc', limit=1)
],
order='sequence asc', limit=1)
res = super()._find_mail_server(email_from) res = super()._find_mail_server(email_from)
lst = list(res) if mail_server:
lst[0] = mail_server lst = list(res)
res = tuple(lst) lst[0] = mail_server
res = tuple(lst)
return res 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'))

20
company_dependent_outgoing_mail_server/static/src/js/get_company.js

@ -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]
});
},
});
Loading…
Cancel
Save