diff --git a/stock_analysis/README.rst b/stock_analysis/README.rst new file mode 100644 index 0000000..81c47e2 --- /dev/null +++ b/stock_analysis/README.rst @@ -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 +`_. 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 +`_. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Lorenzo Battistini + +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. diff --git a/stock_analysis/__init__.py b/stock_analysis/__init__.py new file mode 100644 index 0000000..1738bf2 --- /dev/null +++ b/stock_analysis/__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 diff --git a/stock_analysis/__openerp__.py b/stock_analysis/__openerp__.py new file mode 100644 index 0000000..4727098 --- /dev/null +++ b/stock_analysis/__openerp__.py @@ -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', + ], +} diff --git a/stock_analysis/images/demo_analysis.png b/stock_analysis/images/demo_analysis.png new file mode 100644 index 0000000..30bd05c Binary files /dev/null and b/stock_analysis/images/demo_analysis.png differ diff --git a/stock_analysis/report/__init__.py b/stock_analysis/report/__init__.py new file mode 100644 index 0000000..9431e97 --- /dev/null +++ b/stock_analysis/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 diff --git a/stock_analysis/report/stock_analysis.py b/stock_analysis/report/stock_analysis.py new file mode 100644 index 0000000..6e1cfa2 --- /dev/null +++ b/stock_analysis/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='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) + ) diff --git a/stock_analysis/report/stock_analysis_view.xml b/stock_analysis/report/stock_analysis_view.xml new file mode 100644 index 0000000..74503a5 --- /dev/null +++ b/stock_analysis/report/stock_analysis_view.xml @@ -0,0 +1,58 @@ + + + + + + stock.analysis.graph + stock.analysis + + + + + + + + + + + stock.analysis.search + stock.analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + Stock Analysis + stock.analysis + form + graph + + + {'search_default_internal_location':1} + + + + + + diff --git a/stock_analysis/security/ir.model.access.csv b/stock_analysis/security/ir.model.access.csv new file mode 100644 index 0000000..149ad48 --- /dev/null +++ b/stock_analysis/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 diff --git a/stock_analysis/static/description/icon.png b/stock_analysis/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/stock_analysis/static/description/icon.png differ