# -*- coding: utf-8 -*- ############################################################################# # # Cybrosys Technologies Pvt. Ltd. # # Copyright (C) 2019-TODAY Cybrosys Technologies() # Author: Cybrosys Techno Solutions() # # You can modify it under the terms of the GNU LESSER # GENERAL PUBLIC LICENSE (LGPL v3), Version 3. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE # (LGPL v3) along with this program. # If not, see . # ############################################################################# from odoo import api, models, fields, _ class CashFlow(models.Model): _inherit = 'account.account' def _domain_cash_flow_type(self): cash_flow_id = self.env.ref( 'base_accounting_kit.account_financial_report_cash_flow0') if cash_flow_id: return [('parent_id.id', '=', cash_flow_id.id)] cash_flow_type = fields.Many2one( 'account.financial.report', string="Cash Flow type", domain=_domain_cash_flow_type) @api.onchange('cash_flow_type') def onchange_cash_flow_type(self): for rec in self.cash_flow_type: # update new record rec.write({ 'account_ids': [(4, self._origin.id)] }) if self._origin.cash_flow_type.ids: for rec in self._origin.cash_flow_type: # remove old record rec.write({'account_ids': [(3, self._origin.id)]})