This question has been flagged
1 Reply
4528 Views

Hello Guys

I have created  a report like this :

<report
      id="action_report_batch_product_config"
      string="GuiLherme Configuration Configuration"
      model="stock.picking.batch"
      report_type="qweb-pdf"
      name="teste2"
      file="teste2"
      paperformat=format_teste"
      menu="True"
print_report_name="'Batch Product Config- %s' % (object.name)"
  />

It worked as expected. However I need to show it and sometimes I need to get it invisible due the value that I have in the stock.picking.batch model.

Could u please help me on that ?

Thank you so much

Avatar
Discard
Best Answer

Hi,

Easily what you can do is that, hide the report from the print by giving menu="False" inside the report tag(which you shown in the question) and print the same report from a button in the header of the form. Once you add the button in form and use it for printing, you can easily make it visible and invisible using the attrs .

<report
id="action_report_batch_product_config"
string="GuiLherme Configuration Configuration"
model="stock.picking.batch"
report_type="qweb-pdf"
name="teste2"
file="teste2"
menu="False"
print_report_name="'Batch Product Config- %s' % (object.name)"/>

Add a button to form view,

<button name="print_picking_new" string="Print" type="object" class="oe_highlight"/>


then in the model,

def print_picking_new(self):
return self.env.ref('module_name.action_report_batch_product_config').report_action(self)


Now the print button will be visible always, for making it visible and invisible you can add attrs and give condition, a sample is given below,


<button string="Configure Variants" type="action"
name="%(product_attribute_value_action)d"
attrs="{'invisible': ['|', ('attribute_line_ids', '&lt;=', 0), ('is_product_variant', '=', True)]}"
groups="product.group_product_variant"/>


Thanks

Avatar
Discard