~akretion-team/project-feature/trunk

« back to all changes in this revision

Viewing changes to sale_project_feature_parameter/sale.py

  • Committer: Sebastien Beau
  • Date: 2014-06-27 16:09:32 UTC
  • Revision ID: sebastien.beau@akretion.com-20140627160932-6ie3y1p3cwhrnvpz
[IMP] add the posibility to remove line from extra rate, remove process_by useless option

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
        'rate': fields.float(
74
74
            'Rate',
75
75
            digits_compute=dp.get_precision('Sale Params Rate')),
76
 
        'process_by': fields.selection([
77
 
            ('manager', 'Manager'),
78
 
            ('developer', 'Developer'),
79
 
        ], 'Process By'),
80
76
        'description': fields.text('Description', help='Sale Description'),
81
77
    }
82
78
 
93
89
            'value': {
94
90
                'product_id': product_id,
95
91
                'rate': typo.rate,
96
 
                'process_by': typo.process_by,
97
92
                'price_unit': price,
98
93
            }
99
94
        }
203
198
        #For now only line with day are used
204
199
        day_uom_id = self._get_day_uom_id(cr, uid)
205
200
        for line in sale.order_line:
206
 
            if line.product_uom.id == day_uom_id:
 
201
            if line.product_uom.id == day_uom_id and line.rate_dependent:
207
202
                key = self._build_group_key(cr, uid, line, context=context)
208
203
                self._update_grouped_line(cr, uid, line, res[key], context=context)
209
204
        return [val for key, val in res.items()]
265
260
        line_vals['tax_id'] = [(6, 0, line_vals.get('tax_id', []))]
266
261
        return line_vals
267
262
 
268
 
    def _clear_automatic_line(self, cr, uid, sale, context=None):
 
263
    def remove_automatic_line(self, cr, uid, ids, context=None):
269
264
        "Delete sale.order.line which comes from sale.rate.parameter"
270
265
        order_line_obj = self.pool['sale.order.line']
271
266
        line_ids = order_line_obj.search(cr, uid, [
272
 
            ['order_id', '=', sale.id],
 
267
            ['order_id', 'in', ids],
273
268
            ['rate_param_id', '!=', False],
274
269
        ], context=context)
275
270
        order_line_obj.unlink(cr, uid, line_ids, context=context)
279
274
        for sale in self.browse(cr, uid, ids, context=context):
280
275
            for price_param in sale.sale_price_parameter_ids:
281
276
                self._update_price(cr, uid, price_param, sale, context=context)
282
 
            self._clear_automatic_line(cr, uid, sale, context=context)
 
277
            sale.remove_automatic_line()
283
278
            grouped_lines = self._get_grouped_line(
284
279
                cr, uid, sale, context=context)
285
280
            order_line = []
312
307
            'sale.rate.parameter',
313
308
            'Sale Rate Parameter',
314
309
            ondelete='cascade'),
 
310
        'rate_dependent': fields.boolean(
 
311
            'rate dependent',
 
312
            help=('when add a line in the sale order with this '
 
313
            'typology, the sale will be use when adding the '
 
314
            'addition cost based on rate')),
315
315
    }
 
316
 
 
317
    _defaults = {
 
318
        'rate_dependent': True,
 
319
        }