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.

68 lines
2.5 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. from osv import fields,osv
  22. from mx import DateTime
  23. import tools
  24. import ir
  25. import pooler
  26. import time
  27. class res_partner_address(osv.osv):
  28. _name = 'res.partner.address'
  29. _inherit ='res.partner.address'
  30. _columns = {
  31. 'first_name' : fields.char('First Name', size=128),
  32. 'last_name' : fields.char('Last Name', size=128),
  33. 'name' : fields.char('Name', size=128,readonly=True),
  34. }
  35. def write(self, cr, uid, ids, vals, context={}):
  36. first_name=''
  37. last_name=''
  38. if 'first_name' in vals and vals['first_name']:
  39. first_name=vals['first_name']
  40. if 'last_name' in vals and vals['last_name']:
  41. last_name=vals['last_name']
  42. vals['name']= first_name + ' ' + last_name
  43. return super(res_partner_address, self).write(cr, uid, ids, vals, context)
  44. def create(self, cr, uid, vals, context={}):
  45. first_name=''
  46. last_name=''
  47. if 'first_name' in vals and vals['first_name']:
  48. first_name=vals['first_name']
  49. if 'last_name' in vals and vals['last_name']:
  50. last_name=vals['last_name']
  51. vals['name']= first_name + ' ' + last_name
  52. return super(res_partner_address, self).create(cr, uid, vals, context)
  53. def onchange_name(self, cr, uid, id, first_name,last_name,context={}):
  54. if not first_name:
  55. first_name=''
  56. if not last_name:
  57. last_name=''
  58. return {'value': {'name': first_name + ' ' + last_name}}
  59. res_partner_address()
  60. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: