[IMP]stock: lot_serial number clickable on traceability report
- click on lot/serial number directly send to the traceability of that SN
This commit is contained in:
committed by
Simon Lejeune
parent
23ab8019c0
commit
476ebd08d7
@@ -51,7 +51,7 @@ class MrpStockReport(models.TransientModel):
|
||||
move_line = self.env['stock.move.line']
|
||||
if rec_id and model in ('stock.production.lot', 'stock.move.line'):
|
||||
lines = self.env['stock.move.line'].search([
|
||||
('lot_id', '=', context.get('lot_id') or rec_id),
|
||||
('lot_id', '=', context.get('lot_name') or rec_id),
|
||||
('state', '=', 'done'),
|
||||
('move_id.returned_move_ids', '=', False),
|
||||
])
|
||||
@@ -114,7 +114,8 @@ class MrpStockReport(models.TransientModel):
|
||||
'model_id': move_line.id,
|
||||
'model':'stock.move.line',
|
||||
'product_id': move_line.product_id.display_name,
|
||||
'lot_id': move_line.lot_id.name,
|
||||
'lot_name': move_line.lot_id.name,
|
||||
'lot_id': move_line.lot_id.id,
|
||||
'product_qty_uom': str(move_line.product_uom_id._compute_quantity(move_line.qty_done, move_line.product_id.uom_id, rounding_method='HALF-UP')) + ' ' + move_line.product_id.uom_id.name,
|
||||
'location_source': move_line.location_id.name,
|
||||
'location_destination': move_line.location_dest_id.name,
|
||||
@@ -136,7 +137,8 @@ class MrpStockReport(models.TransientModel):
|
||||
'parent_id': parent_id,
|
||||
'model': model or 'stock.move.line',
|
||||
'product_id': move_line.product_id.display_name,
|
||||
'lot_id': move_line.lot_id.name,
|
||||
'lot_name': move_line.lot_id.name,
|
||||
'lot_id': move_line.lot_id.id,
|
||||
'product_qty_uom': str(move_line.product_uom_id._compute_quantity(move_line.qty_done, move_line.product_id.uom_id, rounding_method='HALF-UP')) + ' ' + move_line.product_id.uom_id.name,
|
||||
'location_source': move_line.location_id.name if not move_line.lot_id else False,
|
||||
'location_destination': move_line.location_dest_id.name if not move_line.lot_id else False,
|
||||
@@ -156,16 +158,17 @@ class MrpStockReport(models.TransientModel):
|
||||
'parent_id': data['parent_id'],
|
||||
'usage': data.get('usage', False),
|
||||
'is_used': data.get('is_used', False),
|
||||
'lot_name': data.get('lot_name', False),
|
||||
'lot_id': data.get('lot_id', False),
|
||||
'type': 'line',
|
||||
'reference': data.get('reference_id', False),
|
||||
'res_id': data.get('res_id', False),
|
||||
'res_model': data.get('res_model', False),
|
||||
'name': _(data.get('lot_id', False)),
|
||||
'name': _(data.get('lot_name', False)),
|
||||
'columns': [data.get('reference_id', False),
|
||||
data.get('product_id', False),
|
||||
data.get('date', False),
|
||||
data.get('lot_id', False),
|
||||
data.get('lot_name', False),
|
||||
data.get('location_source', False),
|
||||
data.get('location_destination', False),
|
||||
data.get('product_qty_uom', 0)],
|
||||
@@ -223,11 +226,11 @@ class MrpStockReport(models.TransientModel):
|
||||
'model_id': data['model_id'],
|
||||
'parent_id': data['parent_id'],
|
||||
'type': 'line',
|
||||
'name': _(data.get('lot_id')),
|
||||
'name': _(data.get('lot_name')),
|
||||
'columns': [data.get('reference_id'),
|
||||
data.get('product_id'),
|
||||
data.get('date'),
|
||||
data.get('lot_id'),
|
||||
data.get('lot_name'),
|
||||
data.get('location_source', False),
|
||||
data.get('location_destination', False),
|
||||
data.get('product_qty_uom', 0)],
|
||||
|
||||
@@ -24,7 +24,7 @@ var stock_report_generic = Widget.extend(ControlPanelMixin, {
|
||||
this.given_context.model = action.context.active_model || false;
|
||||
this.given_context.ttype = action.context.ttype || false;
|
||||
this.given_context.auto_unfold = action.context.auto_unfold || false;
|
||||
this.given_context.lot_id = action.context.lot_id || false;
|
||||
this.given_context.lot_name = action.context.lot_name || false;
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
willStart: function() {
|
||||
@@ -42,7 +42,7 @@ var stock_report_generic = Widget.extend(ControlPanelMixin, {
|
||||
self.report_widget.$el.find('.o_report_heading').html('<h1>Traceability Report</h1>')
|
||||
if (self.given_context.auto_unfold) {
|
||||
_.each(self.$el.find('.fa-caret-right'), function (line) {
|
||||
self.report_widget.autounfold(line, self.given_context.lot_id);
|
||||
self.report_widget.autounfold(line, self.given_context.lot_name);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -34,13 +34,12 @@ var ReportWidget = Widget.extend({
|
||||
},
|
||||
actionOpenLot: function(e) {
|
||||
var $el = $(e.target).parents('tr');
|
||||
var lot_id = $el.data('lot_id');
|
||||
this.do_action({
|
||||
type: 'ir.actions.client',
|
||||
tag: 'stock_report_generic',
|
||||
name: $el.data('lot_id'),
|
||||
name: $el.data('lot_name'),
|
||||
context: {
|
||||
active_id : lot_id,
|
||||
active_id : $el.data('lot_id'),
|
||||
active_model : 'stock.production.lot',
|
||||
url: '/stock/output_format/stock/active_id'
|
||||
},
|
||||
@@ -49,7 +48,6 @@ var ReportWidget = Widget.extend({
|
||||
updownStream: function(e) {
|
||||
var $el = $(e.target).parents('tr');
|
||||
var string = "Traceability Report";
|
||||
console.log($el.data('lot_id'));
|
||||
this.do_action({
|
||||
type: "ir.actions.client",
|
||||
tag: 'stock_report_generic',
|
||||
@@ -58,7 +56,7 @@ var ReportWidget = Widget.extend({
|
||||
active_id : $el.data('model_id'),
|
||||
active_model : $el.data('model'),
|
||||
auto_unfold: true,
|
||||
lot_id: $el.data('lot_id') !== undefined && $el.data('lot_id').toString(),
|
||||
lot_name: $el.data('lot_name') !== undefined && $el.data('lot_name').toString(),
|
||||
url: '/stock/output_format/stock/active_id'
|
||||
},
|
||||
});
|
||||
@@ -89,7 +87,7 @@ var ReportWidget = Widget.extend({
|
||||
$(e.target).parents('tr').find('span.o_stock_reports_foldable').replaceWith(QWeb.render("unfoldable", {lineId: active_id}));
|
||||
$(e.target).parents('tr').toggleClass('o_stock_reports_unfolded');
|
||||
},
|
||||
autounfold: function(target, lot_id) {
|
||||
autounfold: function(target, lot_name) {
|
||||
var self = this;
|
||||
var $CurretElement;
|
||||
$CurretElement = $(target).parents('tr').find('td.o_stock_reports_unfoldable');
|
||||
@@ -112,8 +110,8 @@ var ReportWidget = Widget.extend({
|
||||
_.each(lines, function (line) { // Render each line
|
||||
$cursor.after(QWeb.render("report_mrp_line", {l: line}));
|
||||
$cursor = $cursor.next();
|
||||
if ($cursor && line.unfoldable && line.lot_id == lot_id) {
|
||||
self.autounfold($cursor.find(".fa-caret-right"), lot_id);
|
||||
if ($cursor && line.unfoldable && line.lot_name == lot_name) {
|
||||
self.autounfold($cursor.find(".fa-caret-right"), lot_name);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
<t t-if="l.usage == 'in'"><t t-set="span_color" t-value="'color: #3c763d;'"/></t>
|
||||
<t t-if="l.usage == 'out'"><t t-set="span_color" t-value="'color: #a94442;'"/></t>
|
||||
|
||||
<tr t-att-data-type="l.type" t-att-data-unfold="l.unfoldable" t-att-data-parent_id="l.parent_id" t-att-data-id="l.id" t-att-data-model_id="l.model_id" t-att-data-model="l.model" t-att-class="trclass">
|
||||
<tr t-att-data-type="l.type" t-att-data-unfold="l.unfoldable" t-att-data-parent_id="l.parent_id" t-att-data-id="l.id" t-att-data-model_id="l.model_id" t-att-data-model="l.model" t-att-class="trclass" t-att-data-lot_name="l.lot_name" t-att-data-lot_id="l.lot_id">
|
||||
<t t-if="l.unfoldable == true"><t t-set="tdclass" t-value="'o_stock_reports_unfoldable'" /></t>
|
||||
<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-model="l.model" t-att-data-model_id="l.model_id" t-att-class="tdclass" t-att-data-level="l.level" t-att-data-lot_id="l.lot_id">
|
||||
<td style="white-space: nowrap;" t-att-data-id="l.id" 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-lot_name="l.lot_name">
|
||||
<t t-if="column == 1">
|
||||
<span t-att-style="space_td" t-att-class="domainClass"></span>
|
||||
<t t-if="l.unfoldable">
|
||||
@@ -41,7 +41,12 @@
|
||||
<a t-att-data-active-id="l.res_id" t-att-data-res-model="l.res_model" class="o_stock_reports_web_action"><t t-raw="c" /></a>
|
||||
</span>
|
||||
</t>
|
||||
<t t-if="l.reference != c">
|
||||
<t t-elif="l.lot_name == c and l.lot_name != false">
|
||||
<span>
|
||||
<a class="o_stock_report_lot_action"><t t-raw="c"/></a>
|
||||
</span>
|
||||
</t>
|
||||
<t t-if="l.reference != c and l.lot_name != c">
|
||||
<t t-if="typeof c == 'string' || typeof c == 'number'"><span t-att-style="span_color">
|
||||
<t t-raw="c"/>
|
||||
</span></t>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<t t-set="domainClass" t-value="'o_stock_reports_domain_line_1'"/>
|
||||
</t>
|
||||
<t t-set="column" t-value="0" />
|
||||
<tr t-att-data-type="a['type']" t-att-data-unfold="a['unfoldable']" t-att-data-parent_id="a['parent_id']" t-att-data-id="a['id']" t-att-data-model_id="a['model_id']" t-att-data-model="a['model']" t-att-data-lot_id="a['lot_id']" t-att-class="trclass">
|
||||
<tr t-att-data-type="a['type']" t-att-data-unfold="a['unfoldable']" t-att-data-parent_id="a['parent_id']" t-att-data-id="a['id']" t-att-data-model_id="a['model_id']" t-att-data-model="a['model']" t-att-data-lot_name="a['lot_name']" t-att-data-lot_id="a['lot_id']" t-att-class="trclass">
|
||||
<t t-set="tdclass" t-value="''" />
|
||||
<t t-set="spanclass" t-value="''" />
|
||||
<t t-set="span_color" t-value="'color: #666666;'"/>
|
||||
@@ -36,8 +36,8 @@
|
||||
<a t-att-data-active-id="a['res_id']" t-att-data-res-model="a['res_model']" class="o_stock_reports_web_action"><t t-raw="c" /></a>
|
||||
</span>
|
||||
</t>
|
||||
<t t-elif="a['lot_id'] == c and env.context.get('model') == 'stock.picking'">
|
||||
<span t-att-class="spanclass">
|
||||
<t t-elif="a['lot_name'] == c">
|
||||
<span>
|
||||
<a class="o_stock_report_lot_action"><t t-raw="c"/></a>
|
||||
</span>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user