Skip to content

Commit

Permalink
Merge pull request #48 from akretion/7.0_sale_visible_tax
Browse files Browse the repository at this point in the history
[ADD] add sale visible tax, that show the subtotal tax and ...
  • Loading branch information
jgrandguillaume committed Nov 26, 2014
2 parents 615f752 + ee3fd46 commit 47ec750
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 0 deletions.
24 changes: 24 additions & 0 deletions sale_visible_tax/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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/>.
#
###############################################################################

from . import sale
from . import invoice
41 changes: 41 additions & 0 deletions sale_visible_tax/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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 Visible Tax',
'version': '0.0.1',
'author': 'Akretion',
'website': 'www.akretion.com',
'license': 'AGPL-3',
'category': 'Generic Modules',
'description': """This module adds the fields "Sub total tax inc"
and "Sub total tax" on sale order line and invoice line
""",
'depends': [
'sale',
],
'data': [
'sale_view.xml',
'invoice_view.xml',
],
'installable': True,
'application': False,
}
29 changes: 29 additions & 0 deletions sale_visible_tax/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * sale_visible_tax
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-10-10 15:24+0000\n"
"PO-Revision-Date: 2014-10-10 15:24+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_visible_tax
#: field:account.invoice.line,vat_subtotal:0
#: field:sale.order.line,vat_subtotal:0
msgid "Total VAT"
msgstr "Total TVA"

#. module: sale_visible_tax
#: field:account.invoice.line,price_subtotal_taxinc:0
#: field:sale.order.line,price_subtotal_taxinc:0
msgid "Total Tax Inc"
msgstr "Total TTC"

29 changes: 29 additions & 0 deletions sale_visible_tax/i18n/sale_visible_tax.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * sale_visible_tax
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-10-10 15:24+0000\n"
"PO-Revision-Date: 2014-10-10 15:24+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_visible_tax
#: field:account.invoice.line,sub_total_tax:0
#: field:sale.order.line,sub_total_tax:0
msgid "Sub-Total Tax"
msgstr ""

#. module: sale_visible_tax
#: field:account.invoice.line,sub_total_tax_inc:0
#: field:sale.order.line,sub_total_tax_inc:0
msgid "Sub-Total Tax Inc"
msgstr ""

61 changes: 61 additions & 0 deletions sale_visible_tax/invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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/>.
#
###############################################################################

from openerp.osv import fields, orm
import decimal_precision as dp


class AccountInvoiceLine(orm.Model):
_inherit = "account.invoice.line"

def _amount_line_tax_inc(self, cr, uid, ids, field_names, args,
context=None):
res = {}
tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency')
for line in self.browse(cr, uid, ids):
cur = line.invoice_id.currency_id
price = line.price_unit * (1-(line.discount or 0.0)/100.0)
taxes = tax_obj.compute_all(
cr, uid, line.invoice_line_tax_id, price, line.quantity,
product=line.product_id,
partner=line.invoice_id.partner_id)
res[line.id] = {
'price_subtotal_taxinc': cur_obj.round(
cr, uid, cur, taxes['total_included']),
'vat_subtotal': cur_obj.round(
cr, uid, cur, (taxes['total_included'] - taxes['total'])),
}
return res

_columns = {
'price_subtotal_taxinc': fields.function(
_amount_line_tax_inc,
digits_compute=dp.get_precision('Sale Price'),
string='Total Tax Inc',
multi="tax_details"),
'vat_subtotal': fields.function(
_amount_line_tax_inc,
digits_compute=dp.get_precision('Sale Price'),
string='Total VAT',
multi="tax_details"),
}
20 changes: 20 additions & 0 deletions sale_visible_tax/invoice_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- INHERITED VIEW FOR THE OBJECT : account_invoice -->

<record id="invoice_form" model="ir.ui.view">
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field eval="16" name="priority"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="//tree/field[@name='price_subtotal']" position="after">
<field name="vat_subtotal"/>
<field name="price_subtotal_taxinc"/>
</xpath>
</field>
</record>

</data>
</openerp>
54 changes: 54 additions & 0 deletions sale_visible_tax/sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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/>.
#
###############################################################################

from openerp.osv import fields, orm
import decimal_precision as dp


class SaleOrderLine(orm.Model):
_inherit = "sale.order.line"

def _get_amount_line_tax(self, cr, uid, ids, field_name, arg,
context=None):
order_obj = self.pool.get('sale.order')
res = {}
for line in self.browse(cr, uid, ids, context=context):
amount_tax_line = order_obj._amount_line_tax(
cr, uid, line, context=None)
res[line.id] = {
'price_subtotal_taxinc': amount_tax_line + line.price_subtotal,
'vat_subtotal': amount_tax_line,
}
return res

_columns = {
'price_subtotal_taxinc': fields.function(
_get_amount_line_tax,
digits_compute=dp.get_precision('Sale Price'),
string='Total Tax Inc',
multi="tax_details"),
'vat_subtotal': fields.function(
_get_amount_line_tax,
digits_compute=dp.get_precision('Sale Price'),
string='Total VAT',
multi="tax_details"),
}
20 changes: 20 additions & 0 deletions sale_visible_tax/sale_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- INHERITED VIEW FOR THE OBJECT : sale_order -->

<record id="sale_order_view_form" model="ir.ui.view">
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field eval="200" name="priority"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="price_subtotal" position="after">
<field name="vat_subtotal"/>
<field name="price_subtotal_taxinc"/>
</field>
</field>
</record>

</data>
</openerp>

0 comments on commit 47ec750

Please sign in to comment.