← Back to team overview

openerp-dev-web team mailing list archive

[Bug 668465] Re: [trunk] controllers form, bad contidion on save

 

i know i promise to not come here again, but i see a update today and
i'm not realy agree with you

in the update now we CAN'T click on button if form is not in edit
mode... you take the short way to solve the problem but is not the good
one.

Imagine, we create a sale order, next day sales order is confirmed, we
open the sale order, and try to confirm with button .. nothing because
we are not in edit ... with the update we need to edit record to press a
button, is not the best way, because we DONT need to edit the record so,
no reason to press edit before press confirm order.


anyway i'm not sure is this update is your release because the messagein log is not clear. "[FIX] Fixed Button clicked for view mode. rev 4095"

Maybe you need to ask end user to know on this small change affect them,
but i'm sure they will not be happy to need to press edit before press a
button in a form view.  I know is only a action (press a button) but end
user never happy when you add one action to do.


The best way to correct this problem is allow press button in no
editable state and NOT SAVE record when a button pressed in no editable
state.   i make all code for you before, i you no like it, change  it
but is the best way to correct it.

-- 
You received this bug notification because you are a member of OpenERP
SA's Web Client R&D, which is a bug assignee.
https://bugs.launchpad.net/bugs/668465

Title:
  [trunk] controllers form, bad contidion on save

Status in OpenObject Web Client:
  Fix Released

Bug description:
  If you have a button, link with a action type url, when you press on button in NOT edit mode, original code launch a write,
Comment in code say "bypass save, for button action in non-editable view" but the condition is bad, and 2 else do same thing.

addons/openerp/controllers/form.py  Class Form, Function save

Original code
        # bypass save, for button action in non-editable view
        if not (params.button and params.editable and params.id):
            proxy = rpc.RPCProxy(params.model)
            if not params.id:
                ctx = dict((params.context or {}), **rpc.session.context)
                id = proxy.create(data, ctx)
                params.ids = (params.ids or []) + [int(id)]
                params.id = int(id)
                params.count += 1
            else:
                ctx = utils.context_with_concurrency_info(params.context, params.concurrency_info)
                id = proxy.write([params.id], data, ctx)

        elif params.button and params.editable and params.id:
            proxy = rpc.RPCProxy(params.model)
            ctx = utils.context_with_concurrency_info(params.context, params.concurrency_info)
            id = proxy.write([params.id], data, ctx)

Fix:   The fix do create if button, editable and no id in param, else do a write if button, editable and id in param

if params.button and params.editable and not params.id:
            proxy = rpc.RPCProxy(params.model)
            ctx = dict((params.context or {}), **rpc.session.context)
            id = proxy.create(data, ctx)
            params.ids = (params.ids or []) + [int(id)]
            params.id = int(id)
            params.count += 1
        elif params.button and params.editable and params.id:
            proxy = rpc.RPCProxy(params.model)
            ctx = utils.context_with_concurrency_info(params.context, params.concurrency_info)
            id = proxy.write([params.id], data, ctx)