Odoo Help

0

How do you inherit model and change field to (required = false), when the field is in many views??

By
John Baldwin
on 1/9/15, 10:22 AM 1,924 views

I'm trying to change the name field in the crm.lead model to not be required without changing in the actual crm model. I can't seem to inherit the model in .py only views in xml. I want to make changes to fields that appear in many views, yet are the same field in the .py file.
 

I've tried the docs, the web and this help forum and can't figure out what I'm doing wrong.
_______________________________________________________________

# -*- coding: utf-8 -*-
from openerp import models, fields, api

class MyCrm(models.Model):
    
    _inherit = 'crm.lead'
    
    name = fields.Char(required=False)
---------------------------------------------------------------------------------------------------------------
Thanks for any help!

What was the error?

Kazim Mirza
on 1/9/15, 10:36 AM

Nothing, I got it to work. Was not updating properly.

John Baldwin
on 1/18/15, 11:49 AM
0
Jainesh Shah
On 9/9/17, 6:06 AM

Hi John, 

If you don't require name field in all inherited views then need to change below thing in .py file :-

              # -*- coding: utf-8 -*-
              from openerp import fields, models
        class Lead(models.Model):             _inherit = 'crm.lead'                         name = fields.Char(required=False)

               Alternatively, if you don't require name field then inherit xml view through following code:
                 <record id="inherit_crm_view"  model="ir.ui.view">
                  <field name="name">crm.form.view</field>
                  <field name="model">crm.lead</field>
                  <field name="inherit_id"
      ref="inherit_view_remove_name_required"/>
                  <field name="arch" type="xml">
                      <xpath expr="//field[@name='name']"
      position="attributes">
                          <attribute
      name="required">False</attribute>
                      </xpath>
                  </field>
                 </record>

I hope this will help you.

Thanks!


About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)

Stats

Asked: 1/9/15, 10:22 AM
Seen: 1924 times
Last updated: 9/9/17, 6:06 AM