Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
1851 Tampilan

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
Buang
Jawaban Terbai

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
Buang

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

Penulis

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.

Penulis Jawaban Terbai

Hi Nikhil, 

it works now, thank you! 

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


Best 

Friedrich

Avatar
Buang

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.

Penulis

Thanks Nikhil!

Post Terkait Replies Tampilan Aktivitas
2
Agu 24
3021
2
Jan 24
1046
1
Nov 23
1434
1
Des 24
3676
0
Mar 24
984