From e2acebccc3eba3a62d468561865d8f313f3b868a Mon Sep 17 00:00:00 2001 From: "sbh (Open ERP)" Date: Thu, 11 Mar 2010 14:21:30 +0530 Subject: [PATCH] [IMP] point_of_sale: Conver the get_sale wizard in osv_memory bzr revid: sbh@tinyerp.com-20100311085130-ulfh1yp17xc42245 --- addons/point_of_sale/__terp__.py | 1 + addons/point_of_sale/wizard/__init__.py | 2 +- addons/point_of_sale/wizard/pos_get_sale.py | 78 +++++++++++++++ addons/point_of_sale/wizard/pos_get_sale.xml | 35 +++++++ .../point_of_sale/wizard/wizard_get_sale.py | 95 ------------------- 5 files changed, 115 insertions(+), 96 deletions(-) create mode 100644 addons/point_of_sale/wizard/pos_get_sale.py create mode 100644 addons/point_of_sale/wizard/pos_get_sale.xml delete mode 100644 addons/point_of_sale/wizard/wizard_get_sale.py diff --git a/addons/point_of_sale/__terp__.py b/addons/point_of_sale/__terp__.py index e9e20d1c6d2..415e394b24b 100644 --- a/addons/point_of_sale/__terp__.py +++ b/addons/point_of_sale/__terp__.py @@ -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', diff --git a/addons/point_of_sale/wizard/__init__.py b/addons/point_of_sale/wizard/__init__.py index c98cd507417..fe16ff175c8 100644 --- a/addons/point_of_sale/wizard/__init__.py +++ b/addons/point_of_sale/wizard/__init__.py @@ -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: diff --git a/addons/point_of_sale/wizard/pos_get_sale.py b/addons/point_of_sale/wizard/pos_get_sale.py new file mode 100644 index 00000000000..55da8e9d80c --- /dev/null +++ b/addons/point_of_sale/wizard/pos_get_sale.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +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: \ No newline at end of file diff --git a/addons/point_of_sale/wizard/pos_get_sale.xml b/addons/point_of_sale/wizard/pos_get_sale.xml new file mode 100644 index 00000000000..b44d2b9161e --- /dev/null +++ b/addons/point_of_sale/wizard/pos_get_sale.xml @@ -0,0 +1,35 @@ + + + + + + + + Open Sale Order + pos.get.sale + form + +
+ + + +