247
251
price = max(price, price_limit+res['price_min_margin'])
248
252
if res['price_max_margin']:
249
253
price = min(price, price_limit+res['price_max_margin'])
253
258
# False means no valid line found ! But we may not raise an
254
259
# exception here because it breaks the search
262
result['item_id'] = {id: item_id}
257
263
if context and ('uom' in context):
258
264
product = product_obj.browse(cr, uid, prod_id)
259
265
uom = product.uos_id or product.uom_id
269
275
_description = "Pricelist Version"
271
277
'pricelist_id': fields.many2one('product.pricelist', 'Price List',
272
required=True, select=True),
278
required=True, select=True, ondelete='cascade'),
273
279
'name': fields.char('Name', size=64, required=True, translate=True),
274
280
'active': fields.boolean('Active',
275
281
help="When a version is duplicated it is set to non active, so that the " \
356
362
'name': fields.char('Rule Name', size=64, help="Explicit rule name for this pricelist line."),
357
'price_version_id': fields.many2one('product.pricelist.version', 'Price List Version', required=True, select=True),
358
'product_tmpl_id': fields.many2one('product.template', 'Product Template', ondelete='cascade', help="Sets a template if this rule only apply to a template of product. Keep empty for all products"),
359
'product_id': fields.many2one('product.product', 'Product', ondelete='cascade', help="Sets a product if this rule only apply to one product. Keep empty for all products"),
360
'categ_id': fields.many2one('product.category', 'Product Category', ondelete='cascade', help="Sets a category of product if this rule only apply to products of a category and his childs. Keep empty for all products"),
363
'price_version_id': fields.many2one('product.pricelist.version', 'Price List Version', required=True, select=True, ondelete='cascade'),
364
'product_tmpl_id': fields.many2one('product.template', 'Product Template', ondelete='cascade', help="Set a template if this rule only apply to a template of product. Keep empty for all products"),
365
'product_id': fields.many2one('product.product', 'Product', ondelete='cascade', help="Set a product if this rule only apply to one product. Keep empty for all products"),
366
'categ_id': fields.many2one('product.category', 'Product Category', ondelete='cascade', help="Set a category of product if this rule only apply to products of a category and his childs. Keep empty for all products"),
362
368
'min_quantity': fields.integer('Min. Quantity', required=True, help="The rule only applies if the partner buys/sells more than this quantity."),
363
369
'sequence': fields.integer('Sequence', required=True, help="Gives the sequence order when displaying a list of pricelist items."),
365
371
'base_pricelist_id': fields.many2one('product.pricelist', 'If Other Pricelist'),
367
373
'price_surcharge': fields.float('Price Surcharge',
368
digits=(16, int(config['price_accuracy']))),
374
digits_compute= dp.get_precision('Sale Price')),
369
375
'price_discount': fields.float('Price Discount', digits=(16,4)),
370
376
'price_round': fields.float('Price Rounding',
371
digits=(16, int(config['price_accuracy'])),
377
digits_compute= dp.get_precision('Sale Price'),
372
378
help="Sets the price so that it is a multiple of this value.\n" \
373
379
"Rounding is applied after the discount and before the surcharge.\n" \
374
380
"To have prices that end in 9.99, set rounding 10, surcharge -0.01" \
376
382
'price_min_margin': fields.float('Min. Price Margin',
377
digits=(16, int(config['price_accuracy']))),
383
digits_compute= dp.get_precision('Sale Price')),
378
384
'price_max_margin': fields.float('Max. Price Margin',
379
digits=(16, int(config['price_accuracy']))),
385
digits_compute= dp.get_precision('Sale Price')),
380
386
'company_id': fields.related('price_version_id','company_id',type='many2one',
381
387
readonly=True, relation='res.company', string='Company', store=True)