Skip to content

Commit

Permalink
[FIX][MOD] - Fixing with PEP8 and query split
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel A. Guadarrama B committed Sep 29, 2016
1 parent 07db1da commit f043703
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 24 deletions.
5 changes: 3 additions & 2 deletions stock_analysis/README.rst
Expand Up @@ -16,7 +16,7 @@ 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
:target: https://runbot.odoo-community.org/runbot/151/9.0

Bug Tracker
===========
Expand All @@ -28,7 +28,7 @@ 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**>`_.
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======
Expand All @@ -42,6 +42,7 @@ Contributors
------------

* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* I.A.S. Colombia

Maintainer
----------
Expand Down
3 changes: 1 addition & 2 deletions stock_analysis/__init__.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Lorenzo Battistini - Agile Business Group - I.A.S. Ingenieria,
# Aplicaciones y Software
# © 2016 Lorenzo Battistini - Agile Business Group - I.A.S. Colombia.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import reports
16 changes: 8 additions & 8 deletions stock_analysis/__openerp__.py
@@ -1,22 +1,22 @@
# -*- coding: utf-8 -*-
# © 2016 Lorenzo Battistini - Agile Business Group - I.A.S. Ingenieria,
# Aplicaciones y Software
# © 2016 Lorenzo Battistini - Agile Business Group - I.A.S. Colombia.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Stock Analysis",
"summary": "Analysis view for stock",
"version": "9.0.0.1.1",
"category": "Inventory, Logistic, Storage",
"website": "https://www.agilebg.com - http://www.ias.com.co/",
"author": "Agile Business Group, Odoo Community Association (OCA), \
I.A.S. Ingenieria, Aplicaciones y Software",
"version": "9.0.1.0.0",
"category": "Warehouse Management",
"website": "https://www.agilebg.com",
"author": "Agile Business Group,"
"Odoo Community Association (OCA),"
"I.A.S. Colombia",
"license": "AGPL-3",
'installable': True,
'auto_install': False,
'application': True,
"depends": [
"base", "stock",
"stock",
],
"data": [
'views/stock_analysis_view.xml',
Expand Down
3 changes: 1 addition & 2 deletions stock_analysis/reports/__init__.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Lorenzo Battistini - Agile Business Group - I.A.S. Ingenieria,
# Aplicaciones y Software
# © 2016 Lorenzo Battistini - Agile Business Group - I.A.S. Colombia.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import stock_analysis
28 changes: 18 additions & 10 deletions stock_analysis/reports/stock_analysis.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Lorenzo Battistini - Agile Business Group - I.A.S. Ingenieria,
# Aplicaciones y Software
# © 2016 Lorenzo Battistini - Agile Business Group - I.A.S. Colombia.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, tools
Expand All @@ -26,11 +25,9 @@ class StockAnalysis(models.Model):
company_id = fields.Many2one(
'res.company', string='Company', readonly=True)

def init(self, cr):
tools.drop_view_if_exists(cr, 'stock_analysis')
cr.execute(
"""CREATE or REPLACE VIEW stock_analysis as (
SELECT
def _select(self):
select_str = """
SELECT
quant.id AS id,
quant.product_id AS product_id,
quant.location_id AS location_id,
Expand All @@ -39,10 +36,21 @@ def init(self, cr):
quant.package_id AS package_id,
quant.in_date AS in_date,
quant.company_id,
template.categ_id AS categ_id
template.categ_id AS categ_i
"""
return select_str

def _from(self):
from_str = """
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
)"""
)
"""
return from_str

def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
%s %s
)""" % (self._table, self._select(), self._from()))

0 comments on commit f043703

Please sign in to comment.