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

How can I insert fields from differents classes?

S'inscrire

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

Cette question a été signalée
pythonodoov10
2 Réponses
3750 Vues
Avatar
portillo

Hello

How can I show in the view: id = "product_template_product_form_view" the total field = fields.Float ('total', compute = '_ getamount') of class class AccountTax (models.Model) ?

this is my code:

ratio.py :

from odoo import fields, models, api, tools


class ProductTemplate(models.Model):
_name = 'product.template'
_inherit = 'product.template'

pventa_iva = fields.Float('PVP (IVA)')
pcompra_iva = fields.Float('COSTE (IVA)')
ratio = fields.Float('Ratio')
iva = fields.Integer('datos iva', compute='_venta_iva')
cant = fields.Many2many(comodel_name='account.tax', string='Tasas')
impuestos = fields.Float(compute='_compute_impuestos')

@api.depends('taxes_id')
def _venta_iva(self):
for record in self:
record.iva = record.taxes_id


class AccountTax(models.Model):
_name = 'account.tax'
_inherit = 'account.tax'

total = fields.Float('total', compute='_getamount')

@api.depends('amount')
def _getamount(self):
for record in self:
record.total = record.amount


And this is my view:

<record id="product_template_product_form_view" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="list_price" position="before">
<field name="ratio"/>
<!-- <field name="amount" ref="account.view_tax_form"/> -->
</field>
<field name="list_price" position="after">
<field name="pventa_iva"/>
</field>
<field name="uom_id" position="before">
<field name="pcompra_iva"/>
<field name="iva"/>
<span t-esc="o._getamount"/>
<!-- <field name="total" ref="vista_iva"/>-->
<field name="cant"/>
<field name="impuestos"/>
<field name="taxes_id" widget="many2many_tags" on_change="1" can_create="true" can_write="true" modifiers="{}"/>
</field>
</field>
</record>

<record id="vista_iva" model="ir.ui.view">
<field name="name">vista.iva</field>
<field name="model">account.tax</field>
<field name="inherit_id" ref="account.view_tax_form"/>
<field name="arch" type="xml">
<field name="amount" position="after">
<field name="total"/>
</field>
</field>
</record>
0
Avatar
Ignorer
Sudhir Arya (ERP Harbor Consulting Services)

Would you please share the issue you are facing in this code?

Avatar
Samo Arko
Meilleure réponse

Hm... for Many2many relation I can't say. Are you using the relation correctly? Try using a computed field and get the values with a method that computes all data in the relation.

The One2many and Many2one relations you have other options to get data. One2many you can use display a list of children.

In Many2one you can use related to show fields from parent 

total = fields.Float(related='<field with relation>.total')

 and then you can use that field in the view.

Look at this widgets, maybe one can help you

https://odooforbeginnersblog.wordpress.com/2017/03/09/widgets-in-odoo/

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é
How to fix ImportError: cannot import name UNALTERABLE_COUNTRIES in odoo version10 Résolu
python odoov10
Avatar
Avatar
1
janv. 24
13886
Odoo 10 - Upload file constaraint
python xml odoov10
Avatar
0
avr. 17
3001
new python env
python
Avatar
0
mars 25
2295
What means "Too many values to unpack" message? Résolu
python
Avatar
Avatar
Avatar
Avatar
Avatar
4
avr. 24
175751
have no data in screen. read data in my own module from different model
python
Avatar
0
déc. 23
2936
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