This question has been flagged
1 Reply
10226 Views

Hello,

I want to display a warning message when the user add an existing sale order line,

exp: i have a sale order line with an item x, when i add an other sale order line with the item x i want to display the warning message.

global list_product list_product = []

class sale_order_line(osv.osv): _inherit = 'sale.order.line'

def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
        uom=False, qty_uos=0, uos=False, name='', partner_id=False,
        lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
    context = context or {}
    lang = lang or context.get('lang',False)

................... if product in list_product: WRNNING MESSAGE HERE

    list_product.append(product)

    if warning_msgs:
        warning = {
                   'title': _('Configuration Error!'),
                   'message' : warning_msgs
                }
    return {'value': result, 'domain': domain, 'warning': warning}

sale_order_line()

with this code i can not initialize the variable list_product[]

Any ideas?

Avatar
Discard
Best Answer
if product: line_ids = self.pool.get('sale.order.line').search(cr, uid, [('product_id), '=', product])
Avatar
Discard
Author

Hello nazarii, i tried your code but i have the list of items of all order line in my database. i would like to get just the items of my current order (the order can be not yet saved). Thanks

You'r order items are passed as arguments to product_id_change method (E.g. product will be id of product even if the order is not saved yet)

Author

if i have 3 lines with 3 different items, how can i get those items at the time when i'm adding the 4 th line ( 3 lines not yet saved and i want to do this in product_id_change ). thanks for your response