Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Extension of portal user information not working well

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
userportalextensionecommerce
2 Antwoorden
845 Weergaven
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
Annuleer
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
Beste antwoord

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
Annuleer
Avatar
Christoph Farnleitner
Beste antwoord

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
Annuleer
Chijioke Kanu
Auteur

@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
Auteur

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

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
IndexError: list index out of range from Customer Portal from invoice
portal ecommerce
Avatar
Avatar
Avatar
Avatar
Avatar
4
feb. 17
8672
Query Releted to Portal user openerp 7
user portal
Avatar
0
mrt. 15
4280
Portal User Spam Opgelost
user portal spam
Avatar
Avatar
Avatar
Avatar
Avatar
6
mei 25
2634
How to make portal users see navigation bar in website Opgelost
portal ecommerce navigation
Avatar
Avatar
1
jul. 19
6902
Odoo 9 Public and Portal 500: Internal Server Error on Product Pages.
public portal ecommerce
Avatar
0
nov. 16
3779
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

Website made with

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