The wizard business logic

Excluding the Cancel button, which just closes the form without performing any action, we have the Send action buttons to implement.

The method called by the button is button_send, and it should be defined in the wizard/checkout_mass_message.py file, as shown in the following code:

    @api.multi
def button_send(self):
self.ensure_one()
for checkout in self.checkout_ids:
checkout.message_post(
body=self.message_body,
subject=self.message_subject,
subtype='mail.mt_comment',
)
return True

Our code only needs to handle one wizard instance at a time, so we used self.ensure_one() to make that clear. Here, self represents the browse record for the data on the wizard form.

The method iterates through the selected checkout records and posts a message for each one. The mt_comment subtype is used, so that the message generates a notification to the record followers.

It is good practice for methods to always return something, at least the True value. The sole reason for this is that some XML-RPC protocols don't support None values, so those methods won't be usable with that protocol. In practice, you may not be aware of the issue because the web client uses JSON-RPC, not XML-RPC, but it is still a good practice to follow.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.126.11