From 65cd88d2167fe855ba941bedafe903c791883bc8 Mon Sep 17 00:00:00 2001 From: Wolfgang Taferner Date: Sat, 17 May 2014 09:08:25 +0200 Subject: [PATCH 1/5] [IMP] Added quantity as type and variable_factor + sequence for flexibility to delivery grid line --- addons/delivery/delivery.py | 14 +++++++++----- addons/delivery/delivery_view.xml | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/delivery/delivery.py b/addons/delivery/delivery.py index b5c8bae429e..1d3bc14d5e6 100644 --- a/addons/delivery/delivery.py +++ b/addons/delivery/delivery.py @@ -191,21 +191,23 @@ class delivery_grid(osv.osv): total = 0 weight = 0 volume = 0 + quantity = 0 for line in order.order_line: if not line.product_id or line.is_delivery: continue weight += (line.product_id.weight or 0.0) * line.product_uom_qty volume += (line.product_id.volume or 0.0) * line.product_uom_qty + quantity += line.product_uom_qty total = order.amount_total or 0.0 - return self.get_price_from_picking(cr, uid, id, total,weight, volume, context=context) + return self.get_price_from_picking(cr, uid, id, total,weight, volume, quantity, context=context) - def get_price_from_picking(self, cr, uid, id, total, weight, volume, context=None): + def get_price_from_picking(self, cr, uid, id, total, weight, volume, quantity, context=None): grid = self.browse(cr, uid, id, context=context) price = 0.0 ok = False - price_dict = {'price': total, 'volume':volume, 'weight': weight, 'wv':volume*weight} + price_dict = {'price': total, 'volume':volume, 'weight': weight, 'wv':volume*weight, 'quantity': quantity} for line in grid.line_ids: test = eval(line.type+line.operator+str(line.max_value), price_dict) if test: @@ -227,9 +229,10 @@ class delivery_grid_line(osv.osv): _description = "Delivery Grid Line" _columns = { 'name': fields.char('Name', size=64, required=True), + 'sequence': fields.integer('Sequence', size=64, required=True, help="Gives the sequence order when calculating delivery grid."), 'grid_id': fields.many2one('delivery.grid', 'Grid',required=True, ondelete='cascade'), 'type': fields.selection([('weight','Weight'),('volume','Volume'),\ - ('wv','Weight * Volume'), ('price','Price')],\ + ('wv','Weight * Volume'), ('price','Price'), ('quantity','Quantity')],\ 'Variable', required=True), 'operator': fields.selection([('==','='),('<=','<='),('>=','>=')], 'Operator', required=True), 'max_value': fields.float('Maximum Value', required=True), @@ -239,12 +242,13 @@ class delivery_grid_line(osv.osv): 'standard_price': fields.float('Cost Price', digits_compute= dp.get_precision('Product Price'), required=True), } _defaults = { + 'sequence': lambda *args: 10, 'type': lambda *args: 'weight', 'operator': lambda *args: '<=', 'price_type': lambda *args: 'fixed', 'variable_factor': lambda *args: 'weight', } - _order = 'list_price' + _order = 'sequence, list_price' # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/delivery/delivery_view.xml b/addons/delivery/delivery_view.xml index 31c0e08b093..ffb7146e04a 100644 --- a/addons/delivery/delivery_view.xml +++ b/addons/delivery/delivery_view.xml @@ -179,6 +179,7 @@
+ From e7e4f8cefaf440ea8a59793b221b376a50cac690 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Sat, 17 May 2014 11:44:09 +0200 Subject: [PATCH 2/5] [IMP] remove setting of color.ui After further considering PR #21's arguments, the setup script should not go around setting `color.ui`: * it shouldn't be needed for recent gits with default compile settings[0] * it may override advanced users's own colour configuration/ customisations (or disabling) * it forces default colours on users for which it may be useless (colour- blind) or even detrimental (other vision impairments) * some linux distributions apparently default to idiotic pagers which can't handle ANSI colour codes by default and spew garbage to the terminal [0] https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.4.txt#L178-L180 --- checkout.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/checkout.sh b/checkout.sh index 5a51dd0e4da..0955508a178 100755 --- a/checkout.sh +++ b/checkout.sh @@ -57,7 +57,6 @@ cd $copyname git config user.name "$name" git config user.email "$email" -git config color.ui auto # pre-push script preventing push to odoo repo by default. Git just execs # them, so they need a correct shebang and exec bit From fd223b1d5d3efcb076db6bee308233f587814584 Mon Sep 17 00:00:00 2001 From: Wolfgang Taferner Date: Sat, 17 May 2014 15:53:49 +0200 Subject: [PATCH 3/5] Add quantity in variable factor too... I forgot to add the changes before committing --- addons/delivery/delivery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/delivery/delivery.py b/addons/delivery/delivery.py index 1d3bc14d5e6..362703bccb7 100644 --- a/addons/delivery/delivery.py +++ b/addons/delivery/delivery.py @@ -237,7 +237,7 @@ class delivery_grid_line(osv.osv): 'operator': fields.selection([('==','='),('<=','<='),('>=','>=')], 'Operator', required=True), 'max_value': fields.float('Maximum Value', required=True), 'price_type': fields.selection([('fixed','Fixed'),('variable','Variable')], 'Price Type', required=True), - 'variable_factor': fields.selection([('weight','Weight'),('volume','Volume'),('wv','Weight * Volume'), ('price','Price')], 'Variable Factor', required=True), + 'variable_factor': fields.selection([('weight','Weight'),('volume','Volume'),('wv','Weight * Volume'), ('price','Price'), ('quantity','Quantity')], 'Variable Factor', required=True), 'list_price': fields.float('Sale Price', digits_compute= dp.get_precision('Product Price'), required=True), 'standard_price': fields.float('Cost Price', digits_compute= dp.get_precision('Product Price'), required=True), } From 4e34e3bce5d422865bb7a7c539dc13bf6cf81a97 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 22 May 2014 14:55:26 +0200 Subject: [PATCH 4/5] Add < and > operators to allow rules without gap (eg: until 100 & above 100) --- addons/delivery/delivery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/delivery/delivery.py b/addons/delivery/delivery.py index 362703bccb7..46d76180d08 100644 --- a/addons/delivery/delivery.py +++ b/addons/delivery/delivery.py @@ -234,7 +234,7 @@ class delivery_grid_line(osv.osv): 'type': fields.selection([('weight','Weight'),('volume','Volume'),\ ('wv','Weight * Volume'), ('price','Price'), ('quantity','Quantity')],\ 'Variable', required=True), - 'operator': fields.selection([('==','='),('<=','<='),('>=','>=')], 'Operator', required=True), + 'operator': fields.selection([('==','='),('<=','<='),('<','<'),('>=','>='),('>','>')], 'Operator', required=True), 'max_value': fields.float('Maximum Value', required=True), 'price_type': fields.selection([('fixed','Fixed'),('variable','Variable')], 'Price Type', required=True), 'variable_factor': fields.selection([('weight','Weight'),('volume','Volume'),('wv','Weight * Volume'), ('price','Price'), ('quantity','Quantity')], 'Variable Factor', required=True), From 0efc066aa6228bf27d8724765149fcae04cb1692 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 22 May 2014 14:56:33 +0200 Subject: [PATCH 5/5] Add sequence field with handle in tree view --- addons/delivery/delivery_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/delivery/delivery_view.xml b/addons/delivery/delivery_view.xml index ffb7146e04a..99d58c10b25 100644 --- a/addons/delivery/delivery_view.xml +++ b/addons/delivery/delivery_view.xml @@ -209,6 +209,7 @@ delivery.grid.line +