Update trees of chart of accounts with 2 passes
This commit is contained in:
parent
fc39224ba0
commit
5da611316f
2
series
2
series
|
@ -81,3 +81,5 @@ strftime_format.diff # [ir] Fix problem with strftime format, reducing the time
|
|||
counterpart_party_payment_clearing.diff # [account_payment_clearing] Add the possiblity to have a party in the counterpart move when reconcile on a payment.
|
||||
|
||||
issue12319.diff # [sale_advance_payment] Only create an advance line if the invoice dont have already one.
|
||||
|
||||
update_trees_chart_accounts.diff # [account_account] Update trees of chart of accounts with 2 passes
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
diff --git a/tryton/modules/account/account.py b/tryton/modules/account/account.py
|
||||
index 20676f47c8..6c52a740f7 100644
|
||||
--- a/tryton/modules/account/account.py
|
||||
+++ b/tryton/modules/account/account.py
|
||||
@@ -413,8 +413,11 @@ class Type(
|
||||
if child.template:
|
||||
if not child.template_override:
|
||||
if child.template.parent:
|
||||
+ # Fallback to current parent
|
||||
+ # to keep under the same root
|
||||
parent = template2type.get(
|
||||
- child.template.parent.id)
|
||||
+ child.template.parent.id,
|
||||
+ child.parent)
|
||||
else:
|
||||
parent = None
|
||||
old_parent = (
|
||||
@@ -3049,6 +3052,8 @@ class UpdateChart(Wizard):
|
||||
account.type.template.create_type(
|
||||
company.id,
|
||||
template2type=template2type)
|
||||
+ # Update again to set new parent
|
||||
+ account.type.update_type(template2type=template2type)
|
||||
|
||||
# Update accounts
|
||||
template2account = {}
|
||||
@@ -3073,6 +3078,11 @@ class UpdateChart(Wizard):
|
||||
account.template.id, account.company.id,
|
||||
template2account=template2account,
|
||||
template2tax=template2tax)
|
||||
+ # Update again to set new parent
|
||||
+ Tax.update_tax(
|
||||
+ company.id,
|
||||
+ template2account=template2account,
|
||||
+ template2tax=template2tax)
|
||||
|
||||
# Update tax codes
|
||||
template2tax_code = {}
|
||||
@@ -3084,6 +3094,10 @@ class UpdateChart(Wizard):
|
||||
TaxCodeTemplate.create_tax_code(
|
||||
account.template.id, company.id,
|
||||
template2tax_code=template2tax_code)
|
||||
+ # Update again to set new parent
|
||||
+ TaxCode.update_tax_code(
|
||||
+ company.id,
|
||||
+ template2tax_code=template2tax_code)
|
||||
|
||||
# Update tax code lines
|
||||
template2tax_code_line = {}
|
||||
@@ -3100,7 +3114,7 @@ class UpdateChart(Wizard):
|
||||
template2tax_code=template2tax_code,
|
||||
template2tax_code_line=template2tax_code_line)
|
||||
|
||||
- # Update taxes and replaced_by on accounts
|
||||
+ # Update parent, taxes and replaced_by on accounts
|
||||
account.update_account2(template2account, template2tax)
|
||||
|
||||
# Update tax rules
|
||||
diff --git a/tryton/modules/account/tax.py b/tryton/modules/account/tax.py
|
||||
index 920a60085b..7b0eff082b 100644
|
||||
--- a/tryton/modules/account/tax.py
|
||||
+++ b/tryton/modules/account/tax.py
|
||||
@@ -290,8 +290,8 @@ class TaxCode(ActivePeriodMixin, tree(), ModelSQL, ModelView):
|
||||
if child.template:
|
||||
if not child.template_override:
|
||||
if child.template.parent:
|
||||
- parent = template2tax_code[
|
||||
- child.template.parent.id]
|
||||
+ parent = template2tax_code.get(
|
||||
+ child.template.parent.id)
|
||||
else:
|
||||
parent = None
|
||||
old_parent = (
|
||||
@@ -1129,7 +1129,7 @@ class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin):
|
||||
if child.template:
|
||||
if not child.template_override:
|
||||
if child.template.parent:
|
||||
- parent = template2tax[child.template.parent.id]
|
||||
+ parent = template2tax.get(child.template.parent.id)
|
||||
else:
|
||||
parent = None
|
||||
old_parent = (
|
Loading…
Reference in New Issue