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][MIG] stock_package_autoload: Migration to 16.0 #2218

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from

Conversation

anusriNPS
Copy link

@anusriNPS anusriNPS commented Dec 11, 2024

Migrating stock_package_autoload to 16.0
This module is migrated in 16.0 as this module is introduced as part of this PR in 14.0 : #2027

PicchiSeba and others added 2 commits December 11, 2024 15:39
This module allows to automatically add the content of a package to the transfer lines
@anusriNPS anusriNPS marked this pull request as draft December 11, 2024 14:53
@anusriNPS anusriNPS force-pushed the 16.0-mig-stock_package_autoload branch from d1514e1 to 57d6aeb Compare December 16, 2024 15:43
@anusriNPS anusriNPS marked this pull request as ready for review December 16, 2024 16:31
Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code review, LGTM, one possible suggestion

Comment on lines 23 to 22
[
(
"id",
"in",
self.env["stock.quant.package"]
.search([("quant_ids.product_id", "=", self.product_id.id)])
.ids,
)
]
if self.product_id

Choose a reason for hiding this comment

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

question:Would it be possible to avoid the search (line 28) and return

[("quant_ids.product.id", "=", self.product_id.id ])

?

Copy link
Author

Choose a reason for hiding this comment

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

Updated without search

@anusriNPS anusriNPS force-pushed the 16.0-mig-stock_package_autoload branch from 57d6aeb to edb1d64 Compare December 20, 2024 09:51
"category": "Warehouse Management",
"depends": [
"stock",
"web_domain_field",

Choose a reason for hiding this comment

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

issue: this module is deprecated, the same can be achieved in base Odoo by using a Binary field. See: https://github.com/OCA/web/blob/16.0/web_domain_field/README.rst

Copy link
Author

Choose a reason for hiding this comment

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

Sorry on missing to notice the deprecation. Thank you for noticing it.

@anusriNPS anusriNPS force-pushed the 16.0-mig-stock_package_autoload branch from edb1d64 to 15738ff Compare December 20, 2024 15:15
self.write({"package_domain": "[]"})
return
for sm in self:
sm.package_domain = sm._package_domain()
Copy link

Choose a reason for hiding this comment

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

issue: please keep the json.dumps() https://github.com/OCA/stock-logistics-warehouse/compare/edb1d646519c4e674a32693ca26c3dc85cf83d0f..15738ffc2951eba89528320cc84f8ff18a3e00c6#diff-166f2ecf2683b4ba59287e869e301a4d7bbb12e6a0ac826345a1addd6a11688bL38-L39

it's a best practice when passing data from the python backend to the JavaScript frontend to ensure that there are no issues with encoding, character escaping etc. (Most of the times it works fine even without it, but it's better to keep it, in case)

@anusriNPS
Copy link
Author

While trying to use json.dumps() on domain value, I was observing below frontend error where argument expects to be array:

image

I thought due to json encoding the domain is converted to string and hence it is not required to use json.dumps() here. I also tried to check on other modules for similar implementation such as sale_purchase_force_vendor module under "purchase-workflow" which uses similar binary field and does not encode domain using json.(https://github.com/OCA/purchase-workflow/blob/16.0/sale_purchase_force_vendor/models/sale_order_line.py#L36 )

As you have mentioned, it is best pratice to encode while passing to frontend, I am not sure whether my understanding regarding above error is right. I am not able to figure out other way to overcome it. Please let me know your suggestions on it.

@aleuffre
Copy link

aleuffre commented Jan 3, 2025

@anusriNPS You're probably correct that with the Binary field, it's not necessary to use json.dumps, I'm seeing several other implementations across OCA all omit it as well. It's probably fine as it is. Thank you for checking!

Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code and functional review, LGTM

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.

3 participants