Skip to content

[19.0][FIX] purchase_sale_stock_inter_company - fix "A lot/serial number is required for product..." when sync creating a lot-less stock.move.line for lot_valuated product - #1040

Open
cuongnmtm wants to merge 56 commits into
OCA:19.0from
komit-consulting:19.0-fix-psssic-lot-valuated
Open

cuongnmtm wants to merge 56 commits into
OCA:19.0from
komit-consulting:19.0-fix-psssic-lot-valuated

Conversation

@cuongnmtm

Copy link
Copy Markdown
Contributor

yankinmax and others added 30 commits February 17, 2026 09:21
Update v14 latest changes and test cases
Currently translated at 100.0% (10 of 10 strings)

Translation: multi-company-16.0/multi-company-16.0-purchase_sale_stock_inter_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-purchase_sale_stock_inter_company/es/
Currently translated at 90.0% (9 of 10 strings)

Translation: multi-company-16.0/multi-company-16.0-purchase_sale_stock_inter_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-purchase_sale_stock_inter_company/it/
Currently translated at 100.0% (10 of 10 strings)

Translation: multi-company-16.0/multi-company-16.0-purchase_sale_stock_inter_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-purchase_sale_stock_inter_company/it/
…ation logic for inheritance in purchase_sale_stock_inter_company_mrp
…roducts

Imagine you have a customization that enables the split of a stock move into several moves (distributed in several pickings). Thus, we need to handle this case.
Previously an intercompany picking with tracked products would simply
throw an error.

With this fix, the method searches for a lot in the destination company
that matches the one in the source company (same name and same product).
A new lot is created by duplicating the original, if none is found.
This commit fixes a bug that occurred when the intercompany PO/SO and
therefore the pickings had multiple lines of the same product.

In that case, the quantities done would not be synced correctly,
but rather the larger quantity would be applied
to all destination moves. The receiving company would receive more
product than was ordered in the PO.
…company_ids will be empty and the picking will not sync. Use sale_id.partner_id instead.
When an incomplete sale order is delivered and "No backorder" is chosen, SO moves split in two while PO stays the same.
Aggregating writes per each PO move makes sure qty does not get overwritten.
Usually second qty is zero so the destination move becomes quantity zero and the picking was even cancelled.
A number of things can go wrong in trying to confirm the PO picking
when the SO picking is confirmed. Instead of raising an error and
thereby blocking the confirm of the SO picking, provide an option by
which the exception can be caught. The SO picking will still be
confirmed, but an activity will be posted for someone to deal with the
PO picking manually.
Before this commit, if the company selling had setup 2- or 3-step
deliveries on its warehouse, 2 or 3 receipts would be created
on the PO side.

When synchronizing, we only need to consider the final outgoing
picking, and not the intermediate pickings.
carlos-lopez-tecnativa and others added 25 commits February 17, 2026 09:21
…the origin company to the destination company

The synchronization is done only when the picking is in the "Done" state because, before that, the lots are not yet synchronized.
Just changing these fields to make it easier to test the module.

Technically a bug in "stock" module's demo data. Contact Jeff Lawson is
also the "address" of warehouse "Chicago 1".
The fields property_stock_customer and supplier are set to
"Inter-warehouse transit" on Jeff Lawson for company San Francisco
and not for company Chicago as it should be.

Since there are no routes set for location "Inter-warehouse transit",
creating an inter-company PO from Chicago to SF fails;
when the inter-company SO is automatically created, with delivery
address towards the Chicago Warehouse i.e. Jeff Lawson, the creation
of the SO's picking fails as there is no route available.
… purchase reception if it is a dropshipping

To avoid adding an explicit dependency, check the picking type code when it is a dropship.
Create two dedicated functions to determine when it is an intercompany reception or an intercompany delivery, and use the same logic in multiple places.

We used the locations to cover the dropshipping case and deliveries/receptions in multiples steps, and the respective many2one field to know if it is a purchase or sale intercompany transaction.
We do not use the partner because a picking can be created manually using this contact, but the specific fields for intercompany transactions are the many2one fields.
…companies

After this PR odoo/odoo#146458, Odoo allows shared lots between companies. This commit ensures that lots can be shared by clearing the company field if it is filled.
…cking_batch is installed

- Force recomputation of the picking state based on the field intercompany_sale_order_id, which is set after the picking is created.
- Add the stock.group_stock_user group to the user to ensure proper access rights.
…t locations between companies

Currently, intercompany transactions are handled as follows:
Sale order: from Stock to Customer
Purchase order: from Vendors to Stock

When using Dropshipping, the moves are:
Sale order: from Stock to Customer
Purchase order: from Vendors to Customer

However, when using a product tracked by serial number, an error occurs because the same product cannot exist in the same location with the same lot, the lot is effectively entered twice into the customer location.

To avoid this constraint, the movement of locations is now performed as follows:

Standard flow:

Sale order: from Stock to Intercompany Location
Purchase order: from Intercompany Location to Stock

With Dropshipping:

Sale order: from Stock to Intercompany Location
Purchase order: from Intercompany Location to Customer
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: multi-company-18.0/multi-company-18.0-purchase_sale_stock_inter_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-18-0/multi-company-18-0-purchase_sale_stock_inter_company/
Currently translated at 100.0% (28 of 28 strings)

Translation: multi-company-18.0/multi-company-18.0-purchase_sale_stock_inter_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-18-0/multi-company-18-0-purchase_sale_stock_inter_company/it/
Currently translated at 100.0% (28 of 28 strings)

Translation: multi-company-18.0/multi-company-18.0-purchase_sale_stock_inter_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-18-0/multi-company-18-0-purchase_sale_stock_inter_company/it/
… move

When the counterpart PO already has a done move, the sync copies it with
`move_line_ids: False`. As the copy lands in a done picking,
`stock.move.create` forces it to `done` and `stock_account` values its move
lines from within their `create()`. Those lines are created without a lot,
so on a `lot_valuated` product the valuation raises "A lot/serial number is
required for product ...".

This test reproduces that flow: a first delivery makes the receipt done, and
a second delivery from the backorder then goes through the copy branch. It
also checks the received quantity per lot and `qty_received`, so a lot
cannot be received twice.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… move

When the counterpart PO already has a done move, the sync copies it with
`move_line_ids: False`. That copy lands in a done picking, so
`stock.move.create` forces it to `done` and `stock_account` values its move
lines from within their `create()`. The lines were created without a lot,
which makes `stock.move._set_value` raise "A lot/serial number is required
for product ..." on a `lot_valuated` product -- a control that came with the
new inventory valuation, in its current form since odoo/odoo
d06959e3732286127795e4ee7fc3b2d4012312e5.

Assigning the lot afterwards is too late, so the lines are now created with
their lot from the start, mirrored from the delivery. A line whose quantity
another line already covers ends up zeroed by the existing cleanup; it is
harmless, as it carries neither quantity nor value.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mmircoli-nexapp

Copy link
Copy Markdown

this is the right PR migration?

@cuongnmtm

Copy link
Copy Markdown
Contributor Author

this is the right PR migration?

I believe you found the MIG PR

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

Labels

mod:purchase_sale_stock_inter_company Module purchase_sale_stock_inter_company series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.