Browse Source

Acceso rápido a proyecto desde cliente

Sebas 6 years ago
commit
e4f43fdf37
7 changed files with 147 additions and 0 deletions
  1. 20 0
      __init__.py
  2. BIN
      __init__.pyc
  3. 40 0
      __openerp__.py
  4. 26 0
      res_partner.py
  5. BIN
      res_partner.pyc
  6. 61 0
      res_partner_view.xml
  7. BIN
      static/description/icon.png

+ 20 - 0
__init__.py

@@ -0,0 +1,20 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#                                                                               #
+#    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/>.      #
+#                                                                               #
+#################################################################################
+
+from . import res_partner

BIN
__init__.pyc


+ 40 - 0
__openerp__.py

@@ -0,0 +1,40 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#                                                                               #
+#    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/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product features is an Openobject module wich enable features management for products #
+###################################################################################
+{
+    'name': 'Smarticon para Proyecto',
+    'version': '0.1',
+    'category': 'Proyecto',
+    'description': """
+Smarticon para Proyecto
+========================================
+
+Smarticon para Proyecto
+
+    """,
+    'author': 'Eiru/Sebastian Penayo',
+    'website': '',
+	'depends': ['report', 'project'],
+    'data': [
+		'res_partner_view.xml',
+    ],
+    'installable': True,
+}

+ 26 - 0
res_partner.py

@@ -0,0 +1,26 @@
+
+import math
+
+from openerp.osv import osv, fields
+
+class res_partner(osv.osv):
+    _inherit = 'res.partner'
+
+    def _project_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,0), ids))
+        # The current user may not have access rights for sale orders
+        try:
+            for partner in self.browse(cr, uid, ids, context):
+                res[partner.id] = len(partner.project_ids)
+        except:
+            pass
+        return res
+
+    """ Inherits partner and adds project information in the partner form """
+    _columns = {
+        'project_ids': fields.one2many('project.project', 'partner_id', 'Proyectos'),
+        'project_count': fields.function(_project_count, string='#Proyectos', type='integer'),
+    }
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
res_partner.pyc


+ 61 - 0
res_partner_view.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+		<record id="act_res_partner_2_project" model="ir.actions.act_window">
+            <field name="name">Proyectos</field>
+            <field name="res_model">project.project</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="context">{'search_default_partner_id': active_id}</field>
+            <field name="groups_id"/>
+            <field name="help" type="html">
+              <p class="oe_view_nocontent_create">
+                Click to create a proyect for this customer.
+              </p><p>
+                Odoo will help you efficiently handle the complete sale flow:
+                project.
+              </p>
+            </field>
+        </record>
+
+		<!-- Partner kanban view inherte -->
+        <record model="ir.ui.view" id="project_partner_kanban_view">
+            <field name="name">activity.kanban.project.inherit</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="base.res_partner_kanban_view"/>
+            <field name="priority" eval="20"/>
+            <field name="arch" type="xml">
+                <field name="mobile" position="after">
+                    <field name="project_count"/>
+                </field>
+                <xpath expr="//div[@class='oe_kanban_partner_links']" position="inside">
+                    <a name="%(smarticon_project.act_res_partner_2_project)d" type="action" t-if="record.project_count.value>0">
+                        <t t-esc="record.project_count.value"/> Proyecto
+                    </a>
+                </xpath>
+            </field>
+        </record>
+
+		<!--  Partners inherited form -->
+        <record id="view_project_partner_info_form" model="ir.ui.view">
+            <field name="name">res.partner.project.buttons</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="base.view_partner_form"/>
+            <field name="priority" eval="50"/>
+            <field name="groups_id"/>
+            <field name="arch" type="xml">
+                <xpath expr="//div[@name='buttons']" position="inside">
+                    <button class="oe_inline oe_stat_button" type="action" name="%(smarticon_project.act_res_partner_2_project)d"
+						              attrs="{'invisible': [('customer', '=', False)]}"
+						              icon="fa-ticket"
+						              context="{'search_default_partner_id': active_id}">
+                          <field string="Proyectos" name="project_count" widget="statinfo"/>
+                    </button>
+                </xpath>
+            </field>
+       </record>
+
+
+    </data>
+</openerp>

BIN
static/description/icon.png