瀏覽代碼

Análisis de stock

SEBAS 1 年之前
當前提交
98df2689cf
共有 12 個文件被更改,包括 203 次插入0 次删除
  1. 59 0
      README.rst
  2. 5 0
      __init__.py
  3. 二進制
      __init__.pyc
  4. 25 0
      __openerp__.py
  5. 二進制
      images/demo_analysis.png
  6. 5 0
      report/__init__.py
  7. 二進制
      report/__init__.pyc
  8. 49 0
      report/stock_analysis.py
  9. 二進制
      report/stock_analysis.pyc
  10. 58 0
      report/stock_analysis_view.xml
  11. 2 0
      security/ir.model.access.csv
  12. 二進制
      static/description/icon.png

+ 59 - 0
README.rst

@@ -0,0 +1,59 @@
+.. 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.
+
+.. image:: /stock_analysis/images/demo_analysis.png
+
+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 - 0
__init__.py

@@ -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

二進制
__init__.pyc


+ 25 - 0
__openerp__.py

@@ -0,0 +1,25 @@
+# -*- 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",
+        "eiru_reports",
+    ],
+    "data": [
+        'report/stock_analysis_view.xml',
+        'security/ir.model.access.csv',
+    ],
+    'images': [
+        'images/demo_analysis.png',
+    ],
+}

二進制
images/demo_analysis.png


+ 5 - 0
report/__init__.py

@@ -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

二進制
report/__init__.pyc


+ 49 - 0
report/stock_analysis.py

@@ -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='Producto', readonly=True)
+    location_id = fields.Many2one(
+        'stock.location', string='Ubicacion', readonly=True)
+    qty = fields.Float(string='Cantidad', readonly=True)
+    lot_id = fields.Many2one(
+        'stock.production.lot', string='Lote', readonly=True)
+    package_id = fields.Many2one(
+        'stock.quant.package', string='Paquete', readonly=True)
+    in_date = fields.Datetime('Fecha entrante', readonly=True)
+    categ_id = fields.Many2one(
+        'product.category', string='Categoria', readonly=True)
+    company_id = fields.Many2one(
+        'res.company', string='Compañia', 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)
+        )

二進制
report/stock_analysis.pyc


+ 58 - 0
report/stock_analysis_view.xml

@@ -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="Analisis de Stock">
+                <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="Ubicacion interna" domain="[('location_id.usage', '=', 'internal')]"/>
+                <separator/>
+                <filter name="stockable" string="Productos almacenables" domain="[('product_id.type', '=', 'product')]"/>
+                <filter name="consumable" string="Productos consumibles" domain="[('product_id.type', '=', 'consu')]"/>
+                <separator/>
+                <filter string="Este año" name="year" domain="[('in_date','&lt;=', time.strftime('%%Y-12-31')),('in_date','&gt;=',time.strftime('%%Y-01-01'))]"/>
+                <group expand="1" string="Agrupado por">
+                    <filter string="Categoria" name="Category" context="{'group_by':'categ_id'}"/>
+                    <filter string="Producto" name="Product" context="{'group_by':'product_id'}"/>
+                    <filter string="Serial" name="Lot" context="{'group_by':'lot_id'}"/>
+                    <filter string="Paquete" name="Package" context="{'group_by':'package_id'}"/>
+                    <filter string="Compañia" 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">Analisis de Stock</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="eiru_reports.stock_parent_menu"/>
+
+</data>
+</openerp>

+ 2 - 0
security/ir.model.access.csv

@@ -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

二進制
static/description/icon.png