Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Insert Contact Reference ref in XML

By
Sergio Fernández
on 1/22/16, 7:20 AM 396 views

Good morning!

I would like the Contact Reference to appear in the Calendar View of Tasks (in Project app). I modified some parameters more and now the XML looks like this:.

<?xml version="1.0"?>
<calendar color="user_id" date_start="date_deadline" string="Tasks">
                    <field name="ref"/> 
<field name="partner_id"/>
<field name="name"/>
<field name="project_id"/>
</calendar>
But when saving it tells me:

ValidateErrorField(s) `arch` failed against a constraint: Invalid view definitionError details:Field `ref` does not existError context:View `project.task.calendar`[view_id: 1147, xml_id: project.view_task_calendar, model: project.task, parent_id: n/a]


Do you know where "ref" is located? I don't know where is it, and also I don't know where to begin searching! I will highly appreciate your help..
2

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 1/23/16, 3:15 PM

Hi Sergio,

Because the field ref does not exist in the model project.task. If you want to call a field in the view definition of a model, then that field should be defined in that model. 

Here you want to get the Customer reference which is defined in the res.partner model, ie, Customer. So there is only one field in project.task through which you can reach the Customer, ie, the partner_id field. Through that field you can access the ref field defined in res.partner.

For that, a better option is to define a new related field in project.task, which allows you to access the customer reference and show it in the project.task model.

Inorder to define that new field, you can just create a new custom module, by looking at the Odoo tutorial. And in your module, in the .py file put this:

class project_task(models.Model):

_inherit = 'project.task'

ref = fields.Char(related='partner_id.ref', string='Customer Reference')

Then in the .xml file put this:

<record id="view_task_calendar_inherited" model="ir.ui.view">

<field name="name">project.task.calendar.inherited</field>

<field name="model">project.task</field>

<field name="inherit_id" ref="project.view_task_calendar"/>

<field name="arch" type="xml">

<field name="name" position="before">

<field name="ref" />

</field>

</field>

</record>

This will bring Customer reference in the calender view of project.task

Thank you a lot! I will try it

Sergio Fernández
on 1/29/16, 8:01 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/22/16, 7:20 AM
Seen: 396 times
Last updated: 1/29/16, 8:00 AM