[IMP] point_of_sale: Conver the get_sale wizard in osv_memory
bzr revid: sbh@tinyerp.com-20100311085130-ulfh1yp17xc42245
This commit is contained in:
@@ -46,6 +46,7 @@ Main features :
|
||||
'wizard/pos_add_product.xml',
|
||||
'wizard/pos_confirm.xml',
|
||||
'wizard/pos_discount.xml',
|
||||
'wizard/pos_get_sale.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_get_sale
|
||||
import wizard_scan_product
|
||||
import wizard_receipt
|
||||
import wizard_return
|
||||
@@ -39,5 +38,6 @@ import wizard_all_closed_cashbox_of_the_day
|
||||
import pos_add_product
|
||||
import pos_confirm
|
||||
import pos_discount
|
||||
import pos_get_sale
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
# -*- 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_get_sale(osv.osv_memory):
|
||||
_name = 'pos.get.sale'
|
||||
_description = 'Get From Sale'
|
||||
|
||||
_columns = {
|
||||
'picking_id': fields.many2one('stock.picking', 'Sale Order', domain=[('state','in',('assigned','confirmed')), ('type', '=', 'out')],context="{'contact_display':'partner'}",required=True),
|
||||
}
|
||||
|
||||
def sale_complete(self, cr, uid, ids, context):
|
||||
"""
|
||||
@summary: Select the picking order and add the in Point of sale 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 : nothing
|
||||
"""
|
||||
this = self.browse(cr, uid, ids[0], context=context)
|
||||
record_id = context and context.get('record_id',False)
|
||||
|
||||
proxy_pos = self.pool.get('pos.order')
|
||||
proxy_pick = self.pool.get('stock.picking')
|
||||
|
||||
if record_id:
|
||||
order=proxy_pos.browse(cr, uid, record_id, context)
|
||||
|
||||
if order.state in ('paid', 'invoiced'):
|
||||
raise osv.except_osv(_('UserError '), _("You can't modify this order. It has already been paid"))
|
||||
|
||||
for pick in proxy_pick.browse(cr, uid, [this.picking_id.id], context):
|
||||
proxy_pos.write(cr, uid, record_id, {
|
||||
'last_out_picking':this.picking_id.id,
|
||||
'partner_id': pick.address_id and pick.address_id.partner_id.id
|
||||
})
|
||||
|
||||
order = proxy_pick.write(cr, uid, [this.picking_id.id], {
|
||||
'invoice_state': 'none',
|
||||
'pos_order': record_id
|
||||
})
|
||||
|
||||
for line in pick.move_lines:
|
||||
self.pool.get('pos.order.line').create(cr, uid, {
|
||||
'name': line.sale_line_id.name,
|
||||
'order_id': record_id,
|
||||
'qty': line.product_qty,
|
||||
'product_id': line.product_id.id,
|
||||
'price_unit': line.sale_line_id.price_unit,
|
||||
'discount': line.sale_line_id.discount,
|
||||
})
|
||||
|
||||
return {}
|
||||
pos_get_sale()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Select an Open Sale Order -->
|
||||
|
||||
<record id="view_pos_get_sale" model="ir.ui.view">
|
||||
<field name="name">Open Sale Order</field>
|
||||
<field name="model">pos.get.sale</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Select an Open Sale Order">
|
||||
<field name="picking_id"/>
|
||||
<newline/>
|
||||
<group col="2" colspan="4">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="sale_complete" string="Confirm"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_pos_get_sale" model="ir.actions.act_window">
|
||||
<field name="name">Select an Open Sale Order</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pos.get.sale</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,95 +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 _
|
||||
|
||||
picking_form = """<?xml version="1.0"?>
|
||||
<form string="Select an Open Sale Order">
|
||||
<field name="picking_id" domain="[('state','in',('assigned','confirmed')), ('type', '=', 'out')]" context="{'contact_display':'partner'}"/>
|
||||
</form>
|
||||
"""
|
||||
|
||||
picking_fields = {
|
||||
'picking_id': {'string': 'Sale Order', 'type': 'many2one', 'relation': 'stock.picking', 'required': True}
|
||||
}
|
||||
|
||||
|
||||
def _sale_complete(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
order = pool.get('pos.order').browse(cr, uid, data['id'], context)
|
||||
|
||||
if order.state in ('paid', 'invoiced'):
|
||||
raise wizard.except_wizard(_('UserError'), _("You can't modify this order. It has already been paid"))
|
||||
|
||||
pick = pool.get('stock.picking').browse(cr, uid, data['form']['picking_id'], context)
|
||||
|
||||
pool.get('pos.order').write(cr, uid, data['id'], {
|
||||
'last_out_picking': data['form']['picking_id'],
|
||||
'partner_id': pick.address_id and pick.address_id.partner_id.id
|
||||
})
|
||||
|
||||
order = pool.get('stock.picking').write(cr, uid, [data['form']['picking_id']], {
|
||||
'invoice_state': 'none',
|
||||
'pos_order': data['id']
|
||||
})
|
||||
|
||||
for line in pick.move_lines:
|
||||
pool.get('pos.order.line').create(cr, uid, {
|
||||
'name': line.sale_line_id.name,
|
||||
'order_id': data['id'],
|
||||
'qty': line.product_qty,
|
||||
'product_id': line.product_id.id,
|
||||
'price_unit': line.sale_line_id.price_unit,
|
||||
'discount': line.sale_line_id.discount,
|
||||
})
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
class pos_sale_get(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': picking_form,
|
||||
'fields': picking_fields,
|
||||
'state': (('end', 'Cancel'),
|
||||
('set', 'Confirm', 'gtk-ok', True)
|
||||
)
|
||||
}
|
||||
},
|
||||
'set': {
|
||||
'actions': [_sale_complete],
|
||||
'result': {
|
||||
'type': 'state',
|
||||
'state': "end",
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
pos_sale_get('pos.sale.get')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user