Selaa lähdekoodia

Cada usuario vea su lista de precio disponible

sebastian 5 vuotta sitten
commit
dbb4f35181

+ 7 - 0
__init__.py

@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
+##############################################################################
+from . import res_users
+from . import pricelist

BIN
__init__.pyc


+ 55 - 0
__openerp__.py

@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2017  KnowledgeWare  (http://www.kware-eg.com)
+#    All Rights Reserved.
+#
+#    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': 'PriceList Security',
+    'version': '1.8.0',
+    'category': 'Sales',
+    'sequence': 12,
+    'summary': '',
+    'description': """
+PriceList Security
+================
+It creates a many2many field between PriceLists and users. If you set Pricelists to User, then this PriceLists will be only seen by selected users.
+This fields are only seen by users with "access right management"
+    """,
+    'author':  'KnowledgeWare',
+    'website': 'www.kware-eg.com',
+    'license': 'AGPL-3',
+    'images': [
+    ],
+    'depends': [
+        'base',
+        'product',
+    ],
+    'data': [
+            'res_users_view.xml',
+            'priceList_view.xml',
+            'security/pricelist_security_security.xml',
+    ],
+    'demo': [
+    ],
+    'test': [
+    ],
+    'installable': True,
+    'auto_install': False,
+    'application': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 19 - 0
priceList_view.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+        <!-- Form -->
+        <record id="view_pricelist_security_account_pricelist_form" model="ir.ui.view">
+            <field name="name">pricelist_secuirty.product.pricelist.form</field>
+            <field name="model">product.pricelist</field>
+            <field name="inherit_id" ref="product.product_pricelist_view"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='version_id']" position="after">
+                    <group string="Usuarios Permitidos">
+                        <field name="user_ids" widget="many2many_tags" no_label="1"/>
+                    </group>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>

+ 13 - 0
pricelist.py

@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
+##############################################################################
+from openerp import models,fields,api
+
+class product_pricelist(models.Model):
+    _name = 'product.pricelist'
+    _inherit = 'product.pricelist'
+
+    user_ids = fields.Many2many('res.users', 'pricelist_security_pricelist_users', 'pricelist_id',
+            'user_id', string='Restringido a los usuarios', help='Si elige algunos usuarios, esta Lista de precios y la información relacionada solo serán visibles para esos usuarios.')

BIN
pricelist.pyc


+ 12 - 0
res_users.py

@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
+##############################################################################
+from openerp import models, fields,api
+
+class users(models.Model):
+    _name = 'res.users'
+    _inherit = 'res.users'
+    pricelist_ids = fields.Many2many('product.pricelist', 'pricelist_security_pricelist_users','user_id','pricelist_id', 'Restricted Pricelists', help="This Pricelists and the information related to it will be only visible for users where you specify that they can see them setting this same field.")
+    

BIN
res_users.pyc


+ 19 - 0
res_users_view.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+        <!-- Form -->
+        <record id="view_journal_security_users_form" model="ir.ui.view">
+            <field name="name">journal_security.users.form</field>
+            <field name="model">res.users</field>
+            <field name="inherit_id" ref="base.view_users_form"/>
+            <field name="arch" type="xml">
+                <group string="Allowed Companies" position="before">
+                    <group string="Restricted Pricelist" groups="base.group_erp_manager">
+                        <field name="pricelist_ids" nolabel="1" widget="many2many_tags"/>
+                    </group>               
+                </group>                
+            </field>
+        </record>
+        
+    </data>
+</openerp>

+ 12 - 0
security/pricelist_security_security.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+    <record model="ir.rule" id="pricelist_security_rule">
+        <field name="name">Pricelist only to specified users</field>
+        <field name="model_id" ref="product.model_product_pricelist"/>
+        <field name="domain_force">['|',('user_ids','=',False),('id','in',[pricelist.id for pricelist in user.pricelist_ids])]</field>
+    </record>
+
+</data>
+</openerp>

BIN
static/description/1.jpg


+ 19 - 0
static/description/index.html

@@ -0,0 +1,19 @@
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span12">
+            <h2 class="oe_slogan">Pricelist Security</h2>
+            <h3 class="oe_slogan">Users can be assigned many Pricelists and then they can be restricted to see only this Pricelists
+        <div class="oe_span6">
+            <div class="oe_demo oe_picture oe_screenshot">
+                    <img src="1.jpg"/>
+                
+            </div>
+        </div>
+        <div class="oe_span6">
+            <p class="oe_mt32">
+This module serves to restrict the use of certain Pricelists to certain users. <br>
+-in each user, you can define what Pricelists will be allowed to use.
+            </p>
+        </div>
+    </div>
+</section>