-1

In the vendor bills, when a customer invoice has been created,there will be a message_ids field which creates and sends messages to the concerned persons who are all listed in the followers list. By default,this works like when an invoice is created and a message is entered, after that while clicking on the send button, a notification message will be sent to that followers inbox which will be located in discuss module.

Without clicking the new message and sending the message, i want to send a notification to the followers that the state has been changed when i change the state

Cœur
  • 37,241
  • 25
  • 195
  • 267
Navi
  • 1,000
  • 1
  • 14
  • 44

3 Answers3

1

In python:

state = fields.Selection([
        ('draft', 'Draft'),
        ('open', 'Open'),
        ('paid', 'Paid'),
        ('cancel', 'Cancelled'),
    ], string='Status',track_visibility='onchange')



 @api.multi
    def _track_subtype(self, init_values):
        self.ensure_one()
        if 'state' in init_values and self.state == 'sale':
            return 'custom_invoice.mt_invoices_confirmed'
        return super(SaleOrder, self)._track_subtype(init_values)

In xml:

 <record id="mt_order_confirmed_custom" model="mail.message.subtype">
        <field name="name"> Approval Request</field>
        <field name="res_model">sale.order</field>
        <field name="default" eval="True" />
        <field name="description">Request  Approval</field>
    </record>
Navi
  • 1,000
  • 1
  • 14
  • 44
0

write an onchange function for field state and create a message record for the followers. eg:

@api.depends('states')
def func():
    # create a message record with appropriate data
    return 
Hilar AK
  • 1,655
  • 13
  • 25
-1

Just add track_visibility='onchage' in state field declaration in .py file.

Ajay Chauhan
  • 109
  • 3