You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.7 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
  6. # Copyright (C) 2013 initOS GmbH & Co. KG (<http://www.initos.com>).
  7. # Author Thomas Rehn <thomas.rehn at initos.com>
  8. #
  9. # This program is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU Affero General Public License as
  11. # published by the Free Software Foundation, either version 3 of the
  12. # License, or (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU Affero General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Affero General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. ##############################################################################
  23. from openerp.osv import orm, fields
  24. class ResPartner(orm.Model):
  25. """Assigns 'ref' from a sequence on creation"""
  26. _inherit = 'res.partner'
  27. def create(self, cr, uid, vals, context={}):
  28. # only assign a 'ref' if it is not a child object
  29. # (such as a shipping/invoice address)
  30. if not vals.get('parent_id'):
  31. vals['ref'] = self.pool.get('ir.sequence').get(cr, uid, 'res.partner')
  32. return super(ResPartner, self).create(cr, uid, vals, context)
  33. _columns = {
  34. 'ref': fields.char('Code', size=64, readonly=True),
  35. }
  36. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: