[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
This commit is contained in:
parent
fcaeab33ca
commit
8730f3c832
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -60,12 +60,12 @@
|
|||
|
||||
<wizard string="Scan Product" model="pos.order"
|
||||
name="pos.scan_product" id="pos_scan_product"/-->
|
||||
<wizard
|
||||
<!-- <wizard
|
||||
id="close_statement"
|
||||
model="account.bank.statement"
|
||||
menu="False"
|
||||
menu="True"
|
||||
name="statement.close"
|
||||
string="Close Statements"/>
|
||||
string="Close Statements"/>-->
|
||||
|
||||
|
||||
<wizard
|
||||
|
|
|
@ -417,11 +417,13 @@
|
|||
<menuitem name="Cashboxes to Close" parent="menu_pos_bank_statment_tree"
|
||||
action="action_cashboxes_to_close" id="menu_cashboxes_to_close_tree" groups="base.group_extended"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
name="Open Statements" parent="point_of_sale.menu_point_config"
|
||||
string="Open Statements"
|
||||
name="Open Registers" parent="point_of_sale.menu_point_config"
|
||||
string="Open Register"
|
||||
action="action_pos_open_statement"
|
||||
id="menu_open_statement" sequence="3" />
|
||||
id="menu_open_statement" sequence="1111" />
|
||||
|
||||
<menuitem icon="STOCK_PRINT"
|
||||
action="wizard_all_closed_cashbox_of_the_day"
|
||||
id="menu_all_closed_cashbox_of_the_day"
|
||||
|
@ -429,10 +431,9 @@
|
|||
type="wizard"/>
|
||||
|
||||
<menuitem
|
||||
name="Close Statements" parent="point_of_sale.menu_point_config"
|
||||
string="Close Statements"
|
||||
action="close_statement"
|
||||
type="wizard"
|
||||
id="menu_close_statement" sequence="3" />
|
||||
name="Close Register" parent="point_of_sale.menu_point_config"
|
||||
string="Close Register"
|
||||
action="action_pos_close_statement"
|
||||
id="menu_close_statement" sequence="2" />
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<openerp>
|
||||
<data>
|
||||
<wizard
|
||||
<!-- <wizard
|
||||
id="close_statement"
|
||||
model="account.bank.statement"
|
||||
menu="False"
|
||||
menu="True"
|
||||
name="statement.close"
|
||||
string="Close Statements"/>
|
||||
<menuitem
|
||||
|
@ -13,7 +13,7 @@
|
|||
type="wizard"
|
||||
id="menu_close_statement" sequence="4" />
|
||||
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<wizard
|
||||
|
|
|
@ -33,12 +33,13 @@ import wizard_pos_payment_report_date
|
|||
import wizard_pos_payment_report_user
|
||||
import wizard_pos_sales_user_current_user
|
||||
import wizard_pos_details
|
||||
import wizard_open_statement
|
||||
#import wizard_open_statement
|
||||
import wizard_all_closed_cashbox_of_the_day
|
||||
import pos_add_product
|
||||
import pos_confirm
|
||||
import pos_discount
|
||||
import pos_get_sale
|
||||
import pos_open_statement
|
||||
import pos_close_statement
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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:
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Point of Sale Confirm -->
|
||||
|
||||
<record id="view_pos_close_statement" model="ir.ui.view">
|
||||
<field name="name">Close Statements</field>
|
||||
<field name="model">pos.close.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Close Statements">
|
||||
<label string="Are you sure you want to close the statements ?" colspan="2"/>
|
||||
<newline/>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="No" />
|
||||
<button name="close_statement" string="Yes"
|
||||
colspan="1" type="object" icon="gtk-ok"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window name="Close Statements"
|
||||
res_model="pos.open.statement"
|
||||
src_model="account.bank.statement"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="action_pos_open_statement"/>
|
||||
|
||||
|
||||
<record id="action_pos_close_statement" model="ir.actions.act_window">
|
||||
<field name="name">Close Register</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pos.close.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'record_id' : active_id}</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -4,7 +4,7 @@
|
|||
<!-- Point of Sale Confirm -->
|
||||
|
||||
<record id="view_pos_open_statement" model="ir.ui.view">
|
||||
<field name="name">Open Statements</field>
|
||||
<field name="name">Open Statementsffffffff</field>
|
||||
<field name="model">pos.open.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
|
@ -33,21 +33,9 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="view_pos_open_statement"/>
|
||||
<field name="context">{'record_id' : active_id}</field>
|
||||
</record>
|
||||
|
||||
|
||||
<menuitem name="Point of Sale" id="menu_point_root" sequence="10"/>
|
||||
<menuitem name="Reporting" parent="menu_point_root" id="menu_point_rep" sequence="5"/>
|
||||
<menuitem name="Register Management" parent="menu_point_root"
|
||||
id="menu_point_config" sequence="3"/>
|
||||
<menuitem
|
||||
name="Open Register" parent="menu_point_config"
|
||||
string="Open Register"
|
||||
action="action_pos_open_statement"
|
||||
id="menu_open_statement" sequence="1" />
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,148 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import pooler
|
||||
import wizard
|
||||
from tools.translate import _
|
||||
import time
|
||||
|
||||
statement_form = """<?xml version="1.0"?>
|
||||
<form string="Open Statements">
|
||||
<label string="Are you sure you want to open the statements ?" colspan="2"/>
|
||||
</form>
|
||||
"""
|
||||
statement_form_close = """<?xml version="1.0"?>
|
||||
<form string="Close Statements">
|
||||
<label string="Are you sure you want to close the statements ?" colspan="2"/>
|
||||
</form>
|
||||
"""
|
||||
|
||||
statement_fields = {}
|
||||
|
||||
def _close_statement(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
company_id=pool.get('res.users').browse(cr,uid,uid).company_id.id
|
||||
statement_obj = pool.get('account.bank.statement')
|
||||
singer_obj = pool.get('singer.statement')
|
||||
journal_obj=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 {}
|
||||
#def _open_statement(self, cr, uid, data, context):
|
||||
# print ":::::::::::::::"
|
||||
# pool = pooler.get_pool(cr.dbname)
|
||||
# company_id=pool.get('res.users').browse(cr,uid,uid).company_id.id
|
||||
# statement_obj = pool.get('account.bank.statement')
|
||||
# singer_obj = pool.get('singer.statement')
|
||||
# journal_obj=pool.get('account.journal')
|
||||
# journal_lst=journal_obj.search(cr,uid,[('company_id','=',company_id),('auto_cash','=',True)])
|
||||
# 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)])
|
||||
# if len(ids):
|
||||
# raise wizard.except_wizard(_('Message'),_('You can not open a Cashbox for "%s". \n Please close the cashbox related to. '%(journal.name) ))
|
||||
# sql = """ Select id from account_bank_statement
|
||||
# where journal_id=%d
|
||||
# and company_id =%d
|
||||
# order by id desc limit 1"""%(journal.id,company_id)
|
||||
# singer_ids=None
|
||||
# cr.execute(sql)
|
||||
# st_id = cr.fetchone()
|
||||
# number=''
|
||||
# if journal.statement_sequence_id:
|
||||
# number = pool.get('ir.sequence').get_id(cr, uid, journal.id)
|
||||
# else:
|
||||
# number = pool.get('ir.sequence').get(cr, uid,
|
||||
# 'account.bank.statement')
|
||||
#
|
||||
## statement_id=statement_obj.create(cr,uid,{'journal_id':journal.id,
|
||||
## 'company_id':company_id,
|
||||
## 'user_id':uid,
|
||||
## 'state':'open',
|
||||
## 'name':number
|
||||
## })
|
||||
# period=statement_obj._get_period(cr,uid,context) or None
|
||||
# cr.execute("INSERT INTO account_bank_statement(journal_id,company_id,user_id,state,name, period_id,date) VALUES(%d,%d,%d,'open','%s',%d,'%s')"%(journal.id,company_id,uid,number, period, time.strftime('%Y-%m-%d %H:%M:%S')))
|
||||
# cr.commit()
|
||||
# cr.execute("select id from account_bank_statement where journal_id=%d and company_id=%d and user_id=%d and state='open' and name='%s'"%(journal.id,company_id,uid,number))
|
||||
# statement_id=cr.fetchone()[0]
|
||||
# if st_id:
|
||||
# statemt_id=statement_obj.browse(cr,uid,st_id[0])
|
||||
# if statemt_id and statemt_id.ending_details_ids:
|
||||
# statement_obj.write(cr, uid,[statement_id], {'balance_start':statemt_id.balance_end,
|
||||
# 'state':'open'})
|
||||
# if statemt_id.ending_details_ids:
|
||||
# for i in statemt_id.ending_details_ids:
|
||||
# c=singer_obj.create(cr,uid, { 'pieces':i.pieces,
|
||||
# 'number':i.number,
|
||||
# 'starting_id':statement_id,
|
||||
# })
|
||||
# cr.commit()
|
||||
# return {}
|
||||
|
||||
#class statement_open(wizard.interface):
|
||||
# states = {
|
||||
# 'init': {
|
||||
# 'actions': [],
|
||||
# 'result': {
|
||||
# 'type': 'form',
|
||||
# 'arch': statement_form,
|
||||
# 'fields': statement_fields,
|
||||
# 'state': (('end', 'No','gtk-cancel'),
|
||||
# ('open', 'Yes', 'gtk-ok', True)
|
||||
# )
|
||||
# }
|
||||
# },
|
||||
# 'open': {
|
||||
# 'actions': [_open_statement],
|
||||
# 'result': {
|
||||
# 'type': 'state',
|
||||
## 'action' :_open_statement,
|
||||
# 'state':'end'}
|
||||
# },
|
||||
# }
|
||||
#statement_open('statement.open')
|
||||
class statement_close(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': statement_form_close,
|
||||
'fields': statement_fields,
|
||||
'state': (('end', 'No','gtk-cancel'),
|
||||
('open', 'Yes', 'gtk-ok', True)
|
||||
)
|
||||
}
|
||||
},
|
||||
'open': {
|
||||
'actions': [_close_statement],
|
||||
'result': {
|
||||
'type': 'state',
|
||||
'state':'end'}
|
||||
},
|
||||
}
|
||||
statement_close('statement.close')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
Loading…
Reference in New Issue