Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

How to create/insert multiple row in single action?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
createoverrideodooV8
2 Respostas
18196 Visualizações
Avatar
YOPI ANGI

I have some case where single data from form submitted have posibitilies become multiple row (data/dicts) after manipulation. I am trying to override create method and put it in loop, but after test in website, i got warning message like this.

@api.returns('self', lambda value: value.id)

AttributeError: 'list' object has no attribute 'id'

here my code :

class Test(models.Model):

...

@api.model

def create(self, values):

test_id = self._manipulate_data(values)

res_id = []

if len(test_id) > 0:

for value_id in test_id:

res_id.append(super(Test, self).create(value_id))

return res_id

return super(Test, self).create(values)

res_id containing values like this : [test(160,), test(161,), test(162,)]

1
Avatar
Cancelar
Avatar
Bole
Melhor resposta

here is what happend in pseudo code (human readable translated) :

- original create method recived values, 
- then you 'manipulate' those valuse and put it in test_id ( by naming convention it should be _ids.. butok) 
- after that you check if you have elements in test_id list and for each value in list you try to call create...
that is no good... 
 

if create recived values (in whatever form : list, dict tuple.. ) 
you super class call should be passed the same form of vals... 

in your case : recived values ( one variable, ) returning correct super call only if test_id has no values.. 
but if it has some vals.. it trys to return a list of super calls... 

think again and modify your _manipulate_data method to do whatever, but one the data is ready for next step.. it should be in same form (modified or not) as the entered.. 


one more thing , and this might be the most important part... 
create method can be run on ONE record only, and it MUST return ONE ID of newly created recor, or False if record was not created...
 

hope it helps :)

0
Avatar
Cancelar
Avatar
YOPI ANGI
Autor Melhor resposta

Bole, thanks a lot for advice. :)

I desperate after doing lot of experiments for this case. Before pushing the creation in create method, i implemented it in function workflow but it seems not work too (in function workflow, i put self.create(data_manipulate) inside loop. After debug, i found that the original data submitted from form is process first followed my manipulated data).

i make some modification, like this:

@api.model

def create(self, values):

test_id = self._manipulate_data(values)

if len(test_id) > 0:

for value_id in test_id:

res_id = super(Test, self).create(value_id)

return res_id

return super(Test, self).create(values)

this code is work, but i dont know, it's a good code or bad code.

1
Avatar
Cancelar
Bole

well .. you should try writing a method wich is not create, but some other.. in wich you will loop / iterate over some data, modify/prepare data.. and from that method ( from loop or outside loop) call create method.. (just pass ready vals to create... that would be preffered way to achieve what yu need...

YOPI ANGI
Autor

thanks bole, i will try it :)

Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
[Odoo 8] override function
override odooV8
Avatar
Avatar
1
jul. 15
4108
[odoo 8]: How set value of one2many field by overriding create method with api coding standard? Resolvido
one2many create api override odooV8
Avatar
Avatar
2
dez. 20
9201
Override create method with sudo() Resolvido
create override sudo()
Avatar
Avatar
1
abr. 24
579
How to override a default module using a custom module (e.g. override the 'web' module in order to modify the login screen & rem Resolvido
templates override odooV8
Avatar
Avatar
Avatar
2
dez. 23
24623
[Solved] Error when clicking on create - Odoo 8 Resolvido
error create odooV8
Avatar
Avatar
Avatar
2
jan. 16
4723
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now