~openerp-venezuela/openerp-venezuela-localization/rma

« back to all changes in this revision

Viewing changes to sale_extended/sale.py

  • Committer: Javier Duran
  • Author(s): Javier Duran
  • Date: 2009-12-07 20:00:16 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: javier@n4vir-20091207200016-rg2b5ind6ohszvb1
agregando el modulo sale_extended, el cual restringe que solamente se pueda colocar una orden de compra por cliente y que no se pueda confirmar la orden de venta si el cliente tiene seleccionado el campo ocreq

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
# Copyright (c) 2009 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved.
 
5
#                    Javier Duran <javier.duran@netquatro.com>
 
6
 
7
#
 
8
# WARNING: This program as such is intended to be used by professional
 
9
# programmers who take the whole responsability of assessing all potential
 
10
# consequences resulting from its eventual inadequacies and bugs
 
11
# End users who are looking for a ready-to-use solution with commercial
 
12
# garantees and support are strongly adviced to contract a Free Software
 
13
# Service Company
 
14
#
 
15
# This program is Free Software; you can redistribute it and/or
 
16
# modify it under the terms of the GNU General Public License
 
17
# as published by the Free Software Foundation; either version 2
 
18
# of the License, or (at your option) any later version.
 
19
#
 
20
# This program is distributed in the hope that it will be useful,
 
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
# GNU General Public License for more details.
 
24
#
 
25
# You should have received a copy of the GNU General Public License
 
26
# along with this program; if not, write to the Free Software
 
27
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
28
#
 
29
##############################################################################
 
30
 
 
31
from osv import osv, fields
 
32
from tools.translate import _
 
33
 
 
34
 
 
35
class sale_order(osv.osv):
 
36
    _inherit = "sale.order"
 
37
    
 
38
    _sql_constraints = [
 
39
        ('o_ref_partner_uniq', 'unique (client_order_ref,partner_id)', 'La orden de compra debe ser unica por Cliente !')
 
40
    ]
 
41
    
 
42
 
 
43
 
 
44
    def test_ocreq(self, cr, uid, ids):
 
45
        res = True
 
46
        for os in self.browse(cr, uid, ids):
 
47
            if not os.partner_id:
 
48
                raise osv.except_osv(_('Error, No hay Cliente !'),
 
49
                    _('Por favor seleccione un cliente, si desea generar la factura.'))
 
50
 
 
51
            valor = os.client_order_ref and os.client_order_ref.strip()
 
52
            if os.partner_id.ocreq and not valor:
 
53
                raise osv.except_osv(_('Error, No hay Orden de Compra !'),
 
54
                    _('Por introduzca el Nro. de la orden de compra del cliente, si desea generar la factura.'))
 
55
 
 
56
 
 
57
        return res
 
58
 
 
59
    
 
60
sale_order()