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

[3811][11.0][REF] stock_ext_sst #356

Merged
merged 7 commits into from
Jan 22, 2024
Merged

[3811][11.0][REF] stock_ext_sst #356

merged 7 commits into from
Jan 22, 2024

Conversation

AungKoKoLin1997
Copy link
Contributor

@AungKoKoLin1997 AungKoKoLin1997 commented Oct 2, 2023

3811

This PR does-

  1. Change module name (stock_ext_sst to stock_quant_attribute)
  2. Change dependency of modules from stock_ext_sst to stock_quant_attribute
  3. Move yahoo_product_state_id field definition in stock.quant to product_yahoo_auction_sst
  4. Move view definition of yahoo_product_state_id to stock_quant_list_view
  5. Split new module stock_quant_product_publish for publishing products and assigning the yahoo_product_state_id from stock quant model
  6. Split new module stock_quant_status_update that updates yahoo_product_state_id for products and updates the quantity_done in stock_move depends on yahoo_product_state_id

target="new"
view_type="form"
/>
</odoo>
Copy link
Member

Choose a reason for hiding this comment

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

End with a whitespace.

"license": "AGPL-3",
"depends": [
"stock",
"stock_quant_list_view",
Copy link
Member

Choose a reason for hiding this comment

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

@kanda999 Please check if we should reverse the dependencies. In fact, please check if we can get rid of stock_quant_list_view by delegating necessary changes on stock.quant list to other existing modules.

Copy link
Contributor

Choose a reason for hiding this comment

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

@AungKoKoLin1997
We can remove this module by moving stock_quant.py to product_yahoo_auction_sst and adjusting the view in stock_quant_list_view.
stock_quant_list_view contains product_ext_sst as a dependency, so product_yahoo_aution_sst is installed.

Copy link
Contributor

@kanda999 kanda999 left a comment

Choose a reason for hiding this comment

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

product_publish_cron module depended on the stock_ext_sst module.
Could you check and update this PR?

@yostashiro yostashiro changed the title [11.0[3811]][REF] stock_ext_sst [3811][11.0][REF] stock_ext_sst Oct 4, 2023
@yostashiro
Copy link
Member

@AungKoKoLin1997 Can you please summarize all the changes in the top comment.

Comment on lines 22 to 24
# Using mapped to gather all product_tmpl_id records
product_templates = quants.mapped('product_id.product_tmpl_id')
product_templates.sudo().write(values)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this suffice?

Suggested change
# Using mapped to gather all product_tmpl_id records
product_templates = quants.mapped('product_id.product_tmpl_id')
product_templates.sudo().write(values)
quants.mapped("product_id").sudo().write(values)

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I'm a bit confused about the scope as stock_quant_status_update also seems to update yahoo_product_state_id of the product. Please check to make sure we are not duplicating functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I checked with the customer and they can update yahoo_product_state_id alone. And they have an operation to update yahoo_product_state_id whenever they publish the website.
If each function were to stand alone, it need two operations to publish the product on the website, and it would be difficult to know which product's yahoo_product_state_id was updated.

list_price = fields.Float(
related="product_id.product_tmpl_id.list_price", string="Sale Price",
)
product_id = fields.Many2one(auto_join=True,)
Copy link
Member

Choose a reason for hiding this comment

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

Please correct me if you have a different understanding of the reason of this change.

Suggested change
product_id = fields.Many2one(auto_join=True,)
# To improve search performance by product.
product_id = fields.Many2one(auto_join=True,)

Copy link
Member

Choose a reason for hiding this comment

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

Why delivery as a dependency?

Add website as a dependency.

_inherit = "stock.quant"

website_published = fields.Boolean(
related="product_id.product_tmpl_id.website_published",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
related="product_id.product_tmpl_id.website_published",
related="product_id.website_published",

_inherit = "stock.quant"

yahoo_product_state_id = fields.Many2one(
related="product_id.product_tmpl_id.yahoo_product_state_id",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
related="product_id.product_tmpl_id.yahoo_product_state_id",
related="product_id.yahoo_product_state_id",

Comment on lines 21 to 25
if self.yahoo_product_state_id.id == int(
self.env["ir.config_parameter"]
.sudo()
.get_param("stock_ext_sst.picking_product_state_id")
.get_param("stock_quant_status_update.picking_product_state_id")
):
Copy link
Member

Choose a reason for hiding this comment

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

This is bad. Move this part outside the for loop.

Add a migration script to update the param key, or communicate with @kanda999 to cover this part manually.

@@ -16,11 +16,12 @@ def action_stock_quant_status_update(self):
active_ids = context.get("active_ids", [])
quants = self.env["stock.quant"].browse(active_ids)
values = {"yahoo_product_state_id": self.yahoo_product_state_id.id}
parmas_product_state_id = int(
Copy link
Member

@yostashiro yostashiro Jan 22, 2024

Choose a reason for hiding this comment

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

What is parmas? You mean param?

Copy link
Member

@yostashiro yostashiro 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.

Copy link
Contributor

@kanda999 kanda999 left a comment

Choose a reason for hiding this comment

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

Functional and code review

@kanda999 kanda999 merged commit b1e61a2 into 11.0 Jan 22, 2024
0 of 2 checks passed
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