Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How can I insert fields from differents classes?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
pythonodoov10
2 Răspunsuri
3752 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Sudhir Arya (ERP Harbor Consulting Services)

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

Imagine profil
Samo Arko
Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How to fix ImportError: cannot import name UNALTERABLE_COUNTRIES in odoo version10 Rezolvat
python odoov10
Imagine profil
Imagine profil
1
ian. 24
13886
Odoo 10 - Upload file constaraint
python xml odoov10
Imagine profil
0
apr. 17
3001
new python env
python
Imagine profil
0
mar. 25
2317
What means "Too many values to unpack" message? Rezolvat
python
Imagine profil
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
apr. 24
175773
have no data in screen. read data in my own module from different model
python
Imagine profil
0
dec. 23
2937
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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