From f0f110994fea9bc6be9b9d87e25d1a461017f4c2 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 2 May 2013 15:09:44 +0200 Subject: [PATCH 1/4] [MIG] portage of pricelist_share_companies by OpenERP --- pricelist_share_companies/__openerp__.py | 47 ++++++++++---------- pricelist_share_companies/company.py | 7 ++- pricelist_share_companies/company_view.xml | 10 ++--- pricelist_share_companies/pricelist.py | 9 ++-- pricelist_share_companies/pricelist_view.xml | 3 +- 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/pricelist_share_companies/__openerp__.py b/pricelist_share_companies/__openerp__.py index 3032d271cf6..b34b3fe5670 100644 --- a/pricelist_share_companies/__openerp__.py +++ b/pricelist_share_companies/__openerp__.py @@ -26,12 +26,11 @@ ############################################################################## { - "name" : "Share pricelist between compagnies, not product", - "version" : "1.0", - "author" : "Camptocamp", - "category" : "Generic Modules/Projects & Services", - "description": -""" + 'name' : 'Share pricelist between compagnies, not product', + 'version' : '1.0', + 'category' : 'Generic Modules/Projects & Services', + 'description': +''' In OpenERP, product prices (cost, list) are expressed in the currency of the price_type (by default the same than your company currency). The idea here is to have the same products between compagnies (with each one their own currency through different price_type and different costs) but @@ -40,9 +39,9 @@ Concretely, to have a different cost price for a second company, you have to : - Create a new standard price on product.template - - Create a new "Price Type" on this new field, with the desired currency and assigned to the new currency - - Assign the existing "Cost Price" to your main company - - On the setup of each company, in the "Configuration"'s Tab, select the product field used for the cost + - Create a new 'Price Type' on this new field, with the desired currency and assigned to the new currency + - Assign the existing 'Cost Price' to your main company + - On the setup of each company, in the 'Configuration''s Tab, select the product field used for the cost The Price Type used is the first one found for the cost field configured on the company. To ensure the right Price Type is selected, you have to put the company on the Price Types, and according to the security rule created, you will have access @@ -62,18 +61,20 @@ Product A in company B: The cost price is 70 * currency rate -""", - "website": "http://camptocamp.com", - "depends" : [ - "product", - ], - "init_xml" : [], - "demo_xml" : [], - "update_xml" : [ - "pricelist_view.xml", - "company_view.xml", - "security/pricelist_security.xml", - ], - "active": False, - 'installable': False +''', + 'author' : 'Camptocamp', + 'website': 'http://camptocamp.com', + 'depends' : ['product',], + 'data' : [ + 'pricelist_view.xml', + 'company_view.xml', + 'security/pricelist_security.xml', + ], + 'demo' : [], + 'test': [], + 'installable': True, + 'auto_install': False, + 'application': False } + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/pricelist_share_companies/company.py b/pricelist_share_companies/company.py index 17d5c22dc05..02340a8a79c 100644 --- a/pricelist_share_companies/company.py +++ b/pricelist_share_companies/company.py @@ -29,12 +29,13 @@ from osv import fields, osv - class ResCompany(osv.osv): - """Override company to add the fields to use for the prices""" + '''Override company to add the fields to use for the prices''' _inherit = 'res.company' def _price_field_get(self, cr, uid, context=None): + if context is None: + context = {} mf = self.pool.get('ir.model.fields') ids = mf.search(cr, uid, [('model','in', (('product.product'),('product.template'))), @@ -53,3 +54,5 @@ def _price_field_get(self, cr, uid, context=None): } ResCompany() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/pricelist_share_companies/company_view.xml b/pricelist_share_companies/company_view.xml index 9e672aff8d9..6571a93d125 100644 --- a/pricelist_share_companies/company_view.xml +++ b/pricelist_share_companies/company_view.xml @@ -6,17 +6,17 @@ res.company.form.inherit res.company - form - - - + + + + - + \ No newline at end of file diff --git a/pricelist_share_companies/pricelist.py b/pricelist_share_companies/pricelist.py index d4ea58c49c7..7d003a8521f 100644 --- a/pricelist_share_companies/pricelist.py +++ b/pricelist_share_companies/pricelist.py @@ -30,12 +30,10 @@ from osv import fields from osv import osv - class PriceType(osv.osv): - _inherit = "product.price.type" - + _inherit = 'product.price.type' _columns = { - "company_id" : fields.many2one('res.company', "Company"), + 'company_id' : fields.many2one('res.company', 'Company'), } def _check_unicity_per_company(self, cr, uid, ids, context=None): @@ -80,5 +78,6 @@ def replace_args(search_args, ptype, company): return super(PriceType, self).search(cr, uid, args1, offset, limit, order, context=context, count=count) - PriceType() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/pricelist_share_companies/pricelist_view.xml b/pricelist_share_companies/pricelist_view.xml index 4e8432d8a94..91c3b57747f 100644 --- a/pricelist_share_companies/pricelist_view.xml +++ b/pricelist_share_companies/pricelist_view.xml @@ -6,9 +6,8 @@ product.price.type.form product.price.type - form - + From b9ff488785a5d688c4b26184a0b085d42e74cb80 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 2 May 2013 17:17:56 +0200 Subject: [PATCH 2/4] [IMP] pricelist_share_companies - use orm.Model instead of alias osv.osv --- pricelist_share_companies/company.py | 9 +++------ pricelist_share_companies/pricelist.py | 12 ++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pricelist_share_companies/company.py b/pricelist_share_companies/company.py index 02340a8a79c..dd64a9111e1 100644 --- a/pricelist_share_companies/company.py +++ b/pricelist_share_companies/company.py @@ -26,10 +26,9 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## +from openerp.osv import orm, fields -from osv import fields, osv - -class ResCompany(osv.osv): +class ResCompany(orm.Model): '''Override company to add the fields to use for the prices''' _inherit = 'res.company' @@ -53,6 +52,4 @@ def _price_field_get(self, cr, uid, context=None): "on the search of a Cost Price's Price Type.") } -ResCompany() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/pricelist_share_companies/pricelist.py b/pricelist_share_companies/pricelist.py index 7d003a8521f..7c2065eed8f 100644 --- a/pricelist_share_companies/pricelist.py +++ b/pricelist_share_companies/pricelist.py @@ -26,15 +26,13 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## +from openerp.osv import orm, fields -from osv import fields -from osv import osv - -class PriceType(osv.osv): +class PriceType(orm.Model): _inherit = 'product.price.type' _columns = { 'company_id' : fields.many2one('res.company', 'Company'), - } + } def _check_unicity_per_company(self, cr, uid, ids, context=None): for price_type in self.browse(cr, uid, ids, context=context): @@ -78,6 +76,4 @@ def replace_args(search_args, ptype, company): return super(PriceType, self).search(cr, uid, args1, offset, limit, order, context=context, count=count) -PriceType() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From d5f2b2eaa531e7f19f8086dc9551ec44414b99bd Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 2 May 2013 17:24:09 +0200 Subject: [PATCH 3/4] [IMP] pricelist_share_companies - update license to AGPL --- pricelist_share_companies/__init__.py | 32 +++++++++--------------- pricelist_share_companies/__openerp__.py | 32 ++++++++++-------------- pricelist_share_companies/company.py | 32 +++++++++--------------- pricelist_share_companies/pricelist.py | 32 +++++++++--------------- 4 files changed, 49 insertions(+), 79 deletions(-) diff --git a/pricelist_share_companies/__init__.py b/pricelist_share_companies/__init__.py index 7677c585491..64678f58866 100644 --- a/pricelist_share_companies/__init__.py +++ b/pricelist_share_companies/__init__.py @@ -1,29 +1,21 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2010 Camtocamp SA -# @author Joël Grand-Guillaume +# Author: Joël Grand-Guillaume +# Copyright 2010 Camptocamp SA # -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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 Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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. # -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## import pricelist diff --git a/pricelist_share_companies/__openerp__.py b/pricelist_share_companies/__openerp__.py index b34b3fe5670..9275e6db407 100644 --- a/pricelist_share_companies/__openerp__.py +++ b/pricelist_share_companies/__openerp__.py @@ -1,27 +1,21 @@ # -*- coding: utf-8 -*- ############################################################################## # -# @author Grand-Guillaume Joel -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# Author: Joël Grand-Guillaume +# Copyright 2010 Camptocamp SA # -# This program is Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. +# 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 General Public License for more details. +# 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 General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## @@ -77,4 +71,4 @@ 'application': False } -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/pricelist_share_companies/company.py b/pricelist_share_companies/company.py index dd64a9111e1..fd5c0922243 100644 --- a/pricelist_share_companies/company.py +++ b/pricelist_share_companies/company.py @@ -1,29 +1,21 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2011 Camtocamp SA -# @author Guewen Baconnier +# Author: Guewen Baconnier +# Copyright 2011 Camptocamp SA # -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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 Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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. # -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## from openerp.osv import orm, fields diff --git a/pricelist_share_companies/pricelist.py b/pricelist_share_companies/pricelist.py index 7c2065eed8f..f2a3a61355c 100644 --- a/pricelist_share_companies/pricelist.py +++ b/pricelist_share_companies/pricelist.py @@ -1,29 +1,21 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2011 Camtocamp SA -# @author Guewen Baconnier +# Author: Guewen Baconnier +# Copyright 2011 Camptocamp SA # -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# 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 Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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. # -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## from openerp.osv import orm, fields From 70d004cf01b07c17c5f88c0f882d404701539f8c Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 2 May 2013 17:25:56 +0200 Subject: [PATCH 4/4] [IMP] pricelist_share_companies - retab xml views --- pricelist_share_companies/company_view.xml | 36 +++++++++---------- pricelist_share_companies/pricelist_view.xml | 24 ++++++------- .../security/pricelist_security.xml | 12 +++---- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/pricelist_share_companies/company_view.xml b/pricelist_share_companies/company_view.xml index 6571a93d125..35929157b60 100644 --- a/pricelist_share_companies/company_view.xml +++ b/pricelist_share_companies/company_view.xml @@ -1,22 +1,22 @@ - + - - res.company.form.inherit - res.company - - - - - - - - - - - - + + res.company.form.inherit + res.company + + + + + + + + + + + + - - \ No newline at end of file + + diff --git a/pricelist_share_companies/pricelist_view.xml b/pricelist_share_companies/pricelist_view.xml index 91c3b57747f..9be7cceb8f1 100644 --- a/pricelist_share_companies/pricelist_view.xml +++ b/pricelist_share_companies/pricelist_view.xml @@ -1,17 +1,17 @@ - + - - product.price.type.form - product.price.type - - - - - - - + + product.price.type.form + product.price.type + + + + + + + - + diff --git a/pricelist_share_companies/security/pricelist_security.xml b/pricelist_share_companies/security/pricelist_security.xml index 4e92c218f3c..a8cb8a8baeb 100644 --- a/pricelist_share_companies/security/pricelist_security.xml +++ b/pricelist_share_companies/security/pricelist_security.xml @@ -1,13 +1,13 @@ - + - Product price type multi-company - - - ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + Product price type multi-company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] - +