Отношения в Odoo?Python

Программы на Python
Ответить
Anonymous
 Отношения в Odoo?

Сообщение Anonymous »

Я пытаюсь создать модуль Odoo для тестирования функций CRUD. Я пытаюсь использовать связь между двумя таблицами PostGreSQL, которые я уже создал. Сначала я использовал представление, чтобы Odoo мог связаться с базой данных, но он может только читать данные, а не удалять, создавать или обновлять, поэтому я решил перейти на использование реальных таблиц, но не могу заставить его работать, вот что у меня есть:

Код: Выделить всё

from odoo import models, fields

class PcClientes(models.Model):
_name = 'clientes.pc_clientes'
_description = 'Clientes PC'
_table = 'pc_clientes'  # Nombre de la tabla en la base de datos
_auto = False  # No queremos que Odoo cree la tabla automáticamente, ya existe

# Campos de la tabla pc_clientes
xempgen_id = fields.Char(string='EmpGen ID', required=True)
xcliente_id = fields.Char(string='Cliente ID', required=True)
xcod_postal = fields.Char(string='Código Postal')
xdomicilio = fields.Char(string='Domicilio')
xnif = fields.Char(string='NIF')
xnif_ue = fields.Char(string='NIF UE')
xnomabrev = fields.Char(string='Nombre Abreviado')
xnombre = fields.Char(string='Nombre', required=True)
xpais_id = fields.Char(string='ID País')
xper_fiscal = fields.Char(string='Período Fiscal')
xpoblacion = fields.Char(string='Población')
xprovincia_id = fields.Char(string='ID Provincia')
xlatitud = fields.Float(string='Latitud')
xlongitud = fields.Float(string='Longitud')
trial723 = fields.Char(string='Trial723')

# Relación con la tabla pl_clientes
pl_cliente_id = fields.Many2one(
'clientes.pl_clientes',
string="PL Cliente",
ondelete='cascade',
required=True
)

class PlClientes(models.Model):
_name = 'clientes.pl_clientes'
_description = 'Clientes PL'
_table = 'pl_clientes'  # Nombre de la tabla en la base de datos
_auto = False  # No queremos que Odoo cree la tabla automáticamente, ya existe

# Campos de la tabla pl_clientes
xcliente_id = fields.Char(string='Cliente ID', required=True)
xcod_docto = fields.Char(string='Código Documento')
xcopias_alb = fields.Integer(string='Copias Albarán')
xcopias_fact = fields.Integer(string='Copias Factura')
xmodalidad_id = fields.Char(string='ID Modalidad')
xpor_comision = fields.Float(string='Porcentaje Comisión')
xreferencia = fields.Char(string='Referencia')
xrepresentante_id = fields.Char(string='ID Representante')
xsecpref_id = fields.Char(string='ID SecPref')
xtipo_fact = fields.Integer(string='Tipo de Factura', required=True)
xempgen_id = fields.Char(string='EmpGen ID', required=True)
xempresa_id = fields.Char(string='Empresa ID', required=True)
xfax = fields.Char(string='Fax')
xtelefono = fields.Char(string='Teléfono')
xemail = fields.Char(string='Email')
xfecha_alta = fields.Datetime(string='Fecha Alta')
xfecha_baja = fields.Datetime(string='Fecha Baja')
xinternet = fields.Char(string='Internet')
xlangage = fields.Integer(string='Lenguaje')
xlangage_remplace = fields.Integer(string='Lenguaje Reemplazado')
xcopias_ped = fields.Integer(string='Copias Pedido')
xcredito = fields.Float(string='Crédito')
xctacon = fields.Char(string='Cta Con')
xctamayor = fields.Char(string='Cta Mayor')
xcyc_activo = fields.Integer(string='Cyc Activo')
xcyc_poliza = fields.Char(string='Cyc Póliza')
xdivisa_id = fields.Char(string='ID Divisa')
xdto_com = fields.Float(string='Dto. Comercial')
xcoment_albaran = fields.Char(string='Comentario Albarán')
xcoment_factura = fields.Char(string='Comentario Factura')
xcoment_pedido = fields.Char(string='Comentario Pedido')
xcontacto = fields.Char(string='Contacto')
xagrupa_alb = fields.Integer(string='Agrupa Albarán')
xalb_valorado = fields.Integer(string='Albarán Valorador')
xalta_modif = fields.Integer(string='Alta Modificada')
xcalificacion_id = fields.Char(string='ID Calificación')
xcargo = fields.Char(string='Cargo')
xrecibe_facturae = fields.Integer(string='Recibe Facturae')
xxjuego_id = fields.Char(string='ID Juego')
p856_tipo_tarifa = fields.Char(string='Tipo Tarifa')
p856_dto_metraje = fields.Float(string='Dto. Metraje')
p856_dto_tarifa = fields.Float(string='Dto.  Tarifa')
p856_agen_com_id = fields.Char(string='Agente Com')
p856_eti_metr_ext = fields.Char(string='Etiqueta Metr Ext')
p856_observaciones = fields.Char(string='Observaciones')
p856_cadena = fields.Char(string='Cadena')
p856_credito_aseg = fields.Float(string='Crédito Asegurado')
p856_credito_rioma = fields.Float(string='Crédito Rioma')
p856_crm_id = fields.Char(string='ID CRM')
p856_modificado = fields.Integer(string='Modificado')
p856_modificado_r = fields.Integer(string='Modificado R')
p856_dto_met_max = fields.Float(string='Dto. Metraje Max')
p856_dto_pie_max = fields.Float(string='Dto. Pie Max')
p856_entite = fields.Char(string='Entidad')
p856_pass_crm = fields.Char(string='Pass CRM')
p856_cerrado = fields.Integer(string='Cerrado')
p856_supervisor = fields.Char(string='Supervisor')
p856_tipo_cliente = fields.Integer(string='Tipo Cliente')
p856_fact_ftp = fields.Integer(string='Fact.  FTP')
p856_backoffice_id = fields.Char(string='ID Backoffice')
trial726 = fields.Char(string='Trial 726')

# Relación con la tabla pc_clientes
pc_cliente_id = fields.Many2one(
'clientes.pc_clientes',
string="PC Cliente",
ondelete='cascade',
required=True
)
Это мой файл models.py

Код: Выделить всё

    



clientes.list.view
clientes.pc_clientes












clientes.form.view
clientes.pc_clientes






















Clientes
clientes.pc_clientes
list,form








Это мое мнение.
Когда я запускаю сервер odoo, он выдает следующую ошибку:

Код: Выделить всё

Error while validating view near:




Field "pl_cliente_id.xfax" does not exist in model "clientes.pc_clientes"

View error context:
{'file': 'c:\\odoo\\modules\\clientes\\views\\templates.xml',
'line': 7,
'name': 'clientes.list.view',
'view': ir.ui.view(878,),
'view.model': 'clientes.pc_clientes',
'view.parent': ir.ui.view(),
'xmlid': 'clientes_list_view'}
Я новичок в Odoo, большое спасибо за вашу помощь, ребята

Подробнее здесь: https://stackoverflow.com/questions/792 ... ps-in-odoo
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»