Skip to Content
Menu
This question has been flagged
2 Replies
1790 Views

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
Discard
Best Answer

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
Discard

<?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!

Author

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.

Author Best Answer

Hi Nikhil, 

it works now, thank you! 

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


Best 

Friedrich

Avatar
Discard

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.

Author

Thanks Nikhil!

Related Posts Replies Views Activity
2
Aug 24
2935
2
Jan 24
973
1
Nov 23
1357
1
Dec 24
3607
0
Mar 24
935