I need to use the values generated by a computed field in a domain, to hide specific lines in a tree view, I don't know if I'm using the domain in the wrong way. Exist other way to do what I need? Here's my code:
Python:
What I have done so far is to create a second field that stores the value of the computed field and apply it to the domain. Did not work
@api.one
def method_compute_invoice(self):
res = ''
if self.sale_id:
res = self.sale_id.state
_state = {'draft' : 'Draft Quotation', 'sent' : 'Quotation Sent', 'cancel' : 'Cancelled', 'waiting_date' : 'Waiting Schedule', 'progress' : 'Sales Order',
'manual' : 'Sale to Invoice', 'shipping_except' : 'Shipping Exception', 'done' : 'Done'}
res = _state.get( res, res )
if self.sale_id.invoiced:
res += '/invoiced'
if self.sale_id.shipped:
res += '/shipped'
self.compute_invoice = res
sql = "update visio_prepare_shipment_list set store_invoice = '%s' where id = %s" % (res, self.id)
self.env.cr.execute(sql)
# fields
compute_invoice = fields.Char('Current Odoo order Status', compute='method_compute_invoice')
store_invoice = fields.Char('Current Odoo order Status')
XML:
record id="action_prepare_shipment_tree" model="ir.actions.act_window"> <field name="name">Prepare For Shipment</field> <field name="type">ir.actions.act_window</field> <field name="res_model">visio.prepare.shipment.list</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="search_view_id" ref="prepare_shipment_filter"/> <field name="context">{'search_default_PackingList': 1}</field> <field name="domain">[('store_invoice','!=','Done/invoiced/shipped')]</field> </record>