feat: Add product reference and lot number fields to stock move lines and create new delivery slip report

This commit is contained in:
2026-02-07 14:54:02 +03:30
parent 2c1bdd8c19
commit 5651579d08
3 changed files with 111 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
'depends': ['stock'],
'data': [
'views/stock_picking_form.xml',
'views/delivery_slip_report.xml',
],
'installable': True,
'application': False,

View File

@@ -20,6 +20,18 @@ class StockMoveLine(models.Model):
readonly=True,
)
lot_number = fields.Char(
string='Lot Number',
related='lot_id.name',
readonly=True,
)
product_ref = fields.Char(
string='Product Reference',
related='product_id.default_code',
readonly=True,
)
@api.depends('move_id.create_date')
def _compute_production_date(self):
"""Set production date to today or the move's creation date"""

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- New report action for 5 kg slips -->
<record id="action_report_5kg_slip" model="ir.actions.report">
<field name="name">5 kg Slips</field>
<field name="model">stock.picking</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">delivery_slip_custom.report_5kg_slip_document</field>
<field name="report_file">delivery_slip_custom.report_5kg_slip_document</field>
<field name="print_report_name">'5kg Slip - %s' % (object.name)</field>
<field name="binding_model_id" ref="stock.model_stock_picking"/>
<field name="binding_type">report</field>
</record>
<!-- Main template for 5 kg slips report -->
<template id="report_5kg_slip_document">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<!-- Create a separate label for each move_line (actual product line) -->
<t t-foreach="o.move_line_ids" t-as="line">
<div class="page" style="page-break-after: always; page-break-inside: avoid;">
<!-- Header -->
<div class="text-center mb-4">
<h3>5 kg Product Label</h3>
</div>
<!-- Delivery Info -->
<table class="table table-sm table-borderless mb-3">
<tr>
<td style="width: 40%;"><strong>Delivery Order:</strong></td>
<td><span t-esc="o.name"/></td>
</tr>
<tr>
<td><strong>Customer:</strong></td>
<td><span t-esc="o.partner_id.name"/></td>
</tr>
<tr>
<td><strong>Date:</strong></td>
<td><span t-esc="o.scheduled_date.strftime('%Y-%m-%d') if o.scheduled_date else ''"/></td>
</tr>
</table>
<hr class="my-4"/>
<!-- Product Information -->
<table class="table table-bordered">
<tr>
<td style="width: 35%; background-color: #f8f9fa;"><strong>Product Ref:</strong></td>
<td><span t-esc="line.product_id.default_code or '-'"/></td>
</tr>
<tr>
<td style="background-color: #f8f9fa;"><strong>Product:</strong></td>
<td><strong><span t-esc="line.product_id.name"/></strong></td>
</tr>
<tr>
<td style="background-color: #f8f9fa;"><strong>Quantity:</strong></td>
<td>
<strong>
<span t-esc="line.quantity"/>
<span t-esc="line.product_uom_id.name"/>
</strong>
</td>
</tr>
<tr>
<td style="background-color: #f8f9fa;"><strong>Lot Number:</strong></td>
<td>
<span t-esc="line.lot_id.name if line.lot_id else '-'"/>
</td>
</tr>
</table>
<!-- Date Information - Highlighted -->
<table class="table table-bordered mt-4">
<tr style="background-color: #d4edda;">
<td style="width: 35%;"><strong>Production Date:</strong></td>
<td>
<strong style="font-size: 1.1em;"><span t-esc="line.production_date or '-'"/></strong>
</td>
</tr>
<tr style="background-color: #f8d7da;">
<td><strong>Expiration Date:</strong></td>
<td>
<strong style="font-size: 1.1em; color: #721c24;"><span t-esc="line.expiration_date or '-'"/></strong>
</td>
</tr>
</table>
<!-- Location -->
<div class="mt-3">
<strong>Source Location:</strong>
<span t-esc="o.location_id.complete_name or o.location_id.name"/>
</div>
</div>
</t>
</t>
</t>
</template>
</odoo>