-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] module price_multicompany #1
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dc7e9fa
[ADD] module price_multicompany
bealdav 3887d67
[ADD] module sale_check__multicompany
bealdav 4413a27
[FIX] spell in description
bealdav c87d180
[FIX] format string
bealdav 4a2ea8f
[FIX] description
bealdav 10f5bef
[FIX] module name unshared_...
bealdav 2672517
[FIX] guewen remarks
bealdav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# licence AGPL version 3 or later | ||
# see licence in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt | ||
# Copyright (C) 2014 Akretion (http://www.akretion.com). | ||
# @author David BEAL <[email protected]> | ||
# | ||
############################################################################## | ||
|
||
from . import sale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: David BEAL | ||
# Copyright 2014 Akretion | ||
# | ||
# 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': 'sale_check_multicompany', | ||
'version': '0.1', | ||
'category': '', | ||
'sequence': 10, | ||
'description': """ | ||
Check if data in quotation are linked to the same company | ||
""", | ||
'author': 'Akretion', | ||
'website': 'http://www.akretion.com', | ||
'depends': [ | ||
'sale', | ||
], | ||
'data': [ | ||
], | ||
'demo': [ | ||
], | ||
'installable': True, | ||
'application': False, | ||
'images': [ | ||
], | ||
'css': [ | ||
], | ||
'js': [ | ||
], | ||
'qweb': [ | ||
], | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# licence AGPL version 3 or later | ||
# see licence in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt | ||
# Copyright (C) 2014 Akretion (http://www.akretion.com). | ||
# @author David BEAL <[email protected]> | ||
# | ||
############################################################################## | ||
|
||
from openerp.osv import orm | ||
from openerp.tools.translate import _ | ||
|
||
|
||
class SaleOrder(orm.Model): | ||
_inherit = 'sale.order' | ||
|
||
def _check_pricelist(self, cr, uid, ids): | ||
for elm in self.browse(cr, uid, ids): | ||
if elm.pricelist_id: | ||
if elm.company_id: | ||
company = elm.company_id | ||
else: | ||
company_id = self.pool['res.company']._company_default_get( | ||
cr, uid, 'sale.order') | ||
company = self.pool['res.company'].browse( | ||
cr, uid, company_id) | ||
if elm.pricelist_id.company_id.id != company.id: | ||
raise orm.except_orm( | ||
_("Invalid Pricelist"), | ||
_("The pricelist defined in this quotation is linked " | ||
"to '%s' company\n" | ||
"whereas the quotation is linked to '%s'\n" | ||
"\nChoose a pricelist which match " | ||
"to the company '%s'") | ||
% (elm.pricelist_id.company_id.name, | ||
company.name, company.name)) | ||
return True | ||
|
||
_constraints = [(_check_pricelist, 'Error', ['pricelist_id'])] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# licence AGPL version 3 or later | ||
# see licence in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt | ||
# Copyright (C) 2014 Akretion (http://www.akretion.com). | ||
# @author David BEAL <[email protected]> | ||
# | ||
############################################################################## | ||
|
||
from . import currency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: David BEAL | ||
# Copyright 2014 Akretion | ||
# | ||
# 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': 'Unshared Currency Multicompany', | ||
'version': '0.1', | ||
'category': 'Product', | ||
'sequence': 10, | ||
'summary': "Currency settings multicompany", | ||
'description': """ | ||
This module should be used if your companies have their currencies non shared. | ||
Currencies cannot be shared because 'res.currency.rate' doesn't have | ||
a company_id field | ||
This also implies that each company must have their own price lists | ||
""", | ||
'author': 'Akretion', | ||
'website': 'http://www.akretion.com', | ||
'depends': [ | ||
'product', | ||
], | ||
'data': [ | ||
], | ||
'demo': [ | ||
], | ||
'installable': True, | ||
'application': False, | ||
'images': [ | ||
], | ||
'css': [ | ||
], | ||
'js': [ | ||
], | ||
'qweb': [ | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# licence AGPL version 3 or later | ||
# see licence in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt | ||
# Copyright (C) 2014 Akretion (http://www.akretion.com). | ||
# @author David BEAL <[email protected]> | ||
# | ||
############################################################################## | ||
|
||
from openerp.osv import orm, fields | ||
|
||
|
||
class ResCurrency(orm.Model): | ||
_inherit = 'res.currency' | ||
|
||
def name_get(self, cr, uid, ids, context=None): | ||
""" If currencies are not shared and they have the same name, | ||
then display have to distinguish them""" | ||
result = [] | ||
for currency in self.browse(cr, uid, ids, context): | ||
cpny_info = '' | ||
if currency.company_id: | ||
cpny_info = ' (%s)' % currency.company_id.name | ||
result.append((currency.id, '%s%s' % (currency.name, cpny_info))) | ||
return result | ||
|
||
|
||
class ProductPriceType(orm.Model): | ||
_inherit = 'product.price.type' | ||
|
||
_columns = { | ||
'currency_id': fields.property( | ||
'res.currency', | ||
relation='res.currency', | ||
type='many2one', | ||
string='Currency', | ||
view_load=True, | ||
required=True, | ||
help="The currency the field is expressed in." | ||
"Field redefined in field property " | ||
"for multicompany purpose."), | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception is not translated. By the way, I think the context should be added to the arguments.