Passing an id directly to `search_view_id` is not working. It is silently ignored. The framework js code expects an id/name pair, as described in the ORM doc. Most of the time, this will be unoticed as the specified search view being ignored, the default one will be used instead, which is often the same one as there is only one search view. Only 3 occurences are real misbehavior. Note that the `name` of the pair is useless, you can just pass the ID in an array. Working: 'search_view_id': [123, 'search'], 'search_view_id': [123], Not working: 'search_view_id': 123, closes odoo/odoo#72247 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import time
|
|
|
|
from odoo import api, fields, models, _
|
|
|
|
|
|
class ProductMargin(models.TransientModel):
|
|
_name = 'product.margin'
|
|
_description = 'Product Margin'
|
|
|
|
from_date = fields.Date('From', default=time.strftime('%Y-01-01'))
|
|
to_date = fields.Date('To', default=time.strftime('%Y-12-31'))
|
|
invoice_state = fields.Selection([
|
|
('paid', 'Paid'),
|
|
('open_paid', 'Open and Paid'),
|
|
('draft_open_paid', 'Draft, Open and Paid'),
|
|
], 'Invoice State', index=True, required=True, default="open_paid")
|
|
|
|
def action_open_window(self):
|
|
self.ensure_one()
|
|
context = dict(self.env.context, create=False, edit=False)
|
|
|
|
def ref(module, xml_id):
|
|
proxy = self.env['ir.model.data']
|
|
return proxy.get_object_reference(module, xml_id)
|
|
|
|
model, search_view_id = ref('product', 'product_search_form_view')
|
|
model, graph_view_id = ref('product_margin', 'view_product_margin_graph')
|
|
model, form_view_id = ref('product_margin', 'view_product_margin_form')
|
|
model, tree_view_id = ref('product_margin', 'view_product_margin_tree')
|
|
|
|
context.update(invoice_state=self.invoice_state)
|
|
|
|
if self.from_date:
|
|
context.update(date_from=self.from_date)
|
|
|
|
if self.to_date:
|
|
context.update(date_to=self.to_date)
|
|
|
|
views = [
|
|
(tree_view_id, 'tree'),
|
|
(form_view_id, 'form'),
|
|
(graph_view_id, 'graph')
|
|
]
|
|
return {
|
|
'name': _('Product Margins'),
|
|
'context': context,
|
|
"view_mode": 'tree,form,graph',
|
|
'res_model': 'product.product',
|
|
'type': 'ir.actions.act_window',
|
|
'views': views,
|
|
'view_id': False,
|
|
'search_view_id': [search_view_id],
|
|
}
|