Skip to Content
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4507 Näkymät

I am using multi website for eCommerce. Since there is a field for choose website under product template form, I want to add a field with the website_domain/website_url so that I can click the url and redirect to the right website frontend. I do not like the default Publish on website button since it force me leave the backend. I am new to python. But I already done that with the web.base.url with following code:

class ProductURL(models.Model):
_inherit = 'product.template'

product_url = fields.Char(string="Product URL",compute='_computeURL')

@api.multi
def _computeURL(self):
for record in self:
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url', default='')
if base_url:
record.product_url =base_url+""+record.website_url

So now I have a field with link web.base.url/product/product_id which I can click to go to front-end. But I have no idea how to get the website domain I selected for the product and if the website field is leaving blank then it should fall to web.base.url. Any help is appreciated. Thank you!

Avatar
Hylkää
Paras vastaus

you should see method "open_website_url" if you are on odoo 12.

Avatar
Hylkää
Tekijä

I do not get it. Is this some existing function I am not aware of or some existing field. I simply tried adding <field name="open_website_url"/> to the template form but it is can not be saved. I simply need a need which can be opened in a new tap to the right website of the product. Thank you.

Related Posts Vastaukset Näkymät Toimenpide
3
jouluk. 19
4774
0
huhtik. 19
2968
2
heinäk. 24
380
0
toukok. 24
277
2
toukok. 24
10915