Browse Source

commit inicial

Rodney Enciso Arias 8 years ago
commit
be0da26787
7 changed files with 163 additions and 0 deletions
  1. 21 0
      __init__.py
  2. BIN
      __init__.pyc
  3. 33 0
      __openerp__.py
  4. 16 0
      product.py
  5. BIN
      product.pyc
  6. 83 0
      product_view.xml
  7. 10 0
      security/hide_variants_groups.xml

+ 21 - 0
__init__.py

@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2015 Comunitea All Rights Reserved
+#    $Omar Castiñeira Saavedra <omar@comunitea.com>$
+#
+#    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 product

BIN
__init__.pyc


+ 33 - 0
__openerp__.py

@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2015 Comunitea All Rights Reserved
+#    $Omar Castiñeira Saavedra <omar@comunitea.com>$
+#
+#    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': "Hide product variants",
+    'version': '1.0',
+    'category': 'Products',
+    'description': """Hide by default product variants menu""",
+    'author': 'Comunitea',
+    'website': 'www.comunitea.com',
+    "depends": ['stock', 'product', 'purchase'],
+    "data": ['security/hide_variants_groups.xml',
+             'product_view.xml'],
+    "installable": True
+}

+ 16 - 0
product.py

@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# © 2016 Comunitea
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from openerp import models, api
+
+
+class ProductProduct(models.Model):
+
+    _inherit = 'product.product'
+
+    @api.multi
+    def write(self, vals):
+        if vals.get('image_variant', False):
+            self.mapped('product_tmpl_id').write(
+                {'image': vals['image_variant']})
+        return super(ProductProduct, self).write(vals)

BIN
product.pyc


+ 83 - 0
product_view.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+        <!-- Avoid Menu of product Variants -->
+        <delete model="ir.ui.menu" search="[('id','=',ref('product.menu_products'))]"/>
+        <menuitem id="menu_products2" action="product.product_normal_action_sell" parent="base.menu_product" groups="group_no_variants" sequence="10"/>
+        <delete model="ir.ui.menu" search="[('id','=',ref('stock.menu_product_variant_config_stock'))]"/>
+        <menuitem
+            action="product.product_normal_action" id="menu_product_variant_config_stock2"
+            parent="stock.menu_product_in_config_stock" groups="group_no_variants" sequence="2"/>
+
+        <!-- Avoid page of product Variants -->
+        <record id="product_template_only_form_view_avoid_variants" model="ir.ui.view">
+            <field name="name">product.template.product.form.avoid.variants</field>
+            <field name="model">product.template</field>
+            <field name="inherit_id" ref="product.product_template_only_form_view"/>
+            <field name="arch" type="xml">
+                <page name="variants" position="attributes">
+                    <attribute name="groups">hide_product_variants.group_no_variants</attribute>
+                </page>
+            </field>
+        </record>
+
+        <record id="product.product_template_action" model="ir.actions.act_window">
+            <field name="name">Products</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">product.product</field>
+            <field name="view_mode">kanban,tree,form</field>
+            <field name="view_type">form</field>
+            <field name="view_id" ref="product.product_template_kanban_view"/>
+            <field name="context">{"search_default_filter_to_sell":1}</field>
+        </record>
+
+        <record id="purchase.product_normal_action_puchased" model="ir.actions.act_window">
+            <field name="name">Products</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">product.product</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">kanban,tree,form</field>
+            <field name="context">{"search_default_filter_to_purchase":1}</field>
+            <field name="search_view_id" eval="False"/> <!-- Force empty -->
+            <field name="view_id" eval="False"/> <!-- Force empty -->
+            <field name="help" type="html">
+              <p class="oe_view_nocontent_create">
+                Click to define a new product.
+              </p><p>
+                You must define a product for everything you purchase, whether
+                it's a physical product, a consumable or services you buy to
+                subcontractants.
+              </p><p>
+                The product form contains detailed information to improve the
+                purchase process: prices, procurement logistics, accounting data,
+                available suppliers, etc.
+              </p>
+            </field>
+        </record>
+
+        <record id="product_normal_form_view_rev_name" model="ir.ui.view">
+            <field name="name">product.product.form.rev_name</field>
+            <field name="model">product.product</field>
+            <field name="inherit_id" ref="product.product_normal_form_view"/>
+            <field name="arch" type="xml">
+                <field name="name" position="replace">
+                    <field name="name"/>
+                </field>
+                <field name="product_tmpl_id" position="replace">
+                    <field name="product_tmpl_id" invisible="1" required="0"/>
+                </field>
+            </field>
+        </record>
+
+        <record id="product_template_kanban_view_hide_variants" model="ir.ui.view">
+            <field name="name">Product.template.product.kanban.hide_variants</field>
+            <field name="model">product.template</field>
+            <field name="inherit_id" ref="product.product_template_kanban_view"/>
+            <field name="arch" type="xml">
+                <xpath expr="/kanban/templates/t/div/div/a" position="replace"/>
+            </field>
+        </record>
+
+    </data>
+</openerp>

+ 10 - 0
security/hide_variants_groups.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+        <record model="res.groups" id="group_no_variants">
+            <field name="name">View Product Variants</field>
+        </record>
+
+    </data>
+</openerp>