Skip to content

Conversation

@DjamelTouati
Copy link
Contributor

@DjamelTouati DjamelTouati commented May 9, 2022

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:

production = super(MrpProduction, self).create(values)
production.move_raw_ids.write({
'group_id': production.procurement_group_id.id,
'reference': production.name, # set reference when MO name is different than 'New'
})

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:

@api.depends('picking_id', 'name')
def _compute_reference(self):
for move in self:
move.reference = move.picking_id.name if move.picking_id else move.name

opw-2839202

bug_traceability.mp4

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented May 9, 2022

Pull request status dashboard

@C3POdoo C3POdoo requested a review from a team May 9, 2022 15:53
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label May 9, 2022
@DjamelTouati DjamelTouati force-pushed the 13.0-opw-2839202-mrp-update_stock_move_name-otd branch 2 times, most recently from 4739a11 to 2eaabed Compare May 12, 2022 11:07
@amoyaux
Copy link
Contributor

amoyaux commented May 13, 2022

robodoo r+

Comment on lines 130 to 136
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
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

Copy link
Contributor Author

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 ?

@DjamelTouati
Copy link
Contributor Author

@robodoo r-

@DjamelTouati DjamelTouati force-pushed the 13.0-opw-2839202-mrp-update_stock_move_name-otd branch from 2eaabed to 8fb4782 Compare May 13, 2022 13:06
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
@DjamelTouati DjamelTouati force-pushed the 13.0-opw-2839202-mrp-update_stock_move_name-otd branch from 8fb4782 to 1b4beed Compare May 13, 2022 13:08
@DjamelTouati
Copy link
Contributor Author

Hello @amoyaux
Do you think we can r+ this PR?

@amoyaux
Copy link
Contributor

amoyaux commented Jun 13, 2022

robodoo r+

robodoo pushed a commit that referenced this pull request Jun 13, 2022
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]>
@robodoo robodoo closed this Jun 13, 2022
@robodoo robodoo temporarily deployed to merge June 13, 2022 13:55 Inactive
@fw-bot fw-bot deleted the 13.0-opw-2839202-mrp-update_stock_move_name-otd branch June 27, 2022 14:46
cormaza pushed a commit to cormaza/odoo that referenced this pull request Jul 15, 2022
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]>
gamarino pushed a commit to numaes/numa-public-odoo that referenced this pull request Jan 11, 2023
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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