[IMP] website_sale: Stock Availability banner on shop/product/id view
An availability selection field with 3 values : - Display nothing - In stock - Warning + a warning message that could be something like 'available with a variable delay of 15 days
This commit is contained in:
@@ -92,6 +92,12 @@ class ProductTemplate(models.Model):
|
||||
default=lambda self: self._default_website_sequence())
|
||||
public_categ_ids = fields.Many2many('product.public.category', string='Website Product Category',
|
||||
help="Those categories are used to group similar products for e-commerce.")
|
||||
availability = fields.Selection([
|
||||
('empty', 'Display Nothing'),
|
||||
('in_stock', 'In Stock'),
|
||||
('warning', 'Warning'),
|
||||
], "Availability", default='empty', help="This field is used to display a availability banner with a message on the ecommerce")
|
||||
availability_warning = fields.Text("Availability Warning", translate=True)
|
||||
|
||||
def _default_website_sequence(self):
|
||||
min_sequence = self.sudo().search([], order='website_sequence', limit=1).website_sequence
|
||||
|
||||
@@ -389,6 +389,16 @@
|
||||
|
||||
</form>
|
||||
|
||||
<hr/>
|
||||
<div t-if="product.availability == 'in_stock'" class="alert alert-success">
|
||||
<span class="fa fa-check"/>
|
||||
<span>In Stock</span>
|
||||
</div>
|
||||
<div t-if="product.availability == 'warning'" class="alert alert-warning">
|
||||
<span class="fa fa-warning"/>
|
||||
<span t-field="product.availability_warning"/>
|
||||
</div>
|
||||
|
||||
<hr t-if="product.description_sale"/>
|
||||
<div><p t-field="product.description_sale" class="text-muted"/></div>
|
||||
<hr/>
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
<field name="public_categ_ids" widget="many2many_tags" string="Website Categories"/>
|
||||
<field name="alternative_product_ids" widget="many2many_tags"/>
|
||||
<field name="accessory_product_ids" widget="many2many_tags"/>
|
||||
<field name="availability" widget="selection"/>
|
||||
<field name="availability_warning" attrs="{'invisible': [('availability', '!=', 'warning')]}"/>
|
||||
<field name="website_style_ids" widget="many2many_tags" groups="base.group_no_one"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user