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.

0

inherit and modify priority widget

By
Carlos DuAl
on 5/25/16, 7:53 AM 607 views

Hello, 


I'm trying to modify a priority widget so that instead of having only 3 priority levels, it has 5.

This is the section of the code in the main module's view that contains the priority widget (in bold)

[...]

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

<field name="name">CRM - Claims Tree</field>

<field name="model">crm.claim</field>

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

<tree string="Claims">

<field name="name"/>

<field name="partner_id"/>

<field name="user_id"/>

<field name="date"/>

<field name="stage_id"/>

<field name="date_action_next"/>

<field name="action_next"/>

<field name="date_deadline"/>

<field name="categ_id" string="Type"/>

<field name="date_closed" invisible="1"/>

</tree>

</field>

</record>

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

<field name="name">CRM - Claims Form</field>

<field name="model">crm.claim</field>

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

<form string="Claim">

<header>

<field name="stage_id" widget="statusbar" clickable="True"/>

</header>

<sheet string="Claims">

<group>

<field name="name"/>

<field name="date"/>

</group>

<group colspan="4" col="4" groups="base.group_user">

<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'base.group_sale_salesman_all_leads']}"/>

<field name="priority" widget="priority"/>

<field name="section_id" groups="base.group_multi_salesteams"/>

<field name="date_deadline"/>

</group>

[...]



in the .py file, priority is defined as

'priority': fields.selection([('0','Low'), ('1','Normal'), ('2','High')], 'Priority'),




In my module, I'm trying to inherit the previous view using 

<?xml version="1.0" encoding="UTF-8"?>

<openerp>

<data>

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

<field name="name">crm.claim.mod.view</field>

<field name="model">crm.claim</field>

<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>

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

<field name="priority" position="replace">

<field name="priorityNew" widget="priorityNew"

</field>

</field>

</record>

</data>

</openerp>

and in my .py I have defined 

 # -*- coding: utf-8 -*-

from openerp import models, fields, api

from openerp.osv import fields

AVAILABLE_PRIORITIES = [

('0', 'Low'),

('1', 'Normal'),

('2', 'High'),

('3', 'Very High'),

('4', 'Max'),

]

class crm_claim_mod(models.Model):

_inherit = "crm.claim"

_description = "Claims modification"

priorityNew = fields.selection(AVAILABLE_PRIORITIES, 'Priority', select=True)


@api.model

def create(self,vals):

vals['stage_id']='1'

return super(crm_claim_mod,self).create(vals)



But I keep getting this error message

Error details:
Field `priorityNew` does not exist
Error context:
View `crm.claim.mod.view`
[view_id: 1641, xml_id: carlosUpgrade.crm_claim_mod_view, model: crm.claim, parent_id: 1016]" while parsing /home/carlos/dbTest/codigo/mods/carlosUpgrade/crm_claim_mod_view.xml:4, near
<record model="ir.ui.view" id="crm_claim_mod_view">
<field name="name">crm.claim.mod.view</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>
<field name="arch" type="xml">
<field name="priority" position="replace">
<field name="priorityNew" widget="priorityNew"/>
</field>
</field>
0

Jusab Sida (jsi)

--Jusab Sida (jsi)--
Tiny ERP Pvt Ltd
http://www.odoo.com
874
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--


Jusab Sida (jsi)
On 5/25/16, 9:40 AM

If you use new api, there must be 'Selection' instead of 'selection'...Try this one

priorityNew = fields.Selection(AVAILABLE_PRIORITIES, 'Priority', select=True)                    

(put crm_claim in depends, if not)

Hope this will help you...

Hi, thanks for your answer, but if I use Selection, I get this error 2016-05-27 07:19:14,151 3295 CRITICAL base openerp.modules.module: Couldn't load module carlosUpgrade 2016-05-27 07:19:14,151 3295 CRITICAL base openerp.modules.module: 'module' object has no attribute 'Selection' I have crm_claim in the depends section of __openerp__

Carlos DuAl
on 5/27/16, 3:21 AM
0
ayman mohammed adam
On 5/25/16, 9:27 AM

Hi,

i think you don't need to modify or change the priority widget, you must use it by the same name in xml code and determine your levels on the selection fields.

if you want 5 levels you must start from '0' to  '5' , thats mean 5 levels ,

if you want 3 levels you must start from '0' to  '3' , thats mean 5 levels and so on.

example if you  need 3 levels

priorityNew = fields.selection(

[

('0', 'Low'),

('1', 'Normal'),

('2', 'High'),

('3', 'Very High'),

 

]

, 'Priority', select=True)

The thing is that priorities are set in the original module as _colums: { 'priority': fields.selection([('0','Low'), ('1','Normal'), ('2','High')], 'Priority'),

Carlos DuAl
on 5/27/16, 3:22 AM

Sorry about my previous post, I sent it by mistake before finishing writing it The thing is that priorities are set in the original module as _colums: { 'priority': fields.selection([('0','Low'), ('1','Normal'), ('2','High')], 'Priority'), ...} And I can't access (and modify) those values to add more priorities in my module, so that's why I'm trying to completely replace it

Carlos DuAl
on 5/27/16, 3:24 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: 5/25/16, 7:53 AM
Seen: 607 times
Last updated: 5/25/16, 9:40 AM