Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
6744 มุมมอง

I want to display the custom menu on the odoo portal view. XML File:

```

"1.0" encoding="UTF-8"?>
<odoo>
    <data>
      <template id="portal_my_home_loan" name="Partner Loan"
        customize_show="True" inherit_id="portal.portal_my_home">
        <xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
          <t t-call="portal.portal_docs_entry">
            <t t-set="title">Partner Loant>
            <t t-set="url" t-value="'/my/loan'" />
            
          t>
        xpath>
      template>
  data>
odoo>
```

Controller file:

from odoo.addons.portal.controllers.portal import CustomerPortal

class PortalAccount(CustomerPortal):
   def _prepare_home_portal_values(self, counters):
       values = super()._prepare_home_portal_values(counters)
       values['loan_count'] = 1
       return values

Have added portal​ to depends in the manifest file as well as template.xml to the manifest file. 
Still can't see the menu on my portal view of the user. Any idea where I could go have gone wrong?

อวตาร
ละทิ้ง
ผู้เขียน

Manifest file:
'depends' : ['base', 'product', 'portal'],
'data': ['views/template.xml']

Dd you find a solution? i've the same problem, noo menu Customize --> My portal in Odoo 16

Did you solved? I have the same issue

Missing this line *<t-set="placeholder_count" t-value="'job_count'"/>*

คำตอบที่ดีที่สุด

Hi,

Try refer the following blog

https://www.cybrosys.com/blog/how-to-add-a-custom-menu-in-the-customer-portal-of-odoo-16

Regards

อวตาร
ละทิ้ง
ผู้เขียน

I tried this, still unable to get the results

คำตอบที่ดีที่สุด

Hi,

In my experience, you need to set 'loan_count' or 'job_count' value to something different than numeric 0.

So for show 0 set values['job_count']='0', for show empty counter set values['job_count']='', to hide menu line set values['job_count']=0.

For me (on 16.0) works fine.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

from developper tool of brouser i saw thal a 'd-none' class is added to menu , Thats why it is hidden and not showing. can any body suggest how to correct it?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Seems the codes are fine, are you sure that the xml file is added in the manifest file and installed the module in the database ?

Just go to the views menu under the Settings -> Technical -> User interface -> Views and just ensure that this can be located there


Thanks

อวตาร
ละทิ้ง
ผู้เขียน

Hello, yes the view is visible in ir.ui.view, One more thing I tried is to duplicate an existing view related to the menu on the portal, changed its name, and sequence, and even created model data entry, and even that didn't work...

คำตอบที่ดีที่สุด
Hi, you miss the placeholder_count line in your code please add this line after t-set="url"
t-set="placeholder_count" t-value="'job_count'"/>

thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Madhav Parikh

Please refer below code for the template and controller and let me know if it’s not working.

Template:

Partner Loan

Please find the code in below comment. 

Controller:

class PortalAccount(CustomerPortal):
def _prepare_home_portal_values(self, counters):
values = super()._prepare_home_portal_values(counters)
partner = request.env.user.partner_id
if 'loan_count' in counters:
values['loan_count'] = 1
return values

You can also refer in base too as below:

Xml file:
https://github.com/odoo/odoo/blob/16.0/addons/sale/views/sale_portal_templates.xml#L21

controller file:
https://github.com/odoo/odoo/blob/16.0/addons/sale/controllers/portal.py#L20

I hope it will be useful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

อวตาร
ละทิ้ง

Here is the code of Template:

<template id="portal_my_home_loan" name="Partner Loan" customize_show="True" inherit_id="portal.portal_my_home" priority="20">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-call="portal.portal_docs_entry">
<t t-set="title">Partner Loan</t>
<t t-set="url" t-value="'/my/loan'"/>
<t t-set="placeholder_count" t-value="'loan_count'"/>
</t>
</xpath>
</template>

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ย. 24
2946
Blank Page After Logged in. แก้ไขแล้ว
1
พ.ย. 23
3232
1
ก.ย. 23
4678
1
ก.ย. 23
5231
1
มี.ค. 23
3110