← Back to team overview

savoirfairelinux-openerp team mailing list archive

lp:~extra-addons-commiter/e-commerce-addons/7.0-sale-exceptions-migr into lp:e-commerce-addons

 

Guewen Baconnier @ Camptocamp has proposed merging lp:~extra-addons-commiter/e-commerce-addons/7.0-sale-exceptions-migr into lp:e-commerce-addons.

Commit message:
[MIGR] migration of sale_exceptions for OpenERP 7

Requested reviews:
  extra-addons-commiter (extra-addons-commiter)

For more details, see:
https://code.launchpad.net/~extra-addons-commiter/e-commerce-addons/7.0-sale-exceptions-migr/+merge/175571

Migration of the module 'sale_exceptions' for OpenERP V7.

* removed / replaced deprecated things
* pep8
* improved a bit the views
-- 
https://code.launchpad.net/~extra-addons-commiter/e-commerce-addons/7.0-sale-exceptions-migr/+merge/175571
Your team extra-addons-commiter is requested to review the proposed merge of lp:~extra-addons-commiter/e-commerce-addons/7.0-sale-exceptions-migr into lp:e-commerce-addons.
=== added directory 'sale_exceptions/i18n'
=== added file 'sale_exceptions/i18n/fr_FR.po'
--- sale_exceptions/i18n/fr_FR.po	1970-01-01 00:00:00 +0000
+++ sale_exceptions/i18n/fr_FR.po	2013-07-18 14:02:26 +0000
@@ -0,0 +1,177 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* sale_exceptions
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-05-02 06:57+0000\n"
+"PO-Revision-Date: 2013-05-02 06:57+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: sale_exceptions
+#: model:ir.model,name:sale_exceptions.model_sale_exception_confirm
+msgid "sale.exception.confirm"
+msgstr ""
+
+#. module: sale_exceptions
+#: selection:sale.exception,model:0
+msgid "Sale Order Line"
+msgstr "Ligne de commande"
+
+#. module: sale_exceptions
+#: field:sale.exception,model:0
+msgid "Apply on"
+msgstr "Appliquer sur"
+
+#. module: sale_exceptions
+#: model:sale.exception,name:sale_exceptions.excep_no_stock
+msgid "Not Enough Virtual Stock"
+msgstr "Pas assez de quantité de stock prévue"
+
+#. module: sale_exceptions
+#: field:sale.exception,description:0
+msgid "Description"
+msgstr "Description"
+
+#. module: sale_exceptions
+#: help:sale.exception,sequence:0
+msgid "Gives the sequence order when applying the test"
+msgstr "Définit l'ordre d'application des contrôles"
+
+#. module: sale_exceptions
+#: view:sale.exception.confirm:0
+msgid "Sale Exceptions On Sale Order"
+msgstr "Restrictions sur la commande"
+
+#. module: sale_exceptions
+#: field:sale.exception.confirm,exception_ids:0
+msgid "Exceptions to resolve"
+msgstr "Restrictions à résoudre"
+
+#. module: sale_exceptions
+#: view:sale.exception.confirm:0
+msgid "_Ok"
+msgstr "_Ok"
+
+#. module: sale_exceptions
+#: view:sale.exception:0
+#: view:sale.exception.confirm:0
+msgid "Sale Exception"
+msgstr "Restriction de vente"
+
+#. module: sale_exceptions
+#: view:sale.order:0
+msgid "TO FIX"
+msgstr "A CORRIGER"
+
+#. module: sale_exceptions
+#: help:sale.exception,code:0
+msgid "Python code executed to check if the exception apply or not. The code must apply block = True to apply the exception."
+msgstr "Code Python exécuté pour déterminer si la restriction s'applique. The bloc de code doit retourner block = True pour appliquer la restriction."
+
+#. module: sale_exceptions
+#: view:sale.order:0
+msgid "Exception"
+msgstr "Restriction"
+
+#. module: sale_exceptions
+#: view:sale.order:0
+msgid "Error:"
+msgstr "Erreur :"
+
+#. module: sale_exceptions
+#: selection:sale.exception,model:0
+msgid "Sale Order"
+msgstr "Bon de commande"
+
+#. module: sale_exceptions
+#: field:sale.exception.confirm,sale_id:0
+msgid "Sale"
+msgstr "Commande"
+
+#. module: sale_exceptions
+#: field:sale.exception,active:0
+msgid "Active"
+msgstr "Actif"
+
+#. module: sale_exceptions
+#: field:sale.exception,name:0
+msgid "Exception Name"
+msgstr "Nom de la restriction"
+
+#. module: sale_exceptions
+#: field:sale.order,exceptions_ids:0
+msgid "Exceptions"
+msgstr "Restrictions"
+
+#. module: sale_exceptions
+#: model:ir.actions.act_window,name:sale_exceptions.action_sale_exception_confirm
+#: model:ir.model,name:sale_exceptions.model_sale_exception
+#: view:sale.exception.confirm:0
+msgid "Sale Exceptions"
+msgstr "Restrictions de vente"
+
+#. module: sale_exceptions
+#: model:ir.actions.act_window,name:sale_exceptions.action_sale_test_tree
+#: model:ir.ui.menu,name:sale_exceptions.menu_sale_test
+msgid "Exception Rules"
+msgstr "Règles de restriction"
+
+#. module: sale_exceptions
+#: model:ir.model,name:sale_exceptions.model_sale_order
+msgid "Sales Order"
+msgstr "Bon de commande"
+
+#. module: sale_exceptions
+#: field:sale.exception,sequence:0
+msgid "Sequence"
+msgstr "Séquence"
+
+#. module: sale_exceptions
+#: field:sale.exception,code:0
+msgid "Python Code"
+msgstr "Code Python"
+
+#. module: sale_exceptions
+#: view:sale.order:0
+msgid "Sales"
+msgstr "Bons de commande"
+
+#. module: sale_exceptions
+#: model:sale.exception,name:sale_exceptions.excep_no_zip
+msgid "No ZIP code on destination"
+msgstr "Code postal manquant sur la destination"
+
+#. module: sale_exceptions
+#: view:sale.exception:0
+msgid "Sale Exception Setup"
+msgstr "Configuration des restrictions de vente"
+
+#. module: sale_exceptions
+#: view:sale.exception:0
+msgid "Affected Sales Orders"
+msgstr "Bons de commande affectés"
+
+#. module: sale_exceptions
+#: field:sale.exception,sale_order_ids:0
+msgid "Sale Orders"
+msgstr "Bons de commande"
+
+#. module: sale_exceptions
+#: field:sale.exception.confirm,ignore:0
+#: field:sale.order,ignore_exceptions:0
+msgid "Ignore Exceptions"
+msgstr "Ignorer la restriction"
+
+#. module: sale_exceptions
+#: field:sale.order,main_exception_id:0
+msgid "Main Exception"
+msgstr "Restriction principale"
+

=== added file 'sale_exceptions/i18n/sale_exceptions.pot'
--- sale_exceptions/i18n/sale_exceptions.pot	1970-01-01 00:00:00 +0000
+++ sale_exceptions/i18n/sale_exceptions.pot	2013-07-18 14:02:26 +0000
@@ -0,0 +1,177 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* sale_exceptions
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-05-02 06:57+0000\n"
+"PO-Revision-Date: 2013-05-02 06:57+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: sale_exceptions
+#: model:ir.model,name:sale_exceptions.model_sale_exception_confirm
+msgid "sale.exception.confirm"
+msgstr ""
+
+#. module: sale_exceptions
+#: selection:sale.exception,model:0
+msgid "Sale Order Line"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception,model:0
+msgid "Apply on"
+msgstr ""
+
+#. module: sale_exceptions
+#: model:sale.exception,name:sale_exceptions.excep_no_stock
+msgid "Not Enough Virtual Stock"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception,description:0
+msgid "Description"
+msgstr ""
+
+#. module: sale_exceptions
+#: help:sale.exception,sequence:0
+msgid "Gives the sequence order when applying the test"
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.exception.confirm:0
+msgid "Sale Exceptions On Sale Order"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception.confirm,exception_ids:0
+msgid "Exceptions to resolve"
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.exception.confirm:0
+msgid "_Ok"
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.exception:0
+#: view:sale.exception.confirm:0
+msgid "Sale Exception"
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.order:0
+msgid "TO FIX"
+msgstr ""
+
+#. module: sale_exceptions
+#: help:sale.exception,code:0
+msgid "Python code executed to check if the exception apply or not. The code must apply block = True to apply the exception."
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.order:0
+msgid "Exception"
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.order:0
+msgid "Error:"
+msgstr ""
+
+#. module: sale_exceptions
+#: selection:sale.exception,model:0
+msgid "Sale Order"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception.confirm,sale_id:0
+msgid "Sale"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception,active:0
+msgid "Active"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception,name:0
+msgid "Exception Name"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.order,exceptions_ids:0
+msgid "Exceptions"
+msgstr ""
+
+#. module: sale_exceptions
+#: model:ir.actions.act_window,name:sale_exceptions.action_sale_exception_confirm
+#: model:ir.model,name:sale_exceptions.model_sale_exception
+#: view:sale.exception.confirm:0
+msgid "Sale Exceptions"
+msgstr ""
+
+#. module: sale_exceptions
+#: model:ir.actions.act_window,name:sale_exceptions.action_sale_test_tree
+#: model:ir.ui.menu,name:sale_exceptions.menu_sale_test
+msgid "Exception Rules"
+msgstr ""
+
+#. module: sale_exceptions
+#: model:ir.model,name:sale_exceptions.model_sale_order
+msgid "Sales Order"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception,sequence:0
+msgid "Sequence"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception,code:0
+msgid "Python Code"
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.order:0
+msgid "Sales"
+msgstr ""
+
+#. module: sale_exceptions
+#: model:sale.exception,name:sale_exceptions.excep_no_zip
+msgid "No ZIP code on destination"
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.exception:0
+msgid "Sale Exception Setup"
+msgstr ""
+
+#. module: sale_exceptions
+#: view:sale.exception:0
+msgid "Affected Sales Orders"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception,sale_order_ids:0
+msgid "Sale Orders"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.exception.confirm,ignore:0
+#: field:sale.order,ignore_exceptions:0
+msgid "Ignore Exceptions"
+msgstr ""
+
+#. module: sale_exceptions
+#: field:sale.order,main_exception_id:0
+msgid "Main Exception"
+msgstr ""
+

=== modified file 'sale_exceptions/sale.py'
--- sale_exceptions/sale.py	2012-12-26 13:05:09 +0000
+++ sale_exceptions/sale.py	2013-07-18 14:02:26 +0000
@@ -22,32 +22,35 @@
 ##############################################################################
 
 import time
-import netsvc
-
-from openerp.osv.orm import Model
-from openerp.osv import fields
-from openerp.osv.osv import except_osv
-from tools.safe_eval import safe_eval as eval
-from tools.translate import _
-
-class sale_exception(Model):
+
+from openerp.osv import orm, fields
+from openerp.tools.safe_eval import safe_eval
+from openerp.tools.translate import _
+
+
+class sale_exception(orm.Model):
     _name = "sale.exception"
     _description = "Sale Exceptions"
-    _order="active desc, sequence asc"
+    _order = "active desc, sequence asc"
     _columns = {
-        'name': fields.char('Exception Name', size=64, required=True, translate=True),
+        'name': fields.char('Exception Name', required=True, translate=True),
         'description': fields.text('Description', translate=True),
-        'sequence': fields.integer('Sequence', help="Gives the sequence order when applying the test"),
+        'sequence': fields.integer(
+            'Sequence',
+            help="Gives the sequence order when applying the test"),
         'model': fields.selection([('sale.order', 'Sale Order'),
                                    ('sale.order.line', 'Sale Order Line')],
                                   string='Apply on', required=True),
         'active': fields.boolean('Active'),
-        'code': fields.text('Python Code',
-                    help="Python code executed to check if the exception apply or not. " \
-                         "The code must apply block = True to apply the exception."),
-        'sale_order_ids': fields.many2many('sale.order', 'sale_order_exception_rel',
-                                           'exception_id', 'sale_order_id',
-                                           string='Sale Orders', readonly=True),
+        'code': fields.text(
+            'Python Code',
+            help="Python code executed to check if the exception apply or not. " \
+                 "The code must apply block = True to apply the exception."),
+        'sale_order_ids': fields.many2many(
+            'sale.order',
+            'sale_order_exception_rel', 'exception_id', 'sale_order_id',
+            string='Sale Orders',
+            readonly=True),
     }
 
     _defaults = {
@@ -64,7 +67,8 @@
 """
     }
 
-class sale_order(Model):
+
+class sale_order(orm.Model):
     _inherit = "sale.order"
 
     _order = 'main_exception_id asc, date_order desc, name desc'
@@ -79,25 +83,30 @@
         return res
 
     _columns = {
-        'main_exception_id': fields.function(_get_main_error,
-                        type='many2one',
-                        relation="sale.exception",
-                        string='Main Exception',
-                        store={
-                            'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['exceptions_ids', 'state'], 10),
-                        }),
-        'exceptions_ids': fields.many2many('sale.exception', 'sale_order_exception_rel',
-                                           'sale_order_id', 'exception_id',
-                                           string='Exceptions'),
+        'main_exception_id': fields.function(
+            _get_main_error,
+            type='many2one',
+            relation="sale.exception",
+            string='Main Exception',
+            store={
+                'sale.order': (lambda self, cr, uid, ids, c=None: ids,
+                               ['exceptions_ids', 'state'], 10),
+            }),
+        'exceptions_ids': fields.many2many(
+            'sale.exception',
+            'sale_order_exception_rel', 'sale_order_id', 'exception_id',
+            string='Exceptions'),
         'ignore_exceptions': fields.boolean('Ignore Exceptions'),
     }
 
     def test_all_draft_orders(self, cr, uid, context=None):
-        ids = self.search(cr, uid, [('state', '=', 'draft')])
-        self.test_exceptions(cr, uid, ids)
+        ids = self.search(cr, uid, [('state', '=', 'draft')], context=context)
+        self.test_exceptions(cr, uid, ids, context=context)
         return True
 
     def _popup_exceptions(self, cr, uid, order_id, context=None):
+        if context is None:
+            context = {}
         model_data_obj = self.pool.get('ir.model.data')
         list_obj = self.pool.get('sale.exception.confirm')
         ctx = context.copy()
@@ -107,7 +116,7 @@
         view_id = model_data_obj.get_object_reference(
             cr, uid, 'sale_exceptions', 'view_sale_exception_confirm')[1]
         action = {
-            'name': _("Exceptions On Sale Order"),
+            'name': _("Blocked in draft due to exceptions"),
             'type': 'ir.actions.act_window',
             'view_type': 'form',
             'view_mode': 'form',
@@ -124,7 +133,8 @@
         if exception_ids:
             return self._popup_exceptions(cr, uid, ids[0],  context=context)
         else:
-            return super(sale_order, self).action_button_confirm(cr, uid, ids, context=context)
+            return super(sale_order, self).action_button_confirm(cr, uid, ids,
+                                                                 context=context)
 
     def test_exceptions(self, cr, uid, ids, context=None):
         """
@@ -137,28 +147,40 @@
 
     def detect_exceptions(self, cr, uid, ids, context=None):
         exception_obj = self.pool.get('sale.exception')
-        order_exception_ids = exception_obj.search(cr, uid,
-            [('model', '=', 'sale.order')], context=context)
-        line_exception_ids = exception_obj.search(cr, uid,
-            [('model', '=', 'sale.order.line')], context=context)
+        order_exception_ids = exception_obj.search(
+            cr, uid,
+            [('model', '=', 'sale.order')],
+            context=context)
+        line_exception_ids = exception_obj.search(
+            cr, uid,
+            [('model', '=', 'sale.order.line')],
+            context=context)
 
-        order_exceptions = exception_obj.browse(cr, uid, order_exception_ids, context=context)
-        line_exceptions = exception_obj.browse(cr, uid, line_exception_ids, context=context)
+        order_exceptions = exception_obj.browse(cr, uid, order_exception_ids,
+                                                context=context)
+        line_exceptions = exception_obj.browse(cr, uid, line_exception_ids,
+                                               context=context)
 
         exception_ids = False
-        for order in self.browse(cr, uid, ids):
+        for order in self.browse(cr, uid, ids, context=context):
             if order.ignore_exceptions:
                 continue
-            exception_ids = self._detect_exceptions(cr, uid, order,
-                order_exceptions, line_exceptions, context=context)
+            exception_ids = self._detect_exceptions(cr, uid,
+                                                    order,
+                                                    order_exceptions,
+                                                    line_exceptions,
+                                                    context=context)
 
-            self.write(cr, uid, [order.id], {'exceptions_ids': [(6, 0, exception_ids)]})
+            self.write(cr, uid, [order.id],
+                       {'exceptions_ids': [(6, 0, exception_ids)]},
+                       context=context)
         return exception_ids
 
     def _exception_rule_eval_context(self, cr, uid, obj_name, obj, context=None):
         if context is None:
             context = {}
 
+        user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
         return {obj_name: obj,
                 'self': self.pool.get(obj._name),
                 'object': obj,
@@ -166,24 +188,29 @@
                 'pool': self.pool,
                 'cr': cr,
                 'uid': uid,
-                'user': self.pool.get('res.users').browse(cr, uid, uid),
+                'user': user,
                 'time': time,
                 # copy context to prevent side-effects of eval
-                'context': dict(context),}
+                'context': context.copy()}
 
     def _rule_eval(self, cr, uid, rule, obj_name, obj, context):
         expr = rule.code
         space = self._exception_rule_eval_context(cr, uid, obj_name, obj,
                                                   context=context)
         try:
-            eval(expr, space,
-                 mode='exec', nocopy=True) # nocopy allows to return 'result'
+            safe_eval(expr,
+                      space,
+                      mode='exec',
+                      nocopy=True)  # nocopy allows to return 'result'
         except Exception, e:
-            raise except_osv(_('Error'), _('Error when evaluating the sale exception rule :\n %s \n(%s)') %
-                                 (rule.name, e))
+            raise orm.except_orm(
+                _('Error'),
+                _('Error when evaluating the sale exception '
+                  'rule:\n %s \n(%s)') % (rule.name, e))
         return space.get('failed', False)
 
-    def _detect_exceptions(self, cr, uid, order, order_exceptions, line_exceptions, context=None):
+    def _detect_exceptions(self, cr, uid, order, order_exceptions,
+                           line_exceptions, context=None):
         exception_ids = []
         for rule in order_exceptions:
             if self._rule_eval(cr, uid, rule, 'order', order, context):
@@ -192,8 +219,9 @@
         for order_line in order.order_line:
             for rule in line_exceptions:
                 if rule.id in exception_ids:
-                    continue  # we do not matter if the exception as already been
+                    # we do not matter if the exception as already been
                     # found for an order line of this order
+                    continue
                 if self._rule_eval(cr, uid, rule, 'line', order_line, context):
                     exception_ids.append(rule.id)
 

=== modified file 'sale_exceptions/sale_view.xml'
--- sale_exceptions/sale_view.xml	2012-12-26 13:19:13 +0000
+++ sale_exceptions/sale_view.xml	2013-07-18 14:02:26 +0000
@@ -5,7 +5,6 @@
         <record id="view_sale_exception_tree" model="ir.ui.view">
             <field name="name">sale.exception.tree</field>
             <field name="model">sale.exception</field>
-            <field name="type">tree</field>
             <field name="arch" type="xml">
                 <tree string="Sale Exception">
                     <field name="active"/>
@@ -20,7 +19,6 @@
         <record id="view_sale_exception_form" model="ir.ui.view">
             <field name="name">sale.exception.form</field>
             <field name="model">sale.exception</field>
-            <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Sale Exception Setup">
                     <group colspan="4" col="2">
@@ -59,13 +57,14 @@
         <record id="view_order_form" model="ir.ui.view">
             <field name="name">sale_exceptions.view_order_form</field>
             <field name="model">sale.order</field>
-            <field name="type">form</field>
-            <field name="priority">100</field>
             <field name="inherit_id" ref="sale.view_order_form"/>
             <field name="arch" type="xml">
                 <field name="name" position="after">
-                    <field name="main_exception_id" nolabel="1"
+                    <group>
+                    <field name="main_exception_id" options='{"no_open": True}'
+                           class="oe_inline" string="Error:"
                            attrs="{'invisible':[('main_exception_id','=', False)]}"/>
+                    </group>
                 </field>
                 <xpath expr="//page[@string='Other Information']/group"
                         position="inside">
@@ -80,7 +79,6 @@
         <record id="view_order_tree" model="ir.ui.view">
             <field name="name">sale_exceptions.view_order_tree</field>
             <field name="model">sale.order</field>
-            <field name="type">tree</field>
             <field name="inherit_id" ref="sale.view_order_tree"/>
             <field name="arch" type="xml">
                 <field name="state" position="after">
@@ -93,12 +91,10 @@
             <field name="name">sale_exceptions.view_sales_order_filter</field>
             <field name="model">sale.order</field>
             <field name="inherit_id" ref="sale.view_sales_order_filter" />
-            <field name="type">search</field>
-            <field eval="32" name="priority"/>
             <field name="arch" type="xml">
-                <filter icon="terp-check" string="Sales" position="after">
+                <filter name="sales" position="after">
                     <separator orientation="vertical"/>
-                    <filter icon="terp-emblem-important" name="tofix" string="TO FIX" domain="[('main_exception_id','!=',False)]"/>
+                    <filter icon="terp-emblem-important" name="tofix" string="Blocked in draft" domain="[('main_exception_id','!=',False)]"/>
                 </filter>
             </field>
         </record>

=== modified file 'sale_exceptions/wizard/__init__.py'
--- sale_exceptions/wizard/__init__.py	2012-02-24 09:31:32 +0000
+++ sale_exceptions/wizard/__init__.py	2013-07-18 14:02:26 +0000
@@ -1,1 +1,2 @@
+# -*- coding: utf-8 -*-
 import sale_exception_confirm

=== modified file 'sale_exceptions/wizard/sale_exception_confirm.py'
--- sale_exceptions/wizard/sale_exception_confirm.py	2012-05-16 12:53:59 +0000
+++ sale_exceptions/wizard/sale_exception_confirm.py	2013-07-18 14:02:26 +0000
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright Camptocamp SA
@@ -19,38 +19,45 @@
 #
 ##############################################################################
 
-import netsvc
-
-from osv import osv, fields
-
-
-class SaleExceptionConfirm(osv.osv_memory):
+from openerp.osv import orm, fields
+
+
+class SaleExceptionConfirm(orm.TransientModel):
 
     _name = 'sale.exception.confirm'
 
     _columns = {
         'sale_id': fields.many2one('sale.order', 'Sale'),
-        'exception_ids': fields.many2many('sale.exception', string='Exceptions to resolve', readonly=True),
+        'exception_ids': fields.many2many('sale.exception',
+                                          string='Exceptions to resolve',
+                                          readonly=True),
         'ignore': fields.boolean('Ignore Exceptions'),
     }
 
     def default_get(self, cr, uid, fields, context=None):
-        res = super(SaleExceptionConfirm, self).default_get(cr, uid, fields, context=context)
+        if context is None:
+            context = {}
+        res = super(SaleExceptionConfirm, self).default_get(
+            cr, uid, fields, context=context)
         order_obj = self.pool.get('sale.order')
-        sale_id = context.get('active_id', False)
-        if sale_id:
-            sale = order_obj.browse(cr, uid, sale_id, context=context)
-            exception_ids = [e.id for e in sale.exceptions_ids]
-            res.update({'exception_ids': [(6, 0, exception_ids)]})
-
+        sale_id = context.get('active_ids')
+        assert len(sale_id) == 1, "Only 1 ID accepted, received %r" % ids
+        sale_id = sale_id[0]
+        sale = order_obj.browse(cr, uid, sale_id, context=context)
+        exception_ids = [e.id for e in sale.exceptions_ids]
+        res.update({'exception_ids': [(6, 0, exception_ids)]})
         res.update({'sale_id': sale_id})
         return res
 
     def action_confirm(self, cr, uid, ids, context=None):
-        form = self.browse(cr, uid, ids[0], context=context)
+        if hasattr(ids, '__iter__'):
+            assert len(ids) == 1, "Only 1 ID accepted, received %r" % ids
+            ids = ids[0]
+        form = self.browse(cr, uid, ids, context=context)
         if form.ignore:
-            self.pool.get('sale.order').write(cr, uid, form.sale_id.id,
-                    {'ignore_exceptions': True}, context=context)
+            self.pool.get('sale.order').write(
+                cr, uid,
+                form.sale_id.id,
+                {'ignore_exceptions': True},
+                context=context)
         return {'type': 'ir.actions.act_window_close'}
-
-SaleExceptionConfirm()

=== modified file 'sale_exceptions/wizard/sale_exception_confirm_view.xml'
--- sale_exceptions/wizard/sale_exception_confirm_view.xml	2012-12-26 09:30:24 +0000
+++ sale_exceptions/wizard/sale_exception_confirm_view.xml	2013-07-18 14:02:26 +0000
@@ -5,15 +5,10 @@
         <record id="view_sale_exception_confirm" model="ir.ui.view">
             <field name="name">Sale Exceptions</field>
             <field name="model">sale.exception.confirm</field>
-            <field name="type">form</field>
             <field name="arch" type="xml">
-                <form string="Sale Exceptions On Sale Order" version="7.0">
+                <form string="Blocked in draft due to exceptions" version="7.0">
                     <group>
                         <field name="exception_ids" nolabel="1" colspan="4">
-                            <form string="Sale Exception">
-                               <field name="name" colspan="4"/>
-                               <field name="description" colspan="4"/>
-                            </form>
                             <tree string="Sale Exceptions">
                                 <field name="name"/>
                                 <field name="description"/>
@@ -23,7 +18,7 @@
                         <field name="ignore" groups='base.group_sale_manager'/>
                     </group>
                     <footer>
-                        <button name="action_confirm" string="_Ok"
+                        <button name="action_confirm" string="_Close"
                             colspan="1" type="object" icon="gtk-ok" />
                     </footer>
                 </form>
@@ -31,7 +26,7 @@
         </record>
 
         <record id="action_sale_exception_confirm" model="ir.actions.act_window">
-            <field name="name">Sale Exceptions</field>
+            <field name="name">Blocked in draft due to exceptions</field>
             <field name="type">ir.actions.act_window</field>
             <field name="res_model">sale.exception.confirm</field>
             <field name="view_type">form</field>


Follow ups