Odoo Help


How can I select a single price from pricelist_partnerinfo and place in custom model field?

on 2/9/16, 7:06 AM 396 views

In product.supplierinfo I can create multiple suppliers with multiple unit prices:product.supplierinfo Supplier: JDoe (sequence: 1)

    Quantity: 200 Unit price: 250
    Quantity  300 Unit price  235
    Quantity  500 Unit price  215

In a custom model, I want to use the unit price, based on condition: e.g.

If quantity = 299 or less select unit price 250,
Elif quantity => 300 and <= 500 unit price 235,
Elif quantity => 500 unit price 215

Without the use of pricelists, I want to be able to use pricelist.partnerinfo prices for further calculations in a new product.

#  paper qualities e.g: product.template

class qualities(models.Model):
    _name = 'qualities'
    _description = 'Sheet Qualities'

name = fields.Char('Kwaliteit', required=True, help='Kwaliteit naam')
code_id = fields.Char('Interne code')
marge = fields.Integer('Marge (%)', help="Marge in % = inkoopprijs vs werkprijs")
samenstelling = fields.Char('Samenstelling')
golfdikte = fields.Float('Golfdikte in mm', digits=(3, 1))
golftype = fields.Char('Golf type code')
gramsgewicht = fields.Float('Gramsgewicht / m2', digits=(3, 1))
state = fields.Boolean('active', default=True)
quality_oms = fields.Text('Opmerkingen')
reseller_ids = fields.One2many('kwaliteitinfo', 'product_qual_id', 'Quality Supplier')   
# Quality supplier e.g.: product.supplierinfo
class kwaliteitinfo(models.Model):
_name = 'kwaliteitinfo'
_description = "Information about a quality supplier"
name = fields.Many2one('res.partner', 'Supplier', required=True,domain = [('supplier','=',True)], ondelete='cascade')
product_name = fields.Char('Supplier Product Name')
product_code = fields.Char('Supplier Product Code')
sequence = fields.Integer('Sequence')
min_qty = fields.Float('Minimal Quantity', required=True)
qty = fields.Float(compute=_calc_qty, store=True, string='Quantity', multi="qty")
product_qual_id = fields.Many2one('qualities', 'Quality Template', ondelete='cascade', select=True)
delay = fields.Integer('Delivery Lead Time', required=True)
pricelist_ids = fields.One2many('qualitylist.partnerinfo', 'suppinfo_id', 'Supplier Pricelist', copy=True)
company_id = fields.Many2one('res.company','Company',select=1)

# Quality suppliers prices E.g.: Pricelist.partnerinfo
class qualitylist_partnerinfo(models.Model):
_name = 'qualitylist.partnerinfo'

name = fields.Char('Description')
suppinfo_id = fields.Many2one('kwaliteitinfo', 'Partner Information',       required=True, ondelete='cascade')
min_quantity = fields.Float('Quantity', required=True)
price = fields.Float('Unit Price', required=True)

_order = 'min_quantity asc'

How can I: 

1: select  supplier by sequence : set relation 

2: Based on conditions (quantity) select the price 

3: fill price into custom field for further calculations

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/9/16, 7:06 AM
Seen: 396 times
Last updated: 2/10/16, 3:39 AM