|
@@ -15,7 +15,7 @@
|
|
|
# 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/>.
|
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>. if(l.type='receipt','l.amount','0') AS amount_entrada,
|
|
|
# r.employee_id as 'amount_salida': fields.float('Total Salida', readonly=True),
|
|
|
# GROUP BY p.id ,l.partner_id,l.journal_id,l.create_date,l.amount_total,s.total
|
|
|
|
|
@@ -27,40 +27,46 @@ from openerp.tools.translate import _
|
|
|
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
|
|
|
|
|
|
|
|
-class diariocta_analisis(osv.osv):
|
|
|
- _name = "diariocta.analisis"
|
|
|
- _description = "Analisis de Entrada sobre Diario de Cuentas"
|
|
|
+class diarioacc_voucher(osv.osv):
|
|
|
+ _name = "diarioacc.voucher"
|
|
|
+ _description = "Analisis de Entrada y Salida sobre Diario de Cuentas"
|
|
|
_auto = False
|
|
|
|
|
|
_columns = {
|
|
|
'invoice_id': fields.char('N°Ref Cobro', readonly=True),
|
|
|
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
|
|
|
+ 'reference': fields.char('Ref #', readonly=True),
|
|
|
'type': fields.char('Tipo', readonly=True),
|
|
|
'currency_id': fields.many2one('res.currency', 'Moneda', required=True,readonly=True),
|
|
|
'amount_entrada': fields.float('Total Entrada', readonly=True),
|
|
|
+ 'amount_salida': fields.float('Total Salida', readonly=True),
|
|
|
+ 'saldo': fields.float('Saldo', readonly=True),
|
|
|
'date_x': fields.date('Date Order', readonly=True),
|
|
|
}
|
|
|
_order = 'date_x desc'
|
|
|
|
|
|
|
|
|
def init(self, cr):
|
|
|
- tools.sql.drop_view_if_exists(cr, 'diariocta_analisis')
|
|
|
+ tools.sql.drop_view_if_exists(cr,'diarioacc_voucher')
|
|
|
cr.execute("""
|
|
|
- CREATE OR REPLACE VIEW diariocta_analisis AS (
|
|
|
- SELECT row_number() over (ORDER BY l.id)as id,
|
|
|
+ CREATE OR REPLACE VIEW diarioacc_voucher AS (
|
|
|
+
|
|
|
+ SELECT row_number() over (ORDER BY l.id) as id,
|
|
|
r.name as invoice_id,
|
|
|
l.partner_id as partner_id,
|
|
|
+ l.reference as reference,
|
|
|
l.type as type,
|
|
|
l.payment_rate_currency_id as currency_id,
|
|
|
- l.amount AS amount_entrada,
|
|
|
+ (case when l.type = 'receipt' and l.amount>0 then l.amount else 0 end) as amount_entrada,
|
|
|
+ (case when l.type = 'payment' then l.amount else 0 end) as amount_salida,
|
|
|
+ ((case when l.type = 'payment' then l.amount else 0 end)-(case when l.type = 'receipt' and l.amount>0 then l.amount else 0 end)) as saldo,
|
|
|
l.date as date_x
|
|
|
FROM account_move r
|
|
|
- left join account_voucher l on (r.id=l.move_id)
|
|
|
+ left join account_voucher l on (r.id=l.move_id)
|
|
|
left join account_voucher_line p on (p.voucher_id=l.id)
|
|
|
-
|
|
|
- WHERE l.state='posted' and l.amount>0 and l.type='receipt'
|
|
|
- GROUP BY l.id,r.name,l.partner_id,l.type,l.payment_rate_currency_id ,l.amount,l.date
|
|
|
+ WHERE l.state='posted'
|
|
|
+ GROUP BY l.id,r.name,l.partner_id,l.reference,l.type,l.payment_rate_currency_id ,l.date
|
|
|
|
|
|
)
|
|
|
""")
|
|
|
-diariocta_analisis()
|
|
|
+diarioacc_voucher()
|