[IMP] point_of_sale: convert the open_statement wizard into osv_memory and improve the view and doc string
bzr revid: sbh@tinyerp.com-20100312063909-9i5rucvfqe205s7s
This commit is contained in:
parent
149920642d
commit
cf6bab1520
|
@ -47,6 +47,7 @@ Main features :
|
|||
'wizard/pos_confirm.xml',
|
||||
'wizard/pos_discount.xml',
|
||||
'wizard/pos_get_sale.xml',
|
||||
'wizard/pos_open_statement.xml',
|
||||
'pos_view.xml',
|
||||
'pos_sequence.xml',
|
||||
'posrule_data.xml',
|
||||
|
|
|
@ -66,12 +66,6 @@
|
|||
menu="False"
|
||||
name="statement.close"
|
||||
string="Close Statements"/>
|
||||
<wizard
|
||||
id="open_statement"
|
||||
model="account.bank.statement"
|
||||
menu="False"
|
||||
name="statement.open"
|
||||
string="Open Statements"/>
|
||||
|
||||
|
||||
<wizard
|
||||
|
|
|
@ -420,8 +420,7 @@
|
|||
<menuitem
|
||||
name="Open Statements" parent="point_of_sale.menu_point_config"
|
||||
string="Open Statements"
|
||||
action="open_statement"
|
||||
type="wizard"
|
||||
action="action_pos_open_statement"
|
||||
id="menu_open_statement" sequence="3" />
|
||||
<menuitem icon="STOCK_PRINT"
|
||||
action="wizard_all_closed_cashbox_of_the_day"
|
||||
|
|
|
@ -12,19 +12,9 @@
|
|||
action="close_statement"
|
||||
type="wizard"
|
||||
id="menu_close_statement" sequence="4" />
|
||||
<wizard
|
||||
id="open_statement"
|
||||
model="account.bank.statement"
|
||||
menu="False"
|
||||
name="statement.open"
|
||||
string="Open Register"/>
|
||||
|
||||
<menuitem
|
||||
name="Open Register" parent="point_of_sale.menu_point_config"
|
||||
string="Open Register"
|
||||
action="open_statement"
|
||||
type="wizard"
|
||||
id="menu_open_statement" sequence="1" />
|
||||
|
||||
|
||||
|
||||
<wizard
|
||||
id="wizard_all_closed_cashbox_of_the_day"
|
||||
|
|
|
@ -39,5 +39,6 @@ import pos_add_product
|
|||
import pos_confirm
|
||||
import pos_discount
|
||||
import pos_get_sale
|
||||
import pos_open_statement
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class add_product(osv.osv_memory):
|
|||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param context: A standard dictionary
|
||||
@return : Retrun the add product form again for addin more product
|
||||
@return : Retrun the add product form again for adding more product
|
||||
"""
|
||||
this = self.browse(cr, uid, ids[0], context=context)
|
||||
record_id = context and context.get('record_id',False)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<!-- Point of Sale Confirm -->
|
||||
|
||||
<record id="view_pos_confirm" model="ir.ui.view">
|
||||
<field name="name">Open Statements</field>
|
||||
<field name="name">Sale Confirm</field>
|
||||
<field name="model">pos.confirm</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
|
@ -20,7 +20,7 @@
|
|||
</record>
|
||||
|
||||
<record id="action_pos_confirm" model="ir.actions.act_window">
|
||||
<field name="name">Open Statements</field>
|
||||
<field name="name">Sale Confirm</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pos.confirm</field>
|
||||
<field name="view_type">form</field>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<record model="ir.values" id="values_pos_confirm">
|
||||
<field name="model_id" ref="point_of_sale.model_pos_order" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Open Statements</field>
|
||||
<field name="name">Sale Confirm</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_pos_confirm'))"/>
|
||||
<field name="key">action</field>
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
# -*- 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_open_statement(osv.osv_memory):
|
||||
_name = 'pos.open.statement'
|
||||
_description = 'Open Statements'
|
||||
|
||||
|
||||
def open_statement(self, cr, uid, ids, context):
|
||||
"""
|
||||
@summary: open 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 Directory
|
||||
"""
|
||||
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)])
|
||||
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 osv.except_osv(_('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=''
|
||||
sequence_obj=self.pool.get('ir.sequence')
|
||||
if journal.statement_sequence_id:
|
||||
number = sequence_obj.get_id(cr, uid, journal.id)
|
||||
else:
|
||||
number = sequence_obj.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 {}
|
||||
pos_open_statement()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Point of Sale Confirm -->
|
||||
|
||||
<record id="view_pos_open_statement" model="ir.ui.view">
|
||||
<field name="name">Open Statements</field>
|
||||
<field name="model">pos.open.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Open Statements">
|
||||
<label string="Are you sure you want to open the statements ?" colspan="2"/>
|
||||
<newline/>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="No" />
|
||||
<button name="open_statement" string="Yes"
|
||||
colspan="1" type="object" icon="gtk-ok"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<act_window name="Open Statements"
|
||||
res_model="pos.open.statement"
|
||||
src_model="account.bank.statement"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="act_pos_open_statement"/>
|
||||
|
||||
<record id="action_pos_open_statement" model="ir.actions.act_window">
|
||||
<field name="name">Open Register</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pos.open.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>
|
||||
|
||||
|
||||
<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>
|
|
@ -50,79 +50,80 @@ def _close_statement(self, cr, uid, data, context):
|
|||
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):
|
||||
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')
|
||||
#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 {}
|
||||
|
||||
# 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_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': {
|
||||
|
|
Loading…
Reference in New Issue