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

[18.0][MIG] sale_procurement_group_by_line: Migration to 18.0. #3420

Open
wants to merge 44 commits into
base: 18.0
Choose a base branch
from

Conversation

MeritxellAForgeFlow
Copy link

Migration to 18.0

@ForgeFlow

yvaucher and others added 30 commits November 21, 2024 10:43
This module extract logic to create multiple procurement group
for a single sale order for grouped sale order lines.
* Fix OCA#264
* Fix : Can't create delivery from shipping exception
* [ADD] [9.0] sale_delivery_block

* [IMP] Add data with an example Delivery Block Reason.

* [FIX]
 * Able to edit the Delivery Block Reason in state 'sent'
 * README

* [FIX] make sale_delivery_block compatible with sale_procurement_group_by_line

* [FIX] travis and data nouptade.

* [ADD] delivery block tests.

* [IMP] Add the 'Default Delivery Block Reason' in partners.

* [IMP] track visibility of delivery block reason

* [9.0][IMP] sale_delivery_block:
  * default_delivery_block is now a comercial field.
  * When duplicating a sale order the delivery block is recomputed.

* [9.0][UPD] sale_delivery_block_proc_group_by_line: Update README.

* [FIX] api.model used with api.constrains
Currently translated at 66.7% (2 of 3 strings)

Translation: sale-workflow-11.0/sale-workflow-11.0-sale_procurement_group_by_line
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-11-0/sale-workflow-11-0-sale_procurement_group_by_line/de/
Currently translated at 100.0% (3 of 3 strings)

Translation: sale-workflow-13.0/sale-workflow-13.0-sale_procurement_group_by_line
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-13-0/sale-workflow-13-0-sale_procurement_group_by_line/es/
…_qty.

This avoids duplicated procurements in some cases, basically for
any operation that has a specific `<sale.order.line>._get_qty_procurement`
relying on `previous_product_uom_qty`. E.g: manufacturing kits,
dropshipping...
…uom_qty

Prevents having duplicated procurements when having several order lines involving any operation that has a specific `<sale.order.line>._get_qty_procurement`
relying on `previous_product_uom_qty` (Manufacturing kits, dropshipping..)
Currently translated at 100.0% (6 of 6 strings)

Translation: sale-workflow-15.0/sale-workflow-15.0-sale_procurement_group_by_line
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sale_procurement_group_by_line/ca/
Before the fix, when new quantities are added into an already confirmed
line, we are writing in the previous_product_uom_qty only the new qty that
has been processed, not the total amount that has actually been
processed for the line.

Due to this, when we call super() on _action_launch_stock_rule, the new
quantities are procured again, as we have not really updated the amount
in previous_product_uom_qty including what we have already procured
before calling super().
@OCA-git-bot
Copy link
Contributor

Sorry @RicardCForgeFlow you are not allowed to mark the addon tobe migrated.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

Copy link
Contributor

@JordiMForgeFlow JordiMForgeFlow left a comment

Choose a reason for hiding this comment

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

Could you include the module name in the MIG commit like: [MIG] sale_procurement_group_by_line: Migration to V18?

Code review LGTM :)

@MeritxellAForgeFlow MeritxellAForgeFlow force-pushed the 18.0-mig-sale_procurement_group_by_line branch from 7e59cd0 to 926ec31 Compare November 22, 2024 09:45
Copy link

@RicardCForgeFlow RicardCForgeFlow 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

@AaronHForgeFlow AaronHForgeFlow 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

previous_product_uom_qty = {}
for line in self:
line = line.with_company(line.company_id)
if line.state != "sale" or line.product_id.type not in ("consu", "product"):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if line.state != "sale" or line.product_id.type not in ("consu", "product"):
if line.state != "sale" or line.order_id.locked or line.product_id.type != 'consu':

Comment on lines 86 to 100
product_qty, procurement_uom = line_uom._adjust_uom_quantities(
product_qty, quant_uom
)

procurements.append(
self.env["procurement.group"].Procurement(
line.product_id,
product_qty,
procurement_uom,
line.order_id.partner_shipping_id.property_stock_customer,
line.display_name,
line.order_id.name,
line.order_id.company_id,
values,
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
product_qty, procurement_uom = line_uom._adjust_uom_quantities(
product_qty, quant_uom
)
procurements.append(
self.env["procurement.group"].Procurement(
line.product_id,
product_qty,
procurement_uom,
line.order_id.partner_shipping_id.property_stock_customer,
line.display_name,
line.order_id.name,
line.order_id.company_id,
values,
)
)
origin = f'{line.order_id.name} - {line.order_id.client_order_ref}' if line.order_id.client_order_ref else line.order_id.name
product_qty, procurement_uom = line_uom._adjust_uom_quantities(
product_qty, quant_uom
)
procurements += line._create_procurements(product_qty, procurement_uom, origin, values)

@MeritxellAForgeFlow MeritxellAForgeFlow force-pushed the 18.0-mig-sale_procurement_group_by_line branch 3 times, most recently from c22bae1 to efd1ae8 Compare November 22, 2024 11:24
Comment on lines 99 to 101
self.assertEqual(self.line1.move_ids.name, self.line1.display_name)
self.assertEqual(len(self.line2.move_ids), 1)
self.assertEqual(self.line2.move_ids.name, self.line2.display_name)
Copy link
Contributor

@MiquelRForgeFlow MiquelRForgeFlow Nov 22, 2024

Choose a reason for hiding this comment

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

Suggested change
self.assertEqual(self.line1.move_ids.name, self.line1.display_name)
self.assertEqual(len(self.line2.move_ids), 1)
self.assertEqual(self.line2.move_ids.name, self.line2.display_name)
self.assertEqual(self.line1.move_ids.name, self.line1.product_id.display_name)
self.assertEqual(len(self.line2.move_ids), 1)
self.assertEqual(self.line2.move_ids.name, self.line2.product_id.display_name)

or something like this.

It seems it's due to odoo/odoo@4cc2b3b

@MeritxellAForgeFlow MeritxellAForgeFlow force-pushed the 18.0-mig-sale_procurement_group_by_line branch from efd1ae8 to cac406c Compare November 25, 2024 10:48
@MiquelRForgeFlow MiquelRForgeFlow force-pushed the 18.0-mig-sale_procurement_group_by_line branch 2 times, most recently from e6c97a9 to 9fc802a Compare November 25, 2024 13:10
@MiquelRForgeFlow MiquelRForgeFlow force-pushed the 18.0-mig-sale_procurement_group_by_line branch from 9fc802a to 1c7646d Compare November 25, 2024 13:28
@MiquelRForgeFlow
Copy link
Contributor

Added v17 changes in a separated commit (a forward port of #3428).

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.