cash_box_in.py 1.02 KB
Newer Older
François C. committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
# -*- coding: utf-8 -*-
# Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


from openerp import api

from openerp.addons.account.wizard.pos_box import CashBox


class CashBoxIn(CashBox):
    _inherit = 'cash.box.in'

    @api.one
    def _calculate_values_for_statement_line(self, record):
        session_obj = self.env['pos.session']
        active_model = self._context.get('active_model', False)
        active_ids = self._context.get('active_ids', [])

        # Call with [0] because new api.one func calls old api func
        res = super(CashBoxIn, self)._calculate_values_for_statement_line(
            record)[0]

        if active_model == 'pos.session':
            session = session_obj.browse(active_ids[0])
            if session.config_id.transfer_account_id:
                res['account_id'] =\
                    session.config_id.transfer_account_id.id

        return res