Files
odoo_source/addons/mrp/models/stock_traceability.py
T
Haresh Shyara 68061e2517 [IMP] stock, mrp, repair: optimization traceability report based on stock move lines
- Optimized _lines() to fold/unfold mechanism and use stock move line in get lines.
- Merged into single method (make_dict_move and make_dict_head) to get parent & child traceability result
  and use unfolfable to make line unfoldable.
- Removed _get_produced_or_consumed_vals method and move mechanisam into _line method will do same for this.
- Make some methods private.
- Removed useless vals from dict.
2018-01-31 14:15:00 +01:00

31 lines
1.4 KiB
Python

from odoo import models, api
class MrpStockReport(models.TransientModel):
_inherit = 'stock.traceability.report'
@api.model
def _get_reference(self, move_line):
res_model, res_id, ref = super(MrpStockReport, self)._get_reference(move_line)
if move_line.production_id:
res_model = 'mrp.production'
res_id = move_line.production_id.id
ref = move_line.production_id.name
if move_line.move_id.unbuild_id:
res_model = 'mrp.unbuild'
res_id = move_line.move_id.unbuild_id.id
ref = move_line.move_id.unbuild_id.name
if move_line.move_id.consume_unbuild_id:
res_model = 'mrp.unbuild'
res_id = move_line.move_id.consume_unbuild_id.id
ref = move_line.move_id.consume_unbuild_id.name
return res_model, res_id, ref
@api.model
def _get_linked_move_lines(self, move_line):
move_lines, is_used = super(MrpStockReport, self)._get_linked_move_lines(move_line)
if not move_lines:
move_lines = (move_line.move_id.consume_unbuild_id and move_line.produce_line_ids) or (move_line.move_id.production_id and move_line.consume_line_ids)
if not is_used:
is_used = (move_line.move_id.unbuild_id and move_line.consume_line_ids) or (move_line.move_id.raw_material_production_id and move_line.produce_line_ids)
return move_lines, is_used