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

Hiding delivery prices that has 0.0 sale value [Closed]

By
kaynis
on 9/18/13, 10:05 AM 1,329 views

The Question has been closed

by
kaynis
on 12/19/2013 09:35:22
     am using V6.1 on windows

I am trying to use the delivery pricing methods on OpenERP and I have been able to use it but I would like to hide any delivery carrier that has a price of 0.0 in the sales order. So when delivery cost is selected in Sales order only carriers with price greater than 0.0 shows up in the drop-down list of the pop-up so that the sales person doesn't select a 0 delivery price by mistake. Can anyone help on this please? Thank you in advance.

def get_price(self, cr, uid, ids, field_name, arg=None, context=None):
    res={}
    if context is None:
        context = {}
    sale_obj=self.pool.get('sale.order')
    grid_obj=self.pool.get('delivery.grid')
    for carrier in self.browse(cr, uid, ids, context=context):
        order_id=context.get('order_id',False)
        price=False
        if order_id:
          order = sale_obj.browse(cr, uid, order_id, context=context)
          carrier_grid=self.grid_get(cr,uid,[carrier.id],order.partner_shipping_id.id,context)
          if carrier_grid:
              price=grid_obj.get_price(cr, uid, carrier_grid, order, time.strftime('%Y-%m-%d'), context)
           else:
              price = 0.0
#              attrs="{'invisible':[('carrier_id','!=',carrier_grid.carrier_id)]}
  #            carrier_id (invisible=True)
        res[carrier.id]=price
    return res

I would like to make the carrier invisible if price is 0.0

you should set the rules in attrs dict it will be better should set at the xml part so that you can easily debug the program try it!

Abhishek H Menon
on 9/18/13, 11:03 AM

am not trying to hide a field, I am trying to hide some rows in the list. where the price is 0, so that the sales person does not select the wrong delivery price

kaynis
on 9/18/13, 2:05 PM
2

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 11/14/13, 9:27 AM

HI,

in xml file tree section, just use domain with attribute

domain="[('your_field', '!=', "0")]"

Bye.

Thanks but this did not work.

kaynis
on 11/15/13, 3:58 AM

I am trying to hide delivery carriers that do not have a price to go to a destination. This carriers usually display a value of 0.0 when delivery price is computed on sales order

kaynis
on 11/15/13, 4:04 AM

Try to change in domain 0 by "0" or "0.0".

Cyril Gaspard (GEM)
on 11/16/13, 8:32 PM

Thanks a lot GEM, you are right and gave me the direction to what I needed to do or at least an alternative to what I was trying to achieve. The 0.0 prices still get displayed but it comes up with an error message and is not added to the sales order line. PS I added the code to the window action

kaynis
on 12/18/13, 9:26 AM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 9/18/13, 10:05 AM
Seen: 1329 times
Last updated: 3/16/15, 8:10 AM