Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stock_custom_picking_report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import report
12 changes: 12 additions & 0 deletions stock_custom_picking_report/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Stock Custom Picking Report",
"application": False,
"installable": True,
"author": "sngoh",
"depends": ["mrp", "stock"],
"license": "LGPL-3",
"data": [
"report/report_mo_delivery_note.xml",
"report/stock_report_view.xml",
],
}
1 change: 1 addition & 0 deletions stock_custom_picking_report/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import report_mo_delivery_note
30 changes: 30 additions & 0 deletions stock_custom_picking_report/report/report_mo_delivery_note.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import api, models


class ReportMODeliveryNote(models.AbstractModel):
_name = "report.stock_custom_picking_report.mo_delivery_note_report"
_description = "MO Delivery Note Report"

@api.model
def _get_report_values(self, docids, data=None):
docs = self.env["stock.picking"].browse(docids)
filtered_moves_by_picking = {}

for picking in docs:
linked_mos = picking.move_ids.move_orig_ids.production_id

if linked_mos:
components = self.env["stock.move"].search(
[
("raw_material_production_id", "in", linked_mos.ids),
("bom_line_id.bom_id.type", "!=", "phantom"),
]
)
filtered_moves_by_picking[picking.id] = components
else:
filtered_moves_by_picking[picking.id] = picking.move_ids

return {
"docs": docs,
"filtered_moves": filtered_moves_by_picking,
}
68 changes: 68 additions & 0 deletions stock_custom_picking_report/report/report_mo_delivery_note.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="mo_delivery_note_report">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.external_layout">
<div class="page">

<div class="row mt-4">
<div class="col-5 offset-7" style="font-size: 14px;">
<strong>Delivery Address:</strong>
<div t-field="o.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True}' />
</div>
</div>

<h1 class="mt-4 mb-4"
style="color: #b11f24; font-size: 38px; font-weight: 500;">
<span t-field="o.name" />
</h1>

<div class="row mb-4" style="font-size: 14px;">
<div class="col-6">
<strong>Order:</strong>
<div t-field="o.origin" />
</div>
<div class="col-6">
<strong>Shipping Date:</strong>
<div t-if="o.state == 'done'" t-field="o.date_done"
t-options='{"widget": "date"}' />
<div t-else="" t-field="o.scheduled_date"
t-options='{"widget": "date"}' />
</div>
</div>

<table class="table table-sm mt-4" style="border-top: 2px solid #000;">
<thead>
<tr style="border-bottom: 2px solid #000;">
<th class="text-start" style="color: #777;">Product</th>
<th class="text-end" style="color: #777; width: 15%;">Ordered</th>
<th class="text-end" style="color: #777; width: 15%;">Delivered</th>
</tr>
</thead>
<tbody>
<t t-foreach="filtered_moves[o.id]" t-as="move">
<tr style="border-bottom: 1px solid #dee2e6;">
<td class="text-start py-2">
<span t-field="move.product_id.display_name" />
</td>
<td class="text-end py-2">
<span t-out="'%.2f' % move.product_uom_qty" />
<span t-field="move.product_uom.name" />
</td>
<td class="text-end py-2">
<span t-out="'%.2f' % move.quantity" />
<span t-field="move.product_uom.name" />
</td>
</tr>
</t>
</tbody>
</table>

</div>
</t>
</t>
</t>
</template>
</odoo>
15 changes: 15 additions & 0 deletions stock_custom_picking_report/report/stock_report_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="action_report_mo_delivery_note" model="ir.actions.report">
<field name="name">MO Delivery Note</field>
<field name="model">stock.picking</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">stock_custom_picking_report.mo_delivery_note_report</field>
<field name="report_file">stock_custom_picking_report.mo_delivery_note_report</field>
<field name="print_report_name">'MO Delivery Note - %s' % (object.name)</field>
<field name="binding_model_id" ref="stock.model_stock_picking" />
<field name="binding_type">report</field>
</record>
</data>
</odoo>
2 changes: 2 additions & 0 deletions stock_custom_picking_report/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_report_stock_picking_report_mo_delivery_note_report,access_report_stock_picking_report_mo_delivery_note_report,model_report_stock_custom_picking_report_mo_delivery_note_report,base.group_user,1,1,1,1