diff --git a/addons/account_tax_country/__init__.py b/addons/account_tax_country/__init__.py new file mode 100644 index 00000000000..5b71912151a --- /dev/null +++ b/addons/account_tax_country/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import account_tax_country + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/account_tax_country/__openerp__.py b/addons/account_tax_country/__openerp__.py new file mode 100644 index 00000000000..e7e127127e7 --- /dev/null +++ b/addons/account_tax_country/__openerp__.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + + +{ + "name" : "Accounting and Financial Management", + "version" : "1.1", + "depends" : ["account"], + "author" : "Tiny", + "category": 'Generic Modules/Accounting', + "description": """Taxes to countries + """, + 'website': 'http://www.openerp.com', + 'init_xml': [], + 'update_xml': [ + "account_tax_country.xml" + ], + 'demo_xml': [ + + ], + 'installable': True, + 'active': False, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_tax_country/account_tax_country.py b/addons/account_tax_country/account_tax_country.py new file mode 100644 index 00000000000..6d1f7b1d753 --- /dev/null +++ b/addons/account_tax_country/account_tax_country.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import time +import netsvc +from osv import fields, osv + +from tools.misc import currency +from tools.translate import _ +class account_tax(osv.osv): + _inherit='account.tax' + _columns = { + 'country_id':fields.many2many('res.country','country_invoice_line_tax','invoice_line_id','tax_id',string='Country'), + } +account_tax() +class account_invoice(osv.osv): + _inherit='account.invoice' + + def _checkreset_taxes(self, cr, uid, ids, context=None): + + for invoice in self.browse(cr,uid,ids): + flag=False + country_id = invoice.address_invoice_id.country_id.id + for i in invoice.invoice_line: + tax_ids=i.invoice_line_tax_id + for tax in tax_ids: + for country in tax.country_id: + if country_id!=country.id: + flag=True + if flag: + raise osv.except_osv(_('Error!'), _('Find a valid Tax of country !')) + return True + _constraints = [ + (_checkreset_taxes, 'Unable to find a valid country in Tax', ['invoice_line']) + ] + + +account_invoice() diff --git a/addons/account_tax_country/account_tax_country.xml b/addons/account_tax_country/account_tax_country.xml new file mode 100644 index 00000000000..341e8db0239 --- /dev/null +++ b/addons/account_tax_country/account_tax_country.xml @@ -0,0 +1,22 @@ + + + + + + + account.tax.country.form + account.tax + form + + + + + + + + + + + + + \ No newline at end of file