Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Guys, how to do it:
#Read quantity from table, if qty_available <50 send message
def _get_current_stock(self, cr, uid, ids, field_name, arg, context=None):
res = 
tot_qty = 0
product_id = 0
for obj in self.browse(cr, uid, ids, context=context):
cr.execute(""" select sum(qty) from stock_quant where product_id = %s and location_id != 7;""" %(obj.product_id.id))
tot_qty = cr.fetchall()
if tot_qty<50: #here message sending procedure, how to send message ?
print '|| Product QTY ', res
First, you have to define the outgoing mail server in Settings->General settings, you can use for example your gmail account.
You have to test it and get an 'ok' message , if there is any error, it will show you a message what needs to be changed
I used the following code to send emails under a certain condition
def mailing(self, cr, uid, ids,vals,context=None):
domain=[('name','=','MY_TEMPLATE')] # here is my email template which contains the message
templates = self.pool.get('email.template').search(cr,uid,domain)
if not templates:
template = self.pool.get('email.template').browse(cr,uid,templates)
if template.email_to: #The 'To' email is defined in the template
self.pool.get('email.template').send_mail(cr, uid, template.id, ids, True, context=context)
I applied this code and sent emails successfully
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 1/4/16, 9:42 AM|
|Seen: 827 times|
|Last updated: 1/27/16, 3:19 AM|