~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to sale_order_copy_line/model/sale_order_line.py

  • Committer: Jose Morales
  • Date: 2014-07-28 20:00:11 UTC
  • mfrom: (543.7.551 7.0-addons-vauxoo)
  • Revision ID: jose@vauxoo.com-20140728200011-csytovehrzwp24lr
[FORWARD PORT] 7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################################
 
2
#
 
3
#    OpenERP, Open Source Management Solution
 
4
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
 
5
#
 
6
 
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU General Public License as published by
 
10
#    the Free Software Foundation, either version 3 of the License, or
 
11
#    (at your option) any later version.
 
12
#
 
13
#    This program is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    GNU General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
from openerp.osv import fields, osv
 
24
from openerp.tools.translate import _
 
25
 
 
26
import time
 
27
import unicodedata
 
28
 
 
29
 
 
30
class sale_order_line(osv.Model):
 
31
    
 
32
    _inherit = 'sale.order.line'
 
33
    
 
34
    def sale_order_line_copy(self, cr, uid, ids, context=None):
 
35
        data = self.copy_data(cr,uid,ids[0],context=context)
 
36
        sale_order_obj = self.pool.get('sale.order')
 
37
        data_sale_order = sale_order_obj.browse(cr, uid, data.get('order_id'))
 
38
 
 
39
        if data_sale_order.state == 'draft':
 
40
            sale_order_id = self.create(cr, uid ,data , context=context)
 
41
            return {
 
42
                'type': 'ir.actions.act_window',
 
43
                'name': _('Sales Order'),
 
44
                'res_model': 'sale.order',
 
45
                'res_id': data.get('order_id'),
 
46
                'view_type': 'form',
 
47
                'view_mode': 'form',
 
48
                'target': 'current',
 
49
                'nodestroy': True,}
 
50
        else:
 
51
            raise osv.except_osv(_('Error!'), _("This sale order is not in draft state"))
 
52