1
# -*- encoding: utf-8 -*-
2
#########################################################################
4
# Copyright (C) 2009 Rapha�l Valyi #
6
#This program is free software: you can redistribute it and/or modify #
7
#it under the terms of the GNU General Public License as published by #
8
#the Free Software Foundation, either version 3 of the License, or #
9
#(at your option) any later version. #
11
#This program is distributed in the hope that it will be useful, #
12
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
13
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14
#GNU General Public License for more details. #
16
#You should have received a copy of the GNU General Public License #
17
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
18
#########################################################################
20
from osv import fields, osv
22
class product_product(osv.osv):
23
_inherit = 'product.product'
25
'property_fiscal_classification': fields.property(
26
'account.product.fiscal.classification',
28
relation='account.product.fiscal.classification',
29
string="Fiscal Classification",
32
help="Company wise (eg localizable) Fiscal Classification"),
35
def fiscal_classification_id_change(self, cr, uid, ids, fiscal_classification_id=False, sale_tax_ids=[[6, 0, []]], purchase_tax_ids=[[6, 0, []]]):
36
"""We eventually keep the sale and purchase taxes because those are not company wise in OpenERP. So if we choose a different fiscal position
37
for a different company, we don't want to override other's companies setting"""
39
if fiscal_classification_id:
40
fiscal_classification = self.pool.get('account.product.fiscal.classification').browse(cr, uid, fiscal_classification_id)
42
current_company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.partner_id.id
43
to_keep_sale_tax_ids = self.pool.get('account.tax').search(cr, uid, [('id', 'in', sale_tax_ids[0][2]), ('company_id', '!=', current_company_id)])
44
to_keep_purchase_tax_ids = self.pool.get('account.tax').search(cr, uid, [('id', 'in', purchase_tax_ids[0][2]), ('company_id', '!=', current_company_id)])
46
result['value']['taxes_id'] = to_keep_sale_tax_ids + [x.id for x in fiscal_classification.sale_base_tax_ids]
47
result['value']['supplier_taxes_id'] = to_keep_purchase_tax_ids + [x.id for x in fiscal_classification.purchase_base_tax_ids]
b'\\ No newline at end of file'