Adding the Customer Rating Mixin in Odoo 17
Today every organization whether small or large has to provide excellent customer support for the success of their business. One of the most prudent manners to serve customers is adding customer feedback and ratings in your business. Easy consumer Feedback with Odoo
This blog post will cover the process of incorporating a customer rating mixin in Odoo 17, allowing enterprises to benefit from feedback that would otherwise be used for improving their products & services.
With the customer rating mixin, you can inherit this to implement. and then add this mixin model to your model.
class ModelName (models.Model): _name = model.name _description = ‘Mode Namel' _inherit = ['rating.mixin', 'mail.thread'] user_id = fields.Many2one ('res.users', string='User') partner_id = fields.Many2one ('res.partner', string='Customer')
You can now use the mixin features in your model Odoo
If ranking is inherited after the experts in that field mixin class your model attribute is added by ‘partner_id’ this field is linked with the rating. rating’ records. When you use a field named other than partner_id (for res. get_ranting_partner_id() precedes) default behaviour partner model).
As with the email, if your model extends motorist then the rating event will be displayed in chatter as well. thread model.
Use email to request ratings:
You can create an email with links to rating objects if you’d like to ask your clients to rate you. Below is an example of a simple rating email template.
A link to a website featuring a rating and feedback form will be sent to your consumer via email. Following that, the client can quickly rate and comment on the goods or services to share their thoughts with the company or other customers.
<record id="rating_model_email_template" model="mail.template "> < field name="name" >Model: Rating Request</field> < field name="subject" >Customer Rating Request</field> <field name="model_id" ref= "module_name.model_model_name"/> <field name= "email_from" > { { (object._rating_get_operator ().email_formatted if object._rating_get_operator () else user.email_formatted) } <TA < field name= "partner_to" > { { object._rating_get_partner ().id } } < / field> < field name="body_html" type="html"> <div> < t t-set="access_token"t-value="object._rating_get_access_token () "/> < t t-set="partner" t-value="object._rating_get_partner () "/> <table border= "0" cellpadding= "0" cellspacing= "0" width = "590" style= "width: 100%; margin:0px auto; "> < tbody> <tr> < td valign= "top" style= "font-size: 13px;" > < t-if="partner.name"> Hello < t-out="partner.name or '' > Brandon Freeman</t>, <br/> <br / > </t> < t-else=" > Hello, <br/> <br/> </t> Please take a moment to rate our services related to the task " < t-if="object._rating_get_operator ().name" > assigned to <strong t-out="object._rating_get_operator ().name or '' >Mitchell Admin</strong>.<br/> </t> < t-else=" > .<br/> </t> </td> < /tr> <tr> < td style= "text-align: center;" > <table border= "0" cellpadding= "0" cellspacing= "0" width= "590" summer= "o_mail_notification" style= "width:100%; margin: 32 <tr> < td style= "font-size: 13px;" > <strong>Tell us how you feel about our service</strong> < br/> <span style="font-size: 12px; opacity: 0.5; color: #454748; "> (click on one of these smileys) < /span> </td> < /tr> <tr> < td style="font-size: 13px;" > <table style="width:100%;text-align:center;margin-top:2rem; "> < tr> < td > <a t-attf-href="/rate/{ { access_token } } / 5"> <img alt="Satisfied "src="/rating/static/src/img/rating_5.png "title="Satisfied "/ > </a> </td> < td > <a t-attf-href="/rate/{ { access_token } } / 3"> <img alt= "Okay" src="/rating/static/src/img/rating_3.png "title="Okay "/> </a> </td> <td> <a t-attf-href="/rate/{ { access_token } } / 1"> <img alt="Dissatisfied "src="/rating/static/src/img/rating_1.png "title="Dissatisfied "/> </a> </td> </tr> </table> </td> < /tr> </table> </td> < /tr> </tbody> </table> </div> </field> <field name= "auto_delete" eval= "False" / > </record>
An email is sent when you click the button with the model, as shown below. The operation is started using the ‘send_rating_mail_action’ method:.
def send_rating_mail_action(self): template = self.env.ref (‘ module_name.rating_model_email_template) template.send_mail ( self.id, force_send=True)
The following image displays the output that was produced using the email template:
When you click the email’s rating link to visit the website, you’ll see the following page:
Define an action as follows to show all of the ratings for the model: I’m going to give the menu item an action now: –
<record id="rating_rating_action_model" model="ir.actions.act_window"> < field name="name" >Customer Ratings</field> < field name="res_model" >rating.rating</field> <field name="view_mode" > kanban,form,pivot,graph</field> < field name= "domain" > [('res_model', '=', 'your.model')] </field> </record> < menuitem id= "menu_cust_rating" name= "Customer rating" parent="menu_test" sequence="20" action="rating_rating_action_model"/>
This will provide you with an overview of the fundamentals of incorporating user input into your application. The Project module is one example that you can use.
"Unlock the Full Potential of Your Business with Odoo ERP!"
"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"
Get a Free Quote