-
Notifications
You must be signed in to change notification settings - Fork 0
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
[14.0][IMP] edi_oca: recompute exchange filename after getting related record #21
Conversation
edi_oca/tests/test_record.py
Outdated
self.assertEqual( | ||
record.exchange_filename, | ||
"wood-corner-test_csv_output-2020-10-21-12-00-00.csv", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertEqual( | |
record.exchange_filename, | |
"wood-corner-test_csv_output-2020-10-21-12-00-00.csv", | |
) | |
self.assertEqual( | |
record.exchange_filename, | |
f"{slugify(self.partner.display_name)}-test_csv_output-2020-10-21-12-00-00.csv", | |
) |
Hello @QuocDuong1306, I'm not seeing the benefit of renaming here. Because even if it's a |
Did you have a look at the card (3395)?
Actually, we don't want the |
7d4e588
to
6808be3
Compare
Thanks for your reply @QuocDuong1306 ,
|
6808be3
to
185be18
Compare
Hello a @thienvh332 , thanks for your suggestions, the PR has been updated, could you have a look? |
@@ -130,7 +130,7 @@ def _compute_related_name(self): | |||
related_record = rec.record | |||
rec.related_name = related_record.display_name if related_record else "" | |||
|
|||
@api.depends("model", "type_id") | |||
@api.depends("model", "res_id", "type_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not possible to duplicate then I think there is no need to recalculate when res_id
changes
@api.depends("model", "res_id", "type_id") | |
@api.depends("model", "type_id") |
185be18
to
9963071
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit message seems outdated
name = "[{}] {}".format(rec.type_id.name, rec_name) | ||
name = ( | ||
"[{}] {}".format(rec.type_id.name, rec_name) | ||
if rec._context.get("display_exchange_type_name", True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if rec._context.get("display_exchange_type_name", True) | |
if rec._context.get("include_exchange_type_name", True) |
edi_oca/models/edi_exchange_type.py
Outdated
# Avoid duplicating type code in filename | ||
if "{type.code}" in pattern and slugify(self.code) == slugify(self.name): | ||
exchange_record = exchange_record.with_context( | ||
display_exchange_type_name=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
display_exchange_type_name=False | |
include_exchange_type_name=False |
edi_oca/models/edi_exchange_type.py
Outdated
@@ -222,6 +222,11 @@ def _make_exchange_filename(self, exchange_record): | |||
ext = self.exchange_file_ext | |||
pattern = pattern + ".{ext}" | |||
dt = self._make_exchange_filename_datetime() | |||
# Avoid duplicating type code in filename | |||
if "{type.code}" in pattern and slugify(self.code) == slugify(self.name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes nils, updated
Actually, this context will not affect if we go through a related record. But maybe needing a check for a related record is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, can you improve the PR description to distinct the 2 cases:
- when we have a related record, {record_name} will...
- when we don't, ..., which can lead to redundant information in the filename due to...
also need to update commit name to reflect the new implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank nils, the PR is updated as suggested
9963071
to
9f62e85
Compare
9f62e85
to
e9a26ed
Compare
I think something is missing in that part about |
Hi nils, updated for that part |
I believe you are referring to the second case, right? So it should be: "In this case" (singular), and it should be indented under that case
|
Very sensitive, thank nils, updated |
Context:
When a related record exists,
{record_name}
uses the display name of the related record to differentiate the filename appropriately.When there is no related record (e.g., when creating an exchange record from storage or an endpoint),
{record_name}
uses the exchange record's display name.{record_name}
and{type.code}
are both used in the filename pattern (e.g., "{record_name}-{type.code}-{dt}"), then the filename will end up with some redundant information when the exchange type name and code have similar slugs (e.g., "Test CSV Output" and "test_csv_output").Changes: