Odoo Help


3 Answers
--Qutechs, Ahmed M.Elmubarak--

Qutechs, Ahmed M.Elmubarak
5/25/15, 5:40 AM


I think import will not work in the code section of the server action ...

you can make a new function in your model and call it from the action, model.py :

def play_sound(self, cr, uid, context=None):
    myfile = '/home/ahmed/Music/bell.ogg'
    sound = pyglet.media.load(myfile)
    core = pyglet.media.Player()
    return True

Then from the action you can call this function:

<record model="ir.actions.server" id="play_sound_action">
    <field name="name">Play Server Action</field>
    <field name="model_id" ref="model_test_test"/>
    <field name="code">
           # you code here
    self.play_sound(cr, uid, context)

Regards ..

5/25/15, 2:59 PM

I've added on my modified point_of_sale.py the import and inherit the pos.order model:

class pos_order(osv.Model):
    _inherit = 'pos.order'

def play_sound(self, cr, uid, context=None):
    myfile = '/home/effe/KDE_Beep_Digital_1.ogg'
    sound = pyglet.media.load(myfile)
    core = pyglet.media.Player()
    return True
The update of pos.order did work well but I can't figure out how to implement the python code directly on gui... I've added directly the line
self.play_sound(cr, uid, context)
but obviously didn't work:
ValueError: "'pos.order' object has no attribute 'play_sound'" while evaluating
u'self.play_sound(cr, uid, context)'
Where I'm wrong?
Qutechs, Qutechs, Ahmed M.Elmubarak
6/13/15, 2:59 AM

Hi, where did you added the self.play_sound(cr, uid, context) ?

5/26/15, 6:52 PM


since I got some issues even on pycharm I've update my script using pygame instead of pyglet because I need to separate the audio channels :

import pygame
import time

sound = pygame.mixer.Sound("/home/effe/theetone.wav")
channel = sound.play()
#depending of the sound use left or right channel to mute

Works fine on the IDE but I'm still unable to correctly create a function on point_of_sale.py and link it to the server.action via gui on Odoo.

Qutechs, Qutechs, Ahmed M.Elmubarak
5/27/15, 2:16 AM

Great!, I'll try it on point_of_sale.py whenever I have spare time ... It will be helpful if you can tell me the scenario, because I think you're working on POS ... and may be will need to call the function from js

5/27/15, 9:39 AM

Amhed, thanks for your time.
I'm working on a new module for my restaurant. Since we have just one thermal printer and sincerely I don't like how Odoo manages printers, I started to create a new flow using a server, a client on the kitchen and a tablet to make the orders.
The server is located between the kitchen and the front desk and has one speaker for each ambient. When I send the order to the kitchen the server will to play a sound on the right speaker

and this function should be implemented on pos js as you propose (how is another story).
When an order is done and the button linked to the actions.server on my form view will be pressed, another different sound will be sent to left speaker
That will be the def I need on my .py.
I'm already using this method (without sounds linked) and works fine for my needs but have an alert will be grab the attention when there are many customers. When all will be ready I'll pack a module and share with the community because there are many missing things for a restaurant implementation on stock Odoo. Think on pos_restaurant module for example: if you haven't an ESC/POS compatible printer is pretty unhelpful because the module can't generate pdf or interactive views.
Qutechs, Qutechs, Ahmed M.Elmubarak
6/10/15, 3:02 AM

Hi, I think in Odoo 9 there will be a new POS for restaurants : https://docs.google.com/spreadsheets/d/18CZGaF7igfVEt5_P-F7KzmXPfc-XYXT0iaPFYldCkm0/edit#gid=0 anyway I think the second part is working with the script in the answer right ?

6/10/15, 8:20 AM

Yes, a new pos with (finally) tables management. What second part you're talking about? I'm still stuck but for now I'm not working on pos 9 because is unstable. On production with use V8.

Qutechs, Qutechs, Ahmed M.Elmubarak
6/11/15, 2:00 AM

Hi, the second part is : when the order is done "and the button linked to the actions.server" ... - the first part is when you send the order to the kitchen ...

6/11/15, 8:10 AM

The script that send the order to the kitchen works, but not the sound.

Mr, Harshit Trivedi
5/22/18, 7:15 AM

FEDERICO LEONI My question is that have any idea for the play sound in the single system not in the server, actually, my question is that I have 10 scanner machine so that time scann product if product not found any 1 system then play the sound so how I can archive

Ask a Question
Keep Informed
2 follower(s)
About This Community

This platform 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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now