Skip to content

Commit 6da8ac1

Browse files
author
mathieu
committed
[ADD] module sale_report_out_of_stock
1 parent 4e53a03 commit 6da8ac1

File tree

7 files changed

+79
-0
lines changed

7 files changed

+79
-0
lines changed

sale_report_out_of_stock/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import report
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2020 Pharmasimple (https://www.pharmasimple.be)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Sale Report Out of Stock",
5+
"category": "Tools",
6+
"summary": "Inherit of report_saleorder_document to show when a product is out of stock",
7+
"version": "14.0.1.0.0",
8+
"author": "Pharmasimple",
9+
"license": "AGPL-3",
10+
"website": "https://github.com/akretion/phs-addons",
11+
"depends": ["sale"],
12+
"data": [
13+
"report/sale_report.xml",
14+
],
15+
"installable": True,
16+
"application": False,
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import sale_report
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from odoo import api, models
2+
3+
4+
class SaleReportSaleOrder(models.AbstractModel):
5+
_name = "report.sale.report_saleorder"
6+
7+
@api.model
8+
def _get_report_values(self, docids, data=None):
9+
docs = self.env["sale.order"].browse(docids)
10+
stock = self.env["stock.location"].search(
11+
[("name", "=", "Stock"), ("location_id.name", "=", "WHDV")]
12+
)
13+
move_ids = self.env["stock.picking"].search(
14+
[("origin", "=", docs.name), ("location_id", "=", stock.id)]
15+
)
16+
not_in_stock = []
17+
ok = True
18+
for move in move_ids.move_ids_without_package:
19+
if move.reserved_availability < move.product_uom_qty:
20+
ok = False
21+
not_in_stock.append({"name": move.product_id.name, "in_stock": ok})
22+
ok = True
23+
24+
return {
25+
"doc_ids": docs.ids,
26+
"stock_list": not_in_stock,
27+
"doc_model": "sale.order",
28+
"docs": docs,
29+
"proforma": True,
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<template
4+
id="report_saleorder_document_inherit"
5+
inherit_id="sale.report_saleorder_document"
6+
>
7+
<xpath expr="//td[@name='td_name']" position="replace">
8+
<t t-foreach="stock_list" t-as="stock">
9+
<t t-if="stock['name'] == line.product_id.name">
10+
<t t-if="stock['in_stock'] == True">
11+
<td name="td_name"><span t-field="line.name" /></td>
12+
</t>
13+
<t t-else="stock['in_stock'] == False">
14+
<td name="td_name" style="background-color: red">
15+
<span t-field="line.name" />
16+
<br>HORS STOCK</br>
17+
</td>
18+
</t>
19+
</t>
20+
</t>
21+
</xpath>
22+
</template>
23+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../sale_report_out_of_stock
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)