Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include field add_deduct_tax in Purchase Taxes setup #25757

Merged
merged 4 commits into from
May 28, 2021

Conversation

barredterra
Copy link
Collaborator

@barredterra barredterra commented May 19, 2021

Issue

> bench migrate

  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/setup/doctype/company/company.py", line 114, in on_update
    self.create_default_tax_template()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/setup/doctype/company/company.py", line 72, in create_default_tax_template
    setup_taxes_and_charges(self.name, self.country)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/setup/setup_wizard/operations/taxes_setup.py", line 26, in setup_taxes_and_charges
    from_detailed_data(company_name, country_wise_tax.get('chart_of_accounts'))
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/setup/setup_wizard/operations/taxes_setup.py", line 88, in from_detailed_data
    make_taxes_and_charges_template(company_name, 'Purchase Taxes and Charges Template', template)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/setup/setup_wizard/operations/taxes_setup.py", line 121, in make_taxes_and_charges_template
    return frappe.get_doc(template).insert(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 238, in insert
    self._validate()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 492, in _validate
    self._validate_mandatory()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 811, in _validate_mandatory
    name=self.name))
frappe.exceptions.MandatoryError: [Purchase Taxes and Charges Template, Abziehbare Vorsteuer 19% - AVE]: add_deduct_tax

Note: the after_install hook of my custom app creates a new Company. This is why I can trigger this error via bench migrate. You should be able to reproduce it by creating a new Company programatically.

Solution

Include the field add_deduct_tax as a default in taxes_setup.py. For some reason the field's default value is apparently not used in this case.

@barredterra
Copy link
Collaborator Author

Any ideas how to fix the failing tests? They don't seem to be related to this PR.

@sagarvora sagarvora merged commit 6038663 into frappe:develop May 28, 2021
@barredterra barredterra deleted the fix_purchase_tax_setup branch May 28, 2021 11:25
asoral pushed a commit to asoral/erpnext that referenced this pull request Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants