From 9c051695eb858bb61f7ef6ce99a4cbfaa703863f Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 12 Jul 2010 12:19:14 +0530 Subject: [PATCH] [IMP] sale:-display warning on Cancel button in sale.order.line,renamed call_make_invoices method and set the appearance of button in sale.ordere.line. bzr revid: mtr@mtr-20100712064914-j4dg3e3rsci0otl3 --- addons/sale/sale.py | 15 ++++++++++----- addons/sale/sale_view.xml | 27 ++++++++++++--------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 741bcf3a526..3c7003e49b0 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -829,12 +829,13 @@ class sale_order_line(osv.osv): 'number_packages': fields.function(_number_packages, method=True, type='integer', string='Number Packages'), 'notes': fields.text('Notes'), 'th_weight': fields.float('Weight', readonly=True, states={'draft':[('readonly',False)]}), - 'state': fields.selection([('draft', 'Draft'),('confirmed', 'Confirmed'),('done', 'Done'),('cancel', 'Cancelled'),('exception', 'Exception')], 'State', required=True, readonly=True, + 'state': fields.selection([('draft', 'Draft'),('confirmed', 'Confirmed'),('done', 'Done'),('cancel', 'Cancelled'),('exception', 'Exception'),('invoiced','Invoiced')], 'State', required=True, readonly=True, help=' * The \'Draft\' state is set automatically when sale order in draft state. \ \n* The \'Confirmed\' state is set automatically when sale order in confirm state. \ \n* The \'Exception\' state is set automatically when sale order is set as exception. \ \n* The \'Done\' state is set automatically when sale order is set as done. \ - \n* The \'Cancelled\' state is set automatically when user cancel sale order.'), + \n* The \'Cancelled\' state is set automatically when user cancel sale order\ + \n* The \'Invoiced\' state is set automatically when user creates sale order line invoice.'), 'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer'), 'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='Salesman'), 'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True, states={'draft':[('readonly',False)]}), @@ -852,11 +853,11 @@ class sale_order_line(osv.osv): 'product_packaging': False } - def call_make_invoices(self, cr, uid, ids, context): + def create_sale_order_line_invoice(self, cr, uid, ids, context): line_make_invoice_obj = self.pool.get("sale.order.line.make.invoice") context.update({'active_ids' : ids,'active_id' : ids}) - invoice_call = line_make_invoice_obj.make_invoices(cr, uid, ids, context) - return True + invoice_id = line_make_invoice_obj.make_invoices(cr, uid, ids, context) + return self.write(cr, uid, ids, {'state': 'invoiced'}) def invoice_line_create(self, cr, uid, ids, context=None): if context is None: @@ -939,6 +940,10 @@ class sale_order_line(osv.osv): for line in self.browse(cr, uid, ids, context=context): if line.invoiced: raise osv.except_osv(_('Invalid action !'), _('You cannot cancel a sale order line that has already been invoiced !')) + if line.order_id.picking_ids: + raise osv.except_osv( + _('Could not cancel sale order line!'), + _('You must first cancel stock move attached to this sale order line.')) message = _('Sale order line') + " '" + line.name + "' "+_("is cancelled") self.log(cr, uid, id, message) return self.write(cr, uid, ids, {'state': 'cancel'}) diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 82bf98032ff..44e75125e31 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -165,10 +165,10 @@