Technical mailing list archives

RE: raise a warning on create button

- 10/21/2016 02:35:32

Thanks Stéphane,

   Unfortunately, it doesn’t work. It throws me the below error


My code is per follow:

def create(self, values):

    nota = values.get(
    flag = values.get(

if flag == Flase and nota == False:
self.env.user.notify_warning('Nota non inserita')
        line =
        line =
super(SaleOrderLine, self).create(values)

return line



And then I got the following error

Traceback (most recent call last):

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 648, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 685, in dispatch

    result = self._call_function(**self.params)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 321, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\service\", line 118, in wrapper

    return f(dbname, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 314, in checked_call

    result = self.endpoint(*a, **kw)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 964, in __call__

    return self.method(*args, **kw)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 514, in response_wrap

    response = f(*args, **kw)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\addons\web\controllers\", line 888, in call_kw

    return self._call_kw(model, method, args, kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\addons\web\controllers\", line 880, in _call_kw

    return getattr(request.registry.get(model), method)(, request.uid, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 250, in wrapper

    return old_api(self, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 354, in old_api

    result = method(recs, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\addons\sale\", line 233, in create

    result = super(SaleOrder, self).create(vals)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 248, in wrapper

    return new_api(self, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\addons\mail\models\", line 233, in create

    thread = super(MailThread, self).create(values)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 248, in wrapper

    return new_api(self, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 4157, in create

    record = self.browse(self._create(old_vals))

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 248, in wrapper

    return new_api(self, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 490, in new_api

    result = method(self._model, cr, uid, *args, **old_kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 4348, in _create

    result += self._columns[field].set(cr, self, id_new, field, vals[field], user, rel_context) or []

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\osv\", line 825, in set

    id_new = obj.create(cr, user, act[2], context=context)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 250, in wrapper

    return old_api(self, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 355, in old_api

    return downgrade(recs, result, *args, **kwargs)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 273, in <lambda>

    return lambda self, *args, **kwargs: downgrade(args[0])

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\", line 4113, in <lambda>

    @api.returns('self', lambda value:

AttributeError: 'str' object has no attribute 'id'


Any idea? Anybody?


Kind Regards,,

Christian Valsecchi
Mobile +31 627565200


From: Stéphane Bidoul []
Sent: Thursday, October 20, 2016 5:47 PM
To: Community: Framework <>
Subject: Re: raise a warning on create button


web_notify may help.





On Thu, Oct 20, 2016 at 5:42 PM Christian Valsecchi <> wrote:

Hi there,

   I’m trying to raise a warning (when a certain condition is not met) after the user press the button “Create” on sale order creation.

Any ideas? I tried the warning, but I keep getting errors.


Thanks a lot for any input


Kind Regards,

Christian Valsecchi
IT Manager & Consultant - Technology
Mobile +31.627565200


Post to:

Post to: