diff --git a/l10n_us_hr_payroll/migrations/12.0.2020.1.0/post-migration.py b/l10n_us_hr_payroll/migrations/12.0.2020.1.0/post-migration.py index 0a2a6b16..f5676c9f 100644 --- a/l10n_us_hr_payroll/migrations/12.0.2020.1.0/post-migration.py +++ b/l10n_us_hr_payroll/migrations/12.0.2020.1.0/post-migration.py @@ -76,14 +76,18 @@ def migrate(cr, installed_version): # Some added rules should have the same accounting side effects of other migrated rules # To ease the transition, we will copy the accounting fields from one to the other. - for source, destinations in XMLIDS_COPY_ACCOUNTING_2020.items(): - source_rule = env.ref(source, raise_if_not_found=False) - if source_rule: - for destination in destinations: - destination_rule = env.ref(destination, raise_if_not_found=False) - if destination_rule: - _logger.warn('Mirgrating accounting from rule: ' + source + ' to rule: ' + destination) - destination_rule.write({ - 'account_debit': source_rule.account_debit.id, - 'account_credit': source_rule.account_credit.id, - }) + rule_model = env['hr.salary.rule'] + if hasattr(rule_model, 'account_debit'): + for source, destinations in XMLIDS_COPY_ACCOUNTING_2020.items(): + source_rule = env.ref(source, raise_if_not_found=False) + if source_rule: + for destination in destinations: + destination_rule = env.ref(destination, raise_if_not_found=False) + if destination_rule: + _logger.warn('Mirgrating accounting from rule: ' + source + ' to rule: ' + destination) + destination_rule.write({ + 'account_debit': source_rule.account_debit.id, + 'account_credit': source_rule.account_credit.id, + 'account_tax_id': source_rule.account_tax_id.id, + 'analytic_account_id': source_rule.analytic_account_id.id, + }) \ No newline at end of file