Impacted versions:

10.0

Steps to reproduce:

See  https://youtu.be/I3Qb3m1GmJ4

Current behavior:

Currency mixing in expense sheet view and report

Expected behavior:

Have no currency mixing :smile: 

Video/Screenshot link (optional):

See https://youtu.be/I3Qb3m1GmJ4

Credit : @alexis-via - Barcelona OCA code sprint


res = self.env['ir.actions.act_window'].for_xml_id('base', 'action_attachment')
        res['domain'] = [('res_model', '=', 'hr.expense'), ('res_id', 'in', self.expense_line_ids.ids)]
        res['context'] = {'default_res_model': 'hr.expense.sheet', 'default_res_id': self.id}
        return res
    @api.multi
    def action_open_journal_entries(self):
        res = self.env['ir.actions.act_window'].for_xml_id('account', 'action_move_journal_line')
        
        res['domain'] = [('ref', 'in', self.mapped('name'))]
        res['context'] = {}
        return res
    @api.one
    @api.constrains('expense_line_ids')
    def _check_amounts(self):
        
        positive_lines = any([l.total_amount > 0 for l in self.expense_line_ids])
        negative_lines = any([l.total_amount < 0 for l in self.expense_line_ids])
        if positive_lines and negative_lines:
            raise ValidationError(_('You cannot have a positive and negative amounts on the same expense report.'))
    @api.one
    @api.constrains('expense_line_ids')
    def _check_employee(self):
        employee_ids = self.expense_line_ids.mapped('employee_id')
        if len(employee_ids) > 1 or (len(employee_ids) == 1 and employee_ids != self.employee_id):
            raise ValidationError(_('You cannot add expense lines of another employee.'))