summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2015-03-10 11:54:39 +0100
committerDavid Monjoie <dmo@odoo.com>2015-03-10 14:22:32 +0100
commit6758b4cfc5ab5a9bf54c30aa14ed2dfd2fbf534d (patch)
treef744bdabed1c6ce9b5695779de2949ef1bbb8f5c /addons
parent2cc09e86afad709cc13e3a686afb0687b4752b3f (diff)
[FIX][REF] purchase: prevent confirming order if no stockable item
After discussing with jco, we decided to keep it simple and have a coherent behavior between different versions, we then changed the behavior from the one of jbefficient PR at https://github.com/odoo-dev/odoo/commit/92adf673f7bed26b89b441b8fcd4d4061d685fb3.
Diffstat (limited to 'addons')
-rw-r--r--addons/purchase/purchase.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index e3b0fa5bfd9..8059e2d7788 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -149,19 +149,6 @@ class purchase_order(osv.osv):
limit=1)
return res and res[0] or False
- def _has_non_stockable_item(self, cr, uid, ids, *args):
- res = dict.fromkeys(ids, False)
- for order in self.browse(cr, uid, ids):
- for order_line in order.order_line:
- if (
- not order_line.product_id
- or
- order_line.product_id
- and order_line.product_id.type not in ('product', 'consu')
- ):
- res[order.id] = True
- return res
-
STATE_SELECTION = [
('draft', 'Draft PO'),
('sent', 'RFQ Sent'),
@@ -237,7 +224,6 @@ class purchase_order(osv.osv):
'create_uid': fields.many2one('res.users', 'Responsible'),
'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}),
'journal_id': fields.many2one('account.journal', 'Journal'),
- 'has_non_stockable_item': fields.function(_has_non_stockable_item, method=True, type='boolean', string='Contains a non-stockable item'),
}
_defaults = {
'date_order': fields.date.context_today,
@@ -485,10 +471,10 @@ class purchase_order(osv.osv):
for po in self.browse(cr, uid, ids, context=context):
if not po.order_line:
raise osv.except_osv(_('Error!'),_('You cannot confirm a purchase order without any purchase order line.'))
- if po.invoice_method == 'picking' and po.has_non_stockable_item is True:
+ if po.invoice_method == 'picking' and not any([l.product_id and l.product_id.type in ('product', 'consu') for l in po.order_line]):
raise osv.except_osv(
_('Error!'),
- _("You cannot confirm a purchase order with Invoice Control Method 'Based on incoming shipments' that contains non-stockable items."))
+ _("You cannot confirm a purchase order with Invoice Control Method 'Based on incoming shipments' that doesn't contain any stockable item."))
for line in po.order_line:
if line.state=='draft':
todo.append(line.id)