[IMP] point_of_sale: Converted Add Product wizard into osv_memory wizard
bzr revid: sbh@tinyerp.com-20100310135548-810h40effu2jtwft
This commit is contained in:
parent
bc22b5f593
commit
cefc85c584
|
@ -43,6 +43,7 @@ Main features :
|
|||
'security/ir.model.access.csv',
|
||||
'pos_report.xml',
|
||||
'pos_wizard.xml',
|
||||
'wizard/pos_add_product.xml',
|
||||
'pos_view.xml',
|
||||
'pos_sequence.xml',
|
||||
'posrule_data.xml',
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
import wizard_pos_payment
|
||||
import wizard_default_journal
|
||||
import wizard_refund_order
|
||||
import wizard_add_product
|
||||
import wizard_confirm
|
||||
import wizard_discount
|
||||
import wizard_get_sale
|
||||
|
@ -39,5 +38,6 @@ import wizard_pos_sales_user_current_user
|
|||
import wizard_pos_details
|
||||
import wizard_open_statement
|
||||
import wizard_all_closed_cashbox_of_the_day
|
||||
import pos_add_product
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
# -*- 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 add_product(osv.osv_memory):
|
||||
_name = 'pos.add.product'
|
||||
_description = 'Add Product'
|
||||
|
||||
_columns = {
|
||||
'product_id': fields.many2one('product.product', 'Product',required=True),
|
||||
'quantity': fields.float('Quantity ', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'quantity': lambda *a: 1,
|
||||
}
|
||||
|
||||
def select_product(self, cr, uid, ids, context):
|
||||
"""
|
||||
@summary: To get the product and quantity and add in order .
|
||||
@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 : Retrun the add product form again for addin more product
|
||||
"""
|
||||
this = self.browse(cr, uid, ids[0], context=context)
|
||||
record_id = context and context.get('record_id',False)
|
||||
if record_id:
|
||||
order_obj = self.pool.get('pos.order')
|
||||
order_obj.add_product(cr, uid, record_id, this.product_id.id,this.quantity,context=context)
|
||||
|
||||
return {
|
||||
'name': _('Add Product'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'pos.add.product',
|
||||
'view_id': False,
|
||||
'target':'new',
|
||||
'views': False,
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
add_product()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Add Product -->
|
||||
|
||||
<record id="view_add_product" model="ir.ui.view">
|
||||
<field name="name">Add Product</field>
|
||||
<field name="model">pos.add.product</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add product :">
|
||||
<group col="2" colspan="4">
|
||||
<field name="product_id"/>
|
||||
<field name="quantity"/>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Close" />
|
||||
<button name="select_product" string="Contiue"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_add_product" model="ir.actions.act_window">
|
||||
<field name="name">Add Product</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pos.add.product</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>
|
|
@ -1,88 +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
|
||||
|
||||
|
||||
_form = """<?xml version="1.0"?>
|
||||
<form string="Add product :">
|
||||
<field name="product"/>
|
||||
<field name="quantity"/>
|
||||
</form>
|
||||
"""
|
||||
_fields = {
|
||||
'product': {
|
||||
'string': 'Product',
|
||||
'type': 'many2one',
|
||||
'relation': 'product.product',
|
||||
'required': True,
|
||||
'default': False
|
||||
},
|
||||
|
||||
'quantity': {
|
||||
'string': 'Quantity',
|
||||
'type': 'integer',
|
||||
'required': True,
|
||||
'default': 1},
|
||||
}
|
||||
|
||||
|
||||
def _add(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
order_obj = pool.get('pos.order')
|
||||
order_obj.add_product(cr, uid, data['id'], data['form']['product'],
|
||||
data['form']['quantity'], context=context)
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
def _pre_init(self, cr, uid, data, context):
|
||||
return {'product': False, 'quantity': 1}
|
||||
|
||||
|
||||
class add_product(wizard.interface):
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_pre_init],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': _form,
|
||||
'fields': _fields,
|
||||
'state': [('end', 'Cancel'), ('add', '_Add product', 'gtk-ok', True)
|
||||
]
|
||||
}
|
||||
},
|
||||
'add': {
|
||||
'actions': [_add],
|
||||
'result': {
|
||||
'type': 'state',
|
||||
'state': 'init',
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
add_product('pos.add_product')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue