← Back to team overview

openerp-community team mailing list archive

[Merge] lp:~gdgellatly/openerp-product-attributes/partner-pricelist-7 into lp:openerp-product-attributes

 

Graeme Gellatly has proposed merging lp:~gdgellatly/openerp-product-attributes/partner-pricelist-7 into lp:openerp-product-attributes.

Requested reviews:
  Product Core Editors (product-core-editors)

For more details, see:
https://code.launchpad.net/~gdgellatly/openerp-product-attributes/partner-pricelist-7/+merge/202985

Hi,

New module called partner_pricelist

I really like this module and I finally got around to fixing and cleaning up for v7.  It adds a new field to product called partner_id.  Basically it replicates selecting a pricelist context on product search, except you can select a partner instead, no longer need to know which pricelist a partner has assigned.
-- 
https://code.launchpad.net/~gdgellatly/openerp-product-attributes/partner-pricelist-7/+merge/202985
Your team OpenERP Community is subscribed to branch lp:openerp-product-attributes.
=== added directory 'partner_pricelist'
=== added file 'partner_pricelist/__init__.py'
--- partner_pricelist/__init__.py	1970-01-01 00:00:00 +0000
+++ partner_pricelist/__init__.py	2014-01-24 04:56:59 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution - module extension
+#    Copyright (C) 2014- O4SB (<http://o4sb.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 partner_pricelist

=== added file 'partner_pricelist/__openerp__.py'
--- partner_pricelist/__openerp__.py	1970-01-01 00:00:00 +0000
+++ partner_pricelist/__openerp__.py	2014-01-24 04:56:59 +0000
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution - module extension
+#    Copyright (C) 2014- O4SB (<http://o4sb.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': 'Partner Pricelist Enhancement',
+    'version': '1.0',
+    'category': 'Sales',
+    'author': 'O4SB - Graeme Gellatly',
+    'website': 'http://www.o4sb.com',
+    'depends': ['base', 'product'],
+    'description': '''
+    This module provide :
+        An entry in product search view to show Partner Pricing so when
+        viewing a list of products you can see the customers pricing.
+    ''',
+    'data': ['partner_pricelist_view.xml'],
+    'installable': True,
+    'active': False,
+}

=== added file 'partner_pricelist/partner_pricelist.py'
--- partner_pricelist/partner_pricelist.py	1970-01-01 00:00:00 +0000
+++ partner_pricelist/partner_pricelist.py	2014-01-24 04:56:59 +0000
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution - module extension
+#    Copyright (C) 2014- O4SB (<http://o4sb.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/>.
+#
+##############################################################################
+'''This module allows products view to lookup price by customer (as opposed
+to default from pricelist)'''
+
+from openerp.osv import orm, fields
+
+
+class ProductProduct(orm.Model):
+    '''
+    inherited product.product to add customer field
+    and amend search functions
+    '''
+    _inherit = 'product.product'
+
+    _columns = {
+        'partner_id': fields.dummy(string='Customer', relation='res.partner',
+                                   type='many2one',
+                                   domain=[('customer', '=', True)]),
+        }
+
+    def onchange_partner(self, cr, uid, ids, partner_id, context=None):
+        '''returns partner pricelist id'''
+        res = self.pool['res.partner'].browse(
+                                        cr, uid, partner_id
+                                        ).property_product_pricelist.id
+        return res
+
+
+class ProductPricelist(orm.Model):
+    _inherit = 'product.pricelist'
+
+    def name_search(self, cr, user, name='', args=None, operator='ilike',
+                    context=None, limit=100):
+        if context is None:
+            context = {}
+        if context.get('pricelist', False) == 'partner':
+            partner = self.pool['res.partner'].browse(cr, user,
+                                                      context['partner'])
+            pricelist = partner.property_product_pricelist
+            context['pricelist'] = pricelist.id
+            return [(context['pricelist'], pricelist.name)]
+        else:
+            return super(ProductPricelist, self).name_search(
+                                            cr, user, name=name, args=args,
+                                            operator=operator, context=context,
+                                            limit=limit)

=== added file 'partner_pricelist/partner_pricelist_view.xml'
--- partner_pricelist/partner_pricelist_view.xml	1970-01-01 00:00:00 +0000
+++ partner_pricelist/partner_pricelist_view.xml	2014-01-24 04:56:59 +0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <record id="product_search_form_view" model="ir.ui.view">
+            <field name="name">product.search.form</field>
+            <field name="model">product.product</field>
+            <field name="inherit_id" ref="product.product_search_form_view" />
+            <field name="type">search</field>
+            <field name="arch" type="xml">
+                <field name="pricelist_id" position="after" >
+                    <field name="partner_id" widget="selection" context="{'pricelist': 'partner', 'partner':
+                        self}" filter_domain="[]" groups="product.group_sale_pricelist"/>
+                </field>
+            </field>
+        </record>
+        
+    </data>
+</openerp>
\ No newline at end of file


Follow ups