← Back to team overview

clearcorp team mailing list archive

lp:~dr.clearcorp/openerp-ccorp-addons/6.1-stadistic_module_magento into lp:openerp-ccorp-addons

 

Diana Rodríguez Martínez has proposed merging lp:~dr.clearcorp/openerp-ccorp-addons/6.1-stadistic_module_magento into lp:openerp-ccorp-addons.

Requested reviews:
  CLEARCORP drivers (clearcorp-drivers)

For more details, see:
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/6.1-stadistic_module_magento/+merge/129530

[NEW] New module for product out of stock from magento 
-- 
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/6.1-stadistic_module_magento/+merge/129530
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons.
=== added directory 'magento_stadistic'
=== added file 'magento_stadistic/__init__.py'
--- magento_stadistic/__init__.py	1970-01-01 00:00:00 +0000
+++ magento_stadistic/__init__.py	2012-10-12 22:36:19 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by CLEARCORP S.A.
+#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import magento_stadistic

=== added file 'magento_stadistic/__openerp__.py'
--- magento_stadistic/__openerp__.py	1970-01-01 00:00:00 +0000
+++ magento_stadistic/__openerp__.py	2012-10-12 22:36:19 +0000
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by CLEARCORP S.A.
+#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    "name" : "Magento-OpenERP Stadistic",
+    "version" : "1.0",
+    "author" : "Clearcorp",
+    "license": 'AGPL-3',
+    'author': 'CLEARCORP S.A.',
+    'complexity': 'normal',
+    "description": """
+        Magento-Openerp Stadistic
+        ======================
+        Magento-OpenERP Stadistic. Generate reports and graphics for a failed magento sales and missing product in Magento Store
+        """,
+    "category" : "Interfaces/CMS & eCommerce",
+    "sequence": 4,
+    'website': 'http://www.clearcorp.co.cr',
+    "images" : [],
+    "depends" : ["product", "stock", "sale", "account", "account_analytic_default","sneldev_magento"],
+    "init_xml" : [],
+    "icon" : "icon.png",
+    "demo_xml" : [],
+    "update_xml" :  ['magento_stadistic_view.xml',
+                     'magento_stadistic_menu.xml',                     
+                     ],
+    "active": False,
+    "installable": True
+}

=== added file 'magento_stadistic/magento_stadistic.py'
--- magento_stadistic/magento_stadistic.py	1970-01-01 00:00:00 +0000
+++ magento_stadistic/magento_stadistic.py	2012-10-12 22:36:19 +0000
@@ -0,0 +1,90 @@
+from osv import fields,osv
+from mx import DateTime
+import netsvc
+import tools
+import pooler
+import time
+import datetime
+import math
+import os
+import traceback
+import traceback
+from pprint import pprint
+from pprint import PrettyPrinter
+
+from tools.translate import _
+
+class magento_stadistic (osv.osv):
+    _name = 'magento.stadistic'
+    _description = 'Magento stadistic info'
+    _columns = {
+        'product_ids': fields.many2one('product.product','Product'),
+        'date_out_of_stock': fields.date('Date'),
+        'customer_ids': fields.many2one('res.partner','Customer'),
+        'qty_product':fields.integer('Quantity'),      
+        'address':fields.related('customer_ids','address',type="one2many",relation="res.partner.address",string="Address",store=False)                 
+    } 
+    
+    _defaults = {
+        'date_out_of_stock': lambda *a: '2012-01-01',
+        'qty_product': lambda*a: 1,
+    }
+    
+    _sql_constraints = [
+        (
+            'qty_product_not_zero',
+            'CHECK(qty_product > 0)',
+            'The quantity of product must be greater than 0.'),
+            ]
+    """
+    def onchance_customer(self, cr, uid, ids, customer_ids, context={}):
+        v={}
+        if customer_ids:    
+            id = self.pool.get('res.partner').search(cr,uid,customer_ids)
+            customer = self.pool.get('res.partner').browse(cr,uid,customer_ids)
+            v['address']=customer.address.id
+            if customer.address.id:    
+                v['name']=customer.name.id    
+            
+    
+        return {'value':v}
+    """
+    def save_product (self,cr,uid,product_id,customer_id,qty_product):
+        magento_connect = self.pool.get('sneldev.magento')
+        try:
+            #First, import the product. If exist, update the info
+            magento_connect.import_products(cr, uid,product_id)
+            
+            #search the product in openerp and save in the magento_stadistic object
+            product_ids = []
+            product_ids_openerp = self.pool.get('product.product').search(cr, uid, ['magento_id', '=', product_id])       
+            for product in product_ids_openerp:
+                if product.id not in product_ids:
+                    product_ids.append(product.id)
+            
+            #Search the customer, if exist, update info and        
+            magento_connect.import_customers(cr,uid,customer_id)
+            customer_ids = []
+            customer_ids_openerp = self.pool.get('res.partner').search(cr,uid,['magento_id','=',customer_id])
+            for customer in customer_ids_openerp:
+                if customer.id not in customer_ids:
+                    customer_ids.append(customer.id)
+            
+            today = str(datetime.date.today())
+            
+            product_of_stock = {
+                'product_ids':[(6, 0, product_ids )],
+                'date_out_of_stock': today,
+                'customer_ids':[(6, 0, customer_ids )],
+                'qty_product':qty_product,
+            } 
+             
+            self.pool.get('magento.stadistic').create(cr, uid, product_of_stock)
+            
+        except:
+            log.append('Cannot create stadistic')
+            raise osv.except_osv(_('Error !'), _('Cannot get product, check Magento web user config'))
+            traceback.print_exc(file=sys.stdout)
+            return -1
+    
+magento_stadistic()
\ No newline at end of file

=== added file 'magento_stadistic/magento_stadistic_menu.xml'
--- magento_stadistic/magento_stadistic_menu.xml	1970-01-01 00:00:00 +0000
+++ magento_stadistic/magento_stadistic_menu.xml	2012-10-12 22:36:19 +0000
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+    	<record model="ir.actions.act_window" id="action_magento_stadistic_graphic_form">
+			<field name="name">Magento stadistic</field>
+			<field name="res_model">magento.stadistic</field>
+			<field name="view_type">form</field>
+			<field name="view_mode">tree,form,graph</field>
+		</record>  
+		    	
+    	<menuitem id="base.menu_magento_stadistic" name="Magento stadistic" web_icon="static/src/img/icon.png" web_icon_hover="static/src/img/menu.png" />
+			<menuitem name="Product" id="menu_magento_stadistic_product_form" parent="base.menu_magento_stadistic" />
+				<menuitem id="base.menu_magento_stadistic_product_sub_form" action="action_magento_stadistic_graphic_form" parent="menu_magento_stadistic_product_form" name="Out of stock"></menuitem>	
+	</data>
+</openerp>
\ No newline at end of file

=== added file 'magento_stadistic/magento_stadistic_view.xml'
--- magento_stadistic/magento_stadistic_view.xml	1970-01-01 00:00:00 +0000
+++ magento_stadistic/magento_stadistic_view.xml	2012-10-12 22:36:19 +0000
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>    	
+    	<record model="ir.ui.view" id="view_graph_magento_stadistic">
+			<field name="name">magento.stadistic.form</field>
+			<field name="model">magento.stadistic</field>
+			<field name="type">graph</field>
+			<field name="arch" type="xml">
+				<graph string="Product out of stock" type="bar">
+      				<field name="product_ids"/>
+      				<field name="qty_product" operator="+"/>
+				</graph>
+			</field>
+		</record>
+		
+		<record model="ir.ui.view" id="view_magento_stadistic_form">
+			<field name="name">magento.stadistic.form</field>
+			<field name="model">magento.stadistic</field>
+			<field name="type">form</field>
+			<field name="arch" type="xml">
+				<form string="Product out of stock">
+					<separator string="Product info" colspan="4" />
+					<field name="product_ids" attrs="{'required':True}" />
+					<field name="qty_product" attrs="{'required':True}" />
+					<field name="date_out_of_stock" attrs="{'required':True}"/>
+					<field name="customer_ids" attrs="{'required':True}"/>		
+					<notebook colspan="4">
+						<page string="Customer information">
+							<field colspan="4" mode="tree,form" name="address" nolabel="1" select="1" height="260">
+								<form string="Customer info">
+									<group colspan="4" col="6"> 
+										<field name="name" string="Contact Name"/> 
+										<field domain="[('domain', '=', 'contact')]" name="title" size="0"/> 
+										<field name="function"/> 
+									</group>
+									<newline/> 
+									<group colspan="2" col="4"> 
+										<separator string="Postal Address" colspan="4" col="4"/> 
+										<field name="type" string="Type" colspan="2"/> 
+										<field name="street" colspan="4"/> 
+										<field name="street2" colspan="4"/> 
+										<field name="zip"/> <field name="city"/> 
+										<field name="country_id" completion="1"/> 
+										<field name="state_id"/>
+									 </group> 
+									 <group colspan="2" col="2"> 
+									 	<separator string="Communication" colspan="2" col="2"/> 
+								 		<field name="phone"/> 
+								 		<field name="mobile"/> 
+								 		<field name="fax"/> 
+								 		<field name="email" widget="email"/> 
+									 </group> 
+								</form>
+								<tree string="Partner Contacts"> 
+									<field name="name"/> 
+									<field name="zip"/> 
+									<field name="city"/> 
+									<field name="country_id"/> 
+									<field name="phone"/>
+									 <field name="email"/> 
+									 <field name="type"></field>
+								</tree>
+							</field>
+						</page>
+					</notebook>					 				
+				</form>
+			</field>
+		</record>
+		
+		<record model="ir.ui.view" id="view_magento_stadistic_tree">
+			<field name="name">magento.stadistic.tree</field>
+			<field name="model">magento.stadistic</field>
+			<field name="type">tree</field>
+			<field name="arch" type="xml">
+				 <tree string="Product out of stock">
+					<field name="product_ids"/>
+					<field name="qty_product"></field>
+					<field name="date_out_of_stock"></field>
+					<field name="customer_ids"/>
+				</tree>
+			</field>
+		</record>
+		
+		<record model="ir.ui.view" id="magento_stadistic_search_view">
+            <field name="name">magento.stadistic.search</field>
+            <field name="model">magento.stadistic</field>
+            <field name="type">search</field>
+            <field name="arch" type="xml">
+				<search string="Product out of stock">
+					<newline/>
+					<field name="product_ids" widget="one2many_list"></field>   
+					<field name="date_out_of_stock" widget="float_time"></field>
+					<newline/>
+                    <group expand="0" string="Group By...">
+                        <filter string="Product" icon="terp-accessories-archiver" domain="[]" context="{'group_by':'product_ids'}"/>
+                        <separator orientation="vertical"/>
+                        <filter string="Customer" icon="terp-personal" domain="[]" context="{'group_by':'customer_ids'}"/>
+                        <separator orientation="vertical"/>
+                    </group>
+				</search>         
+            </field>            
+        </record>
+    </data>
+</openerp>

=== added directory 'magento_stadistic/static'
=== added directory 'magento_stadistic/static/src'
=== added directory 'magento_stadistic/static/src/img'
=== added file 'magento_stadistic/static/src/img/icon.png'
Binary files magento_stadistic/static/src/img/icon.png	1970-01-01 00:00:00 +0000 and magento_stadistic/static/src/img/icon.png	2012-10-12 22:36:19 +0000 differ
=== added file 'magento_stadistic/static/src/img/menu.png'
Binary files magento_stadistic/static/src/img/menu.png	1970-01-01 00:00:00 +0000 and magento_stadistic/static/src/img/menu.png	2012-10-12 22:36:19 +0000 differ

Follow ups