[imp] add publish/unpublish button for products

This commit is contained in:
Niels Göttsch 2024-07-30 17:22:26 +02:00
parent 61c1ad297c
commit cd271b6478
4 changed files with 30 additions and 1 deletions

View file

@ -6,7 +6,7 @@
"category": "website", "category": "website",
"version": "16.0.1.0.0", "version": "16.0.1.0.0",
"depends": ["website_sale", "nfu_sale_order_batch_packaging"], "depends": ["website_sale", "nfu_sale_order_batch_packaging"],
"data": ["views/templates.xml"], "data": ["views/product_template_views.xml", "views/templates.xml"],
"assets": {"web.assets_frontend": ["nfu_ecommerce/static/src/js/website_sale.js"]}, "assets": {"web.assets_frontend": ["nfu_ecommerce/static/src/js/website_sale.js"]},
"license": "LGPL-3", "license": "LGPL-3",
} }

View file

@ -1,2 +1,3 @@
from . import product_template
from . import sale_order from . import sale_order
from . import sale_order_line from . import sale_order_line

View file

@ -0,0 +1,13 @@
from odoo import models
class ProductTemplate(models.Model):
_inherit = "product.template"
def action_publish_on_website(self):
for product in self:
product.is_published = True
def action_unpublish_on_website(self):
for product in self:
product.is_published = False

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_template_tree_view" model="ir.ui.view">
<field name="name">product.template.product.tree.inherit.website</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button string="Publish on Website" type="object" name="action_publish_on_website"/>
<button string="Unpublish on Website" type="object" name="action_unpublish_on_website"/>
</xpath>
</field>
</record>
</odoo>