
from openerp import models, fields, api


class HrExpense(models.Model):
    _inherit = 'hr.expense.expense'

    number = fields.Char(required=True, default="/", readonly=True)

    @api.model
    def create(self, vals):
        if vals.get('number', '/') == '/':
            vals['number'] = self.env['ir.sequence'].get('hr.expense')
        return super(HrExpense, self).create(vals)


from openerp import models, fields, api


class HrExpense(models.Model):
    _inherit = 'hr.expense.expense'

    number = fields.Char(required=True, default="/", readonly=True)

    @api.model
    def create(self, vals):
        if vals.get('number', '/') == '/':
            vals['number'] = self.env['ir.sequence'].get('hr.expense')
        return super(HrExpense, self).create(vals)

    @api.model
    def account_move_get(self, expense_id):
        '''Write expense number on account move'''
        vals = super(HrExpense, self).account_move_get(expense_id)
        expense = self.browse(expense_id)
        vals['ref'] = expense.number
        return vals

Write expense number on account move
Write expense number on account move

  
  from openerp import models, fields, api
  
  
  class HrExpense(models.Model):
      _inherit = 'hr.expense.expense'
  
      number = fields.Char(required=True, default="/", readonly=True)
  
      @api.model
      def create(self, vals):
          if vals.get('number', '/') == '/':
              vals['number'] = self.env['ir.sequence'].get('hr.expense')
          return super(HrExpense, self).create(vals)
  
+     @api.model
+     def account_move_get(self, expense_id):
+         '''Write expense number on account move'''
+         vals = super(HrExpense, self).account_move_get(expense_id)
+         expense = self.browse(expense_id)
+         vals['ref'] = expense.number
+         return vals
+ 
Write expense number on account move
## Code Before:

from openerp import models, fields, api


class HrExpense(models.Model):
    _inherit = 'hr.expense.expense'

    number = fields.Char(required=True, default="/", readonly=True)

    @api.model
    def create(self, vals):
        if vals.get('number', '/') == '/':
            vals['number'] = self.env['ir.sequence'].get('hr.expense')
        return super(HrExpense, self).create(vals)

## Instruction:
Write expense number on account move
## Code After:

from openerp import models, fields, api


class HrExpense(models.Model):
    _inherit = 'hr.expense.expense'

    number = fields.Char(required=True, default="/", readonly=True)

    @api.model
    def create(self, vals):
        if vals.get('number', '/') == '/':
            vals['number'] = self.env['ir.sequence'].get('hr.expense')
        return super(HrExpense, self).create(vals)

    @api.model
    def account_move_get(self, expense_id):
        '''Write expense number on account move'''
        vals = super(HrExpense, self).account_move_get(expense_id)
        expense = self.browse(expense_id)
        vals['ref'] = expense.number
        return vals
