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

statusbar does not highlight. [Closed]

By
Gavin Yap
on 7/12/15, 2:30 AM 666 views

Hi,

I tried to mimic hr_recruitment module by allowing customisable of stages instead of a static one.

So instead of doing the below

state = fields.Selection([
('draft', "Draft"),
('confirmed', "Confirmed"),
('done', "Done"),
])

I'm create a Stage class

class Stage(models.Model):
_name = "warranty.stage"
_description = "Stage of Warranty Tracking"
_order = 'sequence'
name = fields.Char('Name', required=True)
sequence = fields.Integer('Sequence', help="Gives the sequence order when displaying a list of stages.")
description = fields.Text('Description')
fold = fields.Boolean('Folded in Kanban View',
help='This stage is folded in the kanban view when'
'there are no records in that stage to display.')
registration_ids = fields.One2many(
'warranty.registration', 'stage_id', string="Registrations")
_defaults = {
'sequence': 1,
'fold': False,
}

and then in another class Registration, it wiill have the stage_id attribute.

stage_id = fields.Many2one('warranty.stage', ondelete='set null', string="Stage")


The Registration view form will have the 

<form string="Registration Form">
<header>
<field name="stage_id" widget="statusbar" clickable="True"/>
</header>

However, I have 3 Stages configure, namely New, Registered, Rejected.

However, if my Registration object that is under New, for example will not highlight in the form view.

What am I missing here? 


0
Gavin Yap
On 7/13/15, 1:29 PM

There is no need  to use selection field.


Due to the fact that I create 2 field of the same, stage_id with widget="status bar", and stage_id normal.

The Form failed to highlight the status bar. Removing the duplicate field solves my problem.

Therefore using using the fields.Many2one, will also work for statusbar.




2

Axel Mendoza

--Axel Mendoza--
10203
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 7/13/15, 4:09 AM

Your stage_id field still need to be a selection but pass a function name as a reference or string name of the function that collect the values of your Stage class records instead of a simple list of tuples. Something like this:

 
    @api.model def _get_stages(self):
        stage_ids = self.env['warranty.stage'].search([]) return [(stage.name,stage.name) for stage in stage_ids]

    stage_id = fields.Selection('_get_stages',string='Stage')



Thanks Axel. I tried your code,but it doesn't work on v8. Also I need the stage_id as multi-relationship with other classes. However, I did find my problem, I'll post my answer next.

Gavin Yap
on 7/13/15, 12:08 PM

Sorry, I'm using a lot of Odoo alfa v9 this days but the idea is the same, search for the values you wana use in the selection from whatever source you may have and declare a function field with that

Axel Mendoza
on 7/13/15, 12:25 PM

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

2 follower(s)

Stats

Asked: 7/12/15, 2:30 AM
Seen: 666 times
Last updated: 8/5/15, 2:23 AM