mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
Merge pull request #22 from eLBati/add_stock_analysis
ADD stock_analysis
This commit is contained in:
58
stock_analysis/README.rst
Normal file
58
stock_analysis/README.rst
Normal file
@@ -0,0 +1,58 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
==============
|
||||
Stock Analysis
|
||||
==============
|
||||
|
||||
This module extends the stock reporting to allow better stock per location analysis.
|
||||
By default, it adds a pivot table where lines are products and columns are locations.
|
||||
See screenshot
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/151/8.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/stock-logistics-reporting/issues>`_. In case of trouble, please
|
||||
check there if your issue has already been reported. If you spotted it first,
|
||||
help us smashing it by providing a detailed and welcomed `feedback
|
||||
<https://github.com/OCA/
|
||||
stock-logistics-reporting/issues/new?body=module:%20
|
||||
stock_analysis%0Aversion:%20
|
||||
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
5
stock_analysis/__init__.py
Normal file
5
stock_analysis/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Lorenzo Battistini - Agile Business Group
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import report
|
||||
24
stock_analysis/__openerp__.py
Normal file
24
stock_analysis/__openerp__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Lorenzo Battistini - Agile Business Group
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "Stock Analysis",
|
||||
"summary": "Analysis view for stock",
|
||||
"version": "8.0.1.0.0",
|
||||
"category": "Inventory, Logistic, Storage",
|
||||
"website": "https://www.agilebg.com",
|
||||
"author": "Agile Business Group, Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"stock",
|
||||
],
|
||||
"data": [
|
||||
'report/stock_analysis_view.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'images': [
|
||||
'images/demo_analysis.png',
|
||||
],
|
||||
}
|
||||
BIN
stock_analysis/images/demo_analysis.png
Normal file
BIN
stock_analysis/images/demo_analysis.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
5
stock_analysis/report/__init__.py
Normal file
5
stock_analysis/report/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Lorenzo Battistini - Agile Business Group
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import stock_analysis
|
||||
49
stock_analysis/report/stock_analysis.py
Normal file
49
stock_analysis/report/stock_analysis.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Lorenzo Battistini - Agile Business Group
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import tools
|
||||
from openerp import models, fields
|
||||
|
||||
|
||||
class StockAnalysis(models.Model):
|
||||
_name = 'stock.analysis'
|
||||
_auto = False
|
||||
_rec_name = 'product_id'
|
||||
|
||||
product_id = fields.Many2one(
|
||||
'product.product', string='Product', readonly=True)
|
||||
location_id = fields.Many2one(
|
||||
'stock.location', string='Location', readonly=True)
|
||||
qty = fields.Float(string='Quantity', readonly=True)
|
||||
lot_id = fields.Many2one(
|
||||
'stock.production.lot', string='Lot', readonly=True)
|
||||
package_id = fields.Many2one(
|
||||
'stock.quant.package', string='Package', readonly=True)
|
||||
in_date = fields.Datetime('Incoming Date', readonly=True)
|
||||
categ_id = fields.Many2one(
|
||||
'product.category', string='Category', readonly=True)
|
||||
company_id = fields.Many2one(
|
||||
'res.company', string='Company', readonly=True)
|
||||
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, self._table)
|
||||
cr.execute(
|
||||
"""CREATE or REPLACE VIEW %s as (
|
||||
SELECT
|
||||
quant.id AS id,
|
||||
quant.product_id AS product_id,
|
||||
quant.location_id AS location_id,
|
||||
quant.qty AS qty,
|
||||
quant.lot_id AS lot_id,
|
||||
quant.package_id AS package_id,
|
||||
quant.in_date AS in_date,
|
||||
quant.company_id,
|
||||
template.categ_id AS categ_id
|
||||
FROM stock_quant AS quant
|
||||
JOIN product_product prod ON prod.id = quant.product_id
|
||||
JOIN product_template template
|
||||
ON template.id = prod.product_tmpl_id
|
||||
)"""
|
||||
% (self._table)
|
||||
)
|
||||
58
stock_analysis/report/stock_analysis_view.xml
Normal file
58
stock_analysis/report/stock_analysis_view.xml
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="stock_analysis_graph" model="ir.ui.view">
|
||||
<field name="name">stock.analysis.graph</field>
|
||||
<field name="model">stock.analysis</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Stock Analysis" type="pivot" stacked="True">
|
||||
<field name="product_id" type="row"/>
|
||||
<field name="location_id" type="col"/>
|
||||
<field name="qty" type="measure"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_analysis_graph_search" model="ir.ui.view">
|
||||
<field name="name">stock.analysis.search</field>
|
||||
<field name="model">stock.analysis</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Stock Analysis">
|
||||
<field name="product_id"/>
|
||||
<field name="lot_id"/>
|
||||
<field name="package_id"/>
|
||||
<field name="location_id"/>
|
||||
<field name="categ_id"/>
|
||||
<field name="company_id"/>
|
||||
<filter name="internal_location" string="Internal location" domain="[('location_id.usage', '=', 'internal')]"/>
|
||||
<separator/>
|
||||
<filter name="stockable" string="Stockable products" domain="[('product_id.type', '=', 'product')]"/>
|
||||
<filter name="consumable" string="Consumable products" domain="[('product_id.type', '=', 'consu')]"/>
|
||||
<separator/>
|
||||
<filter string="This Year" name="year" domain="[('in_date','<=', time.strftime('%%Y-12-31')),('in_date','>=',time.strftime('%%Y-01-01'))]"/>
|
||||
<group expand="1" string="Group By">
|
||||
<filter string="Category" name="Category" context="{'group_by':'categ_id'}"/>
|
||||
<filter string="Product" name="Product" context="{'group_by':'product_id'}"/>
|
||||
<filter string="Serial Number" name="Lot" context="{'group_by':'lot_id'}"/>
|
||||
<filter string="Package" name="Package" context="{'group_by':'package_id'}"/>
|
||||
<filter string="Company" name="Company" context="{'group_by':'company_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_stock_analysis_graph" model="ir.actions.act_window">
|
||||
<field name="name">Stock Analysis</field>
|
||||
<field name="res_model">stock.analysis</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph</field>
|
||||
<field name="search_view_id" ref="stock_analysis_graph_search"/>
|
||||
<field name="view_id" ref="stock_analysis_graph"/>
|
||||
<field name="context">{'search_default_internal_location':1}</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_stock_analysis_graph" id="menu_action_stock_analysis_graph" parent="stock.next_id_61"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
2
stock_analysis/security/ir.model.access.csv
Normal file
2
stock_analysis/security/ir.model.access.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_stock_analysis_user,stock_analysis user,model_stock_analysis,stock.group_stock_user,1,0,0,0
|
||||
|
BIN
stock_analysis/static/description/icon.png
Normal file
BIN
stock_analysis/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
Reference in New Issue
Block a user