Odoo Help


13 Answers
Pravitha Qatar
4/17/13, 8:13 AM

Just add

def action_wait(self, cr, uid, ids, context=None):
context = context or {}
for order in self.browse(cr, uid, ids):
    if not order.order_line:
        raise osv.except_osv(_('Error!'),_('You cannot confirm a sales order which has no line.'))
    # Raising exception to inform the user about the stock level before confirming the sale order
    for product in order.order_line:
        if (product.product_uom_qty > product.product_id.available_qty):
            raise osv.except_osv(_('Not enough stock !'), _('You requested %.2f.The available stock is %s !') %(product.product_uom_qty, product.product_id.available_qty))

in sale.py. The def action_wait is already defined. just add the code to into it. My problem got solved.

Sudhir Arya (ERP Harbor Consulting Services) India
4/17/13, 8:18 AM

You should create your custom module Instead of changing core modules.

Pravitha Qatar
4/17/13, 8:53 AM

Yeah i have inherited sale.order and sale.order.line to do this

Alcaline Philippines
7/17/14, 3:54 AM

where did you get the available_qty?? because i got the same problem..


Sudhir Arya (ERP Harbor Consulting Services) India

--Sudhir Arya (ERP Harbor Consulting Services)--
| 8 9 10
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




ERP Harbor Consulting Services

Website: http://www.erpharbor.com
Sudhir Arya (ERP Harbor Consulting Services) India
4/17/13, 6:45 AM

If you really want to stop the flow, you have to override product_id_change and write osv.except_osv instead of warning.

For example:

raise osv.except_osv(_('Error!'),_("Your Warning/Error Message."))

It will stop the execution and won't allow to proceed further until you solve it.

Pravitha Qatar
4/17/13, 7:01 AM

i did this but the result was the exception raised succesfully but the products description field went blank. and when I filled the description the everything worked normally. the order got confirmed even if there is no stock

Sudhir Arya (ERP Harbor Consulting Services) India
4/17/13, 7:06 AM

It is because onchange is called when you change either product or quantity. But you are changing description only then onchange won't work and exception won't raise.

Pravitha Qatar
4/17/13, 7:12 AM

so wat should i do now? Is there any way?

Sudhir Arya (ERP Harbor Consulting Services) India
4/17/13, 7:18 AM

You can make product_id mandatory.

Pravitha Qatar
4/17/13, 7:21 AM

is there any way i can do it on the confirm button defenition?

Sudhir Arya (ERP Harbor Consulting Services) India
4/17/13, 7:26 AM

Yes, you can check is there product_id or not, if not then you can raise exception "Please Select Product".


Omal Bastin India

--Omal Bastin--

| 6 6 10
Kochi, Kerala, India
--Omal Bastin--

Swiming deep into openERP/ODOO

Omal Bastin India
8/5/13, 8:42 AM

There is a module called warning. Please check it

davidvickyJ Vietnam
4/13/16, 12:38 AM

Warning messages can be displayed for objects like sale order, purchase order, picking and invoice. The message is triggered by the form's onchange event.






Ask a Question
Keep Informed
0 follower(s)
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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now