[已解决]odoo10 确认视图优先级时的错误
-
确认过命名没有重复,是还有其他没有注意到的吗?
Traceback (most recent call last): File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 640, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 677, in dispatch result = self._call_function(**self.params) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 333, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/service/model.py", line 101, in wrapper return f(dbname, *args, **kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 326, in checked_call result = self.endpoint(*a, **kw) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 935, in __call__ return self.method(*args, **kw) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 506, in response_wrap response = f(*args, **kw) File "/home/hui/odoo-dev/odoo10/odoo/addons/web/controllers/main.py", line 889, in call_button action = self._call_kw(model, method, args, {}) File "/home/hui/odoo-dev/odoo10/odoo/addons/web/controllers/main.py", line 877, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/api.py", line 689, in call_kw return call_kw_multi(method, model, args, kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/api.py", line 680, in call_kw_multi result = method(recs, *args, **kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/addons/base/module/module.py", line 528, in button_immediate_upgrade return self._button_immediate_function(type(self).button_upgrade) File "/home/hui/odoo-dev/odoo10/odoo/odoo/addons/base/module/module.py", line 485, in _button_immediate_function modules.registry.Registry.new(self._cr.dbname, update_module=True) File "/home/hui/odoo-dev/odoo10/odoo/odoo/modules/registry.py", line 83, in new odoo.modules.load_modules(registry._db, force_demo, status, update_module) File "/home/hui/odoo-dev/odoo10/odoo/odoo/modules/loading.py", line 335, in load_modules force, status, report, loaded_modules, update_module) File "/home/hui/odoo-dev/odoo10/odoo/odoo/modules/loading.py", line 237, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/home/hui/odoo-dev/odoo10/odoo/odoo/modules/loading.py", line 156, in load_module_graph _load_data(cr, module_name, idref, mode, kind='data') File "/home/hui/odoo-dev/odoo10/odoo/odoo/modules/loading.py", line 95, in _load_data tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report) File "/home/hui/odoo-dev/odoo10/odoo/odoo/tools/convert.py", line 845, in convert_file convert_xml_import(cr, module, fp, idref, mode, noupdate, report) File "/home/hui/odoo-dev/odoo10/odoo/odoo/tools/convert.py", line 915, in convert_xml_import obj.parse(doc.getroot(), mode=mode) File "/home/hui/odoo-dev/odoo10/odoo/odoo/tools/convert.py", line 799, in parse self._tags[rec.tag](rec, de, mode=mode) File "/home/hui/odoo-dev/odoo10/odoo/odoo/tools/convert.py", line 707, in _tag_record id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode) File "/home/hui/odoo-dev/odoo10/odoo/odoo/addons/base/ir/ir_model.py", line 1229, in _update record = record.create(values) File "/home/hui/odoo-dev/odoo10/odoo/odoo/models.py", line 3823, in create record = self.browse(self._create(old_vals)) File "/home/hui/odoo-dev/odoo10/odoo/odoo/models.py", line 3918, in _create cr.execute(query, tuple(u[2] for u in updates if len(u) > 2)) File "/home/hui/odoo-dev/odoo10/odoo/odoo/sql_db.py", line 154, in wrapper return f(self, *args, **kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/sql_db.py", line 231, in execute res = self._obj.execute(query, params) ParseError: "duplicate key value violates unique constraint "act_window_view_unique_mode_per_action" DETAIL: Key (act_window_id, view_mode)=(153, tree) already exists. " while parsing /home/hui/odoo-dev/odoo10/abbsps/sps_product/views/product_template_views.xml:144, near <record id="product_template_sequence_tree_view1" model="ir.actions.act_window.view"> <field eval="1" name="sequence"/> <field name="view_mode">tree</field> <field name="view_id" ref="product_template_tree_view"/> <field name="act_window_id" ref="sps_product.product_template_action_all"/> </record>
-
错误并没有说你命名重复了,而是你的这条记录的值已经有对应的定义了。 window action和视图模式的组合只能有一条唯一记录。
-
有一个问题是
sequence
写在view_ids
中起作用,单独写ir.actions.act_window.view
(把view_ids
注释掉的情况),反而报错的。是```ir.actions.act_window```中写```view_ids```了,``sequence```写在```view_ids```中起作用。解决方法如下代码: <record id="product_template_action_all" model="ir.actions.act_window"> <field name="name">Parts</field> <field name="type">ir.actions.act_window</field> <field name="res_model">product.template</field> <field name="view_mode">tree,kanban,form</field> <field name="view_type">form</field> <field name="context">{}</field> <field name="help" type="html"> <p class="oe_view_nocontent_create"> Click to define a new product. </p> </field> <field name="view_ids" eval="[(5, 0, 0), (0, 0, {'sequence': '1', 'view_mode': 'tree', 'view_id': ref('product_template_tree_view')}), (0, 0, {'sequence': '2', 'view_mode': 'kanban', 'view_id': ref('product_template_kanban_view')}), (0, 0, {'sequence': '3', 'view_mode': 'form', 'view_id': ref('product_template_form_view')})]"/> </record>