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.

3

Warning message in Sale module - OpenERP

By
Pravitha
on 4/17/13, 6:07 AM 7,111 views

Hello, In sale.order.line I have a set a warning message. It pop-ups when the stock level is less than the requested quantity of product in the sale order. The message works perfectly. But the problem is even if the user is warnned that there is not enough stock the order can be confirmed. This should not happen.the order must not get confirmed. How can I do this? Someone please help. this is my warning message code: It is written in def product_id_change

if (qty > product_obj.available_qty):
    warn_msg = _('You requested %.2f.The available stock is %.2f !') %(qty,product_obj.available_qty)
    warning_msgs += _("Not enough stock ! : ") + warn_msg +"\n\n"
3

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 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.

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

Pravitha
on 4/17/13, 7:01 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.

Sudhir Arya (SA)
on 4/17/13, 7:06 AM

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

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

You can make product_id mandatory.

Sudhir Arya (SA)
on 4/17/13, 7:18 AM

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

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

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

Sudhir Arya (SA)
on 4/17/13, 7:26 AM
1
Pravitha
On 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.

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

Sudhir Arya (SA)
on 4/17/13, 8:18 AM

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

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

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

Alcaline
on 7/17/14, 3:54 AM
0
davidvickyJ
On 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.

http://1tour.vn

http://1tour.vn/khach-san/

http://1tour.vn/tour/

http://tainghebeats.vn

http://thuocla-dientu.com

0

Omal Bastin

--Omal Bastin--
1146
| 6 6 8
Kochi, Kerala, India
--Omal Bastin--

Swiming deep into openERP/ODOO

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

There is a module called warning. Please check it

-1
Akash Verma
On 5/15/14, 3:35 AM

Hi Guys !!

We are an IT development company based in India, We are Gold partners with Oracle and are experts in ERP implementation.

We have also developed a Mini ERP to meet the needs of the SME's.

We get very good reviews for our end-to-end IT services from our clients.

We can cater to any requirement in IT and that too in affordable prices.

Why should a modest budget mean you have to compromise on the quality of the services or products.

Do give us a call to discuss your needs and rest assured for the best services.

Best Regards,

Akash Verma

Sr. Business Development Manager

SRDT Pvt. Ltd.

+91-8176047544

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

0 follower(s)

Stats

Asked: 4/17/13, 6:07 AM
Seen: 7111 times
Last updated: 4/13/16, 12:38 AM