CloseISQ
CloseISQ

Reputation: 353

Confirm a sale quotation into a sale order with some quantities set to 0

In my custom sale quotation report I want to show some products with a 0 quantity and therefore have created sale order lines for some products with their quantities set to 0. It works fine and shows in the sale quotation report.

But when I confirm that same sale quotation into a sale order OpenERP throws the following message:

"Data Insufficient ! Please check the quantity in procurement order(s), it should not be 0 or less!"

How can I confirm an order with some quantities set to 0?

Upvotes: 1

Views: 2163

Answers (2)

user1954049
user1954049

Reputation:

class procurement_order(osv.osv):
    _inherit = 'procurement.order'
    def action_confirm(self, cr, uid, ids, context=None):
         move_obj = self.pool.get('stock.move')
        for procurement in self.browse(cr, uid, ids, context=context):
            #if procurement.product_qty <= 0.00:
                #raise osv.except_osv(_('Data Insufficient !'),_('Please check the quantity in procurement order(s), it should not be 0 or less!'))
            if procurement.product_id.type in ('product', 'consu'):
                if not procurement.move_id:
                    source = procurement.location_id.id
                if procurement.procure_method == 'make_to_order':
                    source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
                id = move_obj.create(cr, uid, {
                    'name': procurement.name,
                    'location_id': source,
                    'location_dest_id': procurement.location_id.id,
                    'product_id': procurement.product_id.id,
                    'product_qty': procurement.product_qty,
                    'product_uom': procurement.product_uom.id,
                    'date_expected': procurement.date_planned,
                    'state': 'draft',
                    'company_id': procurement.company_id.id,
                    'auto_validate': True,
                })
                move_obj.action_confirm(cr, uid, [id], context=context)
                self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1})
    self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''})
    return True

Upvotes: 1

Sudhir Arya
Sudhir Arya

Reputation: 3743

First you have to inherit the Procurement and then override the action_confirm method in your custom module.

In procurement.py, find "def action_confirm()" on line: 320. Copy and past the whole method and remove those lines which raise the exception.

Hope this will solve your problem.

Thank You.

Upvotes: 1

Related Questions