[IMP] stock: traceability report origin

Add reference of the traceability report's origin (production.lot,
manufacturing order, picking, ...) to the end of the
report.
Change the layout a bit so the data isn't squashed by
the border.

Task-2467686

closes odoo/odoo#74120

Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
This commit is contained in:
Quentin Wolfs
2021-08-16 08:14:09 +00:00
committed by clesgow
parent ff16769cc4
commit e2f59a6dd1
5 changed files with 22 additions and 9 deletions
+3 -3
View File
@@ -10,8 +10,8 @@ import json
class StockReportController(http.Controller):
@http.route('/stock/<string:output_format>/<string:report_name>/<int:report_id>', type='http', auth='user')
def report(self, output_format, report_name, report_id=False, **kw):
@http.route('/stock/<string:output_format>/<string:report_name>', type='http', auth='user')
def report(self, output_format, report_name=False, **kw):
uid = request.session.uid
domain = [('create_uid', '=', uid)]
stock_traceability = request.env['stock.traceability.report'].with_user(uid).search(domain, limit=1)
@@ -19,7 +19,7 @@ class StockReportController(http.Controller):
try:
if output_format == 'pdf':
response = request.make_response(
stock_traceability.with_context(active_id=report_id).get_pdf(line_data),
stock_traceability.with_context(active_id=kw['active_id'], active_model=kw['active_model']).get_pdf(line_data),
headers=[
('Content-Type', 'application/pdf'),
('Content-Disposition', 'attachment; filename=' + 'stock_traceability' + '.pdf;')
@@ -4,7 +4,7 @@
<record id="action_stock_report" model="ir.actions.client">
<field name="name">Traceability Report</field>
<field name="tag">stock_report_generic</field>
<field name="context" eval="{'url': '/stock/output_format/stock/active_id', 'model': 'stock.traceability.report'}" />
<field name="context" eval="{'url': '/stock/output_format/stock?active_id=:active_id&amp;active_model=:active_model', 'model': 'stock.traceability.report'}" />
</record>
</odoo>
+5 -2
View File
@@ -200,7 +200,8 @@ class MrpStockReport(models.TransientModel):
lines.append(self._final_vals_to_lines(final_vals, line['level'])[0])
return lines
def get_pdf(self, line_data=[]):
def get_pdf(self, line_data=None):
line_data = [] if line_data is None else line_data
lines = self.with_context(print_mode=True).get_pdf_lines(line_data)
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
rcontext = {
@@ -211,6 +212,8 @@ class MrpStockReport(models.TransientModel):
context = dict(self.env.context)
if not config['test_enable']:
context['commit_assetsbundle'] = True
if context.get('active_id') and context.get('active_model'):
rcontext['reference'] = self.env[context.get('active_model')].browse(int(context.get('active_id'))).display_name
body = self.env['ir.ui.view'].with_context(context)._render_template(
"stock.report_stock_inventory_print",
@@ -224,7 +227,7 @@ class MrpStockReport(models.TransientModel):
[body],
header=header,
landscape=True,
specific_paperformat_args={'data-report-margin-top': 10, 'data-report-header-spacing': 10}
specific_paperformat_args={'data-report-margin-top': 17, 'data-report-header-spacing': 12}
)
def _get_html(self):
@@ -89,7 +89,8 @@ var stock_report_generic = AbstractAction.extend({
});
});
framework.blockUI();
var url_data = self.controller_url.replace('active_id', self.given_context.active_id);
var url_data = self.controller_url.replace(':active_id', self.given_context.active_id);
url_data = url_data.replace(':active_model', self.given_context.model);
session.get_file({
url: url_data.replace('output_format', 'pdf'),
data: {data: JSON.stringify(dict)},
@@ -89,9 +89,17 @@
<template id="report_stock_body_print">
<div class="container o_stock_reports_page o_stock_reports_no_print">
<span class="text-left"><h3>Traceability Report</h3></span>
<span class="text-left">
<h3>
Traceability Report
<span t-if="reference" style="margin-left:28%">
Reference: <t t-esc="reference"/>
</span>
</h3>
</span>
<hr/>
<div class="o_stock_reports_table table-responsive">
<table class="table">
<table class="table" style="border-spacing:10px">
<thead>
<tr class="o_report_header">
<th class="o_report_line_header">Reference</th>
@@ -129,6 +137,7 @@
</t>
</tbody>
</table>
<br/>
</div>
</div>
</template>