Hi,
I’m having some problems to move a view from a module A to a module B in my custos.
I’ve defined a view in a module A which is specific for a department.
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="purchase_move_view_list">
<field name="model">stock.move</field>
<field name="type">tree</field>
<field name="name">purchase_move_list</field>
</record>
<record model="ir.ui.view" id="purchase_move_view_form">
<field name="model">stock.move</field>
<field name="type">form</field>
<field name="name">purchase_move_form</field>
</record>
<record model="ir.action.act_window" id="act_move_form_custo">
<field name="name">Purchase Moves</field>
<field name="res_model">stock.move</field>
<field name="domain"
eval="[['OR', ('from_location.type', '=', 'supplier'), ('shipment', 'like', 'stock.shipment.in,%')], ('state', '=', 'draft')]"
pyson="1"/>
<field name="order" eval="[('planned_date', 'ASC'), ('id', 'DESC')]" pyson="1"/>
</record>
<record model="ir.action.act_window.view" id="act_move_form_incoming_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="purchase_move_view_list"/>
<field name="act_window" ref="act_move_form_custo"/>
</record>
<record model="ir.action.act_window.view" id="act_move_form_incoming_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="purchase_move_view_form"/>
<field name="act_window" ref="act_move_form_custo"/>
</record>
...
I’ve also added some new specificfields to the model stock.move and those fields are also on the forms.
I noticed this view should be available for the whole company so I’ve decided to migrate the view into module B but keeping fields customizations in module A.
So I’ve move the xml code above from module A to module B and to keep my fields customizations in module A, I’m doing an inherit from the views.
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="purchase_move_view_list">
<field name="model">stock.move</field>
<field name="inherit" ref="moduleB.purchase_move_view_list"/>
<field name="name">purchase_move_list</field>
</record>
<record model="ir.ui.view" id="purchase_move_view_form">
<field name="model">stock.move</field>
<field name="inherit" ref="moduleB.purchase_move_view_form"/>
<field name="name">purchase_move_form</field>
</record>
</data>
</tryton>
When doing trytond-admin -c config.file -d database –all , I’m getting this error:
Traceback (most recent call last):
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/convert.py”, line 414, in parse_xmlstream
self.sax_parser.parse(source)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File “/usr/lib/python3.13/xml/sax/expatreader.py”, line 105, in parse
xmlreader.IncrementalParser.parse(self, source)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File “/usr/lib/python3.13/xml/sax/xmlreader.py”, line 124, in parse
self.feed(buffer)
~~~~~~~~~^^^^^^^^
File “/usr/lib/python3.13/xml/sax/expatreader.py”, line 211, in feed
self._parser.Parse(data, isFinal)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File “./Modules/pyexpat.c”, line 473, in EndElement
File “/usr/lib/python3.13/xml/sax/expatreader.py”, line 344, in end_element
self._cont_handler.endElement(name)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/convert.py”, line 468, in endElement
self.taghandler = self.taghandler.endElement(name)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/convert.py”, line 318, in endElement
self.mh.import_record(
~~~~~~~~~~~~~~~~~~~~~^
self.model.name, self.values, self.xml_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/convert.py”, line 551, in import_record
self.write_records(model, mdata, values)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/convert.py”, line 595, in write_records
Model.write(*to_update)
~~~~~~~~~~~^^^^^^^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/model/modelsql.py”, line 277, in wrapper
return func(cls, *args, **kwargs)
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/model/modelsql.py”, line 1505, in write
cls._after_write(all_ids, field_names, on_write, trigger_eligibles)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/transaction.py”, line 63, in wrapper
return func(*args, **kwargs)
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/model/modelstorage.py”, line 409, in _after_write
cls._validate(records, field_names=field_names)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/model/modelstorage.py”, line 1598, in _validate
validate_domain(field)
~~~~~~~~~~~~~~~^^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/model/modelstorage.py”, line 1501, in validate_domain
validate_relation_domain(
~~~~~~~~~~~~~~~~~~~~~~~~^
field, list(sub_records), Relation, sub_domain)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/mrichez/Workspace/tryton/issues/tryton_76_dev/trytond/trytond/model/modelstorage.py”, line 1577, in validate_relation_domain
raise DomainValidationError(
msg, domain=(invalid_domain, field_def))
trytond.model.modelstorage.DomainValidationError: The value “Tree” for field “View Type” in record “Stock Move (Stock Move (Tree))” of “Ui View” is not valid according to its domain. -
To bypass the problem, I had to update some fields in database to bypass the domain validation:
update ir_ui_view set type = Null where module = ‘module A’ and name in (‘purchase_move_list’, ‘purchase_move_form’)
Is there another possibility to solve properly this case ?