Files
Victor Feyens 5a801bc602 [ADD] product,(website_)sale: product documents
Introduce new model of "Product Documents" to hold documents linked
to a given product template/variant, displayed on:

* quotations
* confirmed sale orders
* e-commerce product page

This will also replace the previous "Digital Files" (website_sale_digital)
logic & module, which allowed to specify product documents available
to customers after the SO invoice was paid.

This exact feature will be lost after upgrade, since we only keep the
choice to link documents on quotations/orders, but:

1) on e-commerce, carts are supposed paid when confirmed
2) on portal, the "Online Payment" settings makes sure the users
have to pay to confirm their quotation.

therefore we consider new configuration sufficient, without needing
a "paid order" choice as well.

task-3249201

Part-of: odoo/odoo#132739
2023-09-05 10:59:17 +00:00

21 lines
939 B
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
class ProductDocument(models.Model):
_inherit = 'product.document'
shown_on_product_page = fields.Boolean(string="Show on product page")
@api.constrains('res_model', 'shown_on_product_page')
def _unsupported_product_product_document_on_ecommerce(self):
# Not supported for now because product page is dynamic and it would require a lot of work
# to update documents shown according to combination. It'll wait for planned tasks
# rebuilding the product page & variant mixin.
for document in self:
if document.res_model == 'product.product' and document.shown_on_product_page:
raise ValidationError(
_("Documents shown on product page cannot be restricted to a specific variant"))