diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index d3e7c5302a8..79a6b108d65 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -145,6 +145,14 @@ class sale_order(osv.osv):
res[sale.id] = 0.0
return res
+ def _invoice_exists(self, cursor, user, ids, name, arg, context=None):
+ res = {}
+ for sale in self.browse(cursor, user, ids, context=context):
+ res[sale.id] = False
+ if sale.invoice_ids:
+ res[sale.id] = True
+ return res
+
def _invoiced(self, cursor, user, ids, name, arg, context=None):
res = {}
for sale in self.browse(cursor, user, ids, context=context):
@@ -156,7 +164,7 @@ class sale_order(osv.osv):
if invoice.state != 'paid':
res[sale.id] = False
break
- if not invoice_existence:
+ if not invoice_existence or sale.state == 'manual':
res[sale.id] = False
return res
@@ -245,6 +253,8 @@ class sale_order(osv.osv):
'invoiced_rate': fields.function(_invoiced_rate, string='Invoiced', type='float'),
'invoiced': fields.function(_invoiced, string='Paid',
fnct_search=_invoiced_search, type='boolean', help="It indicates that an invoice has been paid."),
+ 'invoice_exists': fields.function(_invoice_exists, string='Invoiced',
+ fnct_search=_invoiced_search, type='boolean', help="It indicates that sale order has at least one invoice."),
'note': fields.text('Terms and conditions'),
'amount_untaxed': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Untaxed Amount',
@@ -547,7 +557,6 @@ class sale_order(osv.osv):
result.update(view_id = res and res[1] or False)
return result
-
def action_view_delivery(self, cr, uid, ids, context=None):
'''
This function returns an action that display existing delivery orders of given sale order ids. It can either be a in a list or in a form view, if there is only one delivery order to show.
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 2a7e85cf243..a9cd3c805f2 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -163,7 +163,7 @@
+ attrs="{'invisible': ['|', '|', '|', ('state', 'not in',('progress','manual')), ('invoiced', '=', True), ('invoice_exists', '=', False), ('order_policy','=','picking')]}"/>