Rodney Enciso Arias 8 gadi atpakaļ
revīzija
cf4344e05c

+ 70 - 0
README.rst

@@ -0,0 +1,70 @@
+
+.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
+   :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+   :alt: License: AGPL-3
+
+========================
+Product Variant Inactive
+========================
+
+This module extend the functionality of Product Variants
+and allow you to make activate or deactivate products using the two buttons
+
+
+Usage
+=====
+
+To use this module, you need to Product menu (Product Template)
+
+On Variant tab, click on the button 'List of variants'
+
+You can now activate or deactivate variants with button on the right side
+
+
+.. image:: static/description/unactive.png
+
+
+.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
+   :alt: Try me on Runbot
+   :target: https://runbot.odoo-community.org/runbot/135/8.0
+
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues
+<https://github.com/OCA/product-attribute/issues>`_. In case of trouble, please
+check there if your issue has already been reported. If you spotted it first,
+help us smashing it by providing a detailed and welcomed `feedback
+<https://github.com/OCA/product-attribute/issues/new?body=module:%20product_variant_inactive%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
+
+Credits
+=======
+
+Images
+------
+
+* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
+
+Contributors
+------------
+
+* Sebastien BEAU <sebastien.beau@akretion.com>
+* Abdessamad HILALI <abdessamad.hilali@akretion.com>
+
+
+Maintainer
+----------
+
+.. image:: https://odoo-community.org/logo.png
+   :alt: Odoo Community Association
+   :target: https://odoo-community.org
+
+This module is maintained by the OCA.
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
+To contribute to this module, please visit https://odoo-community.org.
+

+ 1 - 0
__init__.py

@@ -0,0 +1 @@
+from . import product_variant

BIN
__init__.pyc


+ 17 - 0
__openerp__.py

@@ -0,0 +1,17 @@
+# coding: utf-8
+# © 2015 Abdessamad HILALI <abdessamad.hilali@akretion.com>
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+{
+    'name': "Product Variant Inactive",
+    'author': "Akretion,Odoo Community Association (OCA)",
+    'website': "http://www.akretion.com",
+    'license': 'AGPL-3',
+    'category': 'Product',
+    'version': '8.0.0.0.0',
+    'depends': ['stock'],
+    'data': [
+        'product_variant_view.xml'
+    ],
+    'demo': ['product.product.csv'],
+}

+ 2 - 0
product.product.csv

@@ -0,0 +1,2 @@
+id,active
+product.product_product_4,0

+ 37 - 0
product_variant.py

@@ -0,0 +1,37 @@
+# coding: utf-8
+# © 2015 Abdessamad HILALI <abdessamad.hilali@akretion.com>
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from openerp import models, api
+from lxml import etree
+from openerp.osv import orm
+
+
+class ProductProduct(models.Model):
+    _inherit = 'product.product'
+
+    @api.multi
+    def button_activate(self):
+        self.write({'active': True})
+
+    @api.multi
+    def button_deactivate(self):
+        self.write({'active': False})
+
+    @api.model
+    def fields_view_get(self, view_id=None, view_type='tree',
+                        toolbar=False, submenu=False):
+        """ Dynamic modification of fields """
+        res = super(ProductProduct, self).fields_view_get(
+            view_id=view_id, view_type=view_type,
+            toolbar=toolbar, submenu=submenu)
+        root = etree.fromstring(res['arch'])
+        if view_type == 'tree':
+            for button in root.findall(".//button"):
+                # search_disable_custom_filters is applied when active_id/ids
+                # defined in addons/web/static/src/js/views.js
+                if 'search_disable_custom_filters' in self.env.context:
+                    button.set('invisible', '0')
+                    orm.setup_modifiers(button, root)
+            res['arch'] = etree.tostring(root, pretty_print=True)
+        return res

BIN
product_variant.pyc


+ 38 - 0
product_variant_view.xml

@@ -0,0 +1,38 @@
+<openerp>
+  <data>
+
+    <record model="ir.ui.view" id="view_stock_product_tree">
+        <field name="model">product.product</field>
+        <field name="inherit_id" ref="stock.view_stock_product_tree"/>
+        <field name="arch" type="xml">
+            <!-- Add grey color for inactive record.
+                 Variants are mainly used with stock, 
+                 Then we also embedds color attributes of module stock -->
+            <xpath expr="//tree" position="attributes">
+                <attribute name="colors" translation="off">grey:active==False;red:virtual_available&lt;0;blue:virtual_available&gt;=0 and state in ('draft', 'end', 'obsolete');black:virtual_available&gt;=0 and state not in ('draft', 'end', 'obsolete')</attribute>
+            </xpath>
+        </field>
+    </record>
+
+
+    <record model="ir.ui.view" id="detail_field_custom_in_view">
+        <field name="model">product.product</field>
+        <field name="inherit_id" ref="product.product_product_tree_view"/>
+        <field name="arch" type="xml">
+            <xpath expr="//tree" position="inside">
+                <field name="active" invisible ="1"/>
+                <button type="object" name="button_activate" invisible="1"
+                        attrs="{'invisible': [('active','=',True)]}" icon="gtk-stop"/>
+                <button type="object" name="button_deactivate" invisible="1"
+                        attrs="{'invisible': [('active','=',False)]}" icon="gtk-apply"/>
+            </xpath>
+        </field>
+    </record>
+    <record id="product.product_variant_action" model="ir.actions.act_window">
+        <field name="context">{'search_default_product_tmpl_id': [active_id], 
+                               'default_product_tmpl_id': active_id, 
+                               'active_test': False}</field>
+    </record>
+
+  </data>
+</openerp>

BIN
static/description/icon.png


BIN
static/description/unactive.png