[Add]: Task-897 [audaxis] tax linked to country warning if address diff
bzr revid: sbh@tinyerp.com-20100702101552-u45m5hven8mcu1mn
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import account_tax_country
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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" : "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:
|
||||
@@ -0,0 +1,56 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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()
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="account_country_tax_form_view">
|
||||
<field name="name">account.tax.country.form</field>
|
||||
<field name="model">account.tax</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.view_tax_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page[@string='Special Computation']" position="after">
|
||||
<page string="Country">
|
||||
<field name="country_id" nolabel="1"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user