📱 SMS Integration Tutorial - Learn SMS Features
Master Odoo's SMS integration with practical examples and comprehensive inline documentation
📚 What is This Module?
A complete tutorial module designed to teach developers how to integrate SMS functionality into their Odoo custom modules. Learn three essential SMS integration methods with working examples on Sale Orders!
✨ Three SMS Integration Methods
📲 SMS Widget on Field
Add an SMS icon to any phone field. Simply add widget="phone" and users can send SMS with one click!
📧 Button with SMS Template
Create buttons that send pre-configured SMS using templates. Perfect for standardized messages!
✍️ Custom SMS Composer
Open an SMS composer dialog for users to write custom messages. Maximum flexibility!
📦 What's Included
- Sale Order SMS Integration: Extends sale orders with SMS capabilities
- Mobile Customer Field: Related field with SMS widget for easy messaging
- "Send Customer SMS" Button: Direct button using SMS template
- Action Menu Item: Custom SMS composer in actions dropdown
- SMS Templates: Two pre-configured templates for sale orders
- Comprehensive Documentation: 200+ lines of inline comments
- Mass SMS Action: Send SMS to multiple records at once
🎯 Learning Objectives
After installing and exploring this module, you'll be able to:
- Add SMS widgets to phone fields in any view
- Create SMS templates with dynamic field values
- Build buttons that send SMS using templates
- Open SMS composer programmatically from Python
- Configure server actions for SMS in dropdown menus
- Send mass SMS to multiple records
- Handle SMS errors and validation properly
🚀 Quick Start Guide
- 1Install: Install erpl_sms_tutorial from Apps menu
- 2Configure SMS Provider: Settings > Technical > SMS Settings
- 3Open Sale Order: Sales > Orders > Create or open order
- 4Try SMS Field: Enter mobile number, click SMS icon
- 5Try Button: Click "Send Customer SMS" button
- 6Try Action: Actions dropdown > Send SMS to Customer
- 7Review Code: Check source files for learning!
👨💻 Code Examples
Method 1: SMS Widget on Field
<!-- Add SMS widget to any phone field --> <field name="mobile_customer" widget="phone"/>
Method 2: Button with SMS Template
def action_send_customer_sms(self):
'''Send SMS using predefined template'''
template = self.env.ref('module.sms_template_xmlid')
return {
'type': 'ir.actions.act_window',
'res_model': 'sms.composer',
'view_mode': 'form',
'target': 'new',
'context': {
'default_template_id': template.id,
'default_res_ids': self.ids,
'default_res_model': self._name,
}
}
Method 3: SMS Template Definition
<record id="sms_template_example" model="sms.template">
<field name="name">My SMS Template</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="body">Hello ${object.partner_id.name},
Your order ${object.name} is ready!
Thank you,
${object.company_id.name}</field>
</record>
📋 Technical Details
- Module Name: erpl_sms_tutorial
- Version: 19.0.1.0.0
- Category: Tutorial
- Dependencies: base, sale, sms
- License: OPL-1
- Odoo Version: 19.0+
📱 Features Demonstrated
1. SMS Widget Integration
Added mobile_customer field with SMS widget that:
- Shows SMS icon next to the field
- One-click SMS sending
- Automatic number validation
- Related to partner mobile field
2. SMS Templates
Two pre-configured templates included:
- Portal Notification: Inform customers order is on portal
- Order Confirmation: Confirm order with details and delivery date
- Dynamic fields using
${object.field_name}syntax - Multi-line message support
3. Action Integration
Server actions added to:
- Form view actions dropdown
- List view for mass sending
- Configurable for any model
💡 Best Practices Shown
- Proper SMS composer configuration
- Template creation with dynamic fields
- Error handling for missing phone numbers
- Clear button labeling and icons
- Comprehensive inline documentation
- User-friendly SMS interfaces
- Mass SMS capabilities
⚠️ Important Notes
- SMS Provider Required: Configure SMS provider in Odoo settings
- SMS Costs: Each SMS sent incurs cost based on your provider
- Phone Validation: Ensure phone numbers are in correct format
- Testing: Test with small batches before mass sending
- Regulations: Comply with SMS marketing regulations (opt-in/opt-out)
📖 File Structure
erpl_sms_tutorial/ ├── models/ │ ├── __init__.py │ └── sale_order.py (SMS integration methods) ├── views/ │ └── sale_order_views.xml (widget, buttons, actions) ├── data/ │ └── sms_templates.xml (2 SMS templates) ├── static/description/ │ ├── icon.png │ ├── banner.png │ └── index.html ├── __init__.py └── __manifest__.py
🔧 SMS Provider Setup
- Go to Settings > Technical > SMS > SMS Providers
- Configure your preferred provider (Twilio, etc.)
- Add API credentials
- Test with a sample SMS
- Monitor SMS logs for delivery status
🧪 Testing Checklist
- Open a sale order
- Enter customer mobile number
- Click SMS icon on mobile_customer field
- Verify SMS composer opens
- Click "Send Customer SMS" button
- Verify template is loaded
- Use Actions > Send SMS to Customer
- Send test SMS messages
- Check SMS logs for delivery
- Test mass SMS from list view
📚 Learning Resources
All code includes extensive comments explaining:
- models/sale_order.py: Python methods with detailed docstrings
- views/sale_order_views.xml: XML structure with inline comments
- data/sms_templates.xml: Template configuration examples
- Additional notes: Best practices and common pitfalls
🆘 Support & Contact
This module is developed and maintained by ERP Labz. For support, customization, or custom Odoo development services:
- Website: erplabz.com
- Company: ERP Labz
📜 License
This module is licensed under OPL-1 (Odoo Proprietary License v1.0).
🎉 Ready to Master SMS Integration?
Install this module now and explore SMS features in action! Review the comprehensive inline documentation to understand every aspect of SMS integration in Odoo.
Happy Learning! 📱
Please log in to comment on this module