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

[16.0][IMP] l10n_fr_account_vat_return: make it easy to inherit adjust accounts codes #583

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions l10n_fr_account_vat_return/models/l10n_fr_account_vat_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ def _prepare_speedy(self):
# used to create negative boxes at the end
"negative_box2logs": defaultdict(list),
"vat_groups": ["regular", "extracom_product", "oil"],
"adjust_account_codes": {
"expense_adjust_account": (
"658",
"Charges diverses de gestion courante",
),
"income_adjust_account": ("758", "Produits divers de gestion courante"),
},
}
speedy["bank_cash_journals"] = speedy["aj_obj"].search(
speedy["company_domain"] + [("type", "in", ("bank", "cash"))]
Expand Down Expand Up @@ -487,15 +494,10 @@ def _get_adjust_accounts(self, speedy):
# that all French companies must use the PCG,
# I select the account based on the code they should have
self.ensure_one()
account_lookup = {
"expense_adjust_account": ("658", "Charges diverses de gestion courante"),
"income_adjust_account": ("758", "Produits divers de gestion courante"),
}
for key, (account_code, account_name) in account_lookup.items():
limit = not account_code.startswith("445") and 1 or None
for key, (account_code, account_name) in speedy["adjust_account_codes"].items():
account = speedy["aa_obj"].search(
speedy["company_domain"] + [("code", "=like", account_code + "%")],
limit=limit,
limit=1,
)
if not account:
raise UserError(
Expand All @@ -507,18 +509,6 @@ def _get_adjust_accounts(self, speedy):
company=self.company_id.display_name,
)
)
if len(account) > 1:
raise UserError(
_(
"There are %(count)d accounts "
"%(account_code)s %(account_name)s in the chart of account "
"of company '%(company)s'. This scenario is not supported.",
count=len(account),
account_code=account_code,
account_name=account_name,
company=self.company_id.display_name,
)
)
speedy[key] = account

def manual2auto(self):
Expand Down
Loading