system_administration:infrastructure:module_manager

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
system_administration:infrastructure:module_manager [2022/09/18 11:42] madjidsystem_administration:infrastructure:module_manager [2022/09/18 15:24] (current) – removed madjid
Line 1: Line 1:
-====== Module-Manager ======  
-===== fonctionnement du module ===== 
-Quand l’utilisateur clique sur le lien de téléchargement de l'attachement au niveau du portail Odoo : 
-La fonction download_attachement() sera lancé ,elle vérifie si le client à acheté le produit associé 
-<code python> 
-def download_attachment(self, attachment_id): 
-        # Check if this is a valid attachment id 
-        log.warning("########### i''m in #######################") 
-        attachment = request.env['ir.attachment'].sudo().search_read( 
-            [('id', '=', int(attachment_id))], 
-            ["name", "datas", "mimetype", "res_model", "res_id", "type", "url"] 
-        ) 
  
-        if attachment: 
-            attachment = attachment[0] 
-        else: 
-            return redirect(self.orders_page) 
- 
-        # Check if the user has bought the associated product 
-        res_model = attachment['res_model'] 
-        res_id = attachment['res_id'] 
-        purchased_products = request.env['account.move.line'].get_digital_purchases() 
- 
- 
-        if res_model == 'product.product': 
-            if res_id not in purchased_products: 
-                return redirect(self.orders_page) 
-</code> 
-Aussi elle vérifie la pièce jointe (attachement) sur le module product.template  
-<code python> 
- # Also check for attachments in the product templates 
-        elif res_model == 'product.template': 
-            template_ids = request.env['product.product'].sudo().browse(purchased_products).mapped('product_tmpl_id').ids 
-            if res_id not in template_ids: 
-                return redirect(self.orders_page) 
- 
-        else: 
-            return redirect(self.orders_page) 
-</code> 
-Si le type de l’attachement ='module' une requête sera envoyé pour vérifier si les modules avec ces versions existe sur le serveur (module-manager) a travers la route : http://m-m/api/update/modules/version 
-<code python> 
-data = [] 
-# Get the list of product & append them in a list [name, version] 
-for a in attachments: 
-    if a['version']: 
-        b = requests.get(f'{static_url}/api/update/modules/{a["version"]}') 
-        log.warning('======== B ============== {} '.format(b)) 
-        data.append( 
-            { 
-            "name": a['name'], 
-            "version": a['version'] 
-            }) 
-</code> 
- 
-Au niveau du serveur Module-manager: 
-La fonction update_module_list() fait appel à la fonction module_populator(): 
-<code python> def update_module_list(request, version): 
-    utils.modules_populator(Module, str(version)) 
-    return JsonResponse({'status': 200, 'date':" DATE "}) 
-</code> 
-La fonction module_populator() récupère la version du module et le nom du modele: 
-<code python> 
-def modules_populator(model, version): 
-    """ 
-        Create Modules in The Local Database     
-    """ 
-    for module in get_module_list(version=version): 
-        # Check if module exists in the local database 
-        if not model.objects.filter( 
-            name=module, 
-            version=version 
-            ).exists(): 
-                model.objects.create( 
-                    name=module, 
-                    version=version 
-                ) 
-</code> 
- 
- 
- 
- 
- 
- 
- 
-  
  • system_administration/infrastructure/module_manager.1663497761.txt.gz
  • Last modified: 2022/09/18 11:42
  • by madjid