Commit 2eb8b5b6 by Maria Agustina

389 (falta)

0 parents
from . import models
from . import generadores
# -*- coding: utf-8 -*-
###############################################################################
#
# Odoo, Open Source Management Solution
#
# Copyright (c) All rights reserved:
# (c) 2015 TM_FULLNAME
#
# 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
#
###############################################################################
{
'name': 'hgt_turnos',
'summary': 'hgt_turnos Module Project',
'version': '1.20.06.24',
'description': """
hgt_turnos Module Project.
==============================================
V0 - Adaptación de turnos a asw_cajas \n
""",
'author': 'ANAC SOFT',
'maintainer': 'ANAC SOFT',
'contributors': ['ANAC SOFT <ANAC SOFT@gmail.com>'],
'website': 'http://anacsoft.com',
'license': 'AGPL-3',
'category': 'Uncategorized',
'depends': [
'base',
'asw_cajas',
'report_aeroo'
],
'external_dependencies': {
'python': [
],
},
'data': [
# 'reportes/report_aeroo_turno.xml',
# 'security/reglas.xml',
'view/vista_turnos.xml',
# 'view/transferencia.xml',
# 'view/cierre_turno.xml',
# 'view/caja_view.xml',
# 'view/turno_view.xml',
# 'view/entrada_dinero.xml',
# 'view/valores.xml',
# 'view/user.xml',
'view/menu_turnos.xml',
'security/ir.model.access.csv'
],
'demo': [
],
'js': [
],
'css': [
],
'qweb': [
],
'images': [
],
'test': [
],
'installable': True,
'application': True,
}
\ No newline at end of file
from . import generador_valores_turno
\ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from datetime import datetime
class asw_generador_valores(models.AbstractModel):
_inherit = ['asw.generador_valores']
def crear_valor_turno_efectivo(self, importe, turno, motivo, entrada_salida, caja, con_turno=True):
print("entroooo a la fx crear valor turno efect")
valor = self.crear_valor_efectivo(turno.create_date, importe,entrada_salida,caja)
print("el valor creado es" + str(valor.val_monto))
id_turno = False
if(con_turno):
id_turno = turno.id
valor.write({
'val_nro_pago': motivo,
'val_caja': caja,
'val_turno' : id_turno
})
print("la caja es" + str(turno.turno_caja))
valor._compute_val_monto_valorizado()
def crear_valor_efectivo(self, fecha, importe, mov_caja, caja):
tvalor = self.env['asw.tipos_valores'].search([('tv_tipo','=', 'ef')], limit=1)
return self.crear_valor(fecha, False, tvalor.id, importe, mov_caja,caja)
\ No newline at end of file
from . import caja
from . import valores
from . import turno
from . import usuario
\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class asw_caja(models.Model):
_inherit = "asw.caja"
caja_turno = fields.One2many(
string = 'Turno',
comodel_name = 'asw.turno.caja',
inverse_name = 'turno_caja'
)
# -*- coding: utf-8 -*-
from openerp import api, models, fields
from odoo import exceptions
from datetime import date
from odoo.exceptions import UserError, ValidationError
class asw_turno(models.Model):
_name = 'asw.turno.caja'
_description = 'Turno'
_order = 'id desc'
_rec_name = 'turno_nombre'
_inherit = ['asw.generador_valores']
turno_fecha = fields.Date(
string = 'Fecha'
)
turno_usuario = fields.Many2one(
string = 'Usuario',
comodel_name = 'res.users',
ondelete = 'set null',
)
turno_caja = fields.Many2one(
string = 'Caja',
comodel_name = 'asw.caja',
ondelete = 'set null',
)
turno_estado = fields.Selection(
string = 'Estado',
selection = [
('borrador','Borrador'),
('abierto','Abierto'),
('cerrado','Cerrado')
],
default='borrador'
)
turno_nombre = fields.Char(
string = 'Nombre',
compute = '_compute_nombre',
)
active = fields.Boolean(
string = u'Está activo?',
default = True
)
tur_val_ids = fields.One2many(
string=u'Valores',
comodel_name='asw.valores',
inverse_name='val_turno',
)
turno_valor_ids = fields.Many2many(
related='turno_caja.caja_valor_ids'
)
turno_monto_inicial = fields.Float(
string = 'Monto inicial',
required=True,
)
turno_monto_final = fields.Float(
string = 'Monto final',
compute='_compute_turno_turno_monto_final',
)
turno_monto_final_real = fields.Float(
string = 'Monto final real',
readonly = True
)
turno_diferencia = fields.Float(
string = 'Diferencia',
readonly = True
)
@api.model
def default_get(self, vals):
result = super(asw_turno, self).default_get(vals)
result['turno_usuario'] = self.env.user.id
result['turno_fecha'] = date.today()
return result
def _compute_turno_turno_monto_final(self):
for record in self:
valores_efectivo = record.tur_val_ids.filtered(lambda val: val.val_tipo_elegido == 'ef' and
(val.val_comprobante.comp_estado == 'p' or len(val.val_comprobante) == 0))
#import ipdb; ipdb.set_trace()
record.turno_monto_final = sum(valores_efectivo.mapped('val_monto_valorizado'))
@api.model
def create(self, values):
result = super(asw_turno, self).create(values)
# self.validar_turnos_usuario(values)
values['turno_monto_final'] = values['turno_monto_inicial']
values['turno_estado'] = 'abierto'
ncaja = self.crear_caja(result.id)
result.crear_valor_inicial(ncaja)
print('SE CREO' + str(ncaja))
return result
def crear_caja(self,turno_id):
#creo caja
print('SE ENTRO A CREAR CAJA')
usuario= str(self.env.user.name)
fecha = str(date.today())
nom = "Caja de turno "+ usuario + " " + fecha
cvals={
'caja_nombre': nom,
'caja_active': True,
'caja_usuario_ids': [(4, self.env.user.id)],
'caja_turno': [(4, turno_id)],
}
nva_caja = self.env['asw.caja'].create(cvals)
return nva_caja.id
def crear_valor_inicial(self,caja):
print("entro a crear val inicial")
#esto queda en desuso puesto que la caja esta creada de cero:
# minicial_caja = self.turno_caja.get_total_efectivo()
# if(minicial_caja != 0):
# self.env['asw.valores'].crear_valor_turno_efectivo(
# minicial_caja, self, "Reseteo de Caja", 's', con_turno=False)
if(self.turno_monto_inicial != 0):
self.env['asw.generador_valores'].crear_valor_turno_efectivo(
self.turno_monto_inicial, self, "Monto Inicial Turno", 'e', caja)
def validar_turnos_usuario(self,values):
""" Checkea que no haya un turno invalido.
Un turno es valido cuando:
* Tiene un usuario, caja y fechas unicas
"""
def isInValues(key):
return (key in values and values[key] not in [False, ''])
if 'turno_usuario' not in values:
raise ValidationError('No se ingresó un usuario. Por favor vuelva a intentarlo')
usuario = self.env['res.users'].browse(values['turno_usuario'])
turno_activo = usuario.get_turno_activo()
if len(turno_activo) > 0:
raise UserError('Ya hay un turno abierto. Por favor ciérrelo y vuelva a intentarlo')
def _compute_nombre(self):
for record in self:
record.turno_nombre = "{} {}".format(record.id, record.turno_usuario.display_name)
# turno_comprobantes = fields.One2many(
# string = 'Comprobantes',
# comodel_name = 'asw.comprobante',
# inverse_name = 'comp_turno'
# )
# turno_resumen_ventas = fields.Many2many(
# string = 'Resumen comp. ventas',
# comodel_name = 'asw.resumen_comprobante',
# relation = 'asw_turno_resumen_ventas',
# column1 = 'turno_id',
# column2 = 'resumen_comprobante_id',
# compute = '_compute_resumen_ventas'
# )
# turno_resumen_recibos = fields.Many2many(
# string = 'Resumen recibos ventas',
# comodel_name = 'asw.resumen_recibo',
# relation = 'asw_turno_resumen_recibos',
# column1 = 'turno_id',
# column2 = 'resumen_recibo_id',
# compute = '_compute_resumen_recibos'
# )
# def _compute_resumen_recibos(self):
# for record in self:
# valores = record.tur_val_ids
# fp = valores.mapped('val_tipo')
# lineas_resumen = []
# for fpago in fp:
# vfpago = record.tur_val_ids.filtered(lambda a: a.val_tipo.id == fpago.id)
# valores = vfpago.mapped('val_monto_valorizado')
# total_valores = sum(valores)
# linea_resumen = self.env['asw.resumen_recibo'].create({
# 'rrec_tipo': fpago.id,
# 'rrec_monto': total_valores,
# 'rrec_cnt_cbte' : len(valores)
# })
# lineas_resumen.append(linea_resumen.id)
# record.turno_resumen_recibos = [(6,0,lineas_resumen)]
# def _compute_resumen_ventas(self):
# comprobantes_venta = self.filtrar_comprobantes('fac', 'e')
# lineas_resumen = []
# talonarios = comprobantes_venta.mapped('comp_talonario')
# for tal in talonarios:
# lineas_talonario = comprobantes_venta.filtered(lambda r: r.comp_talonario.id == tal.id)
# linea_resumen = self.env['asw.resumen_comprobante'].create({
# 'rcomp_talonario': tal.id,
# 'rcomp_monto': sum(lineas_talonario.mapped('comp_total_consigno')),
# 'rcomp_adeudado': sum(lineas_talonario.mapped('comp_adeudado_consigno')),
# 'rcomp_cnt_cbte' : len(lineas_talonario)
# })
# lineas_resumen.append(linea_resumen.id)
# self.turno_resumen_ventas = [(6,0,lineas_resumen)]
# def filtrar_comprobantes(self, menu, tipo):
# # : FILTRAR POR COMPROBANTES ADEUDADOS O PAGADOS, los cancelados dejarlos afuera
# comp_filtrados = self.turno_comprobantes.filtered(
# lambda a : (a.comp_tal_menu == menu and a.comp_tipo_comp == tipo))
# return comp_filtrados
\ No newline at end of file
# -*- coding: utf-8 -*-
###############################################################################
# License, author and contributors information in: #
# __manifest__.py file at the root folder of this module. #
###############################################################################
from odoo import models, fields, api, _
from odoo.exceptions import UserError, ValidationError
class res_users(models.Model):
_inherit = 'res.users'
def get_turno_activo(self):
turnos_del_dia = self.env['asw.turno.caja'].search([
('turno_usuario', '=', self.id),
('turno_estado', '=', 'abierto')
])
return turnos_del_dia
\ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class asw_valores(models.Model):
_inherit = 'asw.valores'
val_turno = fields.Many2one(
string=u'Turno',
comodel_name='asw.turno.caja',
ondelete='set null',
)
\ No newline at end of file
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="0">
<!-- Elemento Root -->
<menuitem name="Turnos" sequence='30' id="asw_turnos"/>
<menuitem name="Turnos" id="asw_turnos_turnos" parent="asw_turnos"/>
<menuitem name="Ingresar" id="asw_turnos_turnos_ingresar" parent="asw_turnos_turnos" action="action_turno_act_window_all"/>
</data>
</odoo>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="0">
<record id="view_form_turno" model="ir.ui.view">
<field name="name">Turno</field>
<field name="model">asw.turno.caja</field>
<field name="arch" type="xml">
<form string="Turno">
<header>
<field name="turno_estado" widget="statusbar"/>
</header>
<sheet>
<group string="Descripción" col="4" name="descripcion">
<field name="turno_usuario" force_save="1" readonly="1"/>
<field name="turno_fecha" readonly='1'/>
<field name="turno_caja" readonly='1'/>
</group>
<notebook>
<page string="Resumen" >
<group>
<field name="turno_monto_inicial"
attrs="{'readonly': [('turno_estado', '=', 'cerrado')]}"/>
<field name="turno_monto_final" />
<field name="turno_monto_final_real"/>
<field name="turno_diferencia" />
</group>
<!-- <group string="Resumen comp. ventas">
<field name="turno_resumen_ventas" nolabel='1'>
<tree>
<field name="rcomp_talonario"/>
<field name="rcomp_cnt_cbte" />
<field name="rcomp_monto" sum='1'/>
<field name="rcomp_adeudado" sum='1'/>
</tree>
</field>
</group>
<group string="Resumen recibos ventas">
<field name="turno_resumen_recibos" nolabel='1'>
<tree>
<field name="rrec_tipo"/>
<field name="rrec_monto" sum='1'/>
<field name="rrec_cnt_cbte" />
</tree>
</field>
</group>
-->
</page>
<page string="Valores" >
<!-- <field name="tur_val_ids" > -->
<field name="turno_valor_ids" >
<tree string="Caption" create="true" delete="true" edit="true">
<field name="val_tipo" />
<field name="val_nro_pago" />
<field name="val_entrada_salida" />
<field name="val_monto_valorizado" sum='1'/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="view_tree_turno" model="ir.ui.view">
<field name="name">Turno</field>
<field name="model">asw.turno.caja</field>
<field name="arch" type="xml">
<tree>
<field name="id" />
<field name="turno_usuario" />
<field name="turno_caja" />
<field name="turno_fecha" />
<field name="turno_estado" />
</tree>
</field>
</record>
<record id="view_search_turno" model="ir.ui.view">
<field name="name">Turno</field>
<field name="model">asw.turno.caja</field>
<field name="arch" type="xml">
<search>
<field name="id" />
<field name="turno_caja" />
<field name="turno_fecha" />
<field name="turno_usuario" />
<field name="turno_estado"/>
</search>
</field>
</record>
<record id="action_turno_act_window_all" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="name">Turno</field>
<field name="res_model">asw.turno.caja</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
<field name="target">current</field>
<!-- <field name="context">{
"search_default_turno_estado": "abierto",
"default_turno_estado": "abierto",
}</field> -->
</record>
</data>
</odoo>
\ No newline at end of file
File mode changed
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!