so I got It but now I have other problems:
this is my code:
controller:
from odoo.addons.sale.controllers.portal import CustomerPortal
from odoo.http import request, route
class CustomPortal(CustomerPortal):
@route(['/my/orders/<int:order_id>'], type='http', auth="public", website=True)
def portal_my_order(self, order_id=None, access_token=None, report_type=None, download=False, **kw):
order_sudo = request.env['sale.order'].sudo().browse(order_id).exists()
if not order_sudo:
return request.redirect('/my/orders')
# Zugriff prüfen
try:
order_sudo.check_access_rights('read')
order_sudo.check_access_rule('read')
except Exception:
return request.redirect('/my')
# Beispiel: Zugriff auf rental_ok
for line in order_sudo.order_line:
if line.product_id.product_tmpl_id.rental_ok:
pass # hier kannst du eigene Logik ergänzen
values = self._prepare_portal_layout_values()
values.update({
'order': order_sudo,
'sale_order': order_sudo,
'report_type': report_type,
})
return request.render("sale.sale_order_portal_content", values)
xml view:
?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="portal_my_order_inherit_hide_unit_price_for_rentals" inherit_id>
<!-- Überschreibe nur die Preiszelle, aber zeige sie nur, wenn NICHT rental>
<xpath expr="//t[@name='product_line_row']/td[3]" position="replace">
<td t-if="not line.product_id.rental_ok"
t-attf-class="text-end {{ 'd-none d-sm-table-cell' if report_type == >
<div t-if="line.discount >= 0"
t-field="line.price_unit"
t-att-style="line.discount and 'text-decoration: line-through' or >
t-att-class="(line.discount and 'text-danger' or '') + ' text-end'>
<div t-if="line.discount">
<t t-out="(1-line.discount / 100.0) * line.price_unit"
t-options="{"widget": "float", "decimal_p>
</div>
</td>
</xpath>
</template>
</odoo>
and the problem is:
Error while render the template
AttributeError: 'product.product' object has no attribute 'rental_ok'
Template: sale.sale_order_portal_content
Path: /t/div[2]/section[1]/div[1]/table/tbody/t[3]/tr[1]/t[1]/td[3]
Node: <td t-if="not line.product_id.rental_ok" t-attf-class="text-end {{ \'d-none d-sm-table-cell\' if report_type == \'html\' else \'\' }}"/>
Der Fehler ist beim Rendering der Vorlage aufgetreten sale.sale_order_portal_content und beim Evaluieren des folgenden Ausdrucks: <td t-if="not line.product_id.rental_ok" t-attf-class="text-end {{ \'d-none d-sm-table-cell\' if report_type == \'html\' else \'\' }}"/>