~lepistone/openobject-italia/6.1-fix-account_invoice_entry_date_signature

« back to all changes in this revision

Viewing changes to l10n_it_base/partner/partner.py

  • Committer: Lorenzo Battistini
  • Date: 2013-01-14 14:57:34 UTC
  • Revision ID: lorenzo.battistini@agilebg.com-20130114145734-gacvw4ku7kq4320d
[ADD] l10n_it_base - check existing cities

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from osv import osv
23
23
from osv import fields
 
24
from tools.translate import _
24
25
 
25
26
class res_region(osv.osv):
26
27
    _name = 'res.region'
56
57
        'region': fields.related('province_id','region',type='many2one', relation='res.region', string='Region', readonly=True),
57
58
    }
58
59
 
59
 
res_city()
 
60
    def create(self, cr, uid, vals, context=None):
 
61
        if vals.get('name', False):
 
62
            vals['name'] = vals['name'].title()
 
63
            city_ids=self.search(cr, uid, [('name', '=', vals['name'])], context=context)
 
64
            if city_ids:
 
65
                raise osv.except_osv(_('Error'), _('City %s existing yet') % vals['name'])
 
66
        return super(res_city, self).create(cr, uid, vals, context=context)
60
67
 
61
68
class res_partner_address(osv.osv):
62
69
    _inherit = 'res.partner.address'