1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2004-2012 Pexego Sistemas Informáticos. All Rights Reserved
5
# $Alejandro Núñez Liz$
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
23
from tools.translate import _
25
class pos_open_statement(osv.TransientModel):
26
_inherit = 'pos.open.statement'
28
def open_statement(self, cr, uid, ids, context=None):
31
@param self: The object pointer.
32
@param cr: A database cursor
33
@param uid: ID of the user currently logged in
34
@param context: A standard dictionary
35
@return : Blank Directory
39
seccion = int(context['seccion'])
43
pos_user = int(context['pos_user'])
46
mod_obj = self.pool.get('ir.model.data')
47
statement_obj = self.pool.get('account.bank.statement')
48
sequence_obj = self.pool.get('ir.sequence')
49
journal_obj = self.pool.get('account.journal')
55
j_ids = journal_obj.search(cr, uid, [('journal_user','=',1),
56
('zone_id','=',seccion)], context=context)
59
raise osv.except_osv(_('No Cash Register Defined !'),
60
_('You must define which payment method must be available through the point of sale by reusing existing bank and cash through "Accounting > Configuration > Financial Accounting > Journals". Select a journal and check the field "PoS Payment Method" from the "Point of Sale" tab. You can also create new payment methods directly from menu "PoS Backend > Configuration > Payment Methods".'))
62
for journal in journal_obj.browse(cr, uid, j_ids, context=context):
63
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'),
64
('user_id', '=', uid), ('journal_id', '=', journal.id)], context=context)
66
if journal.sequence_id:
67
number = sequence_obj.next_by_id(cr, uid, journal.sequence_id.id)
69
number = sequence_obj.next_by_code(cr, uid, 'account.cash.statement')
72
'journal_id': journal.id,
80
'journal_id': journal.id,
85
statement_id = statement_obj.create(cr, uid, data, context=context)
86
st_ids.append(int(statement_id))
89
statement_obj.button_open(cr, uid, [statement_id], context)
91
tree_res = mod_obj.get_object_reference(cr, uid, 'point_of_sale',
92
'view_cash_statement_pos_tree')
93
tree_id = tree_res and tree_res[1] or False
94
form_res = mod_obj.get_object_reference(cr, uid, 'account',
95
'view_bank_statement_form2')
96
form_id = form_res and form_res[1] or False
97
search_res = mod_obj.get_object_reference(cr, uid, 'account',
98
'view_account_bank_statement_filter')
99
search_id = search_res and search_res[1] or False
102
'type': 'ir.actions.act_window',
103
'name': _('List of Cash Registers'),
105
'view_mode': 'tree,form',
106
'res_model': 'account.bank.statement',
107
'domain': str([('id', 'in', st_ids)]),
108
'views': [(tree_id, 'tree'), (form_id, 'form')],
109
'search_view_id': search_id,