
from openerp import models, fields, api


class hr_contract(models.Model):
    _inherit = 'hr.contract'

    name = fields.Char('Contract Reference', required=False,
            readonly=True, copy=False)

    @api.model
    def create(self, vals):
        contract = super(hr_contract, self).create(vals)
        if contract:
            contract[0].name = self.env['ir.sequence'].next_by_code(
                'contract.ref')
        return contract


from openerp import models, fields, api


class hr_contract(models.Model):
    _inherit = 'hr.contract'

    name = fields.Char('Contract Reference', required=False,
                       readonly=True, copy=False, default='/')

    @api.model
    def create(self, vals):
        if vals.get('number', '/') == '/':
            vals['name'] = self.env['ir.sequence'].next_by_code('contract.ref')
        return super(hr_contract, self).create(vals)

Update code as commented, update readme.
Update code as commented, update readme.

  
  from openerp import models, fields, api
  
  
  class hr_contract(models.Model):
      _inherit = 'hr.contract'
  
      name = fields.Char('Contract Reference', required=False,
-             readonly=True, copy=False)
+                        readonly=True, copy=False, default='/')
  
      @api.model
      def create(self, vals):
+         if vals.get('number', '/') == '/':
+             vals['name'] = self.env['ir.sequence'].next_by_code('contract.ref')
-         contract = super(hr_contract, self).create(vals)
+         return super(hr_contract, self).create(vals)
-         if contract:
-             contract[0].name = self.env['ir.sequence'].next_by_code(
-                 'contract.ref')
-         return contract
  
Update code as commented, update readme.
## Code Before:

from openerp import models, fields, api


class hr_contract(models.Model):
    _inherit = 'hr.contract'

    name = fields.Char('Contract Reference', required=False,
            readonly=True, copy=False)

    @api.model
    def create(self, vals):
        contract = super(hr_contract, self).create(vals)
        if contract:
            contract[0].name = self.env['ir.sequence'].next_by_code(
                'contract.ref')
        return contract

## Instruction:
Update code as commented, update readme.
## Code After:

from openerp import models, fields, api


class hr_contract(models.Model):
    _inherit = 'hr.contract'

    name = fields.Char('Contract Reference', required=False,
                       readonly=True, copy=False, default='/')

    @api.model
    def create(self, vals):
        if vals.get('number', '/') == '/':
            vals['name'] = self.env['ir.sequence'].next_by_code('contract.ref')
        return super(hr_contract, self).create(vals)
