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

l10n_fr_chorus_account: use _get_buyer_order_ref to be able to retrieve the right ej number #370

Closed
Closed
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
12 changes: 7 additions & 5 deletions l10n_fr_chorus_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
lambda x: x.move_type in ("out_invoice", "out_refund")
and x.transmit_method_code == "fr-chorus"
):
ref = self._get_buyer_order_ref()

Check warning on line 165 in l10n_fr_chorus_account/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_fr_chorus_account/models/account_move.py#L165

Added line #L165 was not covered by tests
company_partner = inv.company_id.partner_id
if not company_partner.siren or not company_partner.nic:
raise UserError(
Expand Down Expand Up @@ -192,7 +193,7 @@
% cpartner.display_name
)
if cpartner.fr_chorus_required in ("engagement", "service_and_engagement"):
if inv.ref:
if ref:
inv.chorus_invoice_check_commitment_number()
else:
raise UserError(
Expand All @@ -207,7 +208,7 @@
inv.partner_id.fr_chorus_service_id
and inv.partner_id.fr_chorus_service_id.engagement_required
):
if inv.ref:
if ref:
inv.chorus_invoice_check_commitment_number()
else:
raise UserError(
Expand All @@ -225,7 +226,7 @@

if cpartner.fr_chorus_required == "service_or_engagement":
if not inv.partner_id.chorus_service_ok():
if not inv.ref:
if not ref:
raise UserError(
_(
"Partner '%s' is configured as "
Expand Down Expand Up @@ -402,13 +403,14 @@

def chorus_invoice_check_commitment_number(self, raise_if_not_found=True):
self.ensure_one()
ref = self._get_buyer_order_ref()

Check warning on line 406 in l10n_fr_chorus_account/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_fr_chorus_account/models/account_move.py#L406

Added line #L406 was not covered by tests
res = self.chorus_check_commitment_number(
self.company_id, self.ref, raise_if_not_found=raise_if_not_found
self.company_id, ref, raise_if_not_found=raise_if_not_found
)
if res is True:
self.message_post(
body=_("Engagement juridique <b>%s</b> checked via Chorus Pro API.")
% self.ref
% ref
)
return res

Expand Down
Loading