1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
25
from tools.translate import _
27
picking_form = """<?xml version="1.0"?>
28
<form string="Select an Open Sale Order">
29
<field name="picking_id" domain="[('state','in',('assigned','confirmed')), ('type', '=', 'out')]" context="{'contact_display':'partner'}"/>
34
'picking_id': {'string': 'Sale Order', 'type': 'many2one', 'relation': 'stock.picking', 'required': True}
38
def _sale_complete(self, cr, uid, data, context):
39
pool = pooler.get_pool(cr.dbname)
40
order = pool.get('pos.order').browse(cr, uid, data['id'], context)
42
if order.state in ('paid', 'invoiced'):
43
raise wizard.except_wizard(_('UserError'), _("You can't modify this order. It has already been paid"))
45
pick = pool.get('stock.picking').browse(cr, uid, data['form']['picking_id'], context)
47
pool.get('pos.order').write(cr, uid, data['id'], {
48
'last_out_picking': data['form']['picking_id'],
49
'partner_id': pick.address_id and pick.address_id.partner_id.id
52
order = pool.get('stock.picking').write(cr, uid, [data['form']['picking_id']], {
53
'invoice_state': 'none',
54
'pos_order': data['id']
57
for line in pick.move_lines:
58
pool.get('pos.order.line').create(cr, uid, {
59
'name': line.sale_line_id.name,
60
'order_id': data['id'],
61
'qty': line.product_qty,
62
'product_id': line.product_id.id,
63
'price_unit': line.sale_line_id.price_unit,
64
'discount': line.sale_line_id.discount,
70
class pos_sale_get(wizard.interface):
77
'fields': picking_fields,
78
'state': (('end', 'Cancel'),
79
('set', 'Confirm', 'gtk-ok', True)
84
'actions': [_sale_complete],
92
pos_sale_get('pos.sale.get')
94
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: