Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

[V8] How to completely hide an order line from a custom view?

By
FEDERICO LEONI
on 5/22/15, 6:12 PM 647 views

We send orders on different work centers and would be great have the pos order filtered on the personalized views I made (not inheriting the stock one) based on the pos category. It that way one workcenter cannot see the part of the order of another and will focus just on his products.

I've added the pos_categ_id field on pos.order and pos.order.line models and I'm already making the products invisible with 'attrs' using the pos category. Works fine but the order on notebook shows empty spaces where the code and the other information like price, quantity, etc, linked to a specific order line should be. The result could be an order with many empty lines before the chosen, filtered, products. 

Is there a way to completely hide the irrelevant lines from my view without creating a new module just to containing the new orders filtered?

1

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 5/23/15, 7:40 AM

try to use domain filter in your custom view:

Odoo domain filter 

domain for relational fields 

example:

<field name="my_one2many_field_name" domain="[('some_field', 'in', context.get('allowed_value_list_for_some_field'))]"/>

note: "some_field" used  in example should be available in the same view in xml as normal or as invisible field.

I'll answer on thread because on comment I didn't manage how to put code...

FEDERICO LEONI
on 5/23/15, 8:24 AM

it may be an option to use multiple views? lets say one view per workcenter type... it should not be too much. then set explicitly view to use in action record.

Temur
on 5/23/15, 8:39 AM

I'm already using a view for any of my work centers on a custom menu. And have a form view filtered by pos_category is exactly what I want. For that reason I'm hiding field with attrs (invisible). But how will you manage to filter with domain an entire form.view without creating others unnecessary fields?

FEDERICO LEONI
on 5/23/15, 8:48 AM

can you post a xml, or the part of it, where empty lines appear?

Temur
on 5/23/15, 8:53 AM

Sure, I've updated my reply.

FEDERICO LEONI
on 5/23/15, 9:29 AM
0
FEDERICO LEONI
On 5/23/15, 8:23 AM

Temur, 

thanks for your time. Sadly even if without syntax errors the filter is not working at all and shows all the products:

<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,qty,parent.partner_id)" domain="[('pos_categ_id', 'in', context.get('category2'))]"/> 

Just a note: product_id is a many2one field, not a one2many, and pos_categ_id (char) is related on pos_categ_id on product,template (many2one). 

Here is my xml:

<?xml version="1.0"?>
    <form string="Workcenter2 Orders">
<header>
<field name="state" widget="statusbar" statusbar_visible="draft,paid,done" statusbar_colors="{"cancel":"red"}"/>
</header>
<sheet>
<group col="4" colspan="4">
<field name="name"/>
<field name="date_order"/>
<field name="session_id" required="1"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer', '=', True)]" context="{'search_default_customer':1}"/>
</group>
<notebook colspan="4">
<page string="Products">
<field name="lines" colspan="4" nolabel="1">
<tree string="Order lines" editable="bottom">
<field name="qty" on_change="onchange_qty(product_id, discount, qty, price_unit, context)" attrs="{'invisible':[('pos_categ_id','=','pos2')]}"/>
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,qty,parent.partner_id)" attrs="{'invisible':[('pos_categ_id','=','pos2')]}"/>
<field name="price_unit" invisible="1"/>
<field name="pos_categ_id" attrs="{'invisible':[('pos_categ_id','=','pos2')]}"/>
</tree>
</field>
<div class="oe_clear"/>
<div class="col-xs-12 text-center">
<button name="622" string="Update" class="oe_highlight" type="action" attrs="{'invisible':[('x_kot_order','=','Ready')]}" />
</div>
</page>
</notebook>
</sheet>
    </form>

And this is what the order looks like when I hide the 'pos2' category (the empty line in the middle). 

 

sorry, I thought it's one2many lines, then domain should work. in many2one domain affects only edit state (you'll have possibility to choose possible values from a list already filtered with domain while editing a record). for normal fields and many2one invisible attribute should be suffice, then where those empty lines come from? maybe fields are wrapped in <grpup > tag? or something that leaves space?

Temur
on 5/23/15, 8:33 AM

There is just a group definition for columns on the header of the form but just before notebook tag is declared. Then the order lines should be not be affected. I'll play a little bit with domain and I see what I can do.

FEDERICO LEONI
on 5/23/15, 9:46 AM

if domain is correct choice for you, then you should place domain property in a "lines" field tag.

<field name="lines" colspan="4" nolabel="1" domain="[ ... ]" />
Temur
on 5/25/15, 4:11 AM

first things first. I see you try to hide fields inside of list(tree)... but I don't get what kind of empty spaces appear? these are empty lines or empty rows in the list? first we need to pick up right tool, if you want to hide columns then correct tool to use is invisible property, but if you want to hide lines(rows), then use domain. so what is a requirement? hide lines(rows) in the list or hide columns ?

Temur
on 5/25/15, 6:15 AM

if domain is correct choice for you, then you should place domain property in a "lines" field tag.

<field name="lines" colspan="4" nolabel="1" domain="[ ... ]" />
Temur
on 5/25/15, 6:16 AM

Yes! I need to hide the entire row! Sorry for this misunderstanding, but English isnot my primary language. Anyway I tried to declare a domain on my line but but even with no errors I didn't get any kind of filter...

 field name="lines" colspan="4" nolabel="1" domain="[('pos_categ_id', 'in', context.get('pos3'))]" 
I've tried other syntax too, like
domain="[('pos_categ_id', '=','pos3')]"
With the same results.
FEDERICO LEONI
on 5/25/15, 7:49 AM

Ok. Probably I see where the problem is: pos_categ_id was merged on pos.order.line, and the filed 'lines' (many2one) is on pos.oder (related to order_id, one2many). I think the form doesn't "see" the filter and add pos_categ_id to the pos.order model rises errors on webpos I didn't manage to sort for now.

FEDERICO LEONI
on 5/25/15, 4:16 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/22/15, 6:12 PM
Seen: 647 times
Last updated: 5/23/15, 12:17 PM