Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
4242 Переглядів

Hello everyone


I want to add track visibility in the price_unit field in the sale order line model. I tried use
track_visibility="always" and track_visibility="onchange", but it's not working. 


How can I track price unit field in sale order line?


Thanks for your help!

Аватар
Відмінити
Найкраща відповідь

Here,

Ensure the model inherits mail.thread

Override sale.order.line and inherit from mail.thread:

from odoo import models, fields


class SaleOrderLine(models.Model):

    _inherit = 'sale.order.line'

    _inherit = ['mail.thread'] 


    price_unit = fields.Float(

        string='Unit Price',

        tracking=True, 

    )


Add mail.thread to the model (if not already present)

In Odoo, sale.order already inherits from mail.thread , but sale.order.line does not by default — so you must add it yourself in a custom module.

I hope it is usefull
Аватар
Відмінити
Найкраща відповідь

Hi,


Track visibility is used to track the changes made to the fields, as our system is a multi-user system and the different person can access the same record. There might be cases where we have to keep track of who changed the field values. In these cases, we can use track_visibilty.

So let us look at how we can do it in our model.


class SaleOrderLine(models.Model):

   _inherit = 'sale.order.line'

    price_unit = fields.Float('Unit Price', required=True, digits='Product Price', default=0.0, track_visibility = 'always')

(or)


price_unit = fields.Float('Unit Price', required=True, digits='Product Price', default=0.0, track_visibility = ‘onchange’)


Track Visibility: onchange (if it should be displayed in the notification only if the field changed) or always (if the value should always be displayed in change notifications even if this particular field did not change - useful to make notification more explanatory by always adding the name field).


Also Refer the youtube video:


https://www.cybrosys.com/odoo/videos/technical/how-to-track-field-value-changes-in-odoo-15



Hope it helps

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
січ. 24
5831
0
черв. 23
2323
1
груд. 22
3686
0
квіт. 22
2829
1
квіт. 19
6448