Commit 5fcd283b by Maria Agustina

227 terminada

1 parent e5922bc5
# -*- coding: utf-8 -*-
from . import controllers
from . import models
\ No newline at end of file
......@@ -26,6 +26,7 @@
# 'security/ir.model.access.csv',
'views/salones.xml',
'views/mesas.xml',
'views/pedidosbar.xml',
'views/menu.xml',
],
# only loaded in demonstration mode
......
# -*- coding: utf-8 -*-
from . import salones
from . import mesas
\ No newline at end of file
from . import mesas
from . import pedidosbar
from . import linea_pedidos
\ No newline at end of file
No preview for this file type
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class hgt_linea_pedidos(models.Model):
_name = 'hgt.linea_pedidos'
#asumo que esto despues será un relacional ocn los productos disponibles
producto = fields.Char(
string='Producto',
)
cantidad = fields.Integer(
string='Cantidad',
default='1',
)
pedidosbar = fields.Many2one(
string='Pedido',
comodel_name='hgt.pedidosbar',
ondelete='restrict',
)
\ No newline at end of file
......@@ -4,15 +4,14 @@ from odoo import models, fields, api
class hgt_mesas(models.Model):
_name = 'hgt.mesas'
_rec_name='nombre'
nombre = fields.Char(
string="Nombre",
compute="obtener_nombre_mesa",
)
numero = fields.Integer(
string=u'Número de Mesa',
compute = "obtener_numero_mesa"
)
salon = fields.Many2one(
......@@ -21,17 +20,21 @@ class hgt_mesas(models.Model):
ondelete='restrict',
)
@api.onchange('numero')
def obtener_nombre_mesa(self):
sal = self.salon.nombre
nom = """{} - {}""".format(sal, self.numero)
self.nombre = nom
@api.onchange('salon')
def obtener_numero_mesa(self):
sal = self.salon
nro = len(sal.mesas)
self.numero = nro
if self.salon:
sal = self.salon
if sal.mesas:
nro = len(sal.mesas)
self.numero = nro
else:
self.numero = 1
......
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class hgt_pedidosbar(models.Model):
_name = 'hgt.pedidosbar'
#cliente,va tipo char o un relacional con clientes de otro modulo?
cliente = fields.Char(
string=u'Cliente',
default='Consumidor Final'
)
mesa = fields.Many2one(
string='Mesa',
comodel_name='hgt.mesas',
ondelete='restrict',
)
linea_pedido = fields.One2many(
string=u'Pedidos',
comodel_name='hgt.linea_pedidos',
inverse_name='pedidosbar',
)
\ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import models, fields, api, exceptions
import re
class hgt_salones(models.Model):
......@@ -24,17 +25,28 @@ class hgt_salones(models.Model):
inverse_name='salon',
)
def valido_letra(self,string):
match = re.match(r'^[A-Za-z ]*$', string)
if match:
return True
else:
return False
@api.model
def create(self,values):
if 'codigo' in values and len(values['codigo']) != 5 and values['codigo'].isalpha() == True:
if 'codigo' in values and len(values['codigo']) != 5:
raise exceptions.ValidationError("El código debe contar con 5 letras")
elif 'codigo' in values and self.valido_letra(values['codigo']) == False:
raise exceptions.ValidationError("El código debe contar con 5 letras, no números u otro caracter")
result=super(hgt_salones,self).create(values)
return result
@api.model
def write(self,values):
if 'codigo' in values and len(values['codigo']) != 5 and values['codigo'].isalpha() == True:
if 'codigo' in values and len(values['codigo']) != 5:
raise exceptions.ValidationError("El código debe contar con 5 letras")
elif 'codigo' in values and self.valido_letra(values['codigo']) == False:
raise exceptions.ValidationError("El código debe contar con 5 letras, no números u otro caracter")
result=super(hgt_salones,self).write(values)
return result
......
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
access_hgt_linea_pedidos,access_hgt_linea_pedidos,hgt_linea_pedidos,,1,1,1,1
access_hgt_mesas,access_hgt_mesas,hgt_mesas,,1,1,1,1
access_hgt_pedidosbar,access_hgt_pedidosbar,hgt_pedidosbar,,1,1,1,1
access_hgt_salones,access_hgt_salones,hgt_salones,,1,1,1,1
\ No newline at end of file
......@@ -13,7 +13,7 @@
<!-- Acciones finales-->
<menuitem name="Salones" sequence='10' id="hgt_salones" parent="hgt_bar_salones_salones" action='hgt_salones_action_window'/>
<menuitem name="Mesas" sequence='10' id="hgt_mesas" parent="hgt_bar_salones_mesas" action='hgt_mesas_action_window'/>
<menuitem name="Pedidos" sequence='10' id="hgt_pedidos" parent="hgt_bar_pedidos_pedidos" action=''/>
<menuitem name="Pedidos" sequence='10' id="hgt_pedidos" parent="hgt_bar_pedidos_pedidos" action='action_pedidosbar_act_window'/>
</data>
</odoo>
......@@ -32,9 +32,9 @@
<form>
<sheet>
<group col="4" string="Datos de la Mesa">
<field colspan="2" name="nombre"/>
<field colspan="2" name="numero"/>
<field colspan="2" name="salon"/>
<field colspan="2" name="salon" />
<field colspan="2" name="nombre" readonly="1" force_save="1" />
<field colspan="2" name="numero" readonly="1" force_save="1" />
</group>
</sheet>
</form>
......
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="0">
<record id="action_pedidosbar_act_window" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="name">Pedidos Bar</field>
<field name="res_model">hgt.pedidosbar</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
<field name="target">current</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Cree el primer Pedido</p>
</field>
</record>
<record id="view_pedidosbar_tree" model="ir.ui.view">
<field name="name">Pedidos</field>
<field name="model">hgt.pedidosbar</field>
<field name="type">tree</field>
<field name="mode">primary</field>
<field name="priority" eval="16" />
<field name="active" eval="True" />
<field name="arch" type="xml">
<tree>
<field name="cliente"/>
<field name="mesa"/>
</tree>
</field>
</record>
<record id="view_pedidosbar_form" model="ir.ui.view">
<field name="name">Pedidos</field>
<field name="model">hgt.pedidosbar</field>
<field name="type">form</field>
<field name="mode">primary</field>
<field name="priority" eval="16" />
<field name="active" eval="True" />
<field name="arch" type="xml">
<form>
<sheet>
<group string="Datos">
<field name="cliente"/>
<field name="mesa"/>
</group>
<group>
<field name="linea_pedido" nolabel="1">
<tree create="1" edit="1" editable="1">
<field name="producto"/>
<field name="cantidad"/>
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>
</data>
</odoo>
......@@ -34,6 +34,11 @@
<field colspan="2" name="nombre"/>
<field colspan="2" name="codigo"/>
</group>
<notebook>
<page string="Mesas">
<field name="mesas" nolabel="1" widget="many2many_tags"/>
</page>
</notebook>
</sheet>
</form>
</field>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!