~vauxoo/addons-vauxoo/8.0-import_tax_tariff-dev-yani-rev-2

« back to all changes in this revision

Viewing changes to mrp_production_cancel/mrp.py

  • Committer: Nhomar Hernandez
  • Date: 2013-04-19 20:33:12 UTC
  • mfrom: (542.1.314 addons-vauxoo)
  • Revision ID: nhomar@gmail.com-20130419203312-o35v7dn79l6vur0t
[MERGE - PEP8 AND V7-MIG] All migrated to V7 Just
improved osv.osv => osv.Model, osv.osv_memory => osv.TransientModel
import inside openerp.* enviroment
Erased class instansiation no necesarry anymore in V7
AUTOPEP8 run, Left PEP8 long lines manually.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
24
#
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
 
28
29
from datetime import datetime
29
 
import netsvc
30
 
 
31
 
 
32
 
class mrp_production(osv.osv):
 
30
import openerp.netsvc as netsvc
 
31
 
 
32
 
 
33
class mrp_production(osv.Model):
33
34
    _inherit = "mrp.production"
34
 
    
 
35
 
35
36
    def action_cancel(self, cr, uid, ids, context=None):
36
37
        wf_service = netsvc.LocalService("workflow")
37
38
 
38
39
        if context is None:
39
40
            context = {}
40
 
            
 
41
 
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)
49
 
    
50
 
mrp_production()
51
 
 
52
53