Community: Framework mailing list archives

expert-framework@mail.odoo.com

RE: raise a warning on create button

by
Christian
- 10/21/2016 03:17:36

Same issue…

 

Kind Regards,,

Christian Valsecchi
Mobile +31 627565200

 

From: Jean-Paul Robineau [mailto:jprobineau@yahoo.com]
Sent: Friday, October 21, 2016 8:47 AM
To: Community: Framework <expert-framework@mail.odoo.com>
Subject: Re: raise a warning on create button

 

Instead of using line ="" use line = False

 

On Friday, October 21, 2016 8:37 AM, Christian Valsecchi <christian.valsecchi@outlook.com> wrote:



Thanks Stéphane,

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

 

My code is per follow:

@api.model
def create(self, values):

    nota = values.get(
'order_line_notes')
    flag = values.get(
'flag_riordino')


   
if flag == Flase and nota == False:
       
self.env.user.notify_warning('Nota non inserita')
        line =
""
   
else:
        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\http.py", line 648, in _handle_exception

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

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

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

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

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

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

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

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

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

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

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

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

    response = f(*args, **kw)

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\addons\web\controllers\main.py", 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\main.py", line 880, in _call_kw

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  File "C:\nexapp\source\odooNexApp9\odoo-9.0\openerp\models.py", 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\fields.py", line 825, in set

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

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

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

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

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

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

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

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

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

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

 

Any idea? Anybody?

 

Kind Regards,,

Christian Valsecchi
Mobile +31 627565200

 

From: Stéphane Bidoul [mailto:stephane.bidoul@acsone.eu]
Sent: Thursday, October 20, 2016 5:47 PM
To: Community: Framework <expert-framework@mail.odoo.com>
Subject: Re: raise a warning on create button

 

web_notify may help.

 

 

-sbi

 

On Thu, Oct 20, 2016 at 5:42 PM Christian Valsecchi <christian.valsecchi@outlook.com> 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

 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe



_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe