deisy 5 éve
commit
e239dbe075

+ 2 - 0
__init__.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+import controller

+ 22 - 0
__openerp__.py

@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+{
+    'name': "Eiru Reports Inmobiliaria",
+    'author': "Deisy Samudio",
+    'category': 'Reports',
+    'version': '0.1',
+    'depends': [
+        'base',
+        'account',
+        'eiru_assets',
+        'eiru_reports',
+    ],
+    'qweb': [
+        'static/src/xml/*.xml',
+        'static/src/reports/*.xml'
+    ],
+    'data': [
+        'templates.xml',
+        'views/actions.xml',
+        'views/menus.xml',
+    ],
+}

+ 2 - 0
controller/__init__.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+import main

+ 15 - 0
controller/helpers/__init__.py

@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+from res_company import get_res_company_inmobiliaria
+from res_company import get_company_logo_inmobiliaria
+from res_store import get_res_store_inmobiliaria
+from account_journal import get_account_journal_inmobiliaria
+from res_users import get_res_users_inmobiliaria
+from account_invoice import get_account_invoice_sale_type_inmobiliaria
+from account_invoice_line import get_account_invoice_line_out_invoice_inmobiliaria
+from pos_order import get_pos_order_inmobiliaria
+from res_partner import get_res_partner_inmobiliaria
+from res_partner import get_all_res_partner_inmobiliaria
+from res_partner import get_supplier_inmobiliaria
+from account_analytic_account import get_contracts_inmobiliaria
+from product_template import get_product_template_inmobiliaria
+from product_template import get_property_state_inmobiliaria

+ 41 - 0
controller/helpers/account_analytic_account.py

@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+def get_contracts_inmobiliaria():
+    query = '''
+        SELECT
+            contract.id,
+            contract.code,
+            contract.partner_id,
+            contract.state,
+            contract.date,
+            contract.description,
+            contract.name,
+            contract.recurring_next_date,
+            contract.recurring_rule_type,
+            contract.nro_cuotas,
+            contract.cuota_total,
+            partner.name
+        FROM account_analytic_account AS contract
+        LEFT JOIN res_partner AS partner
+        ON partner.id = contract.partner_id
+    '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'code': j[1],
+            'partner_id': j[2],
+            'state': j[3],
+            'date': j[4],
+            'description': j[5],
+            'name': j[6],
+            'recurring_next_date': j[7],
+            'recurring_rule_type': j[8],
+            'nro_cuotas': j[9],
+            'cuota_total': j[10],
+            'partner_name': j[11],
+        } for j in r.cr.fetchall()
+    ]

+ 202 - 0
controller/helpers/account_invoice.py

@@ -0,0 +1,202 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+def get_account_invoice_sale_type_inmobiliaria(): #historico de venta
+    company_currency_rate = r.env.user.company_id.currency_id.rate
+    validate_columns = '''
+        SELECT EXISTS (SELECT 1 FROM information_schema.columns
+        WHERE table_name='account_invoice' AND column_name in ('contado','credito'))'''
+
+    query1 = '''
+        SELECT
+        	invoice.id,
+        	rate.currency_id,
+        	invoice.date_invoice,
+        	invoice.type,
+        	invoice.origin,
+        	invoice.partner_id,
+        	invoice.user_id,
+        	invoice.amount_total * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
+            invoice.number,
+            partner.name,
+            customer.name,
+            invoice.amount_tax * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
+            invoice.state,
+            journal.store_id,
+            invoice.journal_id,
+            invoice.state,
+            invoice.company_id,
+            customer.ruc,
+            invoice.supplier_invoice_number,
+            customer.phone,
+            customer.mobile,
+            customer.email,
+            invoice.cuotas
+        FROM account_invoice AS invoice
+        LEFT JOIN res_store_journal_rel AS journal
+        ON journal.journal_id = invoice.journal_id
+        LEFT JOIN res_currency_rate AS rate
+        ON rate.currency_id = invoice.currency_id
+        LEFT JOIN res_company AS company
+        ON company.id = invoice.company_id
+        LEFT JOIN res_users AS users
+        ON users.id = invoice.user_id
+        LEFT JOIN res_partner AS partner
+        ON partner.id = users.partner_id
+        LEFT JOIN res_partner AS customer
+        ON customer.id = invoice.partner_id
+        WHERE invoice.state NOT IN ('draft', 'cancel')
+        AND invoice.type IN ('out_invoice')
+        GROUP BY
+        	invoice.id,
+        	rate.currency_id,
+        	invoice.date_invoice,
+        	invoice.type,
+        	invoice.origin,
+        	invoice.amount_total,
+        	invoice.partner_id,
+        	invoice.user_id,
+            invoice.amount_total,
+            partner.name,
+            customer.name,
+            invoice.amount_tax,
+            invoice.state,
+            journal.store_id,
+            invoice.journal_id,
+            invoice.state,
+            invoice.company_id,
+            customer.ruc,
+            invoice.supplier_invoice_number,
+            customer.phone,
+            customer.mobile,
+            customer.email
+    '''
+
+    query2 = '''
+        SELECT
+        	invoice.id,
+        	rate.currency_id,
+        	invoice.date_invoice,
+        	invoice.type,
+        	invoice.origin,
+        	invoice.partner_id,
+        	invoice.user_id,
+        	invoice.amount_total * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
+            invoice.number,
+            partner.name,
+            customer.name,
+            invoice.amount_tax * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
+            invoice.state,
+            journal.store_id,
+            invoice.journal_id,
+            invoice.state,
+            invoice.company_id,
+            customer.ruc,
+            invoice.supplier_invoice_number,
+            invoice.contado,
+            invoice.credito,
+            customer.phone,
+            customer.mobile,
+            customer.email,
+            invoice.cuotas
+        FROM account_invoice AS invoice
+        LEFT JOIN res_store_journal_rel AS journal
+        ON journal.journal_id = invoice.journal_id
+        LEFT JOIN res_currency_rate AS rate
+        ON rate.currency_id = invoice.currency_id
+        LEFT JOIN res_company AS company
+        ON company.id = invoice.company_id
+        LEFT JOIN res_users AS users
+        ON users.id = invoice.user_id
+        LEFT JOIN res_partner AS partner
+        ON partner.id = users.partner_id
+        LEFT JOIN res_partner AS customer
+        ON customer.id = invoice.partner_id
+        WHERE invoice.state NOT IN ('draft', 'cancel')
+        AND invoice.type IN ('out_invoice')
+        GROUP BY
+        	invoice.id,
+        	rate.currency_id,
+        	invoice.date_invoice,
+        	invoice.type,
+        	invoice.origin,
+        	invoice.amount_total,
+        	invoice.partner_id,
+        	invoice.user_id,
+            invoice.amount_total,
+            partner.name,
+            customer.name,
+            invoice.amount_tax,
+            invoice.state,
+            journal.store_id,
+            invoice.journal_id,
+            invoice.state,
+            invoice.company_id,
+            customer.ruc,
+            invoice.supplier_invoice_number,
+            customer.phone,
+            customer.mobile,
+            customer.email
+    '''
+
+    r.cr.execute(validate_columns)
+
+    for j in r.cr.fetchall():
+        column = j[0]
+
+    if column == True:
+        r.cr.execute(query2,(tuple([company_currency_rate,company_currency_rate])))
+        return [{
+            'invoice_id': j[0],
+            'currency_id': j[1],
+            'date': j[2],
+            'type': j[3],
+            'origin': j[4],
+            'customer_id':j[5],
+            'user_id':j[6],
+            'amount':j[7],
+            'number':j[8],
+            'user_name':j[9],
+            'customer_name':j[10],
+            'amount_tax':j[11],
+            'state':j[12],
+            'store_id':j[13],
+            'journal_id':j[14],
+            'state':j[15],
+            'company_id':j[16],
+            'customer_ruc':j[17],
+            'supplier_invoice_number':j[18],
+            'contado':j[19],
+            'credito':j[20],
+            'phone':j[21],
+            'mobile':j[22],
+            'email':j[23],
+            'cuotas':j[24],
+        } for j in r.cr.fetchall()]
+    else:
+        r.cr.execute(query1,(tuple([company_currency_rate,company_currency_rate])))
+        return [{
+            'invoice_id': j[0],
+            'currency_id': j[1],
+            'date': j[2],
+            'type': j[3],
+            'origin': j[4],
+            'customer_id':j[5],
+            'user_id':j[6],
+            'amount':j[7],
+            'number':j[8],
+            'user_name':j[9],
+            'customer_name':j[10],
+            'amount_tax':j[11],
+            'state':j[12],
+            'store_id':j[13],
+            'journal_id':j[14],
+            'state':j[15],
+            'company_id':j[16],
+            'customer_ruc':j[17],
+            'supplier_invoice_number':j[18],
+            'phone':j[19],
+            'mobile':j[20],
+            'email':j[21],
+            'cuotas':j[22],
+        } for j in r.cr.fetchall()]

+ 257 - 0
controller/helpers/account_invoice_line.py

@@ -0,0 +1,257 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+def get_account_invoice_line_out_invoice_inmobiliaria(): #analisis de venta
+    user_store = r.env.user.store_id.id
+    company_currency_rate = r.env.user.company_id.currency_id.rate
+
+    validate_brand = '''
+        SELECT EXISTS(
+            SELECT table_name
+            FROM information_schema.columns
+            WHERE table_schema='public'
+                AND table_name='product_brand')
+    '''
+
+    query_with_brand = '''
+        SELECT
+        	invoice.id AS invoice_id,
+        	line.id AS invoice_line_id,
+        	invoice.number,
+        	invoice.origin,
+        	invoice.date_invoice,
+        	invoice.type,
+            CASE
+        		WHEN product.default_code IS NOT NULL
+        		THEN ('[' || product.default_code || '] ' || product.name_template)
+        		ELSE product.name_template
+        		END AS display_name,
+        	line.price_unit * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]) as price_unit,
+        	line.quantity AS cant,
+        	line.price_subtotal * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]) AS subtotal,
+        	(line.quantity * (line.price_unit * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]))) - (((line.quantity * (line.price_unit * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]) * line.discount)/100))) - (line.price_subtotal * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1])) AS impuestos,
+        	(array_agg(history.cost ORDER BY history.id DESC))[1] AS cost,
+            --line.name
+            journal.store_id,
+            template.categ_id,
+            partner.ruc,
+            partner.name,
+            product.id,
+            invoice.company_id,
+            invoice.journal_id,
+            (array_agg(attr_rel.att_id)) AS attr_rel,
+            (array_agg(attr_value.name)) AS attr_value,
+            (array_agg(attr.id)) AS attr,
+            template.product_brand_id,
+            brand.name,
+            line.discount,
+            template.comision_inmobiliaria,
+            template.comision_vendedor,
+            template.comision_total,
+            template.t_propietario
+            FROM account_invoice AS invoice
+            LEFT JOIN account_invoice_line AS line
+            ON line.invoice_id = invoice.id
+            --Product
+            LEFT JOIN product_product AS product
+            ON line.product_id = product.id
+            LEFT JOIN product_template AS template
+            ON template.id = product.product_tmpl_id
+            LEFT JOIN product_attribute_value_product_product_rel AS attr_rel
+        	ON attr_rel.prod_id = product.id
+        	LEFT JOIN product_attribute_value AS attr_value
+        	ON attr_value.id = attr_rel.att_id
+        	LEFT JOIN product_attribute AS attr
+        	ON attr.id = attr_value.attribute_id
+            LEFT JOIN res_store_journal_rel AS journal
+            ON journal.journal_id = invoice.journal_id
+            LEFT JOIN product_price_history AS history
+            ON history.product_template_id = product.product_tmpl_id
+            LEFT JOIN res_currency_rate AS rate
+            ON rate.currency_id = invoice.currency_id
+            LEFT JOIN res_partner AS partner
+            ON partner.id = invoice.partner_id
+            LEFT JOIN product_brand AS brand
+            ON brand.id = template.product_brand_id
+            WHERE invoice.state NOT IN ('draft', 'cancel')
+            AND invoice.type = 'out_invoice'
+        GROUP BY
+        	invoice.id,
+        	line.id,
+        	invoice.number,
+        	invoice.origin,
+        	invoice.date_invoice,
+        	product.name_template,
+        	line.price_unit,
+        	line.quantity,
+        	line.price_subtotal,
+            journal.store_id,
+            template.categ_id,
+            product.default_code,
+            partner.ruc,
+            partner.name,
+            product.id,
+            invoice.company_id,
+            invoice.journal_id,
+            template.product_brand_id,
+            brand.name,
+            template.comision_inmobiliaria,
+            template.comision_vendedor,
+            template.comision_total,
+            template.t_propietario
+    '''
+
+    query_without_brand = '''
+        SELECT
+        	invoice.id AS invoice_id,
+        	line.id AS invoice_line_id,
+        	invoice.number,
+        	invoice.origin,
+        	invoice.date_invoice,
+        	invoice.type,
+            CASE
+        		WHEN product.default_code IS NOT NULL
+        		THEN ('[' || product.default_code || '] ' || product.name_template)
+        		ELSE product.name_template
+        		END AS display_name,
+        	line.price_unit * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]) as price_unit,
+        	line.quantity AS cant,
+        	line.price_subtotal * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]) AS subtotal,
+        	(line.quantity * (line.price_unit * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]))) - (((line.quantity * (line.price_unit * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]) * line.discount)/100))) - (line.price_subtotal * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1])) AS impuestos,
+        	(array_agg(history.cost ORDER BY history.id DESC))[1] AS cost,
+            --line.name
+            journal.store_id,
+            template.categ_id,
+            partner.ruc,
+            partner.name,
+            product.id,
+            invoice.company_id,
+            invoice.journal_id,
+            (array_agg(attr_rel.att_id)) AS attr_rel,
+            (array_agg(attr_value.name)) AS attr_value,
+            (array_agg(attr.id)) AS attr,
+            line.discount,
+            template.comision_inmobiliaria,
+            template.comision_vendedor,
+            template.comision_total,
+            template.t_propietario
+            FROM account_invoice AS invoice
+            LEFT JOIN account_invoice_line AS line
+            ON line.invoice_id = invoice.id
+            --Product
+            LEFT JOIN product_product AS product
+            ON line.product_id = product.id
+            LEFT JOIN product_template AS template
+            ON template.id = product.product_tmpl_id
+            LEFT JOIN product_attribute_value_product_product_rel AS attr_rel
+        	ON attr_rel.prod_id = product.id
+        	LEFT JOIN product_attribute_value AS attr_value
+        	ON attr_value.id = attr_rel.att_id
+        	LEFT JOIN product_attribute AS attr
+        	ON attr.id = attr_value.attribute_id
+            LEFT JOIN res_store_journal_rel AS journal
+            ON journal.journal_id = invoice.journal_id
+            LEFT JOIN product_price_history AS history
+            ON history.product_template_id = product.product_tmpl_id
+            LEFT JOIN res_currency_rate AS rate
+            ON rate.currency_id = invoice.currency_id
+            LEFT JOIN res_partner AS partner
+            ON partner.id = invoice.partner_id
+            WHERE invoice.state NOT IN ('draft', 'cancel')
+            AND invoice.type = 'out_invoice'
+        GROUP BY
+        	invoice.id,
+        	line.id,
+        	invoice.number,
+        	invoice.origin,
+        	invoice.date_invoice,
+        	product.name_template,
+        	line.price_unit,
+        	line.quantity,
+        	line.price_subtotal,
+            journal.store_id,
+            template.categ_id,
+            product.default_code,
+            partner.ruc,
+            partner.name,
+            product.id,
+            invoice.company_id,
+            invoice.journal_id,
+            template.comision_inmobiliaria,
+            template.comision_vendedor,
+            template.comision_total,
+            template.t_propietario
+    '''
+
+    r.cr.execute(validate_brand)
+    for j in r.cr.fetchall():
+        brand = j[0]
+
+    if brand == True:
+        r.cr.execute(query_with_brand,[company_currency_rate,company_currency_rate,company_currency_rate,company_currency_rate,company_currency_rate])
+        return [
+            {
+                'invoice_id': j[0],
+                'invoice_line_id': j[1],
+                'number': j[2],
+                'origin': j[3],
+                'date': j[4],
+                'type': j[5],
+                'product_name':j[6],
+                'price_unit':j[7],
+                'quantity':j[8],
+                'subtotal':j[9],
+                'tax': j[10],
+                'cost': j[11],
+                'store_id': j[12],
+                'categ_id': j[13],
+                'partner_name': j[14],
+                'partner_ruc': j[15],
+                'product_id': j[16],
+                'company_id': j[17],
+                'journal_id': j[18],
+                'attribute_value_ids': j[19],
+                'attribute_values': j[20],
+                'attribute_ids': j[21],
+                'product_brand_id': j[22],
+                'brand_name': j[23],
+                'discount': j[24],
+                'comision_inmobiliaria' : j[25],
+                'comision_vendedor':j[26],
+                'comision_total':j[27],
+                't_propietario':j[28],
+            } for j in r.cr.fetchall()
+        ]
+    else:
+        r.cr.execute(query_without_brand,[company_currency_rate,company_currency_rate,company_currency_rate,company_currency_rate,company_currency_rate])
+        return [
+            {
+                'invoice_id': j[0],
+                'invoice_line_id': j[1],
+                'number': j[2],
+                'origin': j[3],
+                'date': j[4],
+                'type': j[5],
+                'product_name':j[6],
+                'price_unit':j[7],
+                'quantity':j[8],
+                'subtotal':j[9],
+                'tax': j[10],
+                'cost': j[11],
+                'store_id': j[12],
+                'categ_id': j[13],
+                'partner_ruc': j[14],
+                'partner_name': j[15],
+                'product_id': j[16],
+                'company_id': j[17],
+                'journal_id': j[18],
+                'attribute_value_ids': j[19],
+                'attribute_values': j[20],
+                'attribute_ids': j[21],
+                'discount': j[22],
+                'comision_inmobiliaria' : j[23],
+                'comision_vendedor':j[24],
+                'comision_total':j[25],
+                't_propietario':j[26],
+            } for j in r.cr.fetchall()
+        ]

+ 15 - 0
controller/helpers/account_journal.py

@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+_MODEL = 'account.journal'
+
+def get_account_journal_inmobiliaria():
+    return [
+        {
+            'id': journal.id,
+            'name': journal.name,
+            'code': journal.code,
+            'type': journal.type,
+            'store_id': journal.store_ids.id
+        } for journal in r.env[_MODEL].search([])
+    ]

+ 88 - 0
controller/helpers/pos_order.py

@@ -0,0 +1,88 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+def get_pos_order_inmobiliaria():
+    user_store = r.env.user.store_id.id
+
+    validate = '''
+        SELECT EXISTS(
+            SELECT table_name
+            FROM information_schema.columns
+            WHERE table_schema='public'
+                AND table_name='pos_order')
+    '''
+
+    query = '''
+        SELECT
+            pos.create_date,
+            pos.name,
+            pos.partner_id,
+            pos.user_id,
+            SUM(line.price_subtotal_incl) as amount,
+            partner.name,
+            pos.id,
+            salesperson.name,
+            SUM(line.price_subtotal) as untaxed,
+            pos.sale_journal,
+            journal.store_id,
+            pos.company_id,
+            partner.ruc,
+            partner.phone,
+            partner.mobile,
+            partner.email
+        FROM pos_order as pos
+        LEFT JOIN res_store_journal_rel as journal
+        ON journal.journal_id = pos.sale_journal
+        LEFT JOIN pos_order_line AS line
+        ON line.order_id = pos.id
+        LEFT JOIN res_partner AS partner
+        ON partner.id = pos.partner_id
+        LEFT JOIN res_users AS users
+        ON users.id = pos.user_id
+        LEFT JOIN res_partner AS salesperson
+        ON salesperson.id = users.partner_id
+        GROUP BY
+            pos.create_date,
+            pos.partner_id,
+            pos.user_id,
+            pos.name,
+            partner.name,
+            pos.id,
+            salesperson.name,
+            pos.sale_journal,
+            journal.store_id,
+            pos.company_id,
+            partner.ruc,
+            partner.phone,
+            partner.mobile,
+            partner.email
+    '''
+
+    r.cr.execute(validate)
+    for j in r.cr.fetchall():
+        band = j[0]
+
+    if band == True:
+        r.cr.execute(query)
+        return [
+            {
+                'date': j[0],
+                'name': j[1],
+                'customer_id': j[2],
+                'user_id': j[3],
+                'amount': j[4],
+                'customer_name': j[5],
+                'order_id': j[6],
+                'user_name': j[7],
+                'amount_untaxed': j[8],
+                'journal_id': j[9],
+                'store_id': j[10],
+                'company_id': j[11],
+                'customer_ruc': j[12],
+                'phone':j[13],
+                'mobile':j[14],
+                'email':j[15],
+            } for j in r.cr.fetchall()
+        ]
+    else:
+        return []

+ 68 - 0
controller/helpers/product_template.py

@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+def get_product_template_inmobiliaria():
+    query = '''
+        SELECT
+        tpt.id,
+        tpt.name,
+        tpt.type,
+        tpt.comision_vendedor,
+        tpt.comision_inmobiliaria,
+        tpt.comision_total,
+        tpt.t_propietario,
+        partner.name,
+        tpt.t_tamanho,
+        tpt.t_direccion,
+        tpt.t_descripcion,
+        tpt.list_price,
+        tpt.categ_id,
+        tpt.t_estado,
+        estado.name
+        FROM product_template AS tpt
+        LEFT JOIN res_partner AS partner
+        ON partner.id = tpt.t_propietario
+        LEFT JOIN property_state AS estado
+        ON estado.id = tpt.t_estado
+        WHERE tpt.active = true AND tpt.sale_ok = true
+          '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'name': j[1],
+            'type': j[2],
+            'comision_vendedor': j[3],
+            'comision_inmobiliaria.': j[4],
+            'comision_total': j[5],
+            'propietario_id': j[6],
+            'propietario_name': j[7],
+            'tamanho': j[8],
+            'direccion': j[9],
+            'descripcion': j[10],
+            'precio': j[11],
+            'categoria': j[12],
+            'estado_id': j[13],
+            'estado_name': j[14],
+
+        } for j in r.cr.fetchall()
+    ]
+
+def get_property_state_inmobiliaria():
+    query = '''
+        SELECT
+            state.id,
+            state.name
+        FROM property_state AS state
+    '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'name': j[1],
+        } for j in r.cr.fetchall()
+    ]

+ 62 - 0
controller/helpers/res_company.py

@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+_MODEL = 'res.company'
+
+def get_company_logo_inmobiliaria():
+    domain = [
+        # ('expense','=', True)
+    ]
+    return [
+        {
+            'id': company.id,
+            'logo': company.logo,
+        } for company in r.env[_MODEL].search(domain)
+    ]
+
+def get_res_company_inmobiliaria():
+    user_company = r.env.user.company_id.id
+    user_store = r.env.user.store_id.id
+    query = '''
+        SELECT
+            company.id,
+            company.name,
+            currency.id,
+            currency.name,
+            currency.symbol,
+            currency.decimal_places,
+            currency.decimal_separator,
+            currency.thousands_separator,
+            currency.symbol_position,
+            store.name AS store,
+            partner.ruc AS company_ruc
+        FROM res_company AS company
+        LEFT JOIN res_currency AS currency
+        ON company.currency_id = currency.id
+        LEFT JOIN res_store AS store
+        ON store.id = ''' + str(user_store) + '''
+        LEFT JOIN res_partner AS partner
+        ON partner.id = company.partner_id
+        WHERE currency.active = true
+        ORDER BY company.id ASC
+    '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'name': j[1],
+            'currency_id':{
+                'id':  j[2],
+                'name':  j[3],
+                'symbol':  j[4],
+                'decimal_places':  j[5],
+                'decimal_separator':  j[6],
+                'thousands_separator':  j[7],
+                'symbol_position':  j[8],
+            },
+            'store': j[9],
+            'ruc': j[10],
+        } for j in r.cr.fetchall()
+    ]

+ 62 - 0
controller/helpers/res_partner.py

@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+def get_res_partner_inmobiliaria():
+    query = '''
+        SELECT
+            partner.id,
+            partner.name,
+            partner.ruc
+        FROM res_partner AS partner
+        WHERE partner.customer = True AND partner.active = True
+    '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'name': j[1],
+            'ruc': j[2],
+        } for j in r.cr.fetchall()
+    ]
+
+def get_all_res_partner_inmobiliaria():
+    query = '''
+        SELECT
+            partner.id,
+            partner.name,
+            partner.ruc
+        FROM res_partner AS partner
+        WHERE partner.active = True
+    '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'name': j[1],
+            'ruc': j[2],
+        } for j in r.cr.fetchall()
+    ]
+
+def get_supplier_inmobiliaria():
+    query = '''
+        SELECT
+            partner.id,
+            partner.name,
+            partner.ruc
+        FROM res_partner AS partner
+        WHERE partner.supplier = true AND partner.active = true
+    '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'name': j[1],
+            'ruc': j[2],
+        } for j in r.cr.fetchall()
+    ]

+ 13 - 0
controller/helpers/res_store.py

@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+_MODEL = 'res.store'
+
+def get_res_store_inmobiliaria():
+    return [
+        {
+            'id': store.id,
+            'name': store.name,
+            'company_id': store.company_id.id,
+        } for store in r.env[_MODEL].search([])
+    ]

+ 27 - 0
controller/helpers/res_users.py

@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+def get_res_users_inmobiliaria():
+    query = '''
+        SELECT
+            users.id,
+            users.company_id,
+            users.store_id,
+            partner.name
+        FROM res_users AS users
+        LEFT JOIN res_partner AS partner
+        ON partner.id = users.partner_id
+        WHERE users.active = true
+    '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'company_id': j[1],
+            'store_id': j[2],
+            'name': j[3],
+
+        } for j in r.cr.fetchall()
+    ]

+ 72 - 0
controller/main.py

@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+from openerp import http
+from werkzeug.wrappers import Response
+from werkzeug.datastructures import Headers
+from gzip import GzipFile
+from StringIO import StringIO as IO
+import simplejson as json
+import helpers as hp
+import logging
+
+LOGGER = logging.getLogger(__name__)
+GZIP_COMPRESSION_LEVEL = 9
+
+def make_gzip_response(data=None, status=200):
+    gzip_buffer = IO()
+
+    with GzipFile(mode='wb', compresslevel=GZIP_COMPRESSION_LEVEL, fileobj=gzip_buffer) as gzip_file:
+        gzip_file.write(json.dumps(data))
+
+    value = gzip_buffer.getvalue()
+    gzip_buffer.close()
+
+    headers = Headers()
+    headers.add('Content-Encoding', 'gzip')
+    headers.add('Vary', 'Accept-Encoding')
+    headers.add('Content-Length', len(value))
+
+    return Response(value, status=status, headers=headers, content_type='application/json')
+
+class ReportController(http.Controller):
+
+    # CONSULTA INICIAL
+    @http.route('/report-filter-data-inmobiliaria', auth='user', methods=['GET', 'POST'])
+    def getFilterData(self, **kw):
+        return make_gzip_response({
+            'companies': hp.get_res_company_inmobiliaria(),
+            'logo': hp.get_company_logo_inmobiliaria(),
+            'stores': hp.get_res_store_inmobiliaria(),
+            'journals': hp.get_account_journal_inmobiliaria(),
+            'users': hp.get_res_users_inmobiliaria(),
+            'partner':hp.get_res_partner_inmobiliaria(),
+            'supplier':hp.get_supplier_inmobiliaria(),
+            'property_state': hp.get_property_state_inmobiliaria(),
+
+        })
+
+    # CONTRATOS
+    @http.route('/report-contracts-inmobiliaria', auth='user', methods=['GET', 'POST'])
+    def getContracts(self, **kw):
+        return make_gzip_response({
+            'contracts': hp.get_contracts_inmobiliaria(),
+            'partners': hp.get_res_partner_inmobiliaria(),
+        })
+
+    #COMISIONES
+    @http.route('/report-sale-history-inmobiliaria', auth='user', methods=['GET', 'POST'])
+    def getSaleHistory(self, **kw):
+        return make_gzip_response({
+            'invoices': hp.get_account_invoice_sale_type_inmobiliaria(),
+            'invoice_line': hp.get_account_invoice_line_out_invoice_inmobiliaria(),
+            'orders': hp.get_pos_order_inmobiliaria(),
+            'partners': hp.get_all_res_partner_inmobiliaria(),
+        })
+
+    #PROPIEDADES
+    @http.route('/report-propiedades-inmobiliaria', auth='user', methods=['GET', 'POST'])
+    def getProductTemplate(self, **kw):
+        return make_gzip_response({
+            'template': hp.get_product_template_inmobiliaria(),
+            'supplier':hp.get_supplier_inmobiliaria(),
+
+        })

BIN
static/description/icon.png


+ 10 - 0
static/src/css/custom.css

@@ -0,0 +1,10 @@
+.openerp_webclient_container {
+    height: 100% !important;
+    height: calc(100% - 45px) !important;
+    overflow: auto !important;
+  }
+
+.hover:hover{
+  cursor: -webkit-grab;
+  cursor: grab;
+}

+ 23 - 0
static/src/js/main.js

@@ -0,0 +1,23 @@
+openerp.eiru_reports_inmobiliaria = function(instance) {
+  "use strict";
+
+  var reporting = instance.eiru_reports_inmobiliaria;
+
+  reporting_base(instance, reporting);
+
+  try {
+    report_contrato_inmobiliaria(reporting);
+    report_comision_inmobiliaria(reporting);
+    report_propiedades_inmobiliaria(reporting);
+
+  } catch (e) {
+    // ignorar error
+  }
+
+
+  instance.web.client_actions.add('eiru_reports_inmobiliaria.contrato_inmobiliaria_action', 'instance.eiru_reports_inmobiliaria.ReportInmobiliariaWidget');
+  instance.web.client_actions.add('eiru_reports_inmobiliaria.comision_inmobiliaria_action', 'instance.eiru_reports_inmobiliaria.ReportComisionWidget');
+  instance.web.client_actions.add('eiru_reports_inmobiliaria.propiedades_inmobiliaria_action', 'instance.eiru_reports_inmobiliaria.ReportPropiedadesInmobiliariaWidget');
+
+
+}

+ 22 - 0
static/src/js/reporting_base.js

@@ -0,0 +1,22 @@
+function reporting_base (instance, widget) {
+    "use strict";
+
+    widget.Base = instance.Widget.extend({
+
+        position: 0,
+
+        init: function (parent, position) {
+            this._super(parent);
+            this.position = position || this.position;
+        },
+        start: function () {
+            
+        },
+        getPosition: function () {
+            return this.position;
+        },
+        setPosition: function (position) {
+            this.position = position;
+        }
+    });
+}

+ 736 - 0
static/src/js/reports/report_comision_inmobiliaria.js

@@ -0,0 +1,736 @@
+function report_comision_inmobiliaria(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportComisionWidget = reporting.Base.extend({
+        template: 'ReportComision',
+        rowsData :[],
+        content :[],
+        modules: ['point_of_sale'],
+
+        events:{
+            'click #generate' : 'fetchGenerate',
+            'change #current-company' : 'updateSelections',
+            'change #current-date' : 'ShowDateRange',
+            'click .print-report':'clickOnAction',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            var date = new model.eiru_reports.ReportDatePickerWidget(self);
+            date.fecthFecha();
+            this.fetchInitial();
+        },
+
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model;
+            });
+        },
+
+        valorNull:function(dato){
+            var valor = "";
+            if (dato){
+                valor = dato;
+            }
+            return valor;
+        },
+
+        ShowDateRange : function(){
+            var self = this;
+            var date = self.$el.find('#current-date').val();
+            if(date == 'range'){
+                self.$el.find('.datepicker').css('display','block');
+            }
+            if(date != 'range'){
+                self.$el.find('.datepicker').css('display','none');
+            }
+        },
+
+        fetchInitial: function () {
+            var self = this;
+            self.fetchInitialSQL().then(function (InitialSQL) {
+                return InitialSQL;
+            }).then(function(InitialSQL) {
+                /*
+                =================================
+                    RES COMPANY
+                =================================
+                */
+                self.ResCompany = InitialSQL.companies;
+                self.CompanyLogo = InitialSQL.logo;
+                if(self.ResCompany.length > 1){
+                    self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+                    _.each(self.ResCompany,function(item){
+                        self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.company').css('display','none');
+                }
+                /*
+                =================================
+                    RES STORE
+                =================================
+                */
+                self.ResStore = InitialSQL.stores;
+                if(self.ResStore.length > 1){
+                    self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                    _.each(self.ResStore,function(item){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.store').css('display','none');
+                }
+                /*
+                =================================
+                    RES PARTNER
+                =================================
+                */
+                self.ResPartner = InitialSQL.partner;
+                if(self.ResPartner.length > 1){
+                    self.$el.find('#current-customer').append('<option value="9999999">Todas los clientes</option>');
+                    _.each(self.ResPartner,function(item){
+                        self.$el.find('#current-customer').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.customer').css('display','none');
+                }
+
+                /*
+                =================================
+                    RES USERS
+                =================================
+                */
+                self.ResUsers = InitialSQL.users;
+                var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                    return item.id;
+                }));
+                var ResUsers = _.flatten(_.filter(self.ResUsers,function (item) {
+                    return _.contains(store_ids, item.store_id);
+                }));
+                if(ResUsers.length > 0){
+                    self.$el.find('#current-user').append('<option value="9999999">Todos los Vendedores</option>');
+                    _.each(ResUsers,function(item){
+                        self.$el.find('#current-user').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.users').css('display','none');
+                }
+                return self.fethIrModuleModule();
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fethCheckType();
+            });
+            self.$el.find('#generate').css('display','inline');
+            return;
+        },
+
+        fetchGenerate: function () {
+            var self = this;
+            self.$el.find('.search-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            self.$el.find('.report-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            this.fetchDataSQL().then(function(DataSQL) {
+                return DataSQL;
+            }).then(function (DataSQL) {
+                self.ResPartners = DataSQL.partners;
+                self.AccountInvoice = DataSQL.invoices;
+                self.AccountInvoiceLine = DataSQL.invoice_line;
+                self.PosOrder = DataSQL.orders;
+
+                return self.BuildTable();
+            });
+        },
+
+        fetchInitialSQL: function() {
+            var self = this;
+            var data = $.get('/report-filter-data-inmobiliaria');
+            return data;
+        },
+
+        fetchDataSQL: function() {
+            var self = this;
+            var data = $.get('/report-sale-history-inmobiliaria');
+            return data;
+        },
+
+        fethIrModuleModule: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['name','id'];
+            var domain=[['state','=','installed'],['name','in',self.modules]];
+            var IrModuleModule = new model.web.Model('ir.module.module');
+            IrModuleModule.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*=====================================================================
+            Check type
+        =====================================================================*/
+        fethCheckType: function(){
+            var self = this;
+            var modules = self.checkModel('point_of_sale');
+            if(modules.length == 0){
+                self.$el.find('.type').css('display','none');
+            }
+        },
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var store;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        getPosOrder:function(partner_id) {
+            var self = this;
+
+            var content = _.filter(self.PosOrder,function(item){
+              return item.customer_id == partner_id;
+            });
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var state = self.$el.find('#current-state').val();
+            var type = self.$el.find('#current-type').val();
+            var user = self.$el.find('#current-user').val();
+            var customer = self.$el.find('#current-customer').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            if((store && store != 9999999)||(company && company != 9999999)){
+                var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                    return item.id;
+                }));
+                var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                    return item.id;
+                }));
+                content = _.flatten(_.filter(content,function (item) {
+                    return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+                }));
+            }
+
+            if(company && company != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.company_id == company;
+                }));
+            }
+            if(store && store != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.store_id == store;
+                }));
+            }
+            if(state && state != 9999999){
+                if(state == 'open'){
+                    content = [];
+                }
+            }
+            if(type && type != 9999999){
+                if(type == 'sale'){
+                    content = [];
+                }
+            }
+
+
+
+            if(user && user != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.user_id == user;
+                }));
+            }
+
+            if(customer && customer != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.customer_id == customer;
+                }));
+            }
+
+            if(date && date != 9999999){
+                if(date == 'range'){
+                    if(desde){
+                        date = desde.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                            utc = moment(utc._d).format('YYYY-MM-DD');
+                            return moment(utc).format('YYYY-MM-DD') >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                            utc = moment(utc._d).format('YYYY-MM-DD');
+                            return moment(utc).format('YYYY-MM-DD') <= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM-DD') === today;
+                    }));
+                }
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+
+            return content;
+        },
+
+        getAccountInvoice:function() {
+            var self = this;
+            var content = self.AccountInvoice;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var state = self.$el.find('#current-state').val();
+            var type = self.$el.find('#current-type').val();
+            var user = self.$el.find('#current-user').val();
+            var customer = self.$el.find('#current-customer').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            if((store && store != 9999999)||(company && company != 9999999)){
+                var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                    return item.id;
+                }));
+                var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                    return item.id;
+                }));
+                content = _.flatten(_.filter(content,function (item) {
+                    return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+                }));
+            }
+
+            if(company && company != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.company_id == company;
+                }));
+            }
+            if(store && store != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.store_id == store;
+                }));
+            }
+            if(state && state != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.state == state;
+                }));
+            }
+            if(type && type != 9999999){
+                if(type == 'tpv'){
+                    content = [];
+                }
+            }
+
+            if(user && user != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.user_id == user;
+                }));
+            }
+
+            if(customer && customer != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.customer_id == customer;
+                }));
+            }
+
+            if(date && date != 9999999){
+                if(date == 'range'){
+                    if(desde){
+                        date = desde.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') <= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === today;
+                    }));
+                }
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+
+            return content;
+        },
+
+        getStoreName:function(store_id){
+          var self = this;
+          var ResStore =  _.filter(self.ResStore,function (item) {
+                  return item.id == store_id;
+          });
+          return ResStore[0].name;
+        },
+
+        getAccountInvoiceLine:function(invoice_id){
+          var self = this;
+          var AccountInvoiceLine =  _.filter(self.AccountInvoiceLine,function (item) {
+                  return item.invoice_id == invoice_id;
+          });
+          return AccountInvoiceLine;
+        },
+
+        getOwnerName:function(partner_id){
+          var self = this;
+          var ResPartners = _.filter(self.ResPartners,function (item) {
+              return item.id == partner_id;
+          });
+
+          if (ResPartners.length > 0){
+            return ResPartners[0].name;
+          }
+          else{
+            return ""
+          }
+        },
+
+
+        BuildTable: function(){
+            var self = this;
+            var data = [];
+            var CurrencyBase = self.ResCompany[0].currency_id;
+
+            var AccountInvoice = self.getAccountInvoice()
+
+            _.each(AccountInvoice, function(item){
+              var AccountInvoiceLine = self.getAccountInvoiceLine(item.invoice_id);
+
+              var suma_comision_inmobiliaria = 0;
+              var suma_comision_vendedor = 0;
+              var suma_comision_total = 0;
+              var owner;
+              _.each(AccountInvoiceLine, function(line){
+                suma_comision_inmobiliaria = suma_comision_inmobiliaria + ((line.subtotal * line.comision_inmobiliaria)/100)
+                suma_comision_vendedor = suma_comision_vendedor + ((line.subtotal * line.comision_vendedor)/100)
+                suma_comision_total = suma_comision_total + ((line.subtotal * line.comision_total)/100)
+                owner = line.t_propietario;
+
+              });
+
+              data.push({
+                  id:item.id,
+                  supplier_invoice_number:self.valorNull(item.supplier_invoice_number),
+                  origin:self.valorNull(item.origin),
+                  number:item.number,
+                  type:'Pedido de venta',
+                  date:moment(item.date).format('DD/MM/YYYY'),
+                  seller_name:item.user_name,
+                  user_id:item.user_id,
+                  customer_ruc:self.valorNull(item.customer_ruc),
+                  customer_name:self.valorNull(item.customer_name),
+                  owner_name: self.getOwnerName(owner),
+                  cuota: self.valorNull(item.cuotas),
+                  seller_comision:  accounting.formatMoney(suma_comision_vendedor, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  company_comision:  accounting.formatMoney(suma_comision_inmobiliaria, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  /*
+                  =======================
+                      NO FORMAT
+                  =======================
+                  */
+                  date_no_format: moment(item.date).format('YYYY-MM-DD'),
+                  seller_comision_no_format:suma_comision_vendedor,
+                  company_comision_no_format:suma_comision_inmobiliaria,
+                  /*
+                  =======================
+                      FOOTER
+                  =======================
+                  */
+                  decimal_places:CurrencyBase.decimal_places,
+                  thousands_separator:CurrencyBase.thousands_separator,
+                  decimal_separator:CurrencyBase.decimal_separator,
+              });
+
+            })
+
+            data.sort(function (a, b) {
+                if (a.date_no_format > b.date_no_format) {
+                    return -1;
+                }
+                if (a.date_no_format < b.date_no_format) {
+                    return 1;
+                }
+                return 0;
+            });
+
+            self.content = data;
+            self.loadTable(data);
+            self.$el.find('.report-form').css('display','block');
+            self.$el.find('.search-form').unblock();
+            self.$el.find('.report-form').unblock();
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var ResCompany;
+            var CurrencyBase;
+            var action = this.$el.find(e.target).val();
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                ResCompany = _.flatten(_.filter(self.ResCompany,function (inv) {
+                    return inv.id == company;
+                }));
+                ResCompany = CompanyLogo[0];
+                CurrencyBase = ResCompany[0].currency_id;
+            }else{
+                ResCompany = self.CompanyLogo[0];
+                CurrencyBase = self.ResCompany[0].currency_id;
+            }
+
+            var getColumns=[];
+            var rows=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+
+            var seller_comision = totalSeller(row);
+            var company_comision = totalCompany(row);
+            row.push({
+                date:'Totales',
+                seller_comision:seller_comision,
+                company_comision:company_comision,
+            });
+
+            if (action === 'pdf') {
+                var data = _.map(column, function (val){
+                    return val.field;
+                });
+                _.each(_.map(column,function(val){
+                    return val;
+                }), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                /*
+                ============================================================
+                    CONFIGURACION DEL PDF
+                ============================================================
+                */
+                var pdf_title = 'Comisión sobre Ventas.';
+                var pdf_type = '';
+                var pdf_name = 'comision_sobre_ventas_';
+
+                var pdf_columnStyles = {
+                    date:{columnWidth:17, halign:'left'},
+                    number:{columnWidth: 24, halign:'left'},
+                    supplier_invoice_number:{columnWidth: 20, halign:'left'},
+                    cuota:{columnWidth: 16,halign:'left'},
+                    origin:{columnWidth: 17,halign:'left'},
+                    customer_name:{halign:'left'},
+                    owner_name:{columnWidth: 20, halign:'left'},
+                    seller_name:{columnWidth: 20, halign:'left'},
+                    seller_comision:{columnWidth: 25, halign:'right'},
+                    company_comision:{columnWidth: 25, halign:'right'},
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new model.eiru_reports.ReportPdfWidget(self);
+                pdf.drawPDF(
+                    _.flatten(getColumns),
+                    row,
+                    ResCompany,
+                    pdf_title,
+                    pdf_type,
+                    pdf_name,
+                    pdf_columnStyles,
+                    filter
+                );
+            }
+        },
+        getFilter: function(){
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var user = self.$el.find('#current-user').val();
+            var customer = self.$el.find('#current-customer').val();
+            var state = self.$el.find('#current-state').val();
+            var type = self.$el.find('#current-type').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var filter = [];
+            if(company && company != 9999999){
+                var ResCompany = _.filter(self.ResCompany, function(item){
+                    return item.id == company;
+                });
+                filter.push({
+                    title:'Empresa',
+                    value: ResCompany[0].name,
+                });
+            }
+            if(store && store != 9999999){
+                var ResStore =  _.filter(self.ResStore,function (item) {
+                        return item.id == store;
+                });
+                filter.push({
+                    title: 'Sucursal',
+                    value:  ResStore[0].name,
+                });
+            }
+            if(user && user != 9999999){
+                var ResUser = _.filter(self.ResUsers, function(item){
+                    return item.id == user;
+                });
+                filter.push({
+                    title:'Vendedor',
+                    value: ResUser[0].name,
+                });
+            }
+            if(customer && customer != 9999999){
+                var ResPartner = _.filter(self.ResPartner, function(item){
+                    return item.id == customer;
+                });
+                filter.push({
+                    title:'Cliente',
+                    value: ResPartner[0].name,
+                });
+            }
+            if(state && state != 9999999){
+                filter.push({
+                    title: 'Estado',
+                    value: $('#current-state option:selected').text(),
+                });
+            }
+
+            if(type && type != 9999999){
+                filter.push({
+                    title: 'Tipo de Factura',
+                    value: $('#current-type option:selected').text(),
+                });
+            }
+
+
+            if(date && date != 9999999){
+                moment.locale('es', {
+                    months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+                });
+
+                if(date == 'range'){
+                    filter.push({
+                        title: 'Fecha',
+                        value:  desde +' al '+hasta,
+                    });
+                }else {
+                    var fecha;
+                    if(date == 'today'){
+                        fecha = moment().format('DD/MM/YYYY');
+                    }
+                    if(date == 'yesterday'){
+                        fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+                    }
+                    if(date == 'currentMonth'){
+                        fecha = moment().format('MMMM/YYYY');
+                    }
+                    if(date == 'lastMonth'){
+                        fecha = moment().add(-1,'months').format('MMMM/YYYY');
+                    }
+                    filter.push({
+                        title: 'Fecha',
+                        value:  fecha,
+                    });
+                }
+            }
+            return filter;
+        },
+    });
+}

+ 542 - 0
static/src/js/reports/report_contrato_inmobiliaria.js

@@ -0,0 +1,542 @@
+function report_contrato_inmobiliaria(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportInmobiliariaWidget = reporting.Base.extend({
+        template: 'ReportInmobiliariaWidget',
+        rowsData :[],
+        content :[],
+
+        events:{
+            'click #generate' : 'fetchGenerate',
+            'change #current-company' : 'updateSelections',
+            'change #current-date' : 'ShowDateRange',
+            'change #current-next-date' : 'ShowDateRange',
+            'click .print-report':'clickOnAction',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            var date = new model.eiru_reports.ReportDatePickerWidget(self);
+            date.fecthFecha();
+            this.fetchInitial();
+        },
+
+
+        valorNull:function(dato){
+            var valor = "";
+            if (dato){
+                valor = dato;
+            }
+            return valor;
+        },
+
+        ShowDateRange : function(){
+            var self = this;
+            var date = self.$el.find('#current-date').val();
+            var next_date = self.$el.find('#current-next-date').val();
+            if (date && date != 9999999){
+              self.$el.find('#current-next-date').val(9999999);
+              self.$el.find('#current-next-date').prop('disabled','disabled');
+              self.$el.find('.datepicker').css('display','none');
+              if(date == 'range'){
+                  self.$el.find('.datepicker').css('display','block');
+              }
+              if(date != 'range'){
+                  self.$el.find('.datepicker').css('display','none');
+              }
+            }else {
+              self.$el.find('#current-next-date').prop('disabled',false);
+            }
+            if (next_date && next_date != 9999999){
+              self.$el.find('#current-date').val(9999999);
+              self.$el.find('#current-date').prop('disabled','disabled');
+              self.$el.find('.datepicker').css('display','none');
+              if(next_date == 'range'){
+                  self.$el.find('.datepicker').css('display','block');
+              }
+              if(next_date != 'range'){
+                  self.$el.find('.datepicker').css('display','none');
+              }
+            }else{
+              self.$el.find('#current-date').prop('disabled',false);
+            }
+
+        },
+
+        fetchInitial: function () {
+            var self = this;
+            self.fetchInitialSQL().then(function (InitialSQL) {
+                return InitialSQL;
+            }).then(function(InitialSQL) {
+                /*
+                =================================
+                    RES COMPANY
+                =================================
+                */
+                self.ResCompany = InitialSQL.companies;
+                self.CompanyLogo = InitialSQL.logo;
+                if(self.ResCompany.length > 1){
+                    self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+                    _.each(self.ResCompany,function(item){
+                        self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.company').css('display','none');
+                }
+                /*
+                =================================
+                    RES STORE
+                =================================
+                */
+                self.ResStore = InitialSQL.stores;
+                if(self.ResStore.length > 1){
+                    self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                    _.each(self.ResStore,function(item){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.store').css('display','none');
+                }
+                /*
+                =================================
+                    RES PARTNER
+                =================================
+                */
+                self.ResPartner = InitialSQL.partner;
+                if(self.ResPartner.length > 1){
+                    self.$el.find('#current-customer').append('<option value="9999999">Todas los clientes</option>');
+                    _.each(self.ResPartner,function(item){
+                        self.$el.find('#current-customer').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.customer').css('display','none');
+                }
+
+            });
+            self.$el.find('#generate').css('display','inline');
+            return;
+        },
+
+        fetchGenerate: function () {
+            var self = this;
+            self.$el.find('.search-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            self.$el.find('.report-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            this.fetchDataSQL().then(function(DataSQL) {
+                return DataSQL;
+            }).then(function (DataSQL) {
+                self.ResPartner = DataSQL.partners;
+                self.Contracts = DataSQL.contracts;
+
+                return self.BuildTable();
+            });
+        },
+
+        fetchInitialSQL: function() {
+            var self = this;
+            var data = $.get('/report-filter-data-inmobiliaria');
+            return data;
+        },
+
+        fetchDataSQL: function() {
+            var self = this;
+            var data = $.get('/report-contracts-inmobiliaria');
+            return data;
+        },
+
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var store;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        get_contracts:function(number) {
+            var self = this;
+            var content = self.Contracts;
+            var state = self.$el.find('#current-state').val();
+            var date = self.$el.find('#current-date').val();
+            var next_date = self.$el.find('#current-next-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            if(state && state != 9999999){
+              var today = moment().format('YYYY-MM-DD');
+
+              if(state == 'open'){
+                content = _.flatten(_.filter(content,function (inv) {
+                    return inv.date > today || inv.date == null;
+                }));
+              }
+              if(state == 'pending'){
+                content = _.flatten(_.filter(content,function (inv) {
+                    return inv.date <= today;
+                }));
+              }
+            }
+
+            if(date && date != 9999999){
+                if(date == 'range'){
+                    if(desde){
+                        date = desde.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') <= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === today;
+                    }));
+                }
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+
+            if(next_date && next_date != 9999999){
+                if(next_date == 'range'){
+                    if(desde){
+                        next_date = desde.split('/');
+                        next_date = (next_date[2]+"-"+next_date[1]+"-"+next_date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.recurring_next_date).format('YYYY-MM-DD') >= next_date;
+                        }));
+                    }
+                    if(hasta){
+                        next_date = hasta.split('/');
+                        next_date = (next_date[2]+"-"+next_date[1]+"-"+next_date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.recurring_next_date).format('YYYY-MM-DD') <= next_date;
+                        }));
+                    }
+                }
+                if(next_date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.recurring_next_date).format('YYYY-MM-DD') === today;
+                    }));
+                }
+                if(next_date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.recurring_next_date).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(next_date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.recurring_next_date).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(next_date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.recurring_next_date).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+            return content;
+        },
+
+
+        BuildTable: function(){
+            var self = this;
+            var data = [];
+            var CurrencyBase = self.ResCompany[0].currency_id;
+
+            var contracts = self.get_contracts();
+
+            _.each(contracts, function(item){
+              if(item.recurring_rule_type == "daily"){ var frecuencia = "Diario"};
+              if(item.recurring_rule_type == "weekly"){ var frecuencia = "Semanal"};
+              if(item.recurring_rule_type == "monthly"){ var frecuencia = "Mensual"};
+              if(item.recurring_rule_type == "yearly"){ var frecuencia = "Anual"};
+
+              data.push({
+                  id:item.id,
+                  name: item.name,
+                  code: item.code,
+                  partner_name: item.partner_name,
+                  cuota_total:item.cuota_total,
+                  nro_cuotas: item.nro_cuotas,
+                  recurring_next_date: item.recurring_next_date != null ? moment(item.recurring_next_date).format('DD/MM/YYYY'): "",
+                  recurring_rule_type: frecuencia,
+                  date: item.date != null ? moment(item.date).format('DD/MM/YYYY') : "",
+
+
+                  /*
+                  ===========================
+                      NO FORMAT
+                  ===========================
+                  */
+                  // date_no_format:moment(utc._d).format('YYYY-MM-DD'),
+                  // total_no_format:item.amount,
+                  // sale_amount_no_format: suma,
+                  /*
+                  ===========================
+                      FOOTER
+                  ===========================
+                  */
+                  decimal_places:CurrencyBase.decimal_places,
+                  thousands_separator:CurrencyBase.thousands_separator,
+                  decimal_separator:CurrencyBase.decimal_separator,
+              });
+
+            });
+
+
+            self.content = data;
+            self.loadTable(data);
+            self.$el.find('.report-form').css('display','block');
+            self.$el.find('.search-form').unblock();
+            self.$el.find('.report-form').unblock();
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var ResCompany;
+            var CurrencyBase;
+            var action = this.$el.find(e.target).val();
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                ResCompany = _.flatten(_.filter(self.ResCompany,function (inv) {
+                    return inv.id == company;
+                }));
+                ResCompany = CompanyLogo[0];
+                CurrencyBase = ResCompany[0].currency_id;
+            }else{
+                ResCompany = self.CompanyLogo[0];
+                CurrencyBase = self.ResCompany[0].currency_id;
+            }
+
+            var getColumns=[];
+            var rows=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+
+            var total = TotalFooter(row);
+            var sale_amount = TotalSaleAmount(row);
+            row.push({
+                store:'Totales',
+                total:total,
+            });
+
+            if (action === 'pdf') {
+                var data = _.map(column, function (val){
+                    return val.field;
+                });
+                _.each(_.map(column,function(val){
+                    return val;
+                }), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                /*
+                ============================================================
+                    CONFIGURACION DEL PDF
+                ============================================================
+                */
+                var pdf_title = 'Fidelización de Ventas.';
+                var pdf_type = 'l';
+                var pdf_name = 'fidelizacion_de_ventas_';
+                var pdf_columnStyles = {
+                    store:{columnWidth:17, halign:'left'},
+                    date:{columnWidth: 16, halign:'center'},
+                    type:{columnWidth: 16,halign:'left'},
+                    number:{halign:'left'},
+                    supplier_invoice_number:{halign:'left'},
+                    origin:{columnWidth: 15, halign:'left'},
+                    customer_name:{columnWidth: 25, halign:'left'},
+                    customer_ruc:{columnWidth: 15, halign:'left'},
+                    phone:{columnWidth: 19, halign:'right'},
+                    mobile:{columnWidth: 20, halign:'right'},
+                    email:{ halign:'right'},
+                    total:{columnWidth: 22, halign:'right'},
+                    sale_type:{columnWidth: 15, halign:'center'},
+                    pos:{columnWidth: 10,halign:'center'},
+                    sale:{columnWidth: 14, halign:'center'},
+                    sale_amount:{columnWidth: 22, halign:'right'},
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new model.eiru_reports.ReportPdfWidget(self);
+                pdf.drawPDF(
+                    _.flatten(getColumns),
+                    row,
+                    ResCompany,
+                    pdf_title,
+                    pdf_type,
+                    pdf_name,
+                    pdf_columnStyles,
+                    filter
+                );
+            }
+        },
+        getFilter: function(){
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var customer = self.$el.find('#current-customer').val();
+            var state = self.$el.find('#current-state').val();
+            var type = self.$el.find('#current-type').val();
+            var sale_type = self.$el.find('#current-sale-type').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var filter = [];
+            if(company && company != 9999999){
+                var ResCompany = _.filter(self.ResCompany, function(item){
+                    return item.id == company;
+                });
+                filter.push({
+                    title:'Empresa',
+                    value: ResCompany[0].name,
+                });
+            }
+            if(store && store != 9999999){
+                var ResStore =  _.filter(self.ResStore,function (item) {
+                        return item.id == store;
+                });
+                filter.push({
+                    title: 'Sucursal',
+                    value:  ResStore[0].name,
+                });
+            }
+
+            if(customer && customer != 9999999){
+                var ResPartner = _.filter(self.ResPartner, function(item){
+                    return item.id == customer;
+                });
+                filter.push({
+                    title:'Cliente',
+                    value: ResPartner[0].name,
+                });
+            }
+            if(state && state != 9999999){
+                filter.push({
+                    title: 'Estado',
+                    value: $('#current-state option:selected').text(),
+                });
+            }
+
+            if(type && type != 9999999){
+                filter.push({
+                    title: 'Tipo de Factura',
+                    value: $('#current-type option:selected').text(),
+                });
+            }
+
+            if(sale_type && sale_type != 9999999){
+                filter.push({
+                    title: 'Tipo de Venta',
+                    value: $('#current-sale-type option:selected').text(),
+                });
+            }
+
+            if(date && date != 9999999){
+                moment.locale('es', {
+                    months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+                });
+
+                if(date == 'range'){
+                    filter.push({
+                        title: 'Fecha',
+                        value:  desde +' al '+hasta,
+                    });
+                }else {
+                    var fecha;
+                    if(date == 'today'){
+                        fecha = moment().format('DD/MM/YYYY');
+                    }
+                    if(date == 'yesterday'){
+                        fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+                    }
+                    if(date == 'currentMonth'){
+                        fecha = moment().format('MMMM/YYYY');
+                    }
+                    if(date == 'lastMonth'){
+                        fecha = moment().add(-1,'months').format('MMMM/YYYY');
+                    }
+                    filter.push({
+                        title: 'Fecha',
+                        value:  fecha,
+                    });
+                }
+            }
+            return filter;
+        },
+    });
+}

+ 385 - 0
static/src/js/reports/report_propiedades_inmobiliaria.js

@@ -0,0 +1,385 @@
+function report_propiedades_inmobiliaria(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportPropiedadesInmobiliariaWidget = reporting.Base.extend({
+        template: 'ReportPropiedadesInmobiliariaWidget',
+        rowsData :[],
+        content :[],
+
+        events:{
+            'click #generate' : 'fetchGenerate',
+            'change #current-company' : 'updateSelections',
+            'click .print-report':'clickOnAction',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            var date = new model.eiru_reports.ReportDatePickerWidget(self);
+            date.fecthFecha();
+            this.fetchInitial();
+        },
+
+
+        valorNull:function(dato){
+            var valor = "";
+            if (dato){
+                valor = dato;
+            }
+            return valor;
+        },
+
+
+
+        fetchInitial: function () {
+            var self = this;
+            self.fetchInitialSQL().then(function (InitialSQL) {
+                return InitialSQL;
+            }).then(function(InitialSQL) {
+                /*
+                =================================
+                    RES COMPANY
+                =================================
+                */
+                self.ResCompany = InitialSQL.companies;
+                self.CompanyLogo = InitialSQL.logo;
+                if(self.ResCompany.length > 1){
+                    self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+                    _.each(self.ResCompany,function(item){
+                        self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.company').css('display','none');
+                }
+                /*
+                =================================
+                    RES STORE
+                =================================
+                */
+                self.ResStore = InitialSQL.stores;
+                if(self.ResStore.length > 1){
+                    self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                    _.each(self.ResStore,function(item){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.store').css('display','none');
+                }
+                /*
+                =================================
+                       supplier
+                =================================
+                */
+                self.Supplier = InitialSQL.supplier;
+                if(self.Supplier.length > 0){
+                    self.$el.find('#current-supplier').append('<option value="9999999">Todas los propietarios</option>');
+                    _.each(self.Supplier,function(item){
+                        self.$el.find('#current-supplier').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.supplier').css('display','none');
+                }
+
+                /*
+                =================================
+                       Estado
+                =================================
+                */
+                self.State = InitialSQL.property_state;
+                if(self.State.length > 0){
+                    self.$el.find('#current-state').append('<option value="9999999">Todas los estados</option>');
+                    _.each(self.State,function(item){
+                        self.$el.find('#current-state').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.state').css('display','none');
+                }
+
+            });
+            self.$el.find('#generate').css('display','inline');
+            return;
+        },
+
+        fetchGenerate: function () {
+            var self = this;
+            self.$el.find('.search-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            self.$el.find('.report-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            this.fetchDataSQL().then(function(DataSQL) {
+                return DataSQL;
+            }).then(function (DataSQL) {
+                self.Template = DataSQL.template;
+                self.Supplier = DataSQL.supplier;
+                return self.BuildTable();
+            });
+        },
+
+        fetchInitialSQL: function() {
+            var self = this;
+            var data = $.get('/report-filter-data-inmobiliaria');
+            return data;
+        },
+
+        fetchDataSQL: function() {
+            var self = this;
+            var data = $.get('/report-propiedades-inmobiliaria');
+            return data;
+        },
+
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var store;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        getProductTemplate:function() {
+            var self = this;
+            var content = self.Template;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var supplier = self.$el.find('#current-supplier').val();
+            var state = self.$el.find('#current-state').val();
+
+            if((store && store != 9999999)||(company && company != 9999999)){
+                var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                    return item.id;
+                }));
+                var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                    return item.id;
+                }));
+                content = _.flatten(_.filter(content,function (item) {
+                    return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+                }));
+            }
+
+            if(company && company != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.company_id == company;
+                }));
+            }
+
+            if(store && store != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.store_id == store;
+                }));
+            }
+
+            if(supplier && supplier != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.propietario_id == supplier;
+                }));
+            }
+
+            if(state && state != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.estado_id == state;
+                }));
+            }
+            return content;
+        },
+
+
+        BuildTable: function(){
+            var self = this;
+            var data = [];
+            var CurrencyBase = self.ResCompany[0].currency_id;
+
+            var template = self.getProductTemplate();
+
+            _.each(template, function(item){
+              data.push({
+                  id:item.id,
+                  propietario_name: self.valorNull(item.propietario_name),
+                  name: item.name,
+                  tamanho:self.valorNull(item.tamanho),
+                  direccion: self.valorNull(item.direccion),
+                  precio:item.precio,
+                  estado_name:self.valorNull(item.estado_name),
+                  descripcion:self.valorNull(item.descripcion),
+
+                  /*
+                  ===========================
+                      FOOTER
+                  ===========================
+                  */
+                  decimal_places:CurrencyBase.decimal_places,
+                  thousands_separator:CurrencyBase.thousands_separator,
+                  decimal_separator:CurrencyBase.decimal_separator,
+              });
+
+            });
+
+
+            self.content = data;
+            self.loadTable(data);
+            self.$el.find('.report-form').css('display','block');
+            self.$el.find('.search-form').unblock();
+            self.$el.find('.report-form').unblock();
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var ResCompany;
+            var CurrencyBase;
+            var action = this.$el.find(e.target).val();
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                ResCompany = _.flatten(_.filter(self.ResCompany,function (inv) {
+                    return inv.id == company;
+                }));
+                ResCompany = CompanyLogo[0];
+                CurrencyBase = ResCompany[0].currency_id;
+            }else{
+                ResCompany = self.CompanyLogo[0];
+                CurrencyBase = self.ResCompany[0].currency_id;
+            }
+
+            var getColumns=[];
+            var rows=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+            row.push({
+            });
+
+
+            if (action === 'pdf') {
+                var data = _.map(column, function (val){
+                    return val.field;
+                });
+                _.each(_.map(column,function(val){
+                    return val;
+                }), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                /*
+                ============================================================
+                    CONFIGURACION DEL PDF
+                ============================================================
+                */
+                var pdf_title = 'Propiedades';
+                var pdf_type = '';
+                var pdf_name = 'propiedades_';
+                var pdf_columnStyles = {
+                    propietario_name:{columnWidth:25, halign:'left'},
+                    name:{columnWidth: 20, halign:'left'},
+                    tamanho:{columnWidth: 16,halign:'left'},
+                    direccion:{halign:'left'},
+                    precio:{columnWidth: 25, halign:'right'},
+                    estado_name:{columnWidth: 18, halign:'left'},
+                    descripcion:{columnWidth: 30, halign:'left'},
+
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new model.eiru_reports.ReportPdfWidget(self);
+                pdf.drawPDF(
+                    _.flatten(getColumns),
+                    row,
+                    ResCompany,
+                    pdf_title,
+                    pdf_type,
+                    pdf_name,
+                    pdf_columnStyles,
+                    filter
+                );
+            }
+        },
+        getFilter: function(){
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var supplier = self.$el.find('#current-supplier').val();
+            var state = self.$el.find('#current-state').val();
+
+            var filter = [];
+            if(company && company != 9999999){
+                var ResCompany = _.filter(self.ResCompany, function(item){
+                    return item.id == company;
+                });
+                filter.push({
+                    title:'Empresa',
+                    value: ResCompany[0].name,
+                });
+            }
+            if(store && store != 9999999){
+                var ResStore =  _.filter(self.ResStore,function (item) {
+                        return item.id == store;
+                });
+                filter.push({
+                    title: 'Sucursal',
+                    value:  ResStore[0].name,
+                });
+            }
+
+            if(supplier && supplier != 9999999){
+                var Supplier = _.filter(self.Supplier, function(item){
+                    return item.id == supplier;
+                });
+                filter.push({
+                    title:'Cliente',
+                    value: Supplier[0].name,
+                });
+            }
+
+            if(state && state != 9999999){
+                var State = _.filter(self.State, function(item){
+                    return item.id == state;
+                });
+                filter.push({
+                    title:'Estado',
+                    value: State[0].name,
+                });
+            }
+            return filter;
+        },
+    });
+}

+ 180 - 0
static/src/reports/report_comision_inmobiliaria.xml

@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportComision">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title"> Comisiones sobre ventas </h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+                <div class="row">
+                    <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Estado</label>
+                        <select id="current-state" class="form-control form-control-sm">
+                            <option value="9999999">Todos los estados</option>
+                            <option value="open">Abierto</option>
+                            <option value="paid">Pagado</option>
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 customer filter-style">
+                        <label>Cliente</label>
+                        <select id="current-customer" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 user filter-style">
+                        <label>Vendedor</label>
+                        <select id="current-user" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <!-- <div class="col-lg-3 type filter-style">
+                        <label>Tipo de Factura</label>
+                        <select id="current-type" class="form-control form-control-sm">
+                            <option value="9999999">Todos los Tipos</option>
+                            <option value="tpv">Terminal</option>
+                            <option value="sale">Pedido de Venta</option>
+                        </select>
+                    </div> -->
+
+                    <div class="col-lg-3 filter-style">
+                       <label>Fechas</label>
+                       <select id="current-date" class="form-control form-control-sm">
+                           <option value="9999999">Sin fechas</option>
+                           <option value="today">Hoy</option>
+                           <option value="yesterday">Ayer</option>
+                           <option value="currentMonth">Mes Actual</option>
+                           <option value="lastMonth">Mes Pasado</option>
+                           <option value="range">Busqueda Avanzada</option>
+                       </select>
+                   </div>
+                </div>
+                <div class="row" >
+                    <div class="datepicker" style="display:none;">
+                        <div class="col-lg-3 filter-style col-md-offset-3">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                        <div class="col-lg-3 filter-style">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="row">
+                    <div class="text-center" style="padding-top:20px;">
+                        <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                            Generar
+                        </button>
+                    </div>
+                    <br/>
+                </div>
+            </div>
+            <div class="report-form" style="display:none;">
+                <div id="toolbar">
+                    <button class="myButton print-report" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container" style="width:100%;">
+                    <table id="table"
+                        data-pagination="true"
+                        data-toggle="table"
+                        data-toolbar="#toolbar"
+                        data-show-columns="true"
+                        data-classes="table"
+                        data-search="true"
+                        data-show-export="true"
+                        data-show-toggle="true"
+                        data-pagination-detail-h-align="left"
+                        data-show-footer="true"
+                        data-footer-style="footerStyle"
+                        data-buttons-class="oe_button myButton"
+                        data-show-pagination-switch="true"
+                        data-page-size="10"
+                        data-search-on-enter-key="true"
+                        data-undefined-text=" "
+                        data-pagination-v-align="top"
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                              <th data-field="date" data-align="center" data-footer-formatter="Totales">Fecha</th>
+                              <th data-field="number" data-align="left">Factura</th>
+                              <th data-field="supplier_invoice_number" data-align="left" data-visible="false">Factura Física</th>
+                              <th data-field="cuota" data-align="left">Cuota</th>
+                              <th data-field="origin" data-align="left">Contrato</th>
+                              <th data-field="customer_name" data-align="left">Cliente</th>
+                              <th data-field="owner_name" data-align="left">Propietario</th>
+                              <th data-field="seller_name" data-align="left">Vendedor</th>
+                              <th data-field="seller_comision" data-align="right" data-footer-formatter="totalSeller">Comisión Vendedor</th>
+                              <th data-field="company_comision" data-align="right" data-footer-formatter="totalCompany">Comisión Empresa</th>
+
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <script>
+
+                <!--
+                    TOTAL
+                -->
+                function totalSeller(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var total =  _.reduce(_.map(rowsTable,function(item){
+                        return item.seller_comision_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function totalCompany(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var total =  _.reduce(_.map(rowsTable,function(item){
+                        return item.company_comision_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold"
+                        }
+                    };
+                };
+
+            </script>
+        </div>
+    </t>
+</template>

+ 157 - 0
static/src/reports/report_contrato_inmobiliaria.xml

@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportInmobiliariaWidget">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title">Contratos</h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
+                <div class="row">
+                    <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 state filter-style">
+                        <label>Estado</label>
+                        <select id="current-state" class="form-control form-control-sm">
+                            <option value="9999999">Todos los estados</option>
+                            <option value="open">En curso</option>
+                            <option value="pending">A renovar</option>
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Fecha próxima factura</label>
+                        <select id="current-next-date" class="form-control form-control-sm">
+                            <option value="9999999">Sin fechas</option>
+                            <option value="today">Hoy</option>
+                            <option value="yesterday">Ayer</option>
+                            <option value="currentMonth">Mes Actual</option>
+                            <option value="lastMonth">Mes Pasado</option>
+                            <option value="range">Busqueda Avanzada</option>
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Fechas termino de contrato</label>
+                        <select id="current-date" class="form-control form-control-sm">
+                            <option value="9999999">Sin fechas</option>
+                            <option value="today">Hoy</option>
+                            <option value="yesterday">Ayer</option>
+                            <option value="currentMonth">Mes Actual</option>
+                            <option value="lastMonth">Mes Pasado</option>
+                            <option value="range">Busqueda Avanzada</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="row" >
+                    <div class="datepicker" style="display:none;">
+                        <div class="col-lg-3 filter-style col-md-offset-3">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                        <div class="col-lg-3 filter-style">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="row">
+                    <div class="text-center" style="padding-top:20px;">
+                        <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                          Generar
+                      </button>
+                    </div>
+                    <br/>
+                </div>
+            </div>
+
+            <div class="report-form" style="display:none;">
+                <div id="toolbar">
+                    <button class="oe_button myButton" value="pdf">Imprimir Informe</button>
+
+                </div>
+                <div class="container" style="width:95%;">
+                    <table id="table"
+                        data-pagination="true"
+                        data-toggle="table"
+                        data-toolbar="#toolbar"
+                        data-show-columns="true"
+                        data-classes="table table-condensed  table-no-bordered"
+                        data-search="true"
+                        data-show-export="true"
+                        data-show-toggle="true"
+                        data-pagination-detail-h-align="left"
+                        data-show-footer="true"
+                        data-footer-style="footerStyle"
+                        data-buttons-class="oe_button myButton"
+                        data-show-pagination-switch="true"
+                        data-page-size="10"
+                        data-search-on-enter-key="true"
+                        data-undefined-text=" "
+                        data-sort-name="recurring_next_date"
+                        data-sort-order="desc"
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                              <th data-field="code" data-align="center">Código</th>
+                                <th data-field="name" data-align="left">Contrato</th>
+                                <th data-field="partner_name" data-align="center">Cliente</th>
+                                <th data-field="nro_cuotas" data-align="center">Cuota actual</th>
+                                <th data-field="cuota_total" data-align="center">Total de cuotas</th>
+                                <th data-field="recurring_next_date" data-align="center" data-sortable="true">Próxima factura</th>
+                                <th data-field="recurring_rule_type" data-align="center">Frecuencia</th>
+                                <th data-field="date" data-align="center" data-sortable="true" data-sorter="dateSorter">Final del contrato</th>
+
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <script>
+                <!--
+                    TOTAL CANTIDAD LOCAL
+                -->
+                function localFormatter(rowsTable) {
+                  var amount = 0;
+
+                  amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.suma_local);
+                    }), function(memo, num){
+                    return memo + num; },0)
+
+                    return amount;
+                }
+
+                function dateSorter(a,b) {
+
+                <!-- rowsTable.sort(function(a, b) { -->
+                console.log(b)
+                  <!-- a = new Date(moment(a.date).format('DD/MM/YYYY'));
+                  b = new Date(moment(b.date).format('DD/MM/YYYY'));
+                  return a>b ? -1 : a< b ? 1 : 0; -->
+                <!-- }); -->
+}
+
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold"
+                        }
+                    };
+                };
+            </script>
+        </div>
+    </t>
+</template>

+ 81 - 0
static/src/reports/report_propiedades_inmobiliaria.xml

@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportPropiedadesInmobiliariaWidget">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title"> Propiedades </h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+                <div class="row">
+                    <!-- <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div> -->
+
+                    <div class="col-lg-3 supplier filter-style">
+                        <label>Propietario</label>
+                        <select id="current-supplier" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 state filter-style">
+                        <label>Estado</label>
+                        <select id="current-state" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                </div>
+
+                <div class="row">
+                    <div class="text-center" style="padding-top:20px;">
+                        <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                            Generar
+                        </button>
+                    </div>
+                    <br/>
+                </div>
+            </div>
+            <div class="report-form" style="display:none;">
+                <div id="toolbar">
+                    <button class="myButton print-report" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container" style="width:90%;">
+                    <table id="table"
+                        data-pagination="true"
+                        data-toggle="table"
+                        data-toolbar="#toolbar"
+                        data-show-columns="true"
+                        data-classes="table"
+                        data-search="true"
+                        data-show-export="true"
+                        data-show-toggle="true"
+                        data-pagination-detail-h-align="left"
+                        data-buttons-class="oe_button myButton"
+                        data-show-pagination-switch="true"
+                        data-page-size="10"
+                        data-search-on-enter-key="true"
+                        data-undefined-text=" "
+                        data-pagination-v-align="top"
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                              <th data-field="propietario_name" data-align="center">Propietario</th>
+                              <th data-field="name" data-align="left">Terreno</th>
+                              <th data-field="tamanho" data-align="left" data-visible="false">Tamaño</th>
+                              <th data-field="direccion" data-align="left">Dirección</th>
+                              <th data-field="precio" data-align="left">Precio Cuota</th>
+                              <th data-field="estado_name" data-align="left">Estado</th>
+                              <th data-field="descripcion" data-align="left">Descripción</th>
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </t>
+</template>

+ 5 - 0
static/src/xml/eiru_reporting.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<template xml:space="preserve">
+    
+</template>

+ 5 - 0
static/src/xml/eiru_reporting_base.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<template xml:space="preserve">
+    
+</template>

+ 23 - 0
templates.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+  <data>
+    <template id="eiru_reports_inmobiliaria_assets" inherit_id="eiru_assets.assets">
+      <xpath expr="." position="inside">
+        <link rel="stylesheet" href="/eiru_reports_inmobiliaria/static/src/css/custom.css"/>
+
+        <!-- configuration < main > -->
+        <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/main.js"/>
+        <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reporting_base.js"/>
+
+        <!-- ================================= inmobiliaria ========================================= -->
+
+
+        <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reports/report_contrato_inmobiliaria.js"/>
+        <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reports/report_comision_inmobiliaria.js"/>
+        <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reports/report_propiedades_inmobiliaria.js"/>
+
+
+      </xpath>
+    </template>
+  </data>
+</openerp>

+ 20 - 0
views/actions.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+
+		<record id="contrato_inmobiliaria_action" model="ir.actions.client">
+			<field name="name">Contratos</field>
+			<field name="tag">eiru_reports_inmobiliaria.contrato_inmobiliaria_action</field>
+		</record>
+
+		<record id="comision_inmobiliaria_action" model="ir.actions.client">
+			<field name="name">Comisiones</field>
+			<field name="tag">eiru_reports_inmobiliaria.comision_inmobiliaria_action</field>
+		</record>
+
+		<record id="propiedades_inmobiliaria_action" model="ir.actions.client">
+			<field name="name">Propiedades</field>
+			<field name="tag">eiru_reports_inmobiliaria.propiedades_inmobiliaria_action</field>
+		</record>
+	</data>
+</openerp>

+ 15 - 0
views/menus.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+  <data>
+    <!-- main menu name -->
+    <menuitem id="inmobiliaria_parent_menu" name="Inmobiliaria" parent="eiru_reports.sale_parent_menu" sequence="70"/>
+
+    <!-- sub menu -->
+
+    <menuitem id="contrato" parent="inmobiliaria_parent_menu" name="Contratos" action="contrato_inmobiliaria_action" sequence="1"/>
+    <menuitem id="comision" parent="inmobiliaria_parent_menu" name="Comisión sobre ventas" action="comision_inmobiliaria_action" sequence="2"/>
+    <menuitem id="propiedades" parent="inmobiliaria_parent_menu" name="Propiedades" action="propiedades_inmobiliaria_action" sequence="3"/>
+
+
+  </data>
+</openerp>