1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
26 class pos_confirm(osv.osv_memory):
28 _description = 'Post POS Journal Entries'
30 def action_confirm(self, cr, uid, ids, context=None):
31 wf_service = netsvc.LocalService("workflow")
32 order_obj = self.pool.get('pos.order')
33 ids = order_obj.search(cr, uid, [('state','=','paid')], context=context)
34 for order in order_obj.browse(cr, uid, ids, context=context):
36 for line in order.statement_ids:
37 if line.statement_id.state <> 'confirm':
41 wf_service.trg_validate(uid, 'pos.order', order.id, 'done', cr)
43 # Check if there is orders to reconcile their invoices
44 ids = order_obj.search(cr, uid, [('state','=','invoiced'),('invoice_id.state','=','open')], context=context)
45 for order in order_obj.browse(cr, uid, ids, context=context):
46 invoice = order.invoice_id
47 data_lines = [x.id for x in invoice.move_id.line_id if x.account_id.id == invoice.account_id.id]
48 for st in order.statement_ids:
49 for move in st.move_ids:
50 data_lines += [x.id for x in move.line_id if x.account_id.id == invoice.account_id.id]
51 self.pool.get('account.move.line').reconcile(cr, uid, data_lines, context=context)
55 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: