Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1791 Vistas

Hi all, 

this is my python code:

class project_Task(models.Model):
_inherit = 'project.task'

lead_id = fields.Many2one(comodel_name='crm.lead', string='Opportunity', track_visibility='onchange')

I want to show it in the form view of project tasks. Here is my xml:

xml version="1.0" encoding="utf-8"?>


id="view_project_task_form_inherit" model="ir.ui.view">
name="name">project.task.form.inherit
name="model">project.task
name="inherit_id" ref="project.view_task_form2" />
name="arch" type="xml">

name="lead_id" position="after">





somehow I get an error:

odoo.tools.convert.ParseError: while parsing task_from_lead/views/task_from_lead_task_view.xml:5, somewhere inside

project.task.form.inherit

...


What is the issue? 

(The file is named in the __manifest__ file.)



Thanks in advance!

Friedrich

Avatar
Descartar
Mejor respuesta

Hi Friedrich Sauer,

can you send perfect code of your form view so i identify issue. 

  • can you try this way after project id field add your lead_id field.
  • Also use XPath using specific field after or before add.
  • i try in my project its complete work 


Thank you.

Avatar
Descartar

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_project_task_form_inherit" model="ir.ui.view">
<field name="name">project.task.form.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2" />
<field name="arch" type="xml">
<xpath expr="//form" position="inside">
<field name="lead_id" />
</xpath>
</field>
</record>
</data>
</odoo>

sorry, that did not work but here is the xml in a txt file https://drive.google.com/drive/folders/1vCBP-NQr-NC4mSiucrUINQgPaLnGCBB0?usp=drive_link

Thanks in advance!

Autor

Hi Nikhil, I switched accounts on accident 'Alberts' comments were mine too!
https://drive.google.com/drive/folders/1vCBP-NQr-NC4mSiucrUINQgPaLnGCBB0?usp=drive_link

hii can you check my latest answer.

Autor Mejor respuesta

Hi Nikhil, 

it works now, thank you! 

Can you tell when to use and when to use xpath?


Best 

Friedrich

Avatar
Descartar

Hi Friedrich Sauer,
Sure, let's say
1. when you define any position your field like in odoo form view so you need to define xpath expression so it locate specific locations,

you need more understand then check this
https://www.scientecheasy.com/2019/08/xpath-axes.html/

Thank you.

Autor

Thanks Nikhil!

Publicaciones relacionadas Respuestas Vistas Actividad
2
ago 24
2936
2
ene 24
973
1
nov 23
1361
1
dic 24
3609
0
mar 24
935