Skip to Content
Menu
This question has been flagged
1 Reply
6533 Views

I'm trying to configure the sender name that is sent with emails to clients. In Settings > Technical > Email > Templates > Notification Email the template contains something like this:

% if ctx.get('actions'): % for action in ctx['actions']:

\\\$\{action\[\'title\'\]\}\\\\\&nbsp\;\%if\ cmp\(len\(ctx\[\'actions\'\]\)\,\ 1\)\ \=\=\ 1\ and\ cmp\(len\(ctx\[\'actions\'\]\)\,\ loop\.index\)\ \=\=\ 1\:\ \|\ \%\ endif\ \%\ endfor\ \%\ else\:\&nbsp\;\\

\Sent\ by\\\\&nbsp\;\%\ if\ ctx\.get\(\'website\_url\'\)\:\&nbsp\;\\

\\%\ endif\\$\{ctx\.get\(\'company\_name\'\)\}\\&nbsp\;\%\ if\ ctx\.get\(\'website\_url\'\)\:\&nbsp\;\\\\%\ endif\&nbsp\;\\

\using\\\\&nbsp\;\\

\Odoo

 % endif

I tried searching for 'company_name' under Settings > Technical > Database Structure > Fields and it doesn't exist. Where is it defined?

Further context: The name of my company under res.company is the registered legal name. I want to make sure that clients get our commercial name in  emails, which is different to our registered name.

Avatar
Discard
Best Answer

company name is coming form this method  _notify_prepare_template_context in side  addons/mail/models/res_partner.py which is the company name of login user  company_name = user.company_id.name



    @api.model
def _notify_prepare_template_context(self, message):
# compute signature
signature = ""
if message.author_id and message.author_id.user_ids and message.author_id.user_ids[0].signature:
signature = message.author_id.user_ids[0].signature
elif message.author_id:
signature = "<p>-- <br/>%s</p>" % message.author_id.name
# compute Sent by
if message.author_id and message.author_id.user_ids:
user = message.author_id.user_ids[0]
else:
user = self.env.user
if user.company_id.website:
website_url = 'http://%s' % user.company_id.website if not user.company_id.website.lower().startswith(('http:', 'https:')) else user.company_id.website
else:
website_url = False
company_name = user.company_id.name
model_name = False
if message.model:
model_name = self.env['ir.model'].sudo().search([('model', '=', self.env[message.model]._name)]).name_get()[0][1]
record_name = message.record_name
tracking = []
for tracking_value in message.tracking_value_ids:
tracking.append((tracking_value.field_desc,
tracking_value.get_old_display_value()[0],
tracking_value.get_new_display_value()[0]))
return {
'signature': signature,
'website_url': website_url,
'company_name': company_name,
'model_name': model_name,
'record_name': record_name,
'tracking': tracking,
}
Avatar
Discard
Related Posts Replies Views Activity
1
Feb 24
902
1
Jul 23
1634
3
Dec 23
17558
1
Feb 22
4392
0
Aug 21
1527