From 49908a6dd2b52efb60cd8a6aebe1cbb3fc42661b Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Tue, 2 Jun 2009 13:02:23 +0200 Subject: [PATCH] Warning message if the order has no line bzr revid: olt@tinyerp.com-20090602110223-aw59wyc1b0rvrzhk --- addons/point_of_sale/pos.py | 5 ----- addons/point_of_sale/wizard/wizard_pos_payment.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py index 25fec4a5e89..004f89d69a3 100644 --- a/addons/point_of_sale/pos.py +++ b/addons/point_of_sale/pos.py @@ -28,11 +28,6 @@ from tools.translate import _ import tools from wizard import except_wizard -# XXX -""" -erreur si pos sans lignes -""" - class pos_config_journal(osv.osv): _name = 'pos.config.journal' diff --git a/addons/point_of_sale/wizard/wizard_pos_payment.py b/addons/point_of_sale/wizard/wizard_pos_payment.py index 8e7c95d86d2..285433d1f15 100644 --- a/addons/point_of_sale/wizard/wizard_pos_payment.py +++ b/addons/point_of_sale/wizard/wizard_pos_payment.py @@ -150,6 +150,16 @@ def _check(self, cr, uid, data, context): return action +def _test_no_line(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + order = pool.get('pos.order').browse(cr, uid, data['id'], context) + + if not order.lines: + raise wizard.except_wizard(_('Error'), _('No order lines defined for this sale.')) + + return {} + + def create_invoice(self, cr, uid, data, context): wf_service = netsvc.LocalService("workflow") for i in data['ids']: @@ -161,7 +171,7 @@ def create_invoice(self, cr, uid, data, context): class pos_payment(wizard.interface): states = { 'init': { - 'actions': [], + 'actions': [_test_no_line], 'result': { 'type': 'choice', 'next_state': _check,