[9.0][IMP] stock_cycle_count: basic_accuracy report

This commit is contained in:
lreficent
2017-10-10 11:52:25 +02:00
committed by Lois Rilo
parent 66413e21dd
commit 54508caee5
5 changed files with 119 additions and 1 deletions

View File

@@ -4,3 +4,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models
from . import reports

View File

@@ -26,7 +26,9 @@
'views/stock_location_view.xml',
'data/cycle_count_sequence.xml',
'data/cycle_count_ir_cron.xml',
'security/ir.model.access.csv'],
'reports/stock_location_accuracy_report.xml',
'security/ir.model.access.csv',
],
"license": "AGPL-3",
'installable': True,
'application': False,

View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import report_stock_location_accuracy

View File

@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
class LocationAccuracyReport(models.AbstractModel):
_name = "report.stock_location_accuracy"
@api.model
def _get_inventory_domain(self, loc_id):
return [('location_id', '=', loc_id),
('exclude_sublocation', '=', True),
('state', '=', 'done')]
@api.model
def _get_location_data(self, locations):
data = dict()
inventory_obj = self.env["stock.inventory"]
for loc in locations:
counts = inventory_obj.search(self._get_inventory_domain(loc.id))
data[loc] = counts
return data
@api.multi
def render_html(self, data=None):
report_obj = self.env["report"]
locs = self.env["stock.location"].browse(self._ids)
data = self._get_location_data(locs)
docargs = {
"doc_ids": locs._ids,
"docs": locs,
"data": data,
}
return report_obj.render(
"stock_cycle_count.stock_location_accuracy", docargs)

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<!-- Templates -->
<template id="stock_location_accuracy">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="report.external_layout">
<div class="page">
<div class="oe_structure"/>
<h3>
<span>Location:</span>
<span t-field="doc.name"/>
</h3>
<div class="row mt32 mb32" id="informations">
<div class="col-xs-6">
<strong>Complete name:</strong>
<p t-field="doc.complete_name"/>
</div>
<div class="col-xs-3">
<strong>Current Accuracy:</strong>
<p t-field="doc.loc_accuracy"/>
</div>
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Inventory</th>
<th class="text-right">Date</th>
<th class="text-right">Accuracy</th>
</tr>
</thead>
<tbody class="sale_tbody">
<t t-foreach="data[doc]" t-as="l">
<tr>
<td>
<span t-field="l.name"/>
</td>
<td class="text-right">
<span t-field="l.date"/>
</td>
<td class="text-right">
<span t-field="l.inventory_accuracy"/>
</td>
</tr>
</t>
</tbody>
</table>
</div>
</t>
</t>
</t>
</template>
<!-- Report action -->
<report
id="action_report_stock_location_accuracy"
model="stock.location"
name="stock_location_accuracy"
string="Accuracy report"
report_type="qweb-pdf"
groups="stock.group_stock_user"/>
</odoo>