-
Notifications
You must be signed in to change notification settings - Fork 30.4k
[FIX] mrp: update the “stock.move” name after the MO creation #90926
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
[FIX] mrp: update the “stock.move” name after the MO creation #90926
Conversation
4739a11 to
2eaabed
Compare
|
robodoo r+ |
addons/mrp/models/stock_move.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| prod_move = self.filtered(lambda m: m.raw_material_production_id) | |
| for move in prod_move: | |
| move.write({ | |
| 'name': move.raw_material_production_id.name, | |
| 'reference': move.raw_material_production_id.name, | |
| }) | |
| super(StockMove, self - prod_move)._compute_reference() | |
| not_prod_move = set() | |
| for move in self: | |
| if not move.raw_material_production_id: | |
| not_prod_move.add(move.id) | |
| continue | |
| move.write({ | |
| 'name': move.raw_material_production_id.name, | |
| 'reference': move.raw_material_production_id.name, | |
| }) | |
| super(StockMove, self.browse(not_prod_move))._compute_reference() |
Always good to avoid an extra loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks! But I think it's better to use an empty recordset to avoid doing a browse when calling the super, what do you think ?
|
@robodoo r- |
2eaabed to
8fb4782
Compare
Steps to reproduce the bug:
- Create a storable product “P1” with BOM:
- component: 1 unit of “C1”
- Consumption: Flexible
- Create a MO to produce one “P1”:
- Click on “Mark as todo”
- Click on “produce”
- In the window that opens, add one unit of "C1" in new line
- Confirm the MO
- Go to the product form of “C1”:
- Click on the traceability button
Problem:
The `stock.move` for the additional unit component(not initially planned in the Bill of materials)
is with reference “New” instead of the MO name
Bug:
The first `stock.move` will be created with the name `New` and after the MO creation,
its reference will be updated but not its name:
https://github.com/odoo/odoo/blob/13241c7a0ebb93998cd918b839e7372f332ec7b1/addons/mrp/models/mrp_production.py#L504-L508
So when an additional unit of the component will be added, the `_create_extra_move`
function will be called, therefore a copy of the first stock.move will be made:
https://github.com/odoo/odoo/blob/13.0/addons/stock/models/stock_move.py#L1371
But as its name is `new` the new `stock.move` will have the same name
and its reference will be calculated based on the name:
https://github.com/odoo/odoo/blob/0b9105cc2c02a714bf5c9a2f554cc181169838af/addons/stock/models/stock_move.py#L212-L215
opw-2839202
8fb4782 to
1b4beed
Compare
|
Hello @amoyaux |
|
robodoo r+ |
Steps to reproduce the bug:
- Create a storable product “P1” with BOM:
- component: 1 unit of “C1”
- Consumption: Flexible
- Create a MO to produce one “P1”:
- Click on “Mark as todo”
- Click on “produce”
- In the window that opens, add one unit of "C1" in new line
- Confirm the MO
- Go to the product form of “C1”:
- Click on the traceability button
Problem:
The `stock.move` for the additional unit component(not initially planned in the Bill of materials)
is with reference “New” instead of the MO name
Bug:
The first `stock.move` will be created with the name `New` and after the MO creation,
its reference will be updated but not its name:
https://github.com/odoo/odoo/blob/13241c7a0ebb93998cd918b839e7372f332ec7b1/addons/mrp/models/mrp_production.py#L504-L508
So when an additional unit of the component will be added, the `_create_extra_move`
function will be called, therefore a copy of the first stock.move will be made:
https://github.com/odoo/odoo/blob/13.0/addons/stock/models/stock_move.py#L1371
But as its name is `new` the new `stock.move` will have the same name
and its reference will be calculated based on the name:
https://github.com/odoo/odoo/blob/0b9105cc2c02a714bf5c9a2f554cc181169838af/addons/stock/models/stock_move.py#L212-L215
opw-2839202
closes #90926
Signed-off-by: Arnold Moyaux (arm) <[email protected]>
Steps to reproduce the bug:
- Create a storable product “P1” with BOM:
- component: 1 unit of “C1”
- Consumption: Flexible
- Create a MO to produce one “P1”:
- Click on “Mark as todo”
- Click on “produce”
- In the window that opens, add one unit of "C1" in new line
- Confirm the MO
- Go to the product form of “C1”:
- Click on the traceability button
Problem:
The `stock.move` for the additional unit component(not initially planned in the Bill of materials)
is with reference “New” instead of the MO name
Bug:
The first `stock.move` will be created with the name `New` and after the MO creation,
its reference will be updated but not its name:
https://github.com/odoo/odoo/blob/13241c7a0ebb93998cd918b839e7372f332ec7b1/addons/mrp/models/mrp_production.py#L504-L508
So when an additional unit of the component will be added, the `_create_extra_move`
function will be called, therefore a copy of the first stock.move will be made:
https://github.com/odoo/odoo/blob/13.0/addons/stock/models/stock_move.py#L1371
But as its name is `new` the new `stock.move` will have the same name
and its reference will be calculated based on the name:
https://github.com/odoo/odoo/blob/0b9105cc2c02a714bf5c9a2f554cc181169838af/addons/stock/models/stock_move.py#L212-L215
opw-2839202
closes odoo#90926
Signed-off-by: Arnold Moyaux (arm) <[email protected]>
Steps to reproduce the bug:
- Create a storable product “P1” with BOM:
- component: 1 unit of “C1”
- Consumption: Flexible
- Create a MO to produce one “P1”:
- Click on “Mark as todo”
- Click on “produce”
- In the window that opens, add one unit of "C1" in new line
- Confirm the MO
- Go to the product form of “C1”:
- Click on the traceability button
Problem:
The `stock.move` for the additional unit component(not initially planned in the Bill of materials)
is with reference “New” instead of the MO name
Bug:
The first `stock.move` will be created with the name `New` and after the MO creation,
its reference will be updated but not its name:
https://github.com/odoo/odoo/blob/13241c7a0ebb93998cd918b839e7372f332ec7b1/addons/mrp/models/mrp_production.py#L504-L508
So when an additional unit of the component will be added, the `_create_extra_move`
function will be called, therefore a copy of the first stock.move will be made:
https://github.com/odoo/odoo/blob/13.0/addons/stock/models/stock_move.py#L1371
But as its name is `new` the new `stock.move` will have the same name
and its reference will be calculated based on the name:
https://github.com/odoo/odoo/blob/0b9105cc2c02a714bf5c9a2f554cc181169838af/addons/stock/models/stock_move.py#L212-L215
opw-2839202
closes odoo/odoo#90926
Signed-off-by: Arnold Moyaux (arm) <[email protected]>

Steps to reproduce the bug:
Create a storable product “P1” with BOM:
Create a MO to produce one “P1”:
Go to the product form of “C1”:
Problem:
The
stock.movefor the additional unit component(not initially planned in the Bill of materials)is with reference “New” instead of the MO name
Bug:
The first
stock.movewill be created with the nameNewand after the MO creation,its reference will be updated but not its name:
odoo/addons/mrp/models/mrp_production.py
Lines 504 to 508 in 13241c7
So when an additional unit of the component will be added, the
_create_extra_movefunction will be called, therefore a copy of the first stock.move will be made:
https://github.com/odoo/odoo/blob/13.0/addons/stock/models/stock_move.py#L1371
But as its name is
newthe newstock.movewill have the same nameand its reference will be calculated based on the name:
odoo/addons/stock/models/stock_move.py
Lines 212 to 215 in 0b9105c
opw-2839202
bug_traceability.mp4
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr