Skip to content

Conversation

@fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Jun 22, 2022

Updating the scheduled date of a delivery doesn't update the quantity to
order of an orderpoint

To reproduce the issue:
(Need purchase)

  1. Create a storable product P with a seller
  2. Create and confirm a planned delivery D with 1 x P
  3. Open the replenishment page
    • There should be a line for P (Forecast: -1, To Order: 1)
  4. Edit D and postpone the scheduled date
  5. Go back to replenishment page

Error: The line is still present, its forecast qty is correct (0) but
the quantity to order is still 1 (instead of 0)

qty_to_order is a stored field, so when loading the replenishment
page, its compute method is not called. Moreover, even though
qty_to_order depends on qty_forecast and the compute method of
qty_forecast is called, it still won't trigger the compute:
when setting the value of qty_forecast from its compute method, it
will lead to:

odoo/odoo/fields.py

Lines 1106 to 1109 in b54f78d

if protected_ids:
# records being computed: no business logic, no recomputation
protected_records = records.browse(protected_ids)
self.write(protected_records, value)

So, as shown and explained, we bypass the write of BaseModel and
skip the business logic and the recomputations

The compute of qty_to_order should actually be triggered earlier: when
we edit the scheduled date (step 4). That's the reason why this commit
adds a dependency to the compute of qty_forecast: it makes more sense
and becomes an implicit dependency of qty_to_order -> update the
scheduled date will trigger the compute of qty_to_order

OPW-2868167

Forward-Port-Of: #94196
Forward-Port-Of: #93889

@robodoo
Copy link
Contributor

robodoo commented Jun 22, 2022

Pull request status dashboard

@fw-bot
Copy link
Contributor Author

fw-bot commented Jun 22, 2022

Ping @adwid, @Whenrow cherrypicking of pull request #93889 failed.

stderr:

13:56:20.197258 git.c:344               trace: built-in: git cherry-pick cf2b50405ba0af52a0a4baccba0d3bb056cfb17a
error: could not apply cf2b50405ba... [FIX] {purchase_,}stock: recompute orderpoints on SM's date change
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
----------
status:

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jun 22, 2022
@robodoo robodoo added conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot labels Jun 22, 2022
Updating the scheduled date of a delivery doesn't update the quantity to
order of an orderpoint

To reproduce the issue:
(Need purchase)
1. Create a storable product P with a seller
2. Create and confirm a planned delivery D with 1 x P
3. Open the replenishment page
    - There should be a line for P (Forecast: -1, To Order: 1)
4. Edit D and postpone the scheduled date
5. Go back to replenishment page

Error: The line is still present, its forecast qty is correct (0) but
the quantity to order is still 1 (instead of 0)

`qty_to_order` is a stored field, so when loading the replenishment
page, its compute method is not called. Moreover, even though
`qty_to_order` depends on `qty_forecast` and the compute method of
`qty_forecast` is called, it still won't trigger the compute:
when setting the value of `qty_forecast` from its compute method, it
will lead to:
https://github.com/odoo/odoo/blob/b54f78de307543efcea934206806f361eaac811a/odoo/fields.py#L1106-L1109
So, as shown and explained, we bypass the `write` of `BaseModel` and
skip the business logic and the recomputations

The compute of `qty_to_order` should actually be triggered earlier: when
we edit the scheduled date (step 4). That's the reason why this commit
adds a dependency to the compute of `qty_forecast`: it makes more sense
and becomes an implicit dependency of `qty_to_order` -> update the
scheduled date will trigger the compute of `qty_to_order`

OPW-2868167

X-original-commit: 1262120
@adwid adwid force-pushed the saas-15.2-14.0-OPW-2868167-purchase_stock_date_and_replenishment-awt-Amfh-fw branch from b1599f1 to 4208597 Compare June 22, 2022 13:23
@adwid
Copy link
Contributor

adwid commented Jun 22, 2022

robodoo r+

@C3POdoo C3POdoo requested a review from a team June 22, 2022 13:26
robodoo pushed a commit that referenced this pull request Jun 22, 2022
Updating the scheduled date of a delivery doesn't update the quantity to
order of an orderpoint

To reproduce the issue:
(Need purchase)
1. Create a storable product P with a seller
2. Create and confirm a planned delivery D with 1 x P
3. Open the replenishment page
    - There should be a line for P (Forecast: -1, To Order: 1)
4. Edit D and postpone the scheduled date
5. Go back to replenishment page

Error: The line is still present, its forecast qty is correct (0) but
the quantity to order is still 1 (instead of 0)

`qty_to_order` is a stored field, so when loading the replenishment
page, its compute method is not called. Moreover, even though
`qty_to_order` depends on `qty_forecast` and the compute method of
`qty_forecast` is called, it still won't trigger the compute:
when setting the value of `qty_forecast` from its compute method, it
will lead to:
https://github.com/odoo/odoo/blob/b54f78de307543efcea934206806f361eaac811a/odoo/fields.py#L1106-L1109
So, as shown and explained, we bypass the `write` of `BaseModel` and
skip the business logic and the recomputations

The compute of `qty_to_order` should actually be triggered earlier: when
we edit the scheduled date (step 4). That's the reason why this commit
adds a dependency to the compute of `qty_forecast`: it makes more sense
and becomes an implicit dependency of `qty_to_order` -> update the
scheduled date will trigger the compute of `qty_to_order`

OPW-2868167

closes #94300

X-original-commit: 1262120
Signed-off-by: William Henrotin (whe) <[email protected]>
Signed-off-by: Adrien Widart <[email protected]>
@robodoo robodoo closed this Jun 22, 2022
@robodoo robodoo temporarily deployed to merge June 22, 2022 16:04 Inactive
@adwid adwid deleted the saas-15.2-14.0-OPW-2868167-purchase_stock_date_and_replenishment-awt-Amfh-fw branch June 23, 2022 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants