This question has been flagged

Hello my friends, 

I want to display helpdesk tickets on my website page. 

I finded the database table "helpdesk_ticket" on pgAdmin4 but i can't display them by foreach loop.

Can someone help me about those attribute in order to display tickets ? 

That my template where i'm trying to find the right technical name of helpdesk_ticket : 


<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="liste_offres" model="ir.ui.view">
<field name="model">helpdesk.team.form.inherit.website.form.helpdesk</field>
<field name="model">helpdesk.team</field>
<field name="inherit_id" ref="coopaname_helpdesk.marchepublic" />
<field name="mode">primary</field>
<field name="key">coopaname_helpdesk.liste_offres</field>
<field name="arch" type="xml">

<xpath expr="//div" position="after">


<h1 style="text-align:center;">le fichier est load</h1>

<t t-foreach="helpdesk.team.id" t-as="helpdesk.team">
<p style="text-align:center;"><t t-esc="i"/></p>
</t>






</xpath>

</field>
</record>
</data>
</odoo>


about my error : 


Error to render compiling AST
AttributeError: 'NoneType' object has no attribute 'team'
Template: 1863
Path: /templates/t/t/t/t[2]
Node: <t t-foreach="helpdesk.team.id" t-as="helpdesk.team">
            <p style="text-align:center;"><t t-esc="i"/></p>
            </t>

Best regards, 

Jules


Avatar
Discard
Best Answer

You have defined the field about the model twice.

Replace:
<field name="model">helpdesk.team.form.inherit.website.form.helpdesk</field>
by
<field name="name">helpdesk.team.form.inherit.website.form.helpdesk</field>


and check if you are still getting an error.

Avatar
Discard
Author Best Answer

Hi my friends, thanks for your help but i still get an error


template.xml : 

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="liste_offres" model="ir.ui.view">
<field name="name">coopaname_helpdesk.liste_offres</field>
<field name="inherit_id" ref="coopaname_helpdesk.marchepublic" />
<field name="mode">primary</field>
<field name="key">coopaname_helpdesk.liste_offres</field>
<field name="arch" type="xml">

<xpath expr="//div" position="after">
<div class="oe_structure" >
<div class="container" >
<h1 style="text-align:center;">le fichier est load</h1>
<t t-foreach="tickets" t-as="ticket">


<div class="panel-footer text-center">
<p class="text-muted">
<i class="o_default_snippet_text"> Publié par : <span t-field="ticket.x_name"/></i>
</p>
</div>


</t>
</div>
</div>
</xpath>

</field>
</record>
</data>
</odoo>

and

 controller.py : 


@http.route('/coopaname_helpdesk/post_form_ticket/<string:model_name>',  methods=['POST'], type = 'http', auth='public',  website= True, Store=True )
def website_form(self, model_name, **kwargs):
try:
objet_consultation = kwargs.get('x_objet_consultation')
cat = kwargs.get('x_cat')
membre_interne = kwargs.get('x_membre_interne')
membre_externe = kwargs.get('x_membre_externe')
equipeok = kwargs.get('x_equipeok')
admin = kwargs.get('x_admin')
type_marche = kwargs.get('x_type_marche')
ville_adju = kwargs.get('x_ville_adju')
date_order = kwargs.get('x_date_order')
date_limite = kwargs.get('x_date_limite')
duree_marche = kwargs.get('x_duree_marche')
montant_marche = kwargs.get('x_montant_marche')
num_ref = kwargs.get('x_num_ref')
pj = kwargs.get('x_pj')
name = kwargs.get('x_name')
mail = kwargs.get('x_mail')
inputstreet1 = kwargs.get('x_inputstreet1')
inputcity1 = kwargs.get('x_inputcity1')
inputzip1 = kwargs.get('x_inputzip1')
inputstreet2 = kwargs.get('x_inputstreet2')
inputcity2 = kwargs.get('x_inputcity2')
inputzip2 = kwargs.get('x_inputzip2')

data = {
'x_cat' : cat,
'x_objet_consultation' : objet_consultation,
'x_membre_interne' : membre_interne,
'x_membre_externe' : membre_externe,
'x_equipeok' : equipeok,
'x_admin' : admin,
'x_type_marche' : type_marche,
'x_ville_adju':ville_adju,
'x_date_order': date_order,
'x_date_limite': date_limite,
'x_duree_marche': duree_marche,
'x_montant_marche' : montant_marche,
'x_num_ref' : num_ref,
'x_pj' : pj,
'x_name' : name,
'x_mail' : mail,
'x_inputstreet1' : inputstreet1,
'x_inputcity1' : inputcity1,
'x_inputzip1' : inputzip1,
'x_inputstreet2': inputstreet2,
'x_inputzip2' : inputzip2,
'x_inputcity2' : inputcity2
}
print('ca passe par le try')
return request.env['monmarchepublic'].create(data)

except:
return json.dumps({'error' : ' tout est casse'})

and 

model.py : 

from odoo import models, fields, api

class MonHelpdeskTicket(models.Model):

_name = "monmarchepublic"
_inherit = 'res.users'
_inherit = [
'mail.thread',
'ir.needaction_mixin',
]
x_name = fields.Char('Nom et Prenom', readonly=0, website_form_blacklisted=0, Store=True )
x_objet_consultation = fields.Char('Objet de la consultation', readonly=0, website_form_blacklisted=0, Store=True)
x_membre_interne = fields.Char("Membres de l'équipe INTERNE Coopaname", readonly=0, website_form_blacklisted=0, Store=True)
x_membre_externe = fields.Char(" Membres de l'équipe EXTERNE et/ou informations utiles", readonly=0, website_form_blacklisted=0, Store=True)
x_equipeok = fields.Boolean('Equipe complète', readonly=0, website_form_blacklisted=0, Store=True)
x_admin = fields.Char('Administration', readonly=0, website_form_blacklisted=0, Store=True)
x_inputstreet1 = fields.Char('N° et Rue', readonly=0, website_form_blacklisted=0, Store=True)
x_inputcity1 = fields.Char('Ville', readonly=0, website_form_blacklisted=0, Store=True)
x_inputzip1 = fields.Char('Code Postal', readonly=0, website_form_blacklisted=0, Store=True)
x_date_order = fields.Date('Date de publication', readonly=0, website_form_blacklisted=0, Store=True)
x_type_marche = fields.Selection([("offre_ferme", "Appel d'offre Fermé"), ('offre_ouvert', "Appel d'offre Ouvert"), ('concours', 'Concours'), ('consultation', 'Consultation'), ('mapa', 'MAPA')], readonly=0, website_form_blacklisted=0, Store=True)
x_date_limite = fields.Datetime('Date et heure limites de dépot de candidature', readonly=0, website_form_blacklisted=0, Store=True)
x_duree_marche = fields.Char('Durée du marché', readonly=0, website_form_blacklisted=0, Store=True)
x_montant_marche = fields.Char('Montant du marché', readonly=0, website_form_blacklisted=0, Store=True)
x_inputstreet2 = fields.Char('N° et Rue', readonly=0, website_form_blacklisted=0, Store=True)
x_inputcity2 = fields.Char('Ville', readonly=0, website_form_blacklisted=0, Store=True)
x_inputzip2 = fields.Char('Code Postal', readonly=0, website_form_blacklisted=0, Store=True)
x_num_ref = fields.Char('Numéro de référence attribué au marché', readonly=0, website_form_blacklisted=0, Store=True)
x_cat = fields.Selection([("Etudes, Maitrise d oeuvre, Controle", "Etudes, Maîtrise d'oeuvre, Contrôle"), ('Travaux de batiment', 'Travaux de bâtiment'), ('Travaux Publics', 'Travaux Publics'), ('Fournitures', 'Fournitures'), ('Services', 'Services')], readonly=0, website_form_blacklisted=0, Store=True)
x_pj = fields.Char('Pièce Jointe', readonly=0, website_form_blacklisted=0, Store=True)
x_ville_adju = fields.Char('Ville du Pouvoir Adjudicateur', readonly=0, website_form_blacklisted=0, Store=True)
x_mail = fields.Char('Email', readonly=0, website_form_blacklisted=0, Store=True)
x_etape = fields.Selection([('New', 'New'), ('CCTP', 'CCTP'), ('En cours de traitement', 'En cours de traitement'), ('Valide', 'Validé'), ('Refuse', 'Refusé'), ('Archive', 'Archivé')], readonly=0, website_form_blacklisted=0, Store=True)
message_ids = fields.One2many('mail.message', 'res_id', string="Commentaire", Store=True)
partner_ids = fields.Many2many('res.partner', string='Recipients', help="List of partners that will be added as follower of the current document.", readonly=0, website_form_blacklisted=0, Store=True)
message_partner_ids = fields.Many2many(
comodel_name='res.partner', string='Followers Test',
compute='_get_followers', search='_search_follower_partners', readonly=0, website_form_blacklisted=0, Store=True)
follower_ids = fields.One2many('mail.followers', 'res_id', string="follo", readonly=0, website_form_blacklisted=0, Store=True)


So How can i display my tickets because i got this error message : 


Error to render compiling AST
BuildError: (<odoo.http.EndPoint object at 0x7f3bd8606990>, {}, None)
Template: website.layout
Path: /templates/t/t/t[5]/t[5]/t
Node: <t t-foreach="website.get_alternate_languages(request.httprequest)" t-as="lg">
                    <link rel="alternate" t-att-hreflang="lg['hreflang']" t-att-href="lg['href']" data-oe-id="1390" data-oe-model="ir.ui.view" data-oe-field="arch" data-oe-xpath="/t[1]/t[1]/t[4]/t[5]/t[1]/link[1]"/>
                </t>





Avatar
Discard

Your helpdesk_ticket is not set or not pass to view, helpdesk_ticket = None