Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Maria Agustina
/
hgt_cobranzas
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 30a0bc8d
authored
2021-06-08 09:28:26 -0300
by
Maria Agustina
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1427 terminada
1 parent
a0970c53
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
8 deletions
models/__pycache__/cobros.cpython-36.pyc
models/__pycache__/linea_deuda.cpython-36.pyc
models/cobros.py
models/linea_deuda.py
views/cobros.xml
models/__pycache__/cobros.cpython-36.pyc
View file @
30a0bc8
No preview for this file type
models/__pycache__/linea_deuda.cpython-36.pyc
View file @
30a0bc8
No preview for this file type
models/cobros.py
View file @
30a0bc8
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
from odoo.exceptions import UserError
from
odoo.exceptions
import
UserError
from
odoo
import
models
,
fields
,
api
from
odoo
import
models
,
fields
,
api
#
from datetime import datetime
from
datetime
import
datetime
class
vnt_cobros
(
models
.
Model
):
class
vnt_cobros
(
models
.
Model
):
_name
=
'vnt.cobros'
_name
=
'vnt.cobros'
_inherit
=
[
'asw.generador_comprobante'
,
'asw.action.manager'
]
co_cliente
=
fields
.
Many2one
(
co_cliente
=
fields
.
Many2one
(
string
=
'Cliente'
,
string
=
'Cliente'
,
...
@@ -42,6 +43,13 @@ class vnt_cobros(models.Model):
...
@@ -42,6 +43,13 @@ class vnt_cobros(models.Model):
default
=
False
,
default
=
False
,
)
)
co_estado
=
fields
.
Selection
(
string
=
u'Estado Cobro'
,
selection
=
[(
'b'
,
'Borrador'
),
(
'a'
,
'Adeudado'
),
(
'p'
,
'Pagado'
),(
'c'
,
'Cancelado'
)],
readonly
=
True
,
default
=
'b'
,
store
=
True
)
#Calculos de totales
#Calculos de totales
@api.depends
(
'co_lin_deuda'
)
@api.depends
(
'co_lin_deuda'
)
...
@@ -72,8 +80,109 @@ class vnt_cobros(models.Model):
...
@@ -72,8 +80,109 @@ class vnt_cobros(models.Model):
self
.
co_deucarg
=
True
self
.
co_deucarg
=
True
#recupero comprobantes de venta, adeudados, con el cliente seleccionado
#recupero comprobantes de venta, adeudados, con el cliente seleccionado
comp_venta_adeud
=
self
.
env
[
'asw.comprobante'
]
.
search
([(
'comp_talonario.tal_menu'
,
'='
,
'fac'
),(
'comp_tipo_comp'
,
'='
,
'e'
),(
'comp_estado'
,
'='
,
'a'
),(
'comp_cliente'
,
'='
,
self
.
co_cliente
.
id
)])
comp_venta_adeud
=
self
.
env
[
'asw.comprobante'
]
.
search
([(
'comp_talonario.tal_menu'
,
'='
,
'fac'
),(
'comp_tipo_comp'
,
'='
,
'e'
),(
'comp_estado'
,
'='
,
'a'
),(
'comp_cliente'
,
'='
,
self
.
co_cliente
.
id
)])
for
comp
in
comp_venta_adeud
:
if
comp_venta_adeud
:
nva_linea
=
self
.
env
[
'vnt.linea_deuda'
]
.
create
({
'ld_factura'
:
comp
.
id
,
'ld_cobros'
:
self
.
id
})
for
comp
in
comp_venta_adeud
:
nva_linea
=
self
.
env
[
'vnt.linea_deuda'
]
.
create
({
'ld_factura'
:
comp
.
id
,
'ld_cobros'
:
self
.
id
})
else
:
raise
UserError
(
"No hay deudas registradas del cliente seleccionado"
)
def
volver_borrador
(
self
):
self
.
co_estado
=
'b'
def
procesar
(
self
):
if
self
.
co_total
==
0
:
raise
UserError
(
'No hay valores seleccionados a cobrar'
)
else
:
for
li
in
self
.
co_lin_deuda
:
if
li
.
ld_select
:
if
li
.
ld_cobro
not
in
[
'todo'
,
'negociado'
,
'perdido'
]:
raise
UserError
(
'Debe elegir un modo de cobro para cada línea seleccionada'
)
self
.
co_estado
=
'a'
def
pagar_deuda
(
self
):
for
li
in
self
.
co_lin_deuda
:
if
li
.
ld_select
:
#paga factura original
fac_id
=
li
.
ld_factura
.
id
fac
=
self
.
env
[
'asw.comprobante'
]
.
search
([(
'id'
,
'='
,
fac_id
)])
fac
.
comp_estado
=
'p'
#obtener total. si hay interes se hace nota de debito
total_int
=
li
.
ld_interes
if
(
total_int
!=
0.0
):
#crear notas de debito
tal_original
=
fac
.
comp_talonario
tal_letra
=
tal_original
.
tal_letra
tal_pto
=
tal_original
.
tal_pto_vta
referencia
=
'Nota de débito del comprobante : '
+
fac
.
comp_talonario
.
tal_codigo
+
"/"
+
fac
.
comp_nro_letras
#crear talonario con mismo pto de venta y letra
tipo_comprobante
=
self
.
env
[
'asw.tipo_comprobante'
]
.
search
([(
'tc_descripcion'
,
'='
,
'NOTA DE DEBITO A'
)])
talonario_nvo
=
self
.
env
[
'asw.talonario'
]
.
create
({
'tal_pto_vta'
:
tal_pto
,
'tal_letra'
:
tal_letra
,
'tal_codigo'
:
"NDEB"
+
tal_original
.
tal_codigo
+
str
(
self
.
id
),
'tal_descripcion'
:
"NDEB-"
+
tal_original
.
tal_descripcion
+
str
(
self
.
id
),
'tal_tipo'
:
tal_original
.
tal_tipo
,
'tal_menu'
:
tal_original
.
tal_menu
,
})
talonario_nvo
.
tal_tpc_id
=
tipo_comprobante
.
id
contra_comprobante
=
self
.
generar_comprobante
(
talonario
=
talonario_nvo
,
cliente
=
fac
.
comp_cliente
,
total
=
total_int
,
referencia
=
referencia
,
comp_estado
=
fac
.
comp_estado
,
comp_nro_letras
=
fac
.
comp_nro_letras
,
comp_moneda
=
fac
.
comp_moneda
.
id
,
comp_nota_credito
=
fac
.
id
,
)
print
(
"se genero nuevo comprobante? de id "
+
str
(
contra_comprobante
.
id
))
contra_comprobante
.
comp_fecha_validacion
=
datetime
.
today
()
#crear lineas nd
linea_comp
=
self
.
env
[
'asw.linea_comprobante'
]
.
create
({
'lcp_descripcion_producto'
:
referencia
,
'lcp_comprobante'
:
contra_comprobante
.
id
,
'lcp_importe'
:
total_int
})
print
(
"se genero nueva linea de comprobante? de id "
+
str
(
linea_comp
.
id
))
# contra_comprobante.comp_linea_facturas = (4,linea_comp.id)
#asociar nd a factura original
fac
.
write
({
'comp_nota_credito'
:
contra_comprobante
.
id
})
#asociar nd a linea deuda tb
li
.
ld_nd
=
contra_comprobante
.
id
self
.
co_estado
=
'p'
def
cancelar
(
self
):
self
.
co_estado
=
'c'
#y marcar comprobantes como adeudados de nuevo
#cancelar notas de debito
for
li
in
self
.
co_lin_deuda
:
if
li
.
ld_select
:
fac_id
=
li
.
ld_factura
.
id
fac
=
self
.
env
[
'asw.comprobante'
]
.
search
([(
'id'
,
'='
,
fac_id
)])
fac
.
comp_estado
=
'a'
if
li
.
ld_nd
:
nd_id
=
li
.
ld_nd
.
id
nd
=
self
.
env
[
'asw.comprobante'
]
.
search
([(
'id'
,
'='
,
nd_id
)])
nd
.
comp_fecha_cancelacion
=
datetime
.
today
()
...
...
models/linea_deuda.py
View file @
30a0bc8
...
@@ -45,6 +45,10 @@ class vnt_linea_deuda(models.Model):
...
@@ -45,6 +45,10 @@ class vnt_linea_deuda(models.Model):
ondelete
=
'set null'
,
ondelete
=
'set null'
,
)
)
ld_co_estado
=
fields
.
Selection
(
related
=
'ld_cobros.co_estado'
,
)
ld_interes
=
fields
.
Float
(
ld_interes
=
fields
.
Float
(
string
=
u'Total Interés'
,
string
=
u'Total Interés'
,
compute
=
'_compute_ld_interes'
,
compute
=
'_compute_ld_interes'
,
...
...
views/cobros.xml
View file @
30a0bc8
...
@@ -40,6 +40,12 @@
...
@@ -40,6 +40,12 @@
<!--<sheet>-->
<!--<sheet>-->
<header>
<header>
<button
type=
"object"
class=
"oe_highlight"
name=
"traer_ld"
string=
"Cargar Deudas"
attrs=
"{ 'invisible' : ['|',('co_deucarg','=',True),('co_cliente','=',False)]}"
/>
<button
type=
"object"
class=
"oe_highlight"
name=
"traer_ld"
string=
"Cargar Deudas"
attrs=
"{ 'invisible' : ['|',('co_deucarg','=',True),('co_cliente','=',False)]}"
/>
<button
name=
"procesar"
string=
"Procesar"
type=
"object"
class=
'btn btn-primary'
attrs=
"{'invisible':[('co_estado','in',['a','p','c'])]}"
/>
<button
name=
"pagar_deuda"
string=
"Pagar"
type=
"object"
class=
'btn btn-primary'
attrs=
"{'invisible':[('co_estado','in',['b','p','c'])]}"
/>
<button
name=
"cancelar"
string=
"Cancelar"
type=
"object"
class=
'btn btn-primary'
attrs=
"{'invisible':[('co_estado','in',['b','a','c'])]}"
/>
<button
name=
"volver_borrador"
string=
"Volver a Borrador"
type=
"object"
class=
'btn btn-primary'
attrs=
"{'invisible':[('co_estado','in',['b','p','c'])]}"
/>
<field
name=
"co_estado"
widget=
"statusbar"
/>
<field
invisible=
"1"
name=
"co_deucarg"
/>
<field
invisible=
"1"
name=
"co_deucarg"
/>
</header>
</header>
<group
col=
"2"
string=
"Cliente y resumen"
>
<group
col=
"2"
string=
"Cliente y resumen"
>
...
@@ -57,14 +63,16 @@
...
@@ -57,14 +63,16 @@
<field
name=
"ld_total"
readonly=
"1"
/>
<field
name=
"ld_total"
readonly=
"1"
/>
<field
name=
"ld_interes"
readonly=
"1"
/>
<field
name=
"ld_interes"
readonly=
"1"
/>
<field
name=
"ld_fecha_calculo"
readonly=
"1"
/>
<field
name=
"ld_fecha_calculo"
readonly=
"1"
/>
<field
name=
"ld_co_estado"
invisible=
"1"
/>
<!-- <field name="ld_fecha_vto" editable="0" readonly="1" />
<!-- <field name="ld_fecha_vto" editable="0" readonly="1" />
<field name="ld_estado" editable="0" readonly="1" />
<field name="ld_estado" editable="0" readonly="1" />
<field name="ld_total" readonly="1" /> -->
<field name="ld_total" readonly="1" /> -->
<field
name=
"ld_cobro"
readonly=
"1"
/>
<field
name=
"ld_cobro"
readonly=
"1"
/>
<button
type=
"object"
class=
"btn btn-primary"
name=
"cobrar_todo"
string=
"Cobrar Todo"
/>
<button
type=
"object"
class=
"btn btn-primary"
name=
"cobrar_todo"
string=
"Cobrar Todo"
attrs=
"{'invisible':[('ld_co_estado','in',['a','p','c'])]}"
/>
<button
type=
"object"
class=
"btn btn-primary"
name=
"cobrar_negociado"
string=
"Cobro Negociado"
/>
<button
type=
"object"
class=
"btn btn-primary"
name=
"cobrar_negociado"
string=
"Cobro Negociado"
attrs=
"{'invisible':[('ld_co_estado','in',['a','p','c'])]}"
/>
<button
type=
"object"
class=
"btn btn-primary"
name=
"interes_perdido"
string=
"Interés Perdido"
/>
<button
type=
"object"
class=
"btn btn-primary"
name=
"interes_perdido"
string=
"Interés Perdido"
attrs=
"{'invisible':[('ld_co_estado','in',['a','p','c'])]}"
/>
<field
name=
"ld_select"
/>
<field
name=
"ld_select"
attrs=
"{'readonly':[('ld_co_estado','in',['a','p','c'])]}"
/>
<field
name=
"ld_nd"
readonly=
"1"
attrs=
"{'invisible':[('ld_co_estado','in',['a','b','c'])]}"
/>
</tree>
</tree>
</field>
</field>
</page>
</page>
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment