product.supplierinfo では、複数の単価で複数のサプライヤーを作成できます: product.supplierinfo サプライヤー: JDoe (シーケンス: 1)
**pricelist.partnerinfo**
Quantity: 200 Unit price: 250
Quantity 300 Unit price 235
Quantity 500 Unit price 215
カスタムモデルで、条件に基づいて単価を使用したい:例
If quantity = 299 or less select unit price 250,
Elif quantity => 300 and <= 500 unit price 235,
Elif quantity => 500 unit price 215
価格表を使用せずに、pricelist.partnerinfo の価格を使用して、新製品の詳細な計算を行えるようにしたいと考えています。
#-------------------------------------------------------------------------------
# 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'
方法: 1: 優先するサプライヤーをシーケンスで選択: 関係を設定する 2: 条件 (数量) に基づいて価格を選択する 3: カスタム フィールドに価格を入力してさらに計算する