manufacture icon indicating copy to clipboard operation
manufacture copied to clipboard

Draft:[14.0][FIX] #10130 mrp_sale_info

Open KKamaa opened this issue 1 year ago • 3 comments

@gjotten @thomaspaulb this should at least fix the error about AttributeError: 'NoneType' object has no attribute 'sale_line_id' by checking if moves exist in the first place.

KKamaa avatar Nov 15 '23 10:11 KKamaa

@sebastienbeau @rousseldenis @OCA/manufacturing-maintainers This fixes a regression introduced by https://github.com/OCA/manufacture/pull/1009

thomaspaulb avatar Nov 15 '23 14:11 thomaspaulb

@KKamaa @thomaspaulb Can you please add a test highlighting why this fix is needed? Then can you please reword the commit message?

grindtildeath avatar Nov 22 '23 20:11 grindtildeath

@KKamaa Could you change the title to be something more OCA-like, then mention in the description that this is about

  File "/home/ubuntu/odoo/auto/addons/stock/models/stock_picking.py", line 747, in action_confirm
    self.mapped('move_lines').filtered(lambda move: move.state not in ('draft', 'cancel', 'done'))._trigger_scheduler()
  File "/home/ubuntu/odoo/auto/addons/stock/models/stock_move.py", line 1828, in _trigger_scheduler
    company_id=company, raise_user_error=False)
  File "/home/ubuntu/odoo/auto/addons/stock/models/stock_orderpoint.py", line 500, in _procure_orderpoint_confirm
    self.env['procurement.group'].with_context(from_orderpoint=True).run(procurements, raise_user_error=raise_user_error)
  File "/home/ubuntu/odoo/auto/addons/purchase_stock/models/stock.py", line 352, in run
    return super().run(procurements, raise_user_error=raise_user_error)
  File "/home/ubuntu/odoo/auto/addons/mrp/models/stock_rule.py", line 216, in run
    return super(ProcurementGroup, self).run(procurements_without_kit, raise_user_error=raise_user_error)
  File "/home/ubuntu/odoo/auto/addons/stock/models/stock_rule.py", line 441, in run
    getattr(self.env['stock.rule'], '_run_%s' % action)(procurements)
  File "/home/ubuntu/odoo/auto/addons/mrp/models/stock_rule.py", line 52, in _run_manufacture
    productions_values_by_company[procurement.company_id.id].append(rule._prepare_mo_vals(*procurement, bom))
  File "/home/ubuntu/odoo/auto/addons/mrp_sale_info/models/stock_rule.py", line 38, in _prepare_mo_vals
    line_ids = moves.sale_line_id

and add a simple test that confirms a stock picking that generates a manufacturing order, but no sale order is connected and so move_dest_ids will be empty, that would have led to the traceback?

thomaspaulb avatar Feb 16 '24 15:02 thomaspaulb

@grindtildeath Added test like you said, only to find that a similar MR https://github.com/OCA/manufacture/pull/1189 was already merged.

However since extra tests are never bad, maybe you can still review this and we can merge the extra test.

thomaspaulb avatar Jun 10 '24 11:06 thomaspaulb

/ocabot merge nobump

grindtildeath avatar Jun 10 '24 14:06 grindtildeath

What a great day to merge this nice PR. Let's do it! Prepared branch 14.0-ocabot-merge-pr-1131-by-grindtildeath-bump-nobump, awaiting test results.

OCA-git-bot avatar Jun 10 '24 14:06 OCA-git-bot

Congratulations, your PR was merged at 1ee992a8e46d4dcb9fa5efa63f1aa05a1f1dc2cd. Thanks a lot for contributing to OCA. ❤️

OCA-git-bot avatar Jun 10 '24 14:06 OCA-git-bot