Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to post a change log message for relational One2many fields?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
10.0
3 Respostes
8768 Vistes
Avatar
Yousef Al-Hadhrami

Dear Community,

I have the o_chatter located on the main record view to post changes to fields

<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="message_ids" widget="mail_thread">
</div>

Right now when I change char fields such as name, it will post a message on the chatter saying that 

Name: Yousef  Al-Hadhrami Ali Al-Hadhrami                       

but when I change a relational field such as employee family which is a relational field, it will only post ids instead of contents


This is the One2many field

class HrEmployeeFamily(models.Model):
_inherit = 'hr.employee'
employee_family_ids = fields.One2many(
string="Family",
comodel_name='hr.employee.family',
inverse_name='related_employee'
)

and let's say this is the family model:

class EmployeeFamily(models.Model):
_name = 'hr.employee.family'
_inherit = 'employee.record'

related_employee = fields.Many2one('hr.employee', string="Related Employee")
family_name = fields.Char(track_visibility='onchange')

instead of writing on the chatter 

Family Name:Jack Sporrow  Jack Smith       

it writes the model and ids:

Family Name:hr.employee.family,8

I'd like it to post a full detailed log on what was changed on the relational field, how can I achieve that?

0
Avatar
Descartar
Ravi Gadhia

which version are you using?

Yousef Al-Hadhrami
Autor

Version 10

Yousef Al-Hadhrami
Autor

@Ravi, your answer kinda did something but not the thing that it should do

it only shows the record if it was updated

so lets say you had family_name + family_date_of_birth, and you modify one of those, it won't show up on the log because it only shows when a record gets linked to the employee himself.

Yousef Al-Hadhrami
Autor

it only shows the record when it gets linked or unliked from an employee

but if you change something in the record, it won't show on the log because the link haven't changed

Ravi Gadhia

I think you need a related field on the model because currently family_name, family_date_of_birth are not direct model field so it does not reflect it's changing on chatter

Yousef Al-Hadhrami
Autor

I think there is,

related_employee = fields.Many2one('hr.employee', string="Related Employee") is the related field on on Family

employee_family_ids = fields.One2many(

string="Family",

comodel_name='hr.employee.family',

inverse_name='related_employee'

) is the related field on the employee

Yousef Al-Hadhrami
Autor

I found a way to [ost to the parent record that one of the family records is updated, deleted or created

here is what I used (for update only):

@api.multi

def write(self, values):

"""Override default Odoo write function and extend."""

self.env['mail.message'].create({

'body': 'Personal Document ' + self.number + ' Updated',

'model': 'hr.employee',

'res_id': self.employee_ref.id,

'subtype_id': '2',

})

return super(HrEmployeePersonalDocument, self).write(values)

Ravi Gadhia

it seems the current implementation of chatter doesn't track change on one2many field and post-change entry on chatter.

you want to track the change of one2many field (employee_family_ids) on hr.employee

https://github.com/odoo/odoo/blob/10.0/addons/mail/models/mail_tracking_value.py#L35

I talked about related field mean getting a related field on 'hr.employee.family' like

employee_name = fields.Char(related="related_employee.name")

but it will not work because of you want post entry on hr.employee

your solution looks good on change/write of a relevant field of family mode post message on employee model

Avatar
Ravi Gadhia
Best Answer

can you try after adding _rec_name in`hr.employee.family`

class EmployeeFamily(models.Model):   
     _name = 'hr.employee.family'   
     _inherit = 'employee.record'  
     _rec_name = 'family_name'​

1
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Related Posts Respostes Vistes Activitat
Can't reconcile bank statement line
10.0
Avatar
Avatar
Avatar
Avatar
4
d’abr. 20
10180
how to use field from same model Solved
10.0
Avatar
Avatar
1
de nov. 19
4768
How to fix: "odoo.addons.base.ir.ir_qweb.assetsbundle: This error occured while compiling the bundle 'web.assets_frontend' containing:"?
10.0
Avatar
Avatar
2
de febr. 18
15361
List view pass context for many2one fields
10.0
Avatar
0
de gen. 18
9531
App is not appearing in the list Solved
accounting 10.0
Avatar
Avatar
Avatar
3
de juny 24
5081
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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