This question has been flagged
2 Replies
8365 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?

Avatar
Discard
Best Answer

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.

Avatar
Discard
Best Answer

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.

Avatar
Discard