Commit fd348cb6 by Maria Agustina

modulo cobrador no telrminado

0 parents
# -*- coding: utf-8 -*-
from . import controllers
from . import models
from . import wizards
\ No newline at end of file
# -*- coding: utf-8 -*-
{
'name': "hgt_cobranza_mobile",
'summary': """
Módulo de Cobranza Móvil""",
'description': """
Módulo de Cobranza Móvil
""",
'author': "HGT SA",
'website': "http://www.yourcompany.com",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/odoo/addons/base/module/module_data.xml
# for the full list
'category': 'Management',
'version': '0.21.18.01',
# any module necessary for this one to work correctly
'depends': ['base', 'asw_cajas'],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'wizards/pago_administracion.xml',
'views/registro_cobros.xml',
'views/menu.xml',
],
# only loaded in demonstration mode
'demo': [
'demo/demo.xml',
],
'application': True,
'installable': True
}
\ No newline at end of file
# -*- coding: utf-8 -*-
from . import controllers
\ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import http
# class MyModule(http.Controller):
# @http.route('/my_module/my_module/', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/my_module/my_module/objects/', auth='public')
# def list(self, **kw):
# return http.request.render('my_module.listing', {
# 'root': '/my_module/my_module',
# 'objects': http.request.env['my_module.my_module'].search([]),
# })
# @http.route('/my_module/my_module/objects/<model("my_module.my_module"):obj>/', auth='public')
# def object(self, obj, **kw):
# return http.request.render('my_module.object', {
# 'object': obj
# })
\ No newline at end of file
<odoo>
<data>
<!-- -->
<!-- <record id="object0" model="my_module.my_module"> -->
<!-- <field name="name">Object 0</field> -->
<!-- <field name="value">0</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object1" model="my_module.my_module"> -->
<!-- <field name="name">Object 1</field> -->
<!-- <field name="value">10</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object2" model="my_module.my_module"> -->
<!-- <field name="name">Object 2</field> -->
<!-- <field name="value">20</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object3" model="my_module.my_module"> -->
<!-- <field name="name">Object 3</field> -->
<!-- <field name="value">30</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object4" model="my_module.my_module"> -->
<!-- <field name="name">Object 4</field> -->
<!-- <field name="value">40</field> -->
<!-- </record> -->
<!-- -->
</data>
</odoo>
\ No newline at end of file
# -*- coding: utf-8 -*-
from . import registro_cobros
from . import valores_cobros
from . import linea_pago_admin
from . import valores
\ No newline at end of file
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 hgt_linea_pago_admin(models.Model):
_name = 'hgt.linea_pago_admin'
monto = fields.Float(
string='Monto',
)
val_tipo = fields.Many2one(
string=u'Tipo',
comodel_name='asw.tipos_valores',
ondelete='set null',
)
\ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class hgt_registro_cobros(models.Model):
_name = 'hgt.registro_cobros'
cobrador = fields.Many2one(
string='Cobrador',
comodel_name='res.users',
ondelete='restrict',
)
caja = fields.Many2one(
string='Caja',
comodel_name='asw.caja',
ondelete='restrict',
)
total = fields.Float(
related = "caja.total_valores"
)
valores_cobro = fields.One2many(
string='Valores Cobrados',
comodel_name='hgt.valores_cobros',
inverse_name='registro',
)
recaudador_valor = fields.Many2many(
string='Valores',
comodel_name='asw.valores',
relation='cajas_valores_rel',
column1='val_monto',
column2='caja_nombre',
store= True,
)
@api.multi
def registrar_valores(self):
for val in self.valores_cobro:
if val.registrado == False:
val.crear_valor()
val.registrado = True
def pago_administracion(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'hgt.pago_administracion',
'view_mode': 'form',
'view_type': 'form',
'res_id': self.id,
'views': [(False, 'form')],
'target': 'new',
}
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class asw_valores(models.Model):
_inherit = 'asw.valores'
@api.model
def crear_valor_salida(self,monto,tvalor,caja_or):
valor = self.env['asw.valores']
datos = {
'val_monto': monto,
'val_tipo': tvalor.id,
'val_entrada_salida': 's',
'valor_caja_id': caja_or,
}
nuevo_valor_salida = valor.create(datos)
return nuevo_valor_salida
@api.model
def crear_valor_entrada(self,monto,tvalor,caja_des):
valor = self.env['asw.valores']
datos = {
'val_monto': monto,
'val_tipo': tvalor.id,
'val_entrada_salida': 'e',
'valor_caja_id': caja_des,
}
nuevo_valor_entrada = valor.create(datos)
return nuevo_valor_entrada
\ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class hgt_valores_cobros(models.Model):
_name = 'hgt.valores_cobros'
monto = fields.Float(
string='Monto',
)
registro = fields.Many2one(
string='Registro',
comodel_name='hgt.registro_cobros',
ondelete='restrict',
)
caja = fields.Many2one(
related='registro.caja'
)
fecha = fields.Datetime(
string='Fecha',
default=fields.Datetime.now,
)
registrado = fields.Boolean(
string=u'registrado como valor?',
default= False,
)
def crear_valor(self):
tvalor = self.env['asw.tipos_valores'].search([('tv_tipo','=', 'ef')], limit=1)
nvo_valor = self.env['asw.generador_valores'].crear_valor(self.fecha,False,tvalor.id,self.monto,'e',self.caja.id)
\ No newline at end of file
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_my_module_my_module,my_module.my_module,model_my_module_my_module,,1,0,0,0
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="0">
<!-- Elemento Root -->
<menuitem name="Recaudador" sequence='30' id="asw_recaudador"/>
<menuitem name="Cobros" id="asw_recaudador_cobros" parent="asw_recaudador"/>
<menuitem name="Registrar Cobros" id="asw_recaudador_cobros_registro" parent="asw_recaudador_cobros" action="action_registro_cobros_act_window"/>
</data>
</odoo>
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="0">
<record id="action_registro_cobros_act_window" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="name">Registro de Cobros</field>
<field name="res_model">hgt.registro_cobros</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
<field name="target">current</field>
<!-- <field name="domain">[]</field> idea: despues agregar domain de que solo el cobrador puede ver su caja y duplicar menu para que admin vea y asigne -->
</record>
<record id="view_registro_cobros_tree" model="ir.ui.view">
<field name="name">Registro de Cobros</field>
<field name="model">hgt.registro_cobros</field>
<field name="type">tree</field>
<field name="mode">primary</field>
<field name="priority" eval="16" />
<field name="arch" type="xml">
<tree>
<field name="cobrador"/>
<field name="caja"/>
<field name="total"/>
</tree>
</field>
</record>
<record id="view_registro_cobros_form" model="ir.ui.view">
<field name="name">Registro de Cobros</field>
<field name="model">hgt.registro_cobros</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<header>
<!-- <button type="action" name="%(action_pago_administracion_act_window)d" string="Pagar a Administración" class="btn btn-primary"
context="{'registro': id }"/> -->
<button type="object" name="pago_administracion" string="Pagar a Administración" class="btn btn-primary" context="{'registro': id }"/>
<button type="object" name="registrar_valores" string="Ingresar valores a caja" class="btn"/>
</header>
<group col="2">
<h1 colspan="2"> Registro de Cobros </h1>
<div colspan="2"><h3>Cobrador:<field name="cobrador" nolabel="1"/></h3></div>
<div colspan="2"><h3>Caja: <field name="caja" nolabel="1"/></h3></div>
</group>
<group col="2">
<h3>Valores:</h3>
<field name="valores_cobro" colspan="2" nolabel="1" >
<tree create="true" delete="true" edit="true" editable="bottom">
<field name="monto"/>
</tree>
</field>
<h3>Total en Caja: <field name="total" nolabel="1"/></h3>
</group>
</form>
</field>
</record>
</data>
</odoo>
from . import pago_administracion
No preview for this file type
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError
class hgt_pago_administracion(models.TransientModel):
_name = 'hgt.pago_administracion'
registro = fields.Many2one(
string='Registro',
comodel_name='hgt.registro_cobros',
ondelete='set null',
)
caja_origen = fields.Many2one(
related='registro.caja'
)
total = fields.Float(
related = "caja_origen.total_valores"
)
caja_destino = fields.Many2one(
string='Caja Destino',
comodel_name='asw.caja',
ondelete='restrict',
)
linea_valores = fields.Many2many(
string='Valores a transferir',
comodel_name='hgt.linea_pago_admin',
relation='linea_valores_pago_rel',
column1='hgt_linea_pago_admin_id',
column2='hgt_pago_administracion_id',
)
@api.onchange('linea_valores')
def restringir_monto(self):
total = 0
for line in self.linea_valores:
total = total + line.monto
if total > self.total:
raise ValidationError('El total ingresado en las líneas de valores es mayor que el monto disponible en caja')
def pagar_admin(self):
for line in self.linea_valores:
self.env['asw.valores'].crear_valor_salida(line.monto,line.val_tipo,self.caja_origen.id)
self.env['asw.valores'].crear_valor_entrada(line.monto,line.val_tipo,self.caja_destino.id)
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="0">
<act_window id="action_pago_administracion_act_window" name="Pago Administración"
src_model="hgt.registro_cobros" res_model="hgt.pago_administracion"
view_mode="form" target="new" multi="True"
context="{'registro': active_id, }"
/>
<record id="view_pago_administracion_form" model="ir.ui.view">
<field name="name">Pago Administración</field>
<field name="model">hgt.pago_administracion</field>
<field name="type">form</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<form>
<h1>Pago a Administración</h1>
<group col="2">
<h3 colspan="2" >Caja Origen:<field name="caja_origen" nolabel="1"/></h3>
<h3 colspan="2" >Caja Destino:<field name="caja_destino" nolabel="1"/></h3>
</group>
<group col="2">
<h3 colspan="2" >Monto Disponible en Caja:</h3>
<field colspan="2" name="total" nolabel="1"/>
</group>
<group col="2">
<h3 colspan="2" >Valores a transferir:</h3>
<field name="linea_valores" widget="one2many" colspan="2" nolabel="1">
<tree string="Caption" create="true" delete="true" edit="true" editable="bottom">
<field name="monto"/>
<field name="val_tipo"/>
</tree>
</field>
</group>
<footer>
<div style="text-align:center">
<button type="object" name="pagar_admin" class="btn btn-primary" string="Pagar"/>
</div>
</footer>
</form>
</field>
</record>
</data>
</odoo>
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!