[IMP] point_of_sale: Convert the pos_confirm wizard into osv_memory

bzr revid: sbh@tinyerp.com-20100311063119-x9zo7cuj2jpv96gn
This commit is contained in:
sbh (Open ERP) 2010-03-11 12:01:19 +05:30
parent cefc85c584
commit b73b0eadb6
5 changed files with 61 additions and 87 deletions

View File

@ -44,6 +44,7 @@ Main features :
'pos_report.xml',
'pos_wizard.xml',
'wizard/pos_add_product.xml',
'wizard/pos_confirm.xml',
'pos_view.xml',
'pos_sequence.xml',
'posrule_data.xml',

View File

@ -30,14 +30,6 @@
<!--<wizard string="Cancel" model="pos.order"
name="pos.cancel" id="pos_cancel" multi="True"/>-->
<wizard
string="Confirm"
model="pos.order"
name="pos.confirm"
id="pos_confirm"
multi="True"
menu="True"
/>
<wizard string="Discount" model="pos.order"
name="pos.discount" id="pos_discount" menu="False"/>

View File

@ -23,7 +23,6 @@
import wizard_pos_payment
import wizard_default_journal
import wizard_refund_order
import wizard_confirm
import wizard_discount
import wizard_get_sale
import wizard_scan_product
@ -39,5 +38,6 @@ import wizard_pos_details
import wizard_open_statement
import wizard_all_closed_cashbox_of_the_day
import pos_add_product
import pos_confirm
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,59 @@
# -*- 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 _
class pos_confirm(osv.osv_memory):
_name = 'pos.confirm'
_description = 'Point of Sale Confirm'
def action_confirm(self, cr, uid, ids, context):
"""
@summary: Confirm the order and close the sales .
@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
"""
this = self.browse(cr, uid, ids[0], context=context)
record_id = context and context.get('record_id',False)
if isinstance(record_id, (int, long)):
record_id=[record_id]
if record_id:
company_id=self.pool.get('res.users').browse(cr,uid,uid).company_id
order_obj = self.pool.get('pos.order')
for order_id in order_obj.browse(cr, uid, record_id, context=context):
if order_id.state =='paid':
order_obj.write(cr,uid,[order_id.id],{'journal_entry':True})
order_obj.create_account_move(cr, uid, [order_id.id], context=context)
wf_service = netsvc.LocalService("workflow")
for i in record_id:
wf_service.trg_validate(uid, 'pos.order', i, 'done', cr)
return {}
pos_confirm()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,78 +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 wizard
import netsvc
import pooler
import time
_form = """<?xml version="1.0"?>
<form string="Open Statements">
<label string="Are you sure you want to close your sales ?" colspan="2"/>
</form>
"""
_fields = {}
def _confirm(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
company_id=pool.get('res.users').browse(cr,uid,uid).company_id
order_obj = pool.get('pos.order')
for order_id in order_obj.browse(cr, uid, data['ids'], context=context):
if order_id.state =='paid':
order_obj.write(cr,uid,[order_id.id],{'journal_entry':True})
order_obj.create_account_move(cr, uid, [order_id.id], context=context)
wf_service = netsvc.LocalService("workflow")
for i in data['ids']:
wf_service.trg_validate(uid, 'pos.order', i, 'done', cr)
return {}
def _get_state(self, cr, uid, data, context):
action = 'invoice'
return action
class pos_confirm(wizard.interface):
states = {
'init': {
'actions': [],
'result': {
'type': 'form',
'arch': _form,
'fields': _fields,
'state': (('end', 'No','gtk-cancel'),
('open', 'Yes', 'gtk-ok', True)
)
}
},
'open': {
'actions': [_confirm],
'result': {
'type': 'state',
'state':'end'}
},
}
pos_confirm('pos.confirm')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: