In product.supplierinfo I can create multiple suppliers with multiple unit prices:product.supplierinfo Supplier: JDoe (sequence: 1)
**pricelist.partnerinfo**
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