Odoo Help

Welcome!

This community 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.

0

create custom fields and set alerts on it

By
Francesco Di Sciascio
on 2/9/16, 9:54 AM 508 views

Hi,

I would like to know if it is possible to create a custom field, for example a threshold for a product, and when the quantity of products is lower than the threshold, the system sends a mail to one of the entities of the system (like Administrator or other people...)

Anybody knows how to perform it?


Thanks all

1

Baiju

--Baiju--
3154
| 5 4 8
Kochi, India
--Baiju--
ODOO technical and functional

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju
On 2/10/16, 2:23 AM

Hi,

I think you can achieve this by defining your own custom field and you can use your script for checking that number in write method and if its positive you can send e-mail(by using script).

By giving the script in write method it will execute and check every time when the value is changed.

Or you can use scheduled actions, but it will execute only at given intervals.

Hope this helps.

1
Jo
On 2/10/16, 4:31 AM

Hi Francesco,

I thought you can achieve by Automated actions, here is what i'm suggested, Try this.

from openerp import models, fields, api
class product_template_inherit(models.Model):
    _inherit = 'product.template'
    threshold = fields.Integer('Threshold')

    def check_product_qty(self, cr, uid, context=None):
        ids = self.search(cr, uid, [], context)
        products = self.browse(cr, uid, ids, context)
for product in products:
            if product.qty_available < product.threshold:
                // Write actions for sending mail here
<openerp>
<data>
        <record model="ir.cron" id="check_poduct_qty_with_threshold">
        <field name="name">Threshold</field>
        <field name="interval_number">1</field>
        <field name="interval_type">minutes</field>
        <field name="numbercall">-1</field>
        <field eval="False" name="doall"/>
        <field eval="'product.template'" name="model"/>
        <field eval="'check_product_qty'" name="function"/>
        <field eval="'()'" name="args"/>
    </record>
    </data>
</openerp>

Your Answer

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/9/16, 9:54 AM
Seen: 508 times
Last updated: 2/10/16, 4:31 AM