Odoo Help

2

How to auto close pos session with Scheduled Actions function?

By
JC
on 3/30/16, 5:26 AM 788 views

I want to auto close my pos session at 12am everyday, can it be done with Scheduled Action? if yes what should I configure for  Object, Method and Arguments?

0
Victor Lopes
On 4/16/18, 2:31 PM

Hi there, you've probably found your answer by now, but for those looking for this, here is a step-by-step way of doing it, in Odoo 10:

As Jainesh stated above, you have to find a way of selecting sessions in a "opened" (in progress) state and then calling the proper method in order to close them.

If you look at the FormView of the "close" page of a given POS session (using the developer menu) you'll note that the method that the button "Validate Closing & Post Entries" calls is the following:

      action_pos_session_closing_control

You will find this method in the file pos_session.py, around line 238. You have to create a new method in this POS module to select the sessions you want and call this action_pos_session_closing_control method for them:

1. Edit the file your_odoo_server_path/addons/point_of_sale/models/pos_session.py and include the following code:

@api.model

def auto_close_pos_session(self):

""" Method called by scheduled actions to close currently open sessions """

return self.search([('state', '=', 'opened')]).action_pos_session_closing_control()

You can place it right bellow the other method, for example. Please mind the spaces, as python has a specific indentation syntax. Restart Odoo's service using: service odoo-server restart

Note that we're creating a new method called "auto_close_pos_session", searching for sessions with state = opened and calling the method we discussed.

2. In Odoo, activate the developer mode and go to "Technical > Scheduled Actions" in the Settings module. Create a new scheduled action and, in the "Technical Data" tab (section "Action to Trigger") provide the following info:

Object: pos.session

Method: auto_close_pos_session

Arguments: ()

Then give this scheduled action a name, plus the interval and date you want and save it.

0

Jainesh Shah

--Jainesh Shah--
1130
| 4 2 5
Ahmedabad, India
--Jainesh Shah--


Jainesh Shah
On 6/15/17, 8:41 AM

Create scheduler which calls every day by 12:00 am in which you need to find all active session(which is in 'open' state)and call open_existing_session_cb_clos method to close sessions.

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.

Register

Odoo Training Center

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

Test it now

Question tools

2 follower(s)

Stats

Asked: 3/30/16, 5:26 AM
Seen: 788 times
Last updated: 4/16/18, 2:31 PM