[REM] stock: removed stock_quant on traceability report

This commit is contained in:
Haresh Shyara
2018-01-31 14:14:59 +01:00
committed by Simon Lejeune
parent 5d463d2c03
commit 53ac302eab
4 changed files with 12 additions and 64 deletions
+10 -57
View File
@@ -70,13 +70,11 @@ class MrpStockReport(models.TransientModel):
model = False
model_id = False
level = 1
parent_quant = False
if kw:
level = kw['level']
model = kw['model_name']
model_id = kw['model_id']
stream = kw['stream']
parent_quant = kw['parent_quant']
res = []
if context.get('active_id') and not context.get('model') or context.get('model') == 'stock.production.lot':
if stream == "downstream":
@@ -86,15 +84,8 @@ class MrpStockReport(models.TransientModel):
('state', '=', 'done'),
('move_id.returned_move_ids', '=', False),
])
res += self._lines(line_id, model_id=model_id, model='stock.move.line', level=level, parent_quant=parent_quant,
res += self._lines(line_id, model_id=model_id, model='stock.move.line', level=level,
stream=stream, obj_ids=move_ids)
quant_ids = self.env['stock.quant'].search([
('lot_id', '=', context.get('active_id')),
('quantity', '<', 0),
('location_id.usage', '=', 'internal'),
])
res += self._lines(line_id, model_id=model_id, model='stock.quant', level=level,
parent_quant=parent_quant, stream=stream, obj_ids=quant_ids)
else:
move_ids = self.env['stock.move.line'].search([
('lot_id', '=', context.get('active_id')),
@@ -102,23 +93,16 @@ class MrpStockReport(models.TransientModel):
('state', '=', 'done'),
('move_id.returned_move_ids', '=', False),
])
res += self._lines(line_id, model_id=model_id, model='stock.move.line', level=level, parent_quant=parent_quant,
res += self._lines(line_id, model_id=model_id, model='stock.move.line', level=level,
stream=stream, obj_ids=move_ids)
quant_ids = self.env['stock.quant'].search([
('lot_id', '=', context.get('active_id')),
('quantity', '>', 0),
('location_id.usage', '=', 'internal'),
])
res += self._lines(line_id, model_id=model_id, model='stock.quant', level=level,
parent_quant=parent_quant, stream=stream, obj_ids=quant_ids)
elif context.get('active_id') and context.get('model') == 'stock.picking':
move_ids = self.env['stock.picking'].browse(context['active_id']).move_lines.mapped('move_line_ids').filtered(lambda m: m.lot_id and m.state == 'done')
res = self._lines(line_id, model_id=model_id, model='stock.move.line', level=level, parent_quant=parent_quant, stream=stream, obj_ids=move_ids)
res = self._lines(line_id, model_id=model_id, model='stock.move.line', level=level, stream=stream, obj_ids=move_ids)
elif context.get('active_id') and context.get('model') == 'stock.move.line':
move_line_ids = self.env['stock.move.line'].browse(context.get('active_id'))
res = self._lines(line_id, model_id=context.get('active_id'), model=context.get('model'), level=level, parent_quant=parent_quant, stream=stream, obj_ids=move_line_ids)
res = self._lines(line_id, model_id=context.get('active_id'), model=context.get('model'), level=level, stream=stream, obj_ids=move_line_ids)
else:
res = self._lines(line_id, model_id=model_id, model=model, level=level, parent_quant=parent_quant, stream=stream)
res = self._lines(line_id, model_id=model_id, model=model, level=level, stream=stream)
reverse_sort = True
if stream == "downstream":
reverse_sort = False
@@ -179,35 +163,13 @@ class MrpStockReport(models.TransientModel):
'location': move_line.location_dest_id.name,
'stream': stream,
'reference_id': False}]
elif model == 'stock.quant':
data = [{
'level': level,
'unfoldable': True,
'date': move_line.write_date,
'model_id': move_line.id,
'parent_id': parent_id,
'model': model or 'stock.quant',
'product_id': move_line.product_id.display_name,
'lot_id': move_line.lot_id.name,
'product_qty_uom': str(move_line.quantity) + ' ' + move_line.product_id.uom_id.name,
'location': move_line.location_id.name,
'stream': stream,
'reference_id': False}]
return data
@api.model
def upstream_traceability(self, level, stream=False, line_id=False, model=False, model_obj=False, parent_quant=False):
def upstream_traceability(self, level, stream=False, line_id=False, model=False, model_obj=False):
final_vals =[]
if model == 'stock.move.line':
moves = self.get_move_lines_upstream(model_obj)
elif model == 'stock.quant':
moves = self.env['stock.move.line'].search([
('location_dest_id', '=', model_obj.location_id.id),
('lot_id', '=', model_obj.lot_id.id),
('date', '<=', model_obj.write_date),
('state', '=', 'done'),
])
moves |= self.get_move_lines_upstream(moves)
for move in moves:
unfoldable = False
if move.consume_line_ids:
@@ -216,18 +178,10 @@ class MrpStockReport(models.TransientModel):
return final_vals
@api.model
def downstream_traceability(self, level, stream=False, line_id=False, model=False, model_obj=False, parent_quant=False):
def downstream_traceability(self, level, stream=False, line_id=False, model=False, model_obj=False):
final_vals = []
if model == 'stock.move.line':
moves = self.get_move_lines_downstream(model_obj)
elif model == 'stock.quant':
moves = self.env['stock.move.line'].search([
('location_id', '=', model_obj.location_id.id),
('lot_id', '=', model_obj.lot_id.id),
('date', '>=', model_obj.write_date),
('state', '=', 'done'),
])
moves |= self.get_move_lines_downstream(moves)
for move in moves:
unfoldable = False
if move.produce_line_ids:
@@ -245,7 +199,6 @@ class MrpStockReport(models.TransientModel):
'model_id': data['model_id'],
'stream': data['stream'] or 'upstream',
'parent_id': data['parent_id'],
'parent_quant': data.get('parent_quant', False),
'type': 'line',
'reference': data.get('reference_id', False),
'res_id': data.get('res_id', False),
@@ -262,19 +215,19 @@ class MrpStockReport(models.TransientModel):
return lines
@api.model
def _lines(self, line_id=None, model_id=False, model=False, level=0, parent_quant=False, stream=False, obj_ids=[], **kw):
def _lines(self, line_id=None, model_id=False, model=False, level=0, stream=False, obj_ids=[], **kw):
final_vals = []
if model and line_id:
model_obj = self.env[model].browse(model_id)
if stream == "downstream":
final_vals += self.downstream_traceability(level, stream='downstream', line_id=line_id, model=model, model_obj=model_obj, parent_quant=parent_quant)
final_vals += self.downstream_traceability(level, stream='downstream', line_id=line_id, model=model, model_obj=model_obj)
if model == 'stock.move.line':
if model_obj.produce_line_ids:
final_vals += self.get_produced_or_consumed_vals(model_obj.produce_line_ids, level, model=model, stream=stream, parent_id=line_id)
else:
final_vals = self.make_dict_move(level, stream=stream, parent_id=line_id,move_line=model_obj) + final_vals
else:
final_vals += self.upstream_traceability(level, stream='upstream', line_id=line_id, model=model, model_obj=model_obj, parent_quant=parent_quant)
final_vals += self.upstream_traceability(level, stream='upstream', line_id=line_id, model=model, model_obj=model_obj)
if model == 'stock.move.line':
if model_obj.consume_line_ids:
final_vals += self.get_produced_or_consumed_vals(model_obj.consume_line_ids, level, model=model, stream=stream, parent_id=line_id)
@@ -84,7 +84,6 @@ var ReportWidget = Widget.extend({
var active_model_id = $CurretElement.data('model_id');
var row_level = $CurretElement.data('level');
var stream = $CurretElement.data('stream');
var parent_quant = $CurretElement.data('parent_quant');
var $cursor = $(e.target).parents('tr');
this._rpc({
model: 'stock.traceability.report',
@@ -94,7 +93,6 @@ var ReportWidget = Widget.extend({
'model_id': active_model_id,
'model_name': active_model_name,
'stream': stream || 'upstream',
'parent_quant': parseInt(parent_quant) || false,
'level': parseInt(row_level) + 30 || 1
},
})
@@ -13,7 +13,6 @@
<t t-name="report_mrp_line">
<t t-set="trclass" t-value="'o_stock_reports_default_style'"/>
<t t-if="l.model == 'stock.move.line'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t>
<t t-if="l.model == 'stock.quant'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t>
<t t-set="space_td" t-value="'margin-left: '+ l.level + 'px;'"/>
<t t-set="domainClass" t-value="'o_stock_reports_domain_line_0'"/>
<t t-if="l.unfoldable == false">
@@ -25,7 +24,7 @@
<t t-set="column" t-value="0" />
<t t-foreach="l.columns" t-as="c">
<t t-set="column" t-value="column + 1" />
<td style="white-space: nowrap;" t-att-data-id="l.id" t-att-data-stream="l.stream" t-att-data-model="l.model" t-att-data-model_id="l.model_id" t-att-class="tdclass" t-att-data-level="l.level" t-att-data-parent_quant="l.parent_quant">
<td style="white-space: nowrap;" t-att-data-id="l.id" t-att-data-stream="l.stream" t-att-data-model="l.model" t-att-data-model_id="l.model_id" t-att-class="tdclass" t-att-data-level="l.level">
<t t-if="column == 1">
<span t-att-style="space_td" t-att-class="domainClass"></span>
<t t-if="l.unfoldable">
@@ -5,7 +5,6 @@
<t t-foreach="lines" t-as="a">
<t t-set="trclass" t-value="'o_stock_reports_default_style'"/>
<t t-if="a.get('model') == 'stock.move.line'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t>
<t t-if="a.get('model') == 'stock.quant'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t>
<t t-set="domainClass" t-value="'o_stock_reports_domain_line'"/>
<t t-if="a['unfoldable'] == false">
<t t-set="domainClass" t-value="'o_stock_reports_domain_line_1'"/>
@@ -17,7 +16,7 @@
<t t-set="column" t-value="0" />
<t t-foreach="a['columns']" t-as="c">
<t t-set="column" t-value="column + 1" />
<td t-att-data-id="a.get('id')" t-att-data-model="a['model']" t-att-data-model_id="a['model_id']" t-att-data-stream="a['stream']" t-att-class="tdclass" t-att-data-level="a['level']" t-att-data-parent_quant="a['parent_quant']">
<td t-att-data-id="a.get('id')" t-att-data-model="a['model']" t-att-data-model_id="a['model_id']" t-att-data-stream="a['stream']" t-att-class="tdclass" t-att-data-level="a['level']">
<t t-if="column == 1">
<span t-att-data-active-id="a['id']" t-att-class="a['type'] + ' ' + domainClass"></span>
<t t-if="a.get('unfoldable')">
@@ -98,7 +97,6 @@
<t t-set="space_td" t-value="'margin-left: '+ str(a['level']) + 'px;'"/>
<t t-set="trclass" t-value="'o_stock_reports_default_style'"/>
<t t-if="a.get('model') == 'stock.move.line'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t>
<t t-if="a.get('model') == 'stock.quant'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t>
<t t-set="column" t-value="0" />
<tr t-att-data-type="a['type']" t-att-data-stream="a['stream']" t-att-data-id="a['id']" t-att-data-model="a['model']" t-att-class="trclass">
<t t-set="tdclass" t-value="''" />