Bonjour a tous,
Voila mon problème est que je n'arrive pas a faire un group by de mon champ many2one dans ma vue tree.
Voici mon code :
Ci-dessous ce trouve ma table ou j'ai met champ de recherche et ou ce trouve mon champ many2one.
Ci-dessous ce trouve l'autre table ou pointe mon many2one et plus prècisement sur le champ "name"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 class res_recherche(osv.osv): _name = "zen.recherche" _columns = { 'recherche_NomDestinataire': fields.many2one('zen.destinateur', 'Nom Destinataire'), 'recherche_numero_address': fields.char('N Rue'), 'recherche_adresse': fields.char('Adresse'), 'recherche_code_postal': fields.char('Code postal'), 'recherche_ville': fields.char('Ville'), 'recherche_name': fields.char('Name'), 'recherche_pays': fields.many2one('res.country', 'Pays'), } def destinateur_info(self, cr, uid, ids, client_id): client_ids = self.pool.get('zen.destinateur').search(cr, uid, [('id', '=', client_id)]) objs = self.pool.get('zen.destinateur').browse(cr, uid, client_ids) res = {} for obj in objs: res = { 'value': { 'recherche_numero_address': obj.dest_numero_address, 'recherche_adresse': obj.dest_adresse, 'recherche_code_postal': obj.dest_code_postal, 'recherche_ville': obj.dest_ville, 'recherche_pays': obj.dest_pays.id, 'recherche_name': obj.id, } } return res
Et ci-dessous mon xml de ma vue de recherche ou ce trouve mes filtre, champ form et tree.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 class res_outils_expediteur(osv.osv): _name = "zen.destinateur" _columns = { 'dest_Chauffeur': fields.many2one('hr.employee', 'Chauffeur', domain=[('department_id.id', '=', 1)], required=True), 'Expediteur': fields.many2one('res.partner', 'Expediteur', required=True), 'name': fields.char('Nom Destinataire', required=True), 'name_compl': fields.char('Nom Complementaire'), 'dest_numero_client': fields.char('N Client'),
Voici quelque photos montrant ce que j'ai comme résultat sur Odoo.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 <!-- ************************************************************************************************************************ ************************************************************************************************************************ VUE RECHERCHE ************************************************************************************************************************ ************************************************************************************************************************ --> <record model="ir.ui.view" id="view_zen_recherche_search"> <field name="name">zen.recherche.filtre</field> <field name="model">zen.recherche</field> <field name="arch" type="xml"> <search> <field name="recherche_NomDestinataire"/> <field name="recherche_numero_address"/> <field name="recherche_adresse"/> <field name="recherche_code_postal"/> <field name="recherche_ville"/> <field name="recherche_pays"/> <field name="recherche_name"/> <group expand='0' string='Group by...'> <filter name="group_recherche_NomDestinataire" string="Nom Destinataire" icon="terp-partner" context="{'group_by' : 'recherche_NomDestinataire'}"/> <!--domain="[('recherche_NomDestinataire','=','name')]"--> <filter name="group_recherche_numero_address" string="N° Rue" icon="terp-partner" context="{'group_by':'recherche_numero_address'}"/> <filter name="group_recherche_adresse" string="Adresse" icon="terp-partner" context="{'group_by':'recherche_adresse'}"/> <filter name="group_recherche_code_postal" string="Code Postal" icon="terp-partner" context="{'group_by':'recherche_code_postal'}"/> <filter name="group_recherche_ville" string="Ville" icon="terp-partner" context="{'group_by':'recherche_ville'}"/> <filter name="group_recherche_pays" string="Pays" icon="terp-partner" context="{'group_by':'recherche_pays'}"/> <filter name="group_recherche_name" string="Name" icon="terp-partner" context="{'group_by':'recherche_name'}"/> </group> </search> </field> </record> <record id="view_zen_recherche_form" model="ir.ui.view"> <field name="name">zen.recherche.form</field> <field name="model">zen.recherche</field> <field name="arch" type="xml"> <form> <sheet> <group string="Destinataire"> <field name="recherche_NomDestinataire" on_change="destinateur_info(recherche_NomDestinataire)" style="width: 40%"/> <field name="recherche_name" style="width: 30%"/> </group> <group string="Adresse"> <label for="recherche_numero_address" string="Adresse" style="min-width: 70px !important;width : 70px;"/> <div class="address_format" t-name="etiquette_module"> <field name="recherche_numero_address" style="width: 10%" placeholder="N°" nolabel="1"/> <field name="recherche_adresse" placeholder="Rue ..." style="width: 75%" nolabel="1"/> <div class="address_format"> <field name="recherche_code_postal" placeholder="CP" style="width: 75px;margin-right: 1em;" nolabel="1"/> <field name="recherche_ville" placeholder="City" style="width: 180px;" nolabel="1"/> </div> <field name="recherche_pays" placeholder="Pays" style="width: 40%"/> </div> </group> </sheet> </form> </field> </record> <record id="view_zen_recherche_tree" model="ir.ui.view"> <field name="name">zen.recherche.tree</field> <field name="model">zen.recherche</field> <field name="context">{ "search_default_filter_group_recherche_NomDestinataire":1, "search_default_filter_group_recherche_numero_address":1, "search_default_filter_group_recherche_adresse":1, "search_default_filter_group_recherche_code_postal":1, "search_default_filter_group_recherche_ville":1, "search_default_filter_group_recherche_pays":1, "search_default_filter_group_recherche_name":1, }</field> <field name="arch" type="xml"> <tree> <field name="recherche_NomDestinataire"/> <field name="recherche_numero_address"/> <field name="recherche_adresse"/> <field name="recherche_code_postal"/> <field name="recherche_ville"/> <field name="recherche_pays"/> <field name="recherche_name"/> </tree> </field> </record>
1er : Représente les records que j'ai dans ma table zen.recherche et ou je doit faire mon "GROUP BY"
2éme : En haut ce trouve met différents filtre qui sont tous des "GROUP BY"
3éme : Voici le "GROUP BY" avec mon champ name qui correspond a l'ID des records dans ma table "zen.destinateur"
4éme : Et voici l'erreur, je fais mon "GROUP BY" par rapport a mon champ many2one, il récupère bien les nom de mes champs de mon many2one mais par contre il trouve aucun records alors qu'il y en a.
J’espère avoir étais le plus précis possible, si des points ne sont pas claire ou mal expliquer, veuillez me le dire pour que je l'ai développe plus précisément.
Merci d'avoir lu mon message
Cordialement Risakiel
Partager