23
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
##############################################################################
26
from osv import osv, fields
27
from tools.translate import _
26
from openerp.osv import osv, fields
27
from openerp.tools.translate import _
28
29
from datetime import datetime
32
class mrp_production(osv.osv):
30
import openerp.netsvc as netsvc
33
class mrp_production(osv.Model):
33
34
_inherit = "mrp.production"
35
36
def action_cancel(self, cr, uid, ids, context=None):
36
37
wf_service = netsvc.LocalService("workflow")
38
39
if context is None:
41
42
move_obj = self.pool.get('stock.move')
42
43
for production in self.browse(cr, uid, ids, context=context):
43
44
if production.picking_id.id:
44
wf_service.trg_validate(uid, 'stock.picking', production.picking_id.id, 'button_cancel', cr)
45
move_obj.action_cancel(cr, uid, [x.id for x in production.move_lines2])
45
wf_service.trg_validate(
46
uid, 'stock.picking', production.picking_id.id, 'button_cancel', cr)
47
move_obj.action_cancel(cr, uid, [
48
x.id for x in production.move_lines2])
46
49
if production.move_created_ids2:
47
move_obj.action_cancel(cr, uid, [x.id for x in production.move_created_ids2])
50
move_obj.action_cancel(cr, uid, [
51
x.id for x in production.move_created_ids2])
48
52
return super(mrp_production, self).action_cancel(cr, uid, ids, context=context)