Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2393 Lượt xem

i am using odoo 14 and trying to create a server action button in product list view. 


"""

record is defined in comment section

"""


server action defines here 


class Products(models.Model):
_inherit = "product.template"

def batch_publish(self):
for prod in self :
if prod.can_publish and prod.is_published != True :
prod.is_published = True


But i got error upgrading the module.

Ảnh đại diện
Huỷ bỏ
Tác giả

<record id="batch_publish_products" model="ir.actions.server">

<field name="name">Published</field>

<field name="model_id" ref="product.template"/>

<field name="binding_view_id" ref="product.template"/>

<field name="binding_view_types">list</field>

<field name="state">code</field>

<field name="code">action = records.batch_publish()</field>

</record>

Câu trả lời hay nhất
try this
Ảnh đại diện
Huỷ bỏ

<record id="batch_publish_products" model="ir.actions.server">

<field name="name">Published</field>

<field name="model_id" ref="your_module_name.product_template"/>

<field name="binding_model_id" ref="your_module_name.product_template"/>

<field name="state">code</field>

<field name="code">action = records.batch_publish()</field>

</record>

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 9 25
2654
0
thg 8 25
205
1
thg 8 25
2168
2
thg 7 25
8065
2
thg 7 25
4521