Hi!
Using domain would not lead you to required behavior. In case of tables it is used in case of many2many fields in order to restrict selection, not visibility of rows. So, it is a constraint to choose records
If I'm not mistaken, the only way to achieve the desired requirement, is to re-define the functions on the Python level.
I guess, there are 2 alternatives:
1. TO re-define the get method of a related model. Technically better, but may influence other places, where lines are used in the interface
2. To create a new computed table, where to put only desired lines, and inverse them in original method. This is logically simplier, e.g.:
To the model account invoice:
@api.multi def _compute_new_line_ids(self)
for invoice in self:
new_ids = invoice.line_ids.filtered(
lambda t: t.quantity > 0,
)
invoice.new_line_ids = [(6,0,new_ids.ids )]
new_ids = invoice.line_ids.filtered(
lambda t: t.quantity == 0,
)
invoice.new_line_ids_zero = [(6,0,new_ids.ids )]
@api.multi def _inverse_new_line_ids(self):
for invoice in self:
invoice.line_ids = [(6,0,invoice.new_line_ids + invoice.new_line_ids_zero)]
new_line_ids = fields.One2many(
"account.invoice.line",
"invoice_new_id",
compute=_compute_new_line_ids,
inverse=_inverse_new_line_ids,
string="Invoice Lines) # invoice_new_id - is a new back reference in line model
new_line_ids_zero = fields.One2many(
"account.invoice.line",
"invoice_new_id_2",
compute=_compute_new_line_ids,
inverse=_inverse_new_line_ids,
string="Invoice Lines) # invoice_new_id_2 - is a new back reference in line model
On a xml form replace line_ids with new_line_ids