Skip to content

Commit

Permalink
[ADD] account_cutoff_accrual_order_stock_base
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaudoux committed Oct 10, 2024
1 parent ede4471 commit 1a2e267
Show file tree
Hide file tree
Showing 12 changed files with 673 additions and 0 deletions.
86 changes: 86 additions & 0 deletions account_cutoff_accrual_order_stock_base/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
========================================
Account Cut-off Accrual Order Stock Base
========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:791c43ae54bd1847ebd5e0f75ad43368499c624e2ec8f67b58ac0e33b1a4a60c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-OCA%2Faccount--closing-lightgray.png?logo=github
:target: https://github.com/OCA/account-closing/tree/16.0/account_cutoff_accrual_order_stock_base
:alt: OCA/account-closing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-closing-16-0/account-closing-16-0-account_cutoff_accrual_order_stock_base
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-closing&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of account_cutoff_base
to define prepaid accounts for prepaid goods in the scope of accrued revenue
and expense.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-closing/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/OCA/account-closing/issues/new?body=module:%20account_cutoff_accrual_order_stock_base%0Aversion:%2016.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
~~~~~~~

* BCIM

Contributors
~~~~~~~~~~~~

* Jacques-Etienne Baudoux (BCIM) <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px
:target: https://github.com/jbaudoux
:alt: jbaudoux

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-jbaudoux|

This module is part of the `OCA/account-closing <https://github.com/OCA/account-closing/tree/16.0/account_cutoff_accrual_order_stock_base>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions account_cutoff_accrual_order_stock_base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
20 changes: 20 additions & 0 deletions account_cutoff_accrual_order_stock_base/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)


{
"name": "Account Cut-off Accrual Order Stock Base",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"license": "AGPL-3",
"summary": "Accrued Order Stock Base",
"author": "BCIM, Odoo Community Association (OCA)",
"maintainers": ["jbaudoux"],
"website": "https://github.com/OCA/account-closing",
"depends": ["account_cutoff_base", "stock"],
"data": [
"views/account_cutoff_view.xml",
],
"installable": True,
"application": False,
}
35 changes: 35 additions & 0 deletions account_cutoff_accrual_order_stock_base/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_cutoff_accrual_order_stock_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-26 12:01+0000\n"
"PO-Revision-Date: 2023-10-26 12:01+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: account_cutoff_accrual_order_stock_base
#: model:ir.model,name:account_cutoff_accrual_order_stock_base.model_account_cutoff
msgid "Account Cut-off"
msgstr "Provision"

#. module: account_cutoff_accrual_order_stock_base
#: model:ir.model.fields,help:account_cutoff_accrual_order_stock_base.field_account_cutoff__cutoff_account_prepaid_stock_id
msgid ""
"Account for accrual of prepaid stock expenses. For instance, goods invoiced "
"and not yet received."
msgstr ""
"Compte pour les provisions sur charges de type marchandise constatées "
"d'avance. Par exemple, les marchandises facturées et pas encore reçues."

#. module: account_cutoff_accrual_order_stock_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_stock_base.field_account_cutoff__cutoff_account_prepaid_stock_id
msgid "Cut-off Prepaid Stock Account"
msgstr "Compte de provision pour marchandise prépayée"
4 changes: 4 additions & 0 deletions account_cutoff_accrual_order_stock_base/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import account_cutoff
66 changes: 66 additions & 0 deletions account_cutoff_accrual_order_stock_base/models/account_cutoff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import Command, api, fields, models
from odoo.tools import float_is_zero


class AccountCutoff(models.Model):
_inherit = "account.cutoff"

cutoff_account_prepaid_stock_id = fields.Many2one(
comodel_name="account.account",
string="Cut-off Prepaid Stock Account",
domain="[('deprecated', '=', False)]",
states={"done": [("readonly", True)]},
check_company=True,
tracking=True,
default=lambda self: self._default_cutoff_account_prepaid_stock_id(),
help="Account for accrual of prepaid stock expenses. "
"For instance, goods invoiced and not yet received.",
)

@api.model
def _default_cutoff_account_prepaid_stock_id(self):
cutoff_type = self.env.context.get("default_cutoff_type")
company = self.env.company
if cutoff_type == "accrued_expense":
account_id = company.default_prepaid_expense_account_id.id or False
elif cutoff_type == "accrued_revenue":
account_id = company.default_prepaid_revenue_account_id.id or False
else:
account_id = False
return account_id

def _prepare_counterpart_moves(
self, to_provision, amount_total_pos, amount_total_neg
):
if not self.cutoff_account_prepaid_stock_id:
return super()._prepare_counterpart_moves(
to_provision, amount_total_pos, amount_total_neg
)
if self.cutoff_type == "accrued_revenue":
prepaid_amount = amount_total_neg
amount = amount_total_pos

Check warning on line 44 in account_cutoff_accrual_order_stock_base/models/account_cutoff.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_stock_base/models/account_cutoff.py#L43-L44

Added lines #L43 - L44 were not covered by tests
elif self.cutoff_type == "accrued_expense":
prepaid_amount = amount_total_pos
amount = amount_total_neg

Check warning on line 47 in account_cutoff_accrual_order_stock_base/models/account_cutoff.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_stock_base/models/account_cutoff.py#L46-L47

Added lines #L46 - L47 were not covered by tests
else:
prepaid_amount = 0
amount = 0
company_currency = self.company_id.currency_id
cur_rprec = company_currency.rounding
movelines_to_create = super()._prepare_counterpart_moves(

Check warning on line 53 in account_cutoff_accrual_order_stock_base/models/account_cutoff.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_stock_base/models/account_cutoff.py#L49-L53

Added lines #L49 - L53 were not covered by tests
to_provision, 0, amount
)
if not float_is_zero(prepaid_amount, precision_rounding=cur_rprec):
movelines_to_create.append(

Check warning on line 57 in account_cutoff_accrual_order_stock_base/models/account_cutoff.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_stock_base/models/account_cutoff.py#L57

Added line #L57 was not covered by tests
Command.create(
{
"account_id": self.cutoff_account_prepaid_stock_id.id,
"debit": prepaid_amount,
"credit": 0,
},
)
)
return movelines_to_create

Check warning on line 66 in account_cutoff_accrual_order_stock_base/models/account_cutoff.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_stock_base/models/account_cutoff.py#L66

Added line #L66 was not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Jacques-Etienne Baudoux (BCIM) <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module extends the functionality of account_cutoff_base
to define prepaid accounts for prepaid goods in the scope of accrued revenue
and expense.
Loading

0 comments on commit 1a2e267

Please sign in to comment.