Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
=======================================================
AEAT 303 - Special Prorate Regularization Capital Asset
=======================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:98b425dda0770bcfc83565048e6fcf816841920e640c9bb173d61eb6e5817ef3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-NuoBiT%2Fodoo--addons-lightgray.png?logo=github
:target: https://github.com/NuoBiT/odoo-addons/tree/18.0/l10n_es_aeat_mod303_special_prorate_regularization_capital_asset
:alt: NuoBiT/odoo-addons

|badge1| |badge2| |badge3|

This module allows to regularize capital assets prorate differences on
303 report

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/NuoBiT/odoo-addons/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/NuoBiT/odoo-addons/issues/new?body=module:%20l10n_es_aeat_mod303_special_prorate_regularization_capital_asset%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* NuoBiT Solutions SL

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

- `NuoBiT <https://www.nuobit.com>`__:

- Kilian Niubo [email protected]
- Deniz Gallo [email protected]

Maintainers
-----------

This module is part of the `NuoBiT/odoo-addons <https://github.com/NuoBiT/odoo-addons/tree/18.0/l10n_es_aeat_mod303_special_prorate_regularization_capital_asset>`_ project on GitHub.

You are welcome to contribute.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright NuoBiT - Kilian Niubo <[email protected]>
# Copyright 2026 NuoBiT Solutions SL - Deniz Gallo <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

{
"name": "AEAT 303 - Special Prorate Regularization Capital Asset",
"summary": "This module allows to regularize capital assets "
"prorate differences on 303 report",
"version": "18.0.1.0.0",
"category": "Accounting",
"author": "NuoBiT Solutions SL",
"website": "https://github.com/NuoBiT/odoo-addons",
"license": "AGPL-3",
"depends": [
"l10n_es_account_capital_asset",
"l10n_es_aeat_mod303_special_prorate_regularization",
"l10n_es_aeat_prorate_asset",
],
"data": [
"data/ir_config_parameter.xml",
"security/ir.model.access.csv",
"views/mod303_views.xml",
"views/account_asset.xml",
"views/res_config_settings_views.xml",
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright NuoBiT Solutions SL - Kilian Niubo <[email protected]>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -->
<odoo noupdate="1">
<record id="capital_asset_prorate_max_diff" model="ir.config_parameter">
<field
name="key"
>l10n_es_aeat_mod303_special_prorate_regularization_capital_asset.capital_asset_prorate_max_diff</field>
<field name="value">10.0</field>
</record>
</odoo>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import mod303
from . import account_asset
from . import capital_asset_prorate_regularization
from . import l10n_es_aeat_report
from . import res_config_settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright NuoBiT Solutions SL - Kilian Niubo <[email protected]>
# Copyright NuoBiT Solutions SL - Eric Antones <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models


class AccountAsset(models.Model):
_inherit = "account.asset"

capital_asset_prorate_regularization_ids = fields.One2many(
comodel_name="capital.asset.prorate.regularization",
inverse_name="asset_id",
string="Asset Prorate Regularization",
)

active_capital_asset_prorate_regularization_ids = fields.One2many(
comodel_name="capital.asset.prorate.regularization",
inverse_name="asset_id",
string="Active Asset Prorate Regularization",
groups="l10n_es_aeat.group_account_aeat",
domain=[
"|",
("mod303_id", "=", False),
("mod303_id.state", "in", ["posted", "done"]),
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright NuoBiT Solutions SL - Kilian Niubo <[email protected]>
# Copyright 2026 NuoBiT Solutions SL - Deniz Gallo <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)


from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class AssetProrateRegularization(models.Model):
_name = "capital.asset.prorate.regularization"
_description = "Capital Asset Prorate Regularization"

year = fields.Integer()
amount = fields.Float()
asset_id = fields.Many2one(
comodel_name="account.asset",
string="Asset",
required=True,
readonly=True,
ondelete="cascade",
)
prorate_percent = fields.Float(
string="Prorate (%)",
)
mod303_id = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report",
string="Model 303",
readonly=True,
ondelete="restrict",
index=True,
)

@api.constrains("year", "asset_id")
def _check_year(self):
for rec in self:
other = self.env[self._name].search(
[("asset_id", "=", rec.asset_id.id), ("year", "=", rec.year)]
)
if len(other) > 1:
raise ValidationError(
_(
"There's another capital capital asset prorate regularization "
"with the same year: %(year)s and asset: %(asset)s"
)
% {"year": rec.year, "asset": rec.asset_id.name}
)

def _get_by_year(self, mod303):
asset_regularization_line = self.filtered(lambda x: x.year == mod303.year)
if asset_regularization_line:
if not asset_regularization_line.mod303_id:
raise ValidationError(
_(
"This asset have a prorate regularization"
" line this year: %(year)s, but it's not related"
" with a model 303. Please, review prorate"
" regularizations of capital asset: %(asset)s"
)
% {
"year": mod303.year,
"asset": self.mapped("asset_id.name"),
}
)
elif asset_regularization_line.mod303_id != mod303:
raise ValidationError(
_(
"This asset have a prorate regularization"
" line this year: %(year)s,"
" but related with another model 303. "
"Please, review prorate regularizations "
"of capital asset: %(asset)s"
)
% {
"year": mod303.year,
"asset": self.mapped("asset_id.name"),
}
)
return asset_regularization_line

def unlink(self):
allow_delete_capital_asset_lines = self.env.context.get(
"allow_delete_capital_asset_lines", False
)
for rec in self:
if rec.mod303_id and not allow_delete_capital_asset_lines:
raise ValidationError(
_(
"You can't delete a capital asset regularization line "
"if it's linked with a model 303."
)
)
return super().unlink()
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright NuoBiT Solutions SL - Kilian Niubo <[email protected]>
# Copyright NuoBiT Solutions SL - Eric Antones <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models


class L10nEsAeatReport(models.AbstractModel):
_inherit = "l10n.es.aeat.report"

move_prorate_capital_asset_id = fields.Many2one(
comodel_name="account.move",
string="Account capital asset entry",
readonly=True,
domain=[("move_type", "=", "entry")],
)

def _prepare_capital_asset_moves(self):
return self.mapped("move_prorate_capital_asset_id").ids
Loading
Loading