我创建了一个包含多个产品的产品包,并且我希望在销售产品包时减少父产品和子产品的数量。我不知道该怎么做。如果有人可以,请帮助我。
class productpack(models.Model):
_name = "product.bundle"
_description = "The complete bundle of products"
config_prod_child_ids =
fields.Many2one(comodel_name='product.template',
string=' Config Product',
ondelete='cascade',
required=True
)
product_required = fields.Many2one('product.product', string =
"Required products",
required=True)
required_quantity = fields.Integer(string = " Required Quantity",
default = "1")
并且父母在:
Class ProductTemplate(models.Model):
_inherit = 'product.template'
config_prod_parent_ids = fields.One2many(comodel_name =
'product.bundle', inverse_name = 'config_prod_child_ids',
string = "Product Pack")
configure_ok = fields.Boolean(string='Can be Configured')