Skip to content

Commit 4619b18

Browse files
committed
[FIX] website_sale: publish product after creation
This is a follow-up for the task: 3977931. In this commit, we make sure that the `product.product_product_view_form_normalized`, which is the common form view used to create a product on-the-fly from different modules, includes the Website Category field and if it's filled, the product is automatically `website_published`. We accomplish this by moving the `public_categ_ids` field from `website_sale.product_product_view_form_normalized_website_sale` to `product.product_product_view_form_normalized`. NOTE that `website_sale.product_product_view_form_normalized_website_sale` should be present and remained the view used by website_sale since it uses the `website_new_content_form` custom form view. closes odoo#176450 Signed-off-by: Fabien Pinckaers (fp) <fp@odoo.com>
1 parent 8c90fc1 commit 4619b18

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

addons/website_sale/models/product_product.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,10 @@ def _is_add_to_cart_allowed(self):
139139
website = self.env['website'].get_current_website()
140140
return (is_product_salable and website.has_ecommerce_access()) \
141141
or self.env.user.has_group('base.group_system')
142+
143+
@api.onchange('public_categ_ids')
144+
def _onchange_public_categ_ids(self):
145+
if self.public_categ_ids:
146+
self.website_published = True
147+
else:
148+
self.website_published = False

addons/website_sale/views/product_product_add.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
<xpath expr="//field[@name='company_id']" position="before">
1414
<field name="website_url" invisible="1"/>
1515
</xpath>
16+
</field>
17+
</record>
18+
19+
<record id="product_product_view_form_normalized" model="ir.ui.view">
20+
<field name="name">product.product.view.form.normalized.website.sale</field>
21+
<field name="model">product.product</field>
22+
<field name="inherit_id" ref="product.product_product_view_form_normalized"/>
23+
<field name="arch" type="xml">
1624
<div name="tax_info" position="after">
1725
<field name="public_categ_ids" string="Website Category" class="oe_inline" widget="many2many_tags" placeholder="Unpublished"/>
1826
</div>

0 commit comments

Comments
 (0)