|
@@ -0,0 +1,93 @@
|
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
|
+##############################################################################
|
|
|
|
+#
|
|
|
|
+# OpenERP, Open Source Management Solution
|
|
|
|
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
+#
|
|
|
|
+# This program is free software: you can redistribute it and/or modify
|
|
|
|
+# it under the terms of the GNU Affero General Public License as
|
|
|
|
+# published by the Free Software Foundation, either version 3 of the
|
|
|
|
+# License, or (at your option) any later version.
|
|
|
|
+#
|
|
|
|
+# This program is distributed in the hope that it will be useful,
|
|
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+# GNU Affero General Public License for more details.
|
|
|
|
+#
|
|
|
|
+# You should have received a copy of the GNU Affero General Public License
|
|
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
+#
|
|
|
|
+##############################################################################
|
|
|
|
+
|
|
|
|
+from openerp import tools
|
|
|
|
+from openerp.osv import fields, osv
|
|
|
|
+from datetime import datetime
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class invoice_reportgral(osv.osv):
|
|
|
|
+ _name = "invoice.reportgral"
|
|
|
|
+ _description = "Facturas - Analisis"
|
|
|
|
+ _auto = False
|
|
|
|
+ _rec_name = 'date'
|
|
|
|
+
|
|
|
|
+ _columns = {
|
|
|
|
+ 'date': fields.date('Date Order', readonly=True),
|
|
|
|
+ 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
|
|
|
|
+ 'supplier_invoice_number':fields.char('N° Factura', readonly=True),
|
|
|
|
+ 'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
|
|
|
+ 'name': fields.char('Descripcion', readonly=True),
|
|
|
|
+ 'product_qty':fields.integer('Product Quantity', readonly=True),
|
|
|
|
+ 'journal_id': fields.many2one('account.journal', 'Journal', readonly=True),
|
|
|
|
+ 'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
|
|
|
+ 'user_id':fields.many2one('res.users', 'Salesperson', readonly=True),
|
|
|
|
+ 'price_total': fields.float('Total Without Tax', readonly=True),
|
|
|
|
+ 'currency_id': fields.many2one('res.currency', 'Moneda',readonly=True),
|
|
|
|
+ 'state': fields.selection([
|
|
|
|
+ ('draft','Draft'),
|
|
|
|
+ ('proforma','Pro-forma'),
|
|
|
|
+ ('proforma2','Pro-forma'),
|
|
|
|
+ ('open','Open'),
|
|
|
|
+ ('paid','Done'),
|
|
|
|
+ ('cancel','Cancelled')
|
|
|
|
+ ], 'Invoice Status', readonly=True),
|
|
|
|
+ 'account_id': fields.many2one('account.account', 'Account',readonly=True),
|
|
|
|
+ 'account_line_id': fields.many2one('account.account', 'Account Line',readonly=True),
|
|
|
|
+ }
|
|
|
|
+ _order = 'date desc'
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ def init(self, cr):
|
|
|
|
+ tools.drop_view_if_exists(cr, 'invoice_reportgral')
|
|
|
|
+ cr.execute("""
|
|
|
|
+ create or replace view invoice_reportgral as (
|
|
|
|
+ select
|
|
|
|
+ min(ail.id) AS id,
|
|
|
|
+ ai.date_invoice AS date,
|
|
|
|
+ ai.partner_id AS partner_id,
|
|
|
|
+ ai.supplier_invoice_number AS supplier_invoice_number,
|
|
|
|
+ ail.product_id AS product_id,
|
|
|
|
+ ail.name AS name,
|
|
|
|
+ sum(ail.quantity) as product_qty,
|
|
|
|
+ ai.journal_id,
|
|
|
|
+ ai.company_id,
|
|
|
|
+ ai.user_id,
|
|
|
|
+ ai.state,
|
|
|
|
+ ai.currency_id,
|
|
|
|
+ ai.account_id,
|
|
|
|
+ ail.account_id AS account_line_id,
|
|
|
|
+ sum(ail.quantity * ail.price_unit) as price_total
|
|
|
|
+ from account_invoice_line ail
|
|
|
|
+ JOIN account_invoice ai ON ai.id = ail.invoice_id
|
|
|
|
+ JOIN res_partner partner ON ai.commercial_partner_id = partner.id
|
|
|
|
+ LEFT JOIN product_product pr ON pr.id = ail.product_id
|
|
|
|
+ left JOIN product_template pt ON pt.id = pr.product_tmpl_id
|
|
|
|
+ LEFT JOIN product_uom u ON u.id = ail.uos_id
|
|
|
|
+ where ai.type = 'in_invoice'
|
|
|
|
+ GROUP BY ail.product_id, ai.date_invoice,
|
|
|
|
+ ai.partner_id,ail.name,ai.currency_id,ai.supplier_invoice_number, ai.journal_id,
|
|
|
|
+ ai.user_id, ai.company_id, ai.state, pt.categ_id,
|
|
|
|
+ ai.account_id, ail.account_id)
|
|
|
|
+ """)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|