Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2131 Представления

I want to post message on chatter whenever I change the unit price in sale order line, in already created quotation.


this is my py file.

class inheritchat(models.Model):
_inherit = 'sale.order.line'
_inherit = ['mail.thread', 'mail.activity.mixin']

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


@api.model
def write(self, vals):
if vals.get('price_unit'):
self.message_post(body=_('updated: %s') % vals.get('price_unit'))
super(inheritchat, self).write(vals)

Аватар
Отменить
Лучший ответ

Hi Ashu:

If you have enabled tracking at the field level, which you seem to have done, that should be sufficient for the message to get logged automatically. You don't need to overwrite "write" unless you want to customize the message.

Аватар
Отменить