Skip to content

Commit

Permalink
[MERGE]
Browse files Browse the repository at this point in the history
  • Loading branch information
yvaucher authored and Maxime Chambreuil committed Jun 22, 2013
2 parents e83852e + 70d004c commit 772cee9
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 154 deletions.
32 changes: 12 additions & 20 deletions pricelist_share_companies/__init__.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import pricelist
Expand Down
77 changes: 36 additions & 41 deletions pricelist_share_companies/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
# -*- 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 <http://www.gnu.org/licenses/>.
#
##############################################################################

{
"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
Expand All @@ -40,9 +33,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
Expand All @@ -62,18 +55,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:
44 changes: 18 additions & 26 deletions pricelist_share_companies/company.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
# -*- 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields

from osv import fields, osv


class ResCompany(osv.osv):
"""Override company to add the fields to use for the prices"""
class ResCompany(orm.Model):
'''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'))),
Expand All @@ -52,4 +44,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:
34 changes: 17 additions & 17 deletions pricelist_share_companies/company_view.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<data>

<record id="company_form_price_fields" model="ir.ui.view">
<field name="name">res.company.form.inherit</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<page string="Configuration" position="inside">
<separator string="Prices Fields" colspan="4"/>
<field name="standard_price_field"/>
<newline/>
</page>
</data>
</field>
</record>
<record id="company_form_price_fields" model="ir.ui.view">
<field name="name">res.company.form.inherit</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<data>
<page string="Configuration" position="inside">
<separator string="Prices Fields"/>
<group>
<field name="standard_price_field"/>
</group>
</page>
</data>
</field>
</record>

</data>
</data>
</openerp>
49 changes: 18 additions & 31 deletions pricelist_share_companies/pricelist.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
# -*- 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields

from osv import fields
from osv import osv


class PriceType(osv.osv):
_inherit = "product.price.type"

class PriceType(orm.Model):
_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):
for price_type in self.browse(cr, uid, ids, context=context):
Expand Down Expand Up @@ -80,5 +68,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:
25 changes: 12 additions & 13 deletions pricelist_share_companies/pricelist_view.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<data>

<record id="product_price_type_view" model="ir.ui.view">
<field name="name">product.price.type.form</field>
<field name="model">product.price.type</field>
<field name="inherit_id" ref="product.product_price_type_view" />
<field name="type">form</field>
<field name="arch" type="xml">
<field name="currency_id" select="1" position="after">
<field name="company_id" widget="selection"/>
</field>
</field>
</record>
<record id="product_price_type_view" model="ir.ui.view">
<field name="name">product.price.type.form</field>
<field name="model">product.price.type</field>
<field name="inherit_id" ref="product.product_price_type_view" />
<field name="arch" type="xml">
<field name="currency_id" position="after">
<field name="company_id" widget="selection"/>
</field>
</field>
</record>

</data>
</data>
</openerp>
12 changes: 6 additions & 6 deletions pricelist_share_companies/security/pricelist_security.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<data noupdate="1">

<record id="product_pricetype_comp_rule" model="ir.rule">
<field name="name" >Product price type multi-company</field>
<field name="model_id" ref="model_product_price_type"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="name" >Product price type multi-company</field>
<field name="model_id" ref="model_product_price_type"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>

</data>
</data>
</openerp>

0 comments on commit 772cee9

Please sign in to comment.