Skip to content

[18.0][MIG] edi_purchase_edifact_oca: Migration to 18.0#4

Open
P-H-Phuc wants to merge 12 commits into18.0from
18.0_mig-edi_purchase_edifact_oca
Open

[18.0][MIG] edi_purchase_edifact_oca: Migration to 18.0#4
P-H-Phuc wants to merge 12 commits into18.0from
18.0_mig-edi_purchase_edifact_oca

Conversation

@P-H-Phuc
Copy link
Owner

@P-H-Phuc P-H-Phuc commented Aug 18, 2025

Changes

  • Replaced move.quantity_done → move.quantity.
  • In Odoo 18, the default picking quantity is set to product_uom_qty. To align with actual receipts, we now initialize move.quantity with 0 and update it only for lines that are physically received.
  • Reference: odoo/odoo@7dda6b
  • Added @tagged("-at_install", "post_install") to the edi_oca module tests.

Rationale

The failure occurs because edi_purchase_edifact_oca indirectly depends on account, which introduces the required field autopost_bills on res.partner.

During TestEDIExchangeRecordSecurity, when a new user is created, the linked partner record is also created. At that moment, the default value for autopost_bills is not yet initialized, leaving it NULL and causing the test to fail.

Fix

Apply @tagged("-at_install") to the base mixin.
This prevents a race condition where the parent class setUp might run before all module models are fully loaded. With this change:

  • Tests are executed only after the environment is fully initialized.

  • Required defaults (like autopost_bills) are properly loaded.

@P-H-Phuc
Copy link
Owner Author

Hi @thienvh332, I’ve just opened a PR. Could you please take a look and share your feedback when you have time?

@thienvh332
Copy link

I’m wondering, why did you create a new PR instead of continuing with the old one?

@thienvh332
Copy link

FYI, you can cherry-pick 2 more commits from here

@P-H-Phuc P-H-Phuc force-pushed the 18.0_mig-edi_purchase_edifact_oca branch from 803b1f4 to 570741c Compare August 20, 2025 09:37
@P-H-Phuc P-H-Phuc force-pushed the 18.0_mig-edi_purchase_edifact_oca branch 2 times, most recently from 5a3b422 to 5582c36 Compare August 21, 2025 07:30
@thienvh332
Copy link

Focus on the testcase result. And don’t use f-strings with self.env._(). Instead, use self.env._("%s", params).

@P-H-Phuc P-H-Phuc force-pushed the 18.0_mig-edi_purchase_edifact_oca branch 2 times, most recently from 2a5cae9 to 6a9c25b Compare August 25, 2025 03:03
@P-H-Phuc P-H-Phuc requested a review from thienvh332 August 25, 2025 03:12
Comment on lines 699 to 726
message = (
"<p>This order has been updated automatically via the import of file "
"<strong>{}</strong><br/>"
"Done quantities were updated on {} lines out of the {} Reception lines</p>"
).format(
html_escape(self.order_filename),
action.get("number_line_updated", 0),
action.get("reception_lines", 0),
)

unknown_products = action.get("unknown_products", False)
if unknown_products:
message += "<p><strong>Unknown Product:</strong><br/>"
message += "<br/>".join(
f"&nbsp;&nbsp;* {html_escape(json.dumps(rec, ensure_ascii=False))}"
for rec in unknown_products
)
message += "</p>"

qty_diff = action.get("qty_diff", False)
if qty_diff:
message += "<p><strong>Difference of Qty:</strong><br/>"
message += "<br/>".join(
f"&nbsp;&nbsp;* {html_escape(json.dumps(rec, ensure_ascii=False))}"
for rec in qty_diff
)
message += "</p>"
return message

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another issue is to update the HTML tags in the messages used for message_post so that they comply with v18
image

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markup applied

@P-H-Phuc P-H-Phuc force-pushed the 18.0_mig-edi_purchase_edifact_oca branch 2 times, most recently from d203914 to af7d036 Compare August 25, 2025 04:42
@thienvh332
Copy link

The last two issues are:

  • Move commit dcc8e23a583fad0a586af7d2300380492d4c1c8e to the very end.
  • Update the PR description to be clearer. (Note: remove the Main Feature section, since it’s just copied from the README.)

@P-H-Phuc P-H-Phuc force-pushed the 18.0_mig-edi_purchase_edifact_oca branch from af7d036 to 3417feb Compare August 25, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants