Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Many2many ir.attachment Portal frontend widget V12

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
attachmentwidgetportalmany2manyV12
1 Répondre
8516 Vues
Avatar
notteccon

Hi!

I have a model with a Many2Many 'ir.attachment' field. The implementation in BackEnd is working as expected and the widget in the form is perfect. Now i need to implement a Portal form view and a Portal detail view (FrontEnd), it is implemented for all the fields but 'file_ids', i can not find the widget docu for the portal.

I checked the docu :

  • https://www.odoo.com/documentation/12.0/reference/javascript_reference.html#relational-fields

Also checked:

  • https://github.com/odoo/odoo/blob/12.0/odoo/addons/base/views/ir_qweb_widget_templates.xml

But just found "contact" template


Model
from odoo import fields, models, api
class MyModel(models.Model):
    _name = 'mymodule.mymodel'
    _inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
    _description = 'My Model'
    _order = 'create_date desc'
    _rec_name = 'name'

    name = fields.Char()
    description = fields.Char()
    file_ids = fields.Many2many(comodel_name='ir.attachment', string='Files')
View
<?xml version="1.0"?>
<odoo>
  <record id="view_mymodule_mymodel_form" model="ir.ui.view">
    <field name="name">MyModel Form</field>
    <field name="model">mymodule.mymodel</field>
    <field name="arch" type="xml">
      <form string="MyModel">
        <sheet>

          <field name="id" invisible="1"/>
          <group name="group_data" col="1">
            <group col="4">
              <field name="name"/>
              <field name="description"/>
            </group>
          </group>

          <field name="file_ids" widget="many2many_binary"/>

          <div class="oe_chatter">
            <field name="message_follower_ids" widget="mail_followers"/>
            <field name="message_ids" widget="mail_thread"/>
          </div>

        </sheet>
      </form>
    </field>
  </record>
</odoo>


Controller
from odoo import http, _
from odoo.addons.portal.controllers.portal import CustomerPortal

class MyModelCustomerPortal(CustomerPortal):
    @http.route(['/mymodule/mymodel/edit/<model("mymodule.mymodel"):mymodel>'], type='http', auth='user', website=True)
    def mymodel_portal_edit(self, mymodel, **post):
        if post:
            mymodel.sudo().write(post)
            return http.request.redirect('/mymodule/mymodel/view/%s' % slug(mymodel))
        response = http.request.render("mymodule.mymodel_portal_edit", {'mymodel': mymodel})
        return response

    @http.route(['/mymodule/mymodel/view/<model("mymodule.mymodel"):mymodel>'], type='http', auth='user', website=True)
    def mymodel_portal_view(self, mymodel, **post):
        response = http.request.render("mymodule.mymodel_portal_view", {'mymodel': mymodel})
        return response


Template
<odoo>
    <template id="mymodel_portal_edit" name="MyModel Form" >
        <t t-call="portal.portal_layout">
            <t t-set="breadcrumbs_searchbar" t-value="True"/>
            <t t-call="portal.portal_searchbar"> <t t-set="title">MyModel</t> </t>
            <t t-if="not mymodel"><p>There are currently no data for your account.</p></t>
            <h3>My Model</h3>
            <form t-attf-action="/mymodule/mymodel/edit/{{slug(mymodel)}}" method="post">
                <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
                <div class="row o_portal_details">
                    <div class="col-lg-12">
                        <div class="row">
                            <div class="col-lg-12">
                              <div t-if="error_message" class="alert alert-danger" role="alert">
                                  <t t-foreach="error_message" t-as="err"><t t-esc="err"/><br /></t>
                              </div>
                            </div>
                            <div t-attf-class="form-group col-xl-6">
                                <label class="col-form-label" for="name">Name</label>
                                <input type="text" name="name" t-att-value="mymodel.name" t-attf-class="form-control"/>
                            </div>
                            <div t-attf-class="form-group col-xl-6">
                                <label class="col-form-label" for="description">Description</label>
                                <input type="text" name="description" t-att-value="mymodel.description" t-attf-class="form-control"/>
                            </div>
                            <div t-attf-class="form-group col-xl-6">
                                <label class="col-form-label" for="file?ids">Files</label>
                               
<input type="file" class="form-control o_website_form_input" name="file_ids" t-options="{'widget': 'many2many_binary'}"/>
<!-- This render a simple input file selector -->
                            </div>
                        </div>
                        <div class="clearfix">
                            <button type="submit" class="btn btn-primary float-left mb32 ">
                                Save<span class="fa fa-long-arrow-right" />
                            </button>
                            <a t-attf-href="/mymodule/mymodel/view/{{slug(mymodel)}}" class="btn btn-danger float-right mb32 ">
                                Cancel <span class="fa fa-long-arrow-right" />
                            </a>
                        </div>
                    </div>
                </div>
            </form>
            <div class="oe_structure"/>
        </t>
    </template>
</odoo>


Thanks!


0
Avatar
Ignorer
Avatar
Ach
Meilleure réponse

You have managed to solve this problem. If yes, please share the final code

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Custom many2many_checkboxs
widget many2many
Avatar
Avatar
1
sept. 25
1803
Widget many2many - how disable 'Add an item'? Résolu
widget many2many
Avatar
Avatar
Avatar
4
juil. 25
24873
Change view of Many2many field
widget many2many
Avatar
Avatar
2
janv. 23
5510
Issue in many2many_binary widget unable to delete the attachment?.. Résolu
attachment many2many
Avatar
Avatar
1
mars 15
12076
Handle widget on extra field many2many
widget many2many handler
Avatar
0
août 23
2003
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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