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

Popup messages wizzard - how to

By
Dr Obx
on 2/2/16, 4:59 AM 461 views

My new module require to inform user about some things like stock levels, quantities etc. I can of course display it on screen but i would like to have it as a popup instead to make sure that the user is seeing it and react on this information.

For example if stock level is LOW message will popup "Hey you, do you know that your stock level is almost zero ? ;)" or something :)

If it's only on the screen among many other can be easily overlooked but if message popup, user must click to close it so I can record this information and if something will be wrong and for example order will not created I will know who is responsible for this mess ;)

I was trying to use warnings but warning stops all processes and roll them back. How to create popup message using other solution ?

Have some ideas but i'm not sure will it work.

def popup_method(...........):
    return {
              'name': _(some name),
              'view_type': 'form',
              "view_mode": 'form',
              'res_model': model-name,
              'type': 'ir.actions.act_window',
              'target': 'new',
              }

and call it conditionally. What do you think guys ?
1

Atul Arvind

--Atul Arvind--
1854
| 3 3 5
India
--Atul Arvind--

Hello, 

I am odoo Enthusiast/Consultant from Baroda, Gujarat, India. Working with odoo from v5 to v9 and other opensource technology since 4+ years. Having Strong Expertise in

Requirement gathering & Gap Analysis

Odoo Development

Odoo Customization

Odoo Training

Odoo Integration

Server Administration

Odoo Migration

Implementation

I am also active on StackOverflow.

or 


Atul Arvind
On 2/2/16, 5:53 AM

Yes, you can use the wizard to display the pop up message in order to show dynamic message and it will not stop the process. 

if you have a button and the text is static, can also use a button confirm attribute in xml, like

<button name="method" string="Confirm" type="object" confirm="are you sure you want to continue?"/>

It will display a confirmation dialog with yes and no button on it and won't break the process.


This second method is useless because as you said is static text only. I'm interested in first one ;) But how, never used wizards or things like that. Have you got any examples ?

Dr Obx
on 2/2/16, 6:09 AM

and also must be triggered depending on if condition ;)

Dr Obx
on 2/2/16, 6:11 AM
0
Dr Obx
On 2/3/16, 5:57 AM

Hah, that's simple, thank you Pawan :)


0

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 2/3/16, 12:51 AM

Rob,

Create a new object as osv.osv_memory( as its data will not be stored in database and is for temporary use only.

class YOUR_CLASS(osv.osv_memory):

and then keep one field in it:

_columns = {'name': fields.char('Message', readonly="1"),

Now under your if condition when u are calling that action as u have in ur part, modify it as:

if YOUR_CONDITION:
    

return {
              'name': _(some name),
              'view_type': 'form',
              "view_mode": 'form',
              'res_model': YOUR_CLASS,
              'type': 'ir.actions.act_window',    
          'context': {'default_name': 'YOUR CUSTOM MESSAGE'}
     'target': 'new', }

and design your xml as needed...

Hope it helps you!    

Testing ;)

Dr Obx
on 2/3/16, 6:25 AM

Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 530, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 567, in dispatch result = self._call_function(**self.params) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 303, in _call_function return checked_call(self.db, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper return f(dbname, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 300, in checked_call return self.endpoint(*a, **kw) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 796, in __call__ return self.method(*args, **kw) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 396, in response_wrap response = f(*args, **kw) File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 944, in call_kw return self._call_kw(model, method, args, kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 336, in old_api result = method(recs, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/connector/producer.py", line 48, in create record_id = create_original(self, vals) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper return new_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4074, in create record = self.browse(self._create(old_vals)) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper return new_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 462, in new_api result = method(self._model, cr, uid, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4265, in _create recs._validate_fields(vals) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper return new_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 1262, in _validate_fields res_msg = trans._get_source(self._name, 'constraint', self.env.lang, msg) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper return new_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 441, in new_api result = method(self._model, cr, uid, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_translation.py", line 369, in _get_source return self.__get_source(cr, uid, name, types, lang, source, res_id) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "", line 2, in __get_source File "/usr/lib/python2.7/dist-packages/openerp/tools/cache.py", line 74, in lookup value = d[key] = self.method(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_translation.py", line 336, in __get_source cr.execute(query, params) File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 158, in wrapper return f(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 234, in execute res = self._obj.execute(query, params) InternalError: current transaction is aborted, commands ignored until end of transaction block

Dr Obx
on 2/3/16, 6:28 AM

Its a bit messy , can u pls figure out your file in it ..

Pawan
on 2/4/16, 1:05 AM

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

1 follower(s)

Stats

Asked: 2/2/16, 4:59 AM
Seen: 461 times
Last updated: 2/3/16, 5:57 AM