on_change should be supported on search view fields

Bug #892804 reported by Mihai Satmarean
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo GTK Client (MOVED TO GITHUB)
Won't Fix
Undecided
Unassigned
Odoo Web (MOVED TO GITHUB)
Won't Fix
Undecided
Unassigned

Bug Description

the code for the view:

         <record id="view_employee_filter" model="ir.ui.view">
            <field name="name">Employees</field>
            <field name="model">hr.employee</field>
            <field name="type">search</field>
            <field name="inherit_id" ref="hr.view_employee_filter"/>
            <field name="arch" type="xml">
            <field name="name" position="before">
               <field name="id_search" on_change="search_id_change(id_search)"/>
            </field>
            <field name="parent_id" position="after">
                 <button name="attendance_action_change" states="present" string="Sign Out" type="object" icon="gtk-go-forward" context="{'type':'sign_out'}" groups="base.group_hr_user"/>
                 <button name="attendance_action_change" states="absent" string="Sign In" type="object" icon="gtk-go-back" context="{'type':'sign_in'}" groups="base.group_hr_user"/>
                 <field name="state"/>
            </field>
            </field>
         </record>

and the code for the controller:

    def search_id_change(self, cr, uid, ids, idsearch, context=None):
        print idsearch
        result = {}
        return result

the on_change is never called.

Thanks

Revision history for this message
Ferdinand (office-chricar) wrote :
Revision history for this message
Mihai Satmarean (mihai-satmarean) wrote :

definetly connected,
It is blocking my entire project,

Revision history for this message
Mihai Satmarean (mihai-satmarean) wrote :

You marked the bug as duplicate, but is not,

For me also in the GTK is not working,

Thanks

Revision history for this message
Mihai Satmarean (mihai-satmarean) wrote :

Please remove the duplicate mark.

affects: openobject-addons → openobject-server
Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello ,

Currently we have not implemented on change in search view fields for
working on search view field you can pass context on
field of search view means that context you can get on
search method of object.so this is not a bug and I am consider
this as feature.

That's way I am setting this as wish list.

Thanks for reporting.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Wishlist
status: New → Confirmed
affects: openobject-server → openobject-client
Changed in openobject-client:
assignee: OpenERP's Framework R&D (openerp-dev-framework) → OpenERP sa GTK client R&D (openerp-dev-gtk)
Changed in openerp-web:
assignee: nobody → OpenERP R&D Web Team (openerp-dev-web)
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

> definetly connected,

No it's not, the `on_change` feature is only specified for form views — hence bug over there, this is a feature request: on_change currently *does not exist* for search views. It's perfectly normal that it's not working as it's not supposed to work.

summary: - on_change for search field not working
+ on_change should be supported on search view fields
Changed in openerp-web:
status: Confirmed → Opinion
Changed in openobject-client:
status: Confirmed → Opinion
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

As Xavier explained, this is by design, and on_change triggers are meant for editable views (form views or editable list/tree views), but have no sense in other cases.

An on_change relies on the current value of some fields of a record, and helps to validate them or provide suggestions for other fields. There is no sense to do that on a search view, which never represents a record.

Depending on what you want to accomplish in the search view, you may be able to use the `filter_domain` attribute that lets you filter on multiple criterions based on the input in a single field, or the `context` attribute that lets you alter the search context, and give different search/read results based on it (look for examples of both in existing addons).

I'm closing this bug now, to clearly show that this is by design and we don't plan to change the scope of on_change triggers.

Thanks for your understanding.

Changed in openerp-web:
importance: Wishlist → Undecided
status: Opinion → Won't Fix
Changed in openobject-client:
importance: Wishlist → Undecided
status: Opinion → Won't Fix
assignee: OpenERP sa GTK client R&D (openerp-dev-gtk) → nobody
Changed in openerp-web:
assignee: OpenERP R&D Web Team (openerp-dev-web) → nobody
Revision history for this message
Mihai Satmarean (mihai-satmarean) wrote :

I was trying to empty the respective search field upon trigger.

There is currently no way I can do that, if is possible please give me the solution.
After the search is triggered, I have no access to the search field to change it's value to nothing.

Thanks

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote : Re: [Bug 892804] Re: on_change should be supported on search view fields

On 11/23/2011 10:15 AM, Mihai Satmarean wrote:
> I was trying to empty the respective search field upon trigger.
>
> There is currently no way I can do that, if is possible please give me the solution.
> After the search is triggered, I have no access to the search field to change it's value to nothing.

There is no way to do that, I think, and it sounds like a very strange
thing to do. So the question is more: why would you want to do something
like that?

Revision history for this message
Mihai Satmarean (mihai-satmarean) wrote :

There is a codebar scanner, that scans codes in the search field and then presses enter,
the search function is overwritten to generate an sign in action.

All is working as expected,
but for the next scan somebody has to manually clear the field otherwise the scanner concatenates the new code to the old code and the search fails.

I need help. I am blocked here.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

On 11/23/2011 11:05 AM, Mihai Satmarean wrote:
> There is a codebar scanner, that scans codes in the search field and then presses enter,
> the search function is overwritten to generate an sign in action.

This is really not recommended, you should never hijack the search()
method to make it do other things than what it is supposed to do.
It will cause all kinds of problems, and the question you are asking now
is just an example of them.

> All is working as expected,

Obviously not ;-)

> but for the next scan somebody has to manually clear the field
> otherwise the scanner concatenates the new code to the old code and
> the search fails.

Most barcode scanners act like keyboards, and you can probably make it
send a series of delete (^H) characters after the enter key to erase the
field.

In any case you should not be using the search view to implement this.
From what I understand you're trying to display a form where users (or
the scanner) can type in their employee ID, and that will record a sign
in/sign out event.
Two suggestions:
- make a real wizard form with an employee ID field and a confirm
button, that will perform the search and create the appropriate records.
After performing this the wizard can reopen itself with a blank form.
- many people implement this with a stand-alone badge scanner rather
than a scanner peripheral. It's a very simple device that records scan
time + badge ID and usually saves it as an XML file. You can then make a
simple OpenERP cron job that retrieves the file every 5 minutes and
creates the corresponding entries.

> I need help. I am blocked here.

OpenERP bug reports are not meant for tech support. Members of the
community will be happy to assist you in the Launchpad Answers (Answers
link on top of project pages), in the mailing-list or the forum.
You may also contact the tech support for further questions if you have
a support subscription.

Thanks!

Revision history for this message
Mihai Satmarean (mihai-satmarean) wrote :

Thanks a lot for your input.
I will try as suggested.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.