Skip to content
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

[FW][IMP] l10n_ar_account_withholding_cba: new module #948

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions l10n_ar_account_withholding_ratio/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.. |company| replace:: ADHOC SA

.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png
:alt: ADHOC SA
:target: https://www.adhoc.com.ar

.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=============================
Argentinean Withholding Ratio
=============================

Este módulo imlementa:

* Permite establecer un ratio de 1 a 100 en el impuesto y representa el porcentaje de base imponible que se tendrá en cuenta para aplicar el impuesto siempre y cuando la alícuota del impuesto se obtenega del partner. Si bien se puede usar ese ratio para cualquier impuesto en principio fue solicitado solo para Córdoba.


Installation
============

To install this module, you need to:

#. Only need to install the module

Configuration
=============

To configure this module, you need to:

#. Nothing to configure

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/

Credits
=======

Images
------

* |company| |icon|

Contributors
------------

Maintainer
----------

|company_logo|

This module is maintained by the |company|.

To contribute to this module, please visit https://www.adhoc.com.ar.
1 change: 1 addition & 0 deletions l10n_ar_account_withholding_ratio/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions l10n_ar_account_withholding_ratio/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
'name': 'Argentinean Withholding Ratio',
'version': "17.0.1.0.0",
'category': 'Localization/Argentina',
'sequence': 14,
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'summary': '',
'depends': [
'l10n_ar_withholding_ux',
],
'data': [
'views/account_tax_view.xml',
],
'demo': [
],
'installable': True,
'auto_install': False,
'application': False,
}
5 changes: 5 additions & 0 deletions l10n_ar_account_withholding_ratio/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import account_tax
30 changes: 30 additions & 0 deletions l10n_ar_account_withholding_ratio/models/account_tax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import fields, models, api, _
from odoo.exceptions import ValidationError


class AccountTax(models.Model):
_inherit = 'account.tax'

ratio = fields.Float(default=100.00, help="Ratio to apply to tax base amount.")

@api.constrains('ratio')
def _check_line_ids_percent(self):
""" Check that the total percent is not bigger than 100.0 """
for tax in self:
if not tax.ratio or tax.ratio < 0.0 or tax.ratio > 100.0:
raise ValidationError(_('The total percentage (%s) should be higher than 0 and less or equal to 100.', tax.ratio))

def get_withholding_vals(self, payment):
vals = super().get_withholding_vals(payment)
if self.withholding_type == 'partner_tax' and self.ratio != 100:
vals['withholdable_base_amount'] *= self.ratio / 100
vals['period_withholding_amount'] *= self.ratio / 100
return vals

def _compute_amount(
self, base_amount, price_unit, quantity, product, partner=None, fixed_multiplicator=1):
if self.amount_type == 'partner_tax' and self.ratio != 100:
date = self._context.get('invoice_date') or fields.Date.context_today(self)
partner = partner and partner.sudo()
return base_amount * self.sudo().get_partner_alicuota_percepcion(partner, date) * self.ratio / 100
return super()._compute_amount(base_amount, price_unit, quantity, product, partner=partner, fixed_multiplicator=fixed_multiplicator)
20 changes: 20 additions & 0 deletions l10n_ar_account_withholding_ratio/views/account_tax_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_tax_form" model="ir.ui.view">
<field name="name">account.tax.form</field>
<field name="model">account.tax</field>
<field name="inherit_id" ref="l10n_ar_withholding_ux.view_tax_form"/>
<field name="arch" type="xml">
<field name="withholding_user_error_message" position="after">
<label for="ratio" invisible="country_code != 'AR'"/>
<div invisible="country_code != 'AR'">
<field name="ratio" class="oe_inline"/>
%
</div>
</field>
</field>
</record>

</odoo>