Trying to use view_ids in form

i am trying to define some view

i have a class

class Contrats(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin):
	'Contrats'
	__name__ = 'formo.contrats'
[.....]
    produits = fields.Many2Many(
		'formo.contrats_rel_product.product', 'contrat', 'produit', "Produits")
==== link=====
class ContratsProduits(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin):
    'Contrats - Produits'
    __name__ = 'formo.contrats_rel_product.product'
    _table = 'formo_contrat_products_rel'
    contrat = fields.Many2One('formo.contrats', 'Contrat', ondelete='CASCADE',
            required=True, select=True)
    produit = fields.Many2One('product.template', 'Produits',
        ondelete='CASCADE', required=True, select=True)
    goToZz=fields.Boolean('Zz')

if in a view i chose to show the ā€œproduitsā€ (i though i should view ContratsProduits as it is link to it, but i just see product.product

 <record model="ir.ui.view" id="formo_delatour_contrat_form_id">
    <field name="model">formo.contrats</field>
    <field name="type">form</field>
    <field name="name">contrat_form</field>
</record>

==== in view/contrat_form.xml ====
        <field name="produits" colspan="2"/>

i see the product template

if i create a tree/form

   <record model="ir.ui.view" id="formo_delatour_contrat_produits_tree_id">
    <field name="model">formo.contrats_rel_product.product</field>
    <field name="type">tree</field>
    <field name="name">contrat_produits_tree</field>
</record>

==== in view/contrat_form.xml ====
        <field name="produits" colspan="2"/>

        <field name="produits" colspan="2"
        view_ids="formo_delatour.formo_delatour_contrat_produits_tree_id "/>

formo_delatour is the name of the module. it says it cans find the ui
keyError: ā€˜Reference to formo_delatour.formo_delatour_contrat_produits_form_id not foundā€™

but in the ir_ui_view

 id  |               model                | type | data | field_childs | priority |        create_date         | create_uid | domain | inherit |          module          |            name             | write_date | write_uid 
-----+------------------------------------+------+------+--------------+----------+----------------------------+------------+--------+---------+--------------------------+-----------------------------+------------+-----------
 580 | formo.contrats_rel_product.product | form |      |              |       16 | 2024-12-13 09:22:31.504482 |          0 |        |         | formo_delatour           | contrat_produits_form       |            |          
 579 | formo.contrats_rel_product.product | tree |      |              |       16 | 2024-12-13 09:22:31.504482 |          0 |        |         | formo_delatour           | contrat_produits_tree       |            |          
 578 | formo.contrats_rel_ayant_droits    | form |      |              |       16 | 2024-12-13 09:22:31.504482 |          0 |        |         | formo_delatour           | contrat_ayantdroits_form    |            |          
 577 | formo.contrats_rel_ayant_droits    | tree |      |              |       16 | 2024-12-13 09:22:31.504482 |          0 |        |         | formo_delatour           | contrat_ayantdroits_tree    |            |          
 576 | formo.contrats                     | form |      |              |       16 | 2024-12-13 09:22:31.504482 |          0 |        |         | formo_delatour           | contrat_form                |            |          
 575 | formo.contrats                     | tree |      |              |       16 | 2024-12-13 09:22:31.504482 |          0 |        |         | formo_delatour           | contrat_tree                |            |          
 574 | product.template                   | tree |      |              |       16 | 2024-12-13 09:22:31.504482 |          0 |        |         | formo_delatour           | product_list                |            |          

what did i missed ?

There is a trailing space.

1 Like

without that trailling space i just have processing also the view acts correctly alone. maybe i should link with the contract id with something like [ā€˜domainā€™]???

i have the impression to do the same as in party and contact_mechanismā€¦ but mine is not workingā€¦ iā€™ll inspect much more precisely

the one is One2many, mine is many2manyithink i misunderstood the One2Many Many2One and Many1Many filedsā€¦

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.