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

Extension of portal user information not working well

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
userportalextensionecommerce
2 Respostas
852 Visualizações
Avatar
Chijioke Kanu

I heve been trying to extend the portal user information by adding some fields. At the odoo backend it works propery but at the frontend user dashboard when you want to save the data, it raises an error that says "Unknown field 'company_cac_number,company_registration_type,industry,business_description,company_website,company_email,company_phone,company_logo'"

Here are my codes:
1. __manifest__ 

{
'name': 'Partner Company Extension',
'version': '1.1',
'category': 'Contacts',
'summary': 'Adds company details fields to res.partner',
'depends': ['base', 'portal'],
'data': [
'views/partner_view.xml',
'views/portal_templates.xml',
],
'installable': True,
'application': False,
}

2. /controllers/portal .py

from odoo.addons.portal.controllers.portal import CustomerPortal
from odoo import http
from odoo.http import request


class CustomerPortalExtended(CustomerPortal):

def details_form_fields(self):
"""Extend portal details form fields with custom fields"""
fields = super().details_form_fields()
fields.extend([
'company_cac_number',
'company_registration_type',
'industry',
'business_description',
'company_website',
'company_email',
'company_phone',
'company_logo',
])
return fields

@http.route(['/my/account'], type='http', auth="user", website=True, methods=['POST'])
def details_form_submit(self, **kwargs):
# allow default processing first
response = super(CustomerPortalExtended, self).details_form_submit(**kwargs)
# then explicitly write our custom fields
partner = request.env.user.partner_id.sudo()
values = {k: v for k, v in kwargs.items() if k in self.details_form_fields()}
if values:
partner.write(values)
return response

3. models/partner .py

from odoo import models, fields

class ResPartner(models.Model):
_inherit = 'res.partner'

company_cac_number = fields.Char(string="Company CAC Number")
company_registration_type = fields.Selection([
('business_name', 'Business Name'),
('limited_liability', 'Limited Liability'),
('limited_by_guarantee', 'Limited by Guarantee'),
('incorporated_trustee', 'Incorporated Trustee')
], string="Company Type")
industry = fields.Char(string="Industry")
business_description = fields.Text(string="Business Description")
company_website = fields.Char(string="Company Website")
company_email = fields.Char(string="Company Email")
company_phone = fields.Char(string="Company Phone")
company_logo = fields.Binary(string="Company Logo")

4. /views/partner_view .xml

 

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_partner_form_inherit_company" model="ir.ui.view">
<field name="name">res.partner.form.company.extension</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<sheet position="inside">
<group string="Company Information">
<field name="company_cac_number"/>
<field name="company_registration_type"/>
<field name="industry"/>
<field name="business_description"/>
<field name="company_website"/>
<field name="company_email"/>
<field name="company_phone"/>
</group>
</sheet>
</field>
</record>
</odoo>

5. /views/portal_template .xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="portal_my_details_inherit" inherit_id="portal.portal_my_details">
<xpath expr="//div[@class='row o_portal_details']//div[@class='row']" position="inside">
<div class="form-group">
<label for="company_cac_number">CAC Number</label>
<input type="text" name="company_cac_number"
t-att-value="partner.company_cac_number or ''"
class="form-control"/>
</div>

<div class="form-group">
<label for="company_registration_type">Registration Type</label>
<select name="company_registration_type" class="form-select">
<option value="ltd" t-att-selected="partner.company_registration_type == 'ltd'">Limited</option>
<option value="enterprise" t-att-selected="partner.company_registration_type == 'enterprise'">Enterprise</option>
<option value="ngo" t-att-selected="partner.company_registration_type == 'ngo'">NGO</option>
</select>
</div>

<div class="form-group">
<label for="industry">Industry</label>
<input type="text" name="industry" t-att-value="partner.industry or ''" class="form-control"/>
</div>

<div class="form-group">
<label for="business_description">Business Description</label>
<textarea name="business_description" class="form-control"><t t-esc="partner.business_description"/></textarea>
</div>

<div class="form-group">
<label for="company_website">Website</label>
<input type="url" name="company_website" t-att-value="partner.company_website or ''" class="form-control"/>
</div>

<div class="form-group">
<label for="company_email">Email</label>
<input type="email" name="company_email" t-att-value="partner.company_email or ''" class="form-control"/>
</div>

<div class="form-group">
<label for="company_phone">Phone</label>
<input type="text" name="company_phone" t-att-value="partner.company_phone or ''" class="form-control"/>
</div>

<div class="form-group">
<label for="company_logo">Company Logo</label>
<input type="file" name="company_logo" class="form-control"/>
</div>
</xpath>
</template>
</odoo>


Thanks in anticipation!




0
Avatar
Cancelar
Dawid Gacek

I have deleted my post @Chijoke, as I misunderstood your question. I though it was related to Partner Form.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Melhor resposta

Hi,



Try the following,


1-Align the selection values


Update your portal template options to match your model’s selection keys:


<select name="company_registration_type" class="form-select">

    <option value="business_name" t-att-selected="partner.company_registration_type == 'business_name'">Business Name</option>

    <option value="limited_liability" t-att-selected="partner.company_registration_type == 'limited_liability'">Limited Liability</option>

    <option value="limited_by_guarantee" t-att-selected="partner.company_registration_type == 'limited_by_guarantee'">Limited by Guarantee</option>

    <option value="incorporated_trustee" t-att-selected="partner.company_registration_type == 'incorporated_trustee'">Incorporated Trustee</option>

</select>



2- Handle file upload for company_logo



In your controller:


import base64

@http.route(['/my/account'], type='http', auth="user", website=True, methods=['POST'])

def details_form_submit(self, **kwargs):

    response = super(CustomerPortalExtended, self).details_form_submit(**kwargs)

    partner = request.env.user.partner_id.sudo()

    values = {k: v for k, v in kwargs.items() if k in self.details_form_fields()}


    # Handle file upload

    file = request.httprequest.files.get('company_logo')

    if file:

        values['company_logo'] = base64.b64encode(file.read())


    if values:

        partner.write(values)

    return response


Hope it helps

0
Avatar
Cancelar
Avatar
Christoph Farnleitner
Melhor resposta

I don't know where you've got the idea of

def details_form_fields(self):
    super().details_form_fields()
    ...

from. Certainly not a thing since Odoo 16 - haven't checked earlier versions though. You're actually looking for _get_optional_fields() - or _get_mandatory_fields() if necessary, i.e.:

class CustomerPortalExtended(CustomerPortal):

    def _get_optional_fields(self):
        """Extend portal details form fields with custom fields"""
        fields = super()._get_optional_fields()
        fields.append(
            'company_cac_number',
            'company_registration_type',
            'industry',
            'business_description',
            'company_website',
            'company_email',
            'company_phone',
            'company_logo',
        )
        return fields

...

Also, the Registration Type in your portal template does not match the actual options of that selection field.

0
Avatar
Cancelar
Chijioke Kanu
Autor

@Christoph Farnleitner, please can you guide me exacly on how to achieve this?

Christoph Farnleitner

Just add that method to your controller file.

Chijioke Kanu
Autor

I did, upgraded the module then tried it again but still the same.

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
IndexError: list index out of range from Customer Portal from invoice
portal ecommerce
Avatar
Avatar
Avatar
Avatar
Avatar
4
fev. 17
8673
Query Releted to Portal user openerp 7
user portal
Avatar
0
mar. 15
4291
Portal User Spam Resolvido
user portal spam
Avatar
Avatar
Avatar
Avatar
Avatar
6
mai. 25
2638
How to make portal users see navigation bar in website Resolvido
portal ecommerce navigation
Avatar
Avatar
1
jul. 19
6908
Odoo 9 Public and Portal 500: Internal Server Error on Product Pages.
public portal ecommerce
Avatar
0
nov. 16
3782
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