From 8730f3c8325bb906edbe8e423541e31b80f0e6fd Mon Sep 17 00:00:00 2001 From: "sbh (Open ERP)" Date: Fri, 12 Mar 2010 13:58:03 +0530 Subject: [PATCH] [IMP]:point_of_sale: convert the close statement in osv_memeroy and Fix the probelm of company_id bzr revid: sbh@tinyerp.com-20100312082803-6m8cdlrg7t3yn6cu --- addons/point_of_sale/__terp__.py | 3 +- .../point_of_sale/account_bank_statement.py | 19 ++- addons/point_of_sale/pos_wizard.xml | 6 +- addons/point_of_sale/statement_view.xml | 17 +- addons/point_of_sale/statement_wizard.xml | 6 +- addons/point_of_sale/wizard/__init__.py | 3 +- .../wizard/pos_close_statement.py | 52 ++++++ .../wizard/pos_close_statement.xml | 41 +++++ .../wizard/pos_open_statement.xml | 16 +- .../wizard/wizard_open_statement.py | 148 ------------------ 10 files changed, 125 insertions(+), 186 deletions(-) create mode 100644 addons/point_of_sale/wizard/pos_close_statement.py create mode 100644 addons/point_of_sale/wizard/pos_close_statement.xml delete mode 100644 addons/point_of_sale/wizard/wizard_open_statement.py diff --git a/addons/point_of_sale/__terp__.py b/addons/point_of_sale/__terp__.py index 640ed1d67c4..6ee05318544 100644 --- a/addons/point_of_sale/__terp__.py +++ b/addons/point_of_sale/__terp__.py @@ -47,7 +47,8 @@ Main features : 'wizard/pos_confirm.xml', 'wizard/pos_discount.xml', 'wizard/pos_get_sale.xml', - 'wizard/pos_open_statement.xml', + 'wizard/pos_open_statement.xml', + 'wizard/pos_close_statement.xml', 'pos_view.xml', 'pos_sequence.xml', 'posrule_data.xml', diff --git a/addons/point_of_sale/account_bank_statement.py b/addons/point_of_sale/account_bank_statement.py index b599f0531f9..b71e78afcfd 100644 --- a/addons/point_of_sale/account_bank_statement.py +++ b/addons/point_of_sale/account_bank_statement.py @@ -125,14 +125,17 @@ class account_bank_statement(osv.osv): } def create(self, cr, uid, vals, context=None): - open_jrnl = self.search(cr, uid, [('company_id', '=', vals['company_id']), ('journal_id', '=', vals['journal_id']), ('state', '=', 'open')]) - if open_jrnl: - raise osv.except_osv('Error', u'Une caisse de type espèce est déjà ouverte') - if 'starting_details_ids' in vals: - vals['starting_details_ids'] = starting_details_ids = map(list, vals['starting_details_ids']) - for i in starting_details_ids: - if i and i[0] and i[1]: - i[0], i[1] = 0, 0 + + company_id = vals and vals.get('company_id',False) + if company_id: + open_jrnl = self.search(cr, uid, [('company_id', '=', vals['company_id']), ('journal_id', '=', vals['journal_id']), ('state', '=', 'open')]) + if open_jrnl: + raise osv.except_osv('Error', u'Une caisse de type espèce est déjà ouverte') + if 'starting_details_ids' in vals: + vals['starting_details_ids'] = starting_details_ids = map(list, vals['starting_details_ids']) + for i in starting_details_ids: + if i and i[0] and i[1]: + i[0], i[1] = 0, 0 res = super(account_bank_statement, self).create(cr, uid, vals, context=context) return res diff --git a/addons/point_of_sale/pos_wizard.xml b/addons/point_of_sale/pos_wizard.xml index aaaeb8cd58a..711d33784a2 100644 --- a/addons/point_of_sale/pos_wizard.xml +++ b/addons/point_of_sale/pos_wizard.xml @@ -60,12 +60,12 @@ - + string="Close Statements"/>--> + + id="menu_open_statement" sequence="1111" /> + + name="Close Register" parent="point_of_sale.menu_point_config" + string="Close Register" + action="action_pos_close_statement" + id="menu_close_statement" sequence="2" /> diff --git a/addons/point_of_sale/statement_wizard.xml b/addons/point_of_sale/statement_wizard.xml index b6b06bb6765..d00668a5657 100644 --- a/addons/point_of_sale/statement_wizard.xml +++ b/addons/point_of_sale/statement_wizard.xml @@ -1,9 +1,9 @@ - - +--> ). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import netsvc +from osv import osv,fields +from tools.translate import _ +import time + +class pos_close_statement(osv.osv_memory): + _name = 'pos.close.statement' + _description = 'Close Statements' + + + def close_statement(self, cr, uid, ids, context): + """ + @summary: Close the statements + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param context: A standard dictionary + @return : Blank Dictionary + """ + company_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.id + statement_obj = self.pool.get('account.bank.statement') + singer_obj = self.pool.get('singer.statement') + journal_obj=self.pool.get('account.journal') + journal_lst=journal_obj.search(cr,uid,[('company_id','=',company_id),('auto_cash','=',True),('check_dtls','=',False)]) + journal_ids=journal_obj.browse(cr,uid, journal_lst) + for journal in journal_ids: + ids = statement_obj.search(cr, uid, [('state','!=','confirm'),('user_id','=',uid),('journal_id','=',journal.id)]) + statement_obj.button_confirm(cr,uid,ids) + return {} +pos_close_statement() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/point_of_sale/wizard/pos_close_statement.xml b/addons/point_of_sale/wizard/pos_close_statement.xml new file mode 100644 index 00000000000..ff219b1c61f --- /dev/null +++ b/addons/point_of_sale/wizard/pos_close_statement.xml @@ -0,0 +1,41 @@ + + + + + + + Close Statements + pos.close.statement + form + +
+