Le 30/01/2019 à 12:26, jftempo a écrit : > > > Diff comments: > >> === modified file 'bin/addons/account_corrections/wizard/journal_items_corrections.py' >> --- bin/addons/account_corrections/wizard/journal_items_corrections.py 2018-10-11 10:21:46 +0000 >> +++ bin/addons/account_corrections/wizard/journal_items_corrections.py 2019-01-30 11:21:23 +0000 >> @@ -462,12 +462,37 @@ >> :param account: new account selected in the Correction Wizard >> :param aml: Journal Item with the Third Party to check >> """ >> + if context is None: >> + context = {} >> acc_obj = self.pool.get('account.account') >> + employee_obj = self.pool.get('hr.employee') >> + partner_obj = self.pool.get('res.partner') >> + journal_obj = self.pool.get('account.journal') >> acc_type = account.type_for_register >> if acc_type != 'none': >> + # get the right Third Party to check if there is a partner_txt ONLY (e.g.: correction made on HQ entry) >> + partner_txt = aml.partner_txt >> + partner_id = aml.partner_id and aml.partner_id.id or False >> + employee_id = aml.employee_id and aml.employee_id.id or False >> + partner_journal = aml.transfer_journal_id >> + if partner_txt and not partner_id and not employee_id and not partner_journal: >> + employee_ids = employee_obj.search(cr, uid, [('name', '=', partner_txt)], limit=1, context=context) > > Julie, > Do you confirm we do not need ('active', 'in', ['t', 'f']) in the domain ? > Thanks for making me think about that! This is actually not needed for this specific domain on employees (apparently inactive employees are still retrieved). However it's a good idea to add it in the partner domain, and not only in this method. I have updated the branch accordingly. >> + if employee_ids: >> + employee_id = employee_ids[0] >> + else: >> + partner_ids = partner_obj.search(cr, uid, [('name', '=', partner_txt)], limit=1, context=context) >> + if partner_ids: >> + partner_id = partner_ids[0] >> + else: >> + journal_ids = journal_obj.search(cr, uid, [('code', '=', partner_txt)], limit=1, context=context) >> + if journal_ids: >> + partner_journal = journal_obj.browse(cr, uid, journal_ids[0], context=context) >> + # if there is a partner_txt but no related Third Party found: >> + # ignore the check if "ignore_non_existing_tp" is in context (e.g. when validating HQ entries) >> + if not partner_id and not employee_id and not partner_journal and context.get('ignore_non_existing_tp', False): >> + return True >> # Check the compatibility with the "Type For Specific Treatment" of the account >> if acc_type in ['transfer', 'transfer_same']: >> - partner_journal = aml.transfer_journal_id >> is_liquidity = partner_journal and partner_journal.type in ['cash', 'bank', 'cheque'] and partner_journal.currency >> if acc_type == 'transfer_same' and (not is_liquidity or partner_journal.currency.id != aml.currency_id.id): >> raise osv.except_osv(_('Warning'), > > -- TeMPO Consulting 20, avenue de la Paix 67000 Strasbourg France http://www.tempo-consulting.fr