Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
9124 Lượt xem

Hello everyone I need your help.

I am working on a custom module in odoo 11 I have created an email template and I want to insert the current record into the template so when a user receives an email it should contain a link. for example I want to send an email to the user to notify him that a new bill has been created and attached the link of that bill in the message. How can I do that??? 
  

I have written this code but it does not work in my model 

@api.multi
def get_full_url(self):
self.ensure_one()
base_url = self.env["ir.config_parameter"].get_param("web.base.url")
url_params = {
'id': self.id,
'view_type': 'form',
'model': 'account.move',
# 'menu_id': self.env.ref('module_name.menu_record_id').id,
'action': self.env.ref('custom_accounting.email_template_journal_invoice_create_bill').id,
}
params = '/web?#%s' % url_encode(url_params)
return base_url + params

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello Sanjo,

Here is the code for the get link of the backend record.

web_base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
action_id = self.env.ref('project.open_view_project_all', raise_if_not_found=False)
link = """{}/web#id={}&view_type=form&model=project.project&action={}""".format(web_base_url,self.project_id.id,action_id.id)

Thanks

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Ảnh đại diện
Huỷ bỏ

Hi Jainesh. I tried the code you suggested in a custom module in V11 CE (inheriting sale.order) and got the error "self is not defined" after restarting the server. Is there any other code that should be included?

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 22
3131
2
thg 8 22
7465
1
thg 9 21
6481
1
thg 3 21
5184
1
thg 1 21
2063