[IMP] mrp,stock: always show product in reception report labels

Previously the reception report > "print labels" would only print the
picking name (or SO if provided) + delivery address (if provided) when
not for a MO. Label has been updated to include the product name.

During this update a few other related improvements were made:
- make the label based on stock.move (so extending is no longer
  needed in MRP)
- formatting of label is improved so now address will be truncated
  instead of wrapping (and potentially losing lines at end of address)
- line padding is reduced so we can fit more lines in the label
- "Print Labels" button at source level will now be enabled when its
  corresponding "Assign All" button is pushed (previously only the
  "Print Label"s of each moves' line was enabled.

Part of Task: 2632884

X-original-commit: 9774c1ab1d68cf095b64a82b56f100d747fc8a56
Part-of: odoo/odoo#79408
This commit is contained in:
Tiffany Chang (tic)
2021-11-05 13:48:50 +00:00
parent 23ef79f69b
commit 1c97b75c97
8 changed files with 20 additions and 39 deletions
-1
View File
@@ -76,7 +76,6 @@
'mrp/static/src/js/mrp_document_kanban_view.js',
'mrp/static/src/js/mrp_should_consume.js',
'mrp/static/src/js/mrp_field_one2many_with_copy.js',
'mrp/static/src/js/report_stock_reception.js',
],
'web.qunit_suite_tests': [
'mrp/static/tests/**/*',
@@ -40,6 +40,7 @@
<field name="binding_model_id" ref="model_mrp_production"/>
<field name="binding_type">report</field>
</record>
<!-- TODO: Delete this report -->
<record id="label_production_order" model="ir.actions.report">
<field name="name">Order Label</field>
<field name="model">mrp.production</field>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- TODO: Delete this file -->
<!-- Reception Report Labels -->
<template id="report_reception_report_label_mrp">
<t t-if="quantity" t-set="qtys" t-value="[int(q) for q in quantity.split(',')]"/>
@@ -1,16 +0,0 @@
/** @odoo-module **/
import ReceptionReport from '@stock/js/report_stock_reception';
ReceptionReport.include({
/**
* @override
*/
_onClickPrintLabel: function (ev) {
return this._super(ev).then(() => {
return this._printLabel(ev, 'mrp.report_reception_report_label_mrp', 'mrp.production');
});
},
});
@@ -8,15 +8,15 @@
<t t-call="web.basic_layout">
<div class="page">
<t t-foreach="range(len(docs))" t-as="index">
<t t-set="picking" t-value="docs[index]"/>
<t t-set="move" t-value="docs[index]"/>
<t t-set="qty" t-value="qtys[index]"/>
<t t-foreach="range(qty)" t-as="j">
<div class="o_label_page o_label_dymo">
<span t-if="picking._name == 'stock.picking' and picking.origin" t-esc="picking.origin"/>
<span t-else="" t-esc="picking.name"/>
<div t-out="move.product_id.display_name"/>
<div t-out="move._get_source_document().name"/>
<div class="address"
t-if="picking._name == 'stock.picking' and picking.partner_id"
t-field="picking.partner_id"
t-if="move.picking_id and move.picking_id.partner_id"
t-field="move.picking_id.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True}'/>
</div>
</t>
@@ -132,8 +132,7 @@
</td>
<td t-if="report_type == 'html'">
<button t-if="line['is_qty_assignable'] and line['source']"
t-att-source-id="line['source'].id"
t-att-source-model="line['source']._name"
t-att-move-id="line['move_out'].id"
t-att-qty="line['quantity']"
t-attf-class="btn btn-sm btn-primary o_print_label"
t-att-disabled="not line['is_assigned']"
+2 -3
View File
@@ -132,13 +132,12 @@
<field name="binding_type">report</field>
</record>
<record id="label_picking" model="ir.actions.report">
<field name="name">Picking Label</field>
<field name="model">stock.picking</field>
<field name="name">Reception Report Label</field>
<field name="model">stock.move</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">stock.report_reception_report_label</field>
<field name="report_file">stock.report_reception_report_label</field>
<field name="paperformat_id" ref="product.paperformat_label_sheet_dymo"/>
<field name="binding_model_id" ref="model_stock_picking"/>
<field name="binding_type">report</field>
</record>
</data>
@@ -99,7 +99,9 @@ const ReceptionReport = clientAction.extend({
nodeToAssign = iframe.querySelectorAll('.o_report_reception_assign:not(.o_assign_all)');
} else { // Local assign all
nodeToAssign = el.closest('thead').nextElementSibling.querySelectorAll('.o_report_reception_assign:not(.o_assign_all)');
el.closest('thead').nextElementSibling.querySelectorAll('.o_print_label_all').forEach(button => button.removeAttribute('disabled'));
const thead = el.closest('thead');
thead.querySelector('.o_print_label_all').removeAttribute('disabled');
thead.nextElementSibling.querySelectorAll('.o_print_label_all').forEach(button => button.removeAttribute('disabled'));
}
}
nodeToAssign.forEach(node => {
@@ -156,16 +158,10 @@ const ReceptionReport = clientAction.extend({
* Print the corresponding source label
*/
_onClickPrintLabel: function (ev) {
// unfortunately, due to different reports needed for different models, we will handle
// pickings here and others models will have to be extended/printed separately until better
// technique to merge into continuous pdf to written
return this._printLabel(ev, 'stock.report_reception_report_label', 'stock.picking');
},
_printLabel: function (ev, report_file, sourceModel) {
const el = ev.currentTarget;
const modelIds = [];
const productQtys = [];
const report_file = 'stock.report_reception_report_label';
let nodeToPrint = [];
if (el.name === 'print_label') { // One line print
@@ -179,10 +175,8 @@ const ReceptionReport = clientAction.extend({
}
nodeToPrint.forEach(node => {
if (node.getAttribute('source-model') === sourceModel) {
modelIds.push(parseInt(node.getAttribute('source-id')));
productQtys.push(Math.ceil(node.getAttribute('qty')) || '1');
}
modelIds.push(parseInt(node.getAttribute('move-id')));
productQtys.push(Math.ceil(node.getAttribute('qty')) || '1');
});
if (!modelIds.length) { // Nothing to print for this model.
@@ -38,6 +38,10 @@
font-size:80%;
width: 57mm;
height: 32mm;
& span, div {
line-height: 1;
white-space: nowrap;
}
}
span[itemprop="name"] {