Skip to content

Commit

Permalink
[IMP] account_cutoff_picking: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thaolt99 committed Nov 30, 2023
1 parent 3e42461 commit 57761b8
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 98 deletions.
88 changes: 59 additions & 29 deletions account_cutoff_picking/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,71 @@ Account Cut-off Picking
: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_picking
:target: https://github.com/OCA/account-closing/tree/17.0/account_cutoff_picking
: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_picking
:target: https://translation.odoo-community.org/projects/account-closing-17-0/account-closing-17-0-account_cutoff_picking
: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
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-closing&target_branch=17.0
:alt: Try me on Runboat

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

This module generates expense/revenue accruals and prepaid expense/revenue based on the status of orders, pickings and invoices. The module is named *account_cutoff_accrual_picking* because it initially only supported accruals ; support for prepaid expense/revenue was added later (it should be renamed in later versions).

To understand the behavior of this module, let's take the example of an expense accrual. When you click on the button *Re-Generate Lines* of an *Expense Accrual*:

1. Odoo will look for all incoming picking in Done state with a *Transfer Date* <= *Cut-off Date*. For performance reasons, by default, the incoming picking dated before *Cut-off Date* minus 30 days will not be taken into account (this limit is configurable via the field *Picking Analysis*). It will go to the stock moves of those pickings and see if they are linked to a purchase order line.
2. Once this analysis is completed, Odoo has a list of purchase order lines to analyse for potential expense accrual.
This module generates expense/revenue accruals and prepaid
expense/revenue based on the status of orders, pickings and invoices.
The module is named *account_cutoff_accrual_picking* because it
initially only supported accruals ; support for prepaid expense/revenue
was added later (it should be renamed in later versions).

To understand the behavior of this module, let's take the example of an
expense accrual. When you click on the button *Re-Generate Lines* of an
*Expense Accrual*:

1. Odoo will look for all incoming picking in Done state with a
*Transfer Date* <= *Cut-off Date*. For performance reasons, by
default, the incoming picking dated before *Cut-off Date* minus 30
days will not be taken into account (this limit is configurable via
the field *Picking Analysis*). It will go to the stock moves of those
pickings and see if they are linked to a purchase order line.
2. Once this analysis is completed, Odoo has a list of purchase order
lines to analyse for potential expense accrual.
3. For each of these purchase order lines, Odoo will:

- scan the related stock moves in *done* state and check their transfer date,
- scan the related invoices lines and check their invoice date.

4. If, for a particular purchase order line, the quantity of products received before the cutoff-date (or on the same day) minus the quantity of products invoiced before the cut-off date (or on the same day) is positive, Odoo will generate a cut-off line.

Now, let's take the example of a prepaid expense. When you click on the button *Re-Generate Lines* of a *Prepaid Expense*:

1. Odoo will look for all vendor bills dated before (or equal to) *Cut-off Date*. For performance reasons, by default, the vendor bills dated before *Cut-off Date* minus 30 days will not be taken into account (this limit is configurable via the field *Picking Analysis*). It will go to the invoice lines of those vendor bills and see if they are linked to a purchase order line.
2. Once this analysis is completed, Odoo has a list of purchase order lines to analyse for potential prepaid expense.
- scan the related stock moves in *done* state and check their
transfer date,
- scan the related invoices lines and check their invoice date.

4. If, for a particular purchase order line, the quantity of products
received before the cutoff-date (or on the same day) minus the
quantity of products invoiced before the cut-off date (or on the same
day) is positive, Odoo will generate a cut-off line.

Now, let's take the example of a prepaid expense. When you click on the
button *Re-Generate Lines* of a *Prepaid Expense*:

1. Odoo will look for all vendor bills dated before (or equal to)
*Cut-off Date*. For performance reasons, by default, the vendor bills
dated before *Cut-off Date* minus 30 days will not be taken into
account (this limit is configurable via the field *Picking
Analysis*). It will go to the invoice lines of those vendor bills and
see if they are linked to a purchase order line.
2. Once this analysis is completed, Odoo has a list of purchase order
lines to analyse for potential prepaid expense.
3. For each of these purchase order lines, Odoo will:

- scan the related stock moves in *done* state and check their transfer date,
- scan the related invoices lines and check their invoice date.
- scan the related stock moves in *done* state and check their
transfer date,
- scan the related invoices lines and check their invoice date.

4. If, for a particular purchase order line, the quantity of products invoiced before the cutoff-date (or on the same day) minus the quantity of products received before the cut-off date (or on the same day) is positive, Odoo will generate a cut-off line.
4. If, for a particular purchase order line, the quantity of products
invoiced before the cutoff-date (or on the same day) minus the
quantity of products received before the cut-off date (or on the same
day) is positive, Odoo will generate a cut-off line.

This module should work well with multiple units of measure (including products purchased and invoiced in different units of measure) and in multi-currency.
This module should work well with multiple units of measure (including
products purchased and invoiced in different units of measure) and in
multi-currency.

**Table of contents**

Expand All @@ -62,33 +91,34 @@ This module should work well with multiple units of measure (including products
Configuration
=============

For configuration instructions, refer to the README of the module *account_cutoff_base*.
For configuration instructions, refer to the README of the module
*account_cutoff_base*.

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_picking%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-closing/issues/new?body=module:%20account_cutoff_picking%0Aversion:%2017.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
~~~~~~~
-------

* Akretion

Contributors
~~~~~~~~~~~~
------------

* Alexis de Lattre <[email protected]>
- Alexis de Lattre <[email protected]>

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -108,6 +138,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-alexis-via|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
40 changes: 14 additions & 26 deletions account_cutoff_picking/models/account_cutoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,24 @@ def picking_prepare_cutoff_line(self, vdict, account_mapping):
notes += (
"\n"
+ _("Pre-cutoff delivered quantity:")
+ " %s %s"
% (
precut_delivered_qty_fl,
uom_name,
)
+ f" {precut_delivered_qty_fl} {uom_name}"
)
if vdict.get("precut_delivered_logs"):
notes += (
"\n"
+ _("Pre-cutoff delivered quantity details:")
+ "\n%s" % "\n".join(vdict["precut_delivered_logs"])
)
param = "\n".join(vdict["precut_delivered_logs"])
notes += "\n" + _("Pre-cutoff delivered quantity details:") + f"\n{param}"
precut_invoiced_qty_fl = formatLang(
self.env, vdict.get("precut_invoiced_qty", 0), dp="Product Unit of Measure"
)
notes += (
"\n"
+ _("Pre-cutoff invoiced quantity:")
+ " %s %s" % (precut_invoiced_qty_fl, uom_name)
+ f" {precut_invoiced_qty_fl} {uom_name}"
)
if vdict.get("precut_invoiced_logs"):
notes += (
"\n"
+ _("Pre-cutoff invoiced quantity details:")
+ "\n%s" % "\n".join(vdict["precut_invoiced_logs"])
)
param = "\n".join(vdict["precut_invoiced_logs"])
notes += "\n" + _("Pre-cutoff invoiced quantity details:") + f"\n{param}"
qty_fl = formatLang(self.env, qty, dp="Product Unit of Measure")
notes += "\n%s %s %s" % (qty_label, qty_fl, uom_name)
notes += f"\n{qty_label} {qty_fl} {uom_name}"

vals = {
"parent_id": self.id,
Expand Down Expand Up @@ -227,7 +217,7 @@ def order_line_update_oline_dict_from_stock_moves(
)
move_logs.append((in_move, move_qty))
move_logs_sorted = sorted(move_logs, key=lambda to_sort: to_sort[0].date)
for (move, move_qty_signed) in move_logs_sorted:
for move, move_qty_signed in move_logs_sorted:
wdict["precut_delivered_qty"] += move_qty_signed
move_qty_signed_formatted = formatLang(
self.env, move_qty_signed, dp="Product Unit of Measure"
Expand Down Expand Up @@ -281,15 +271,13 @@ def order_line_update_oline_dict_from_invoice_lines(
iline_qty_puom_formatted = formatLang(
self.env, iline_qty_puom, dp="Product Unit of Measure"
)
qty = iline_qty_puom_formatted
uom = iline.product_id.uom_id.name
move_type = move_type2label[invoice.move_type]
move_name = invoice.name
date = format_date(self.env, invoice.date)
wdict["precut_invoiced_logs"].append(
" • %(qty)s %(uom)s (%(move_type)s %(move_name)s dated %(date)s)"
% {
"qty": iline_qty_puom_formatted,
"uom": iline.product_id.uom_id.name,
"move_type": move_type2label[invoice.move_type],
"move_name": invoice.name,
"date": format_date(self.env, invoice.date),
}
f" • {qty} {uom} ({move_type} {move_name} dated {date})"
)
# Most recent invoice line used for price_unit, account,...
wdict["price_unit"] = iline.price_subtotal / iline_qty_puom
Expand Down
3 changes: 3 additions & 0 deletions account_cutoff_picking/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
For configuration instructions, refer to the README of the module *account_cutoff_base*.
For configuration instructions, refer to the README of the module
*account_cutoff_base*.
1 change: 1 addition & 0 deletions account_cutoff_picking/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Alexis de Lattre \<<[email protected]>\>
1 change: 0 additions & 1 deletion account_cutoff_picking/readme/CONTRIBUTORS.rst

This file was deleted.

50 changes: 50 additions & 0 deletions account_cutoff_picking/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
This module generates expense/revenue accruals and prepaid
expense/revenue based on the status of orders, pickings and invoices.
The module is named *account_cutoff_accrual_picking* because it
initially only supported accruals ; support for prepaid expense/revenue
was added later (it should be renamed in later versions).

To understand the behavior of this module, let's take the example of an
expense accrual. When you click on the button *Re-Generate Lines* of an
*Expense Accrual*:

1. Odoo will look for all incoming picking in Done state with a
*Transfer Date* \<= *Cut-off Date*. For performance reasons, by
default, the incoming picking dated before *Cut-off Date* minus 30
days will not be taken into account (this limit is configurable via
the field *Picking Analysis*). It will go to the stock moves of
those pickings and see if they are linked to a purchase order line.
2. Once this analysis is completed, Odoo has a list of purchase order
lines to analyse for potential expense accrual.
3. For each of these purchase order lines, Odoo will:
- scan the related stock moves in *done* state and check their
transfer date,
- scan the related invoices lines and check their invoice date.
4. If, for a particular purchase order line, the quantity of products
received before the cutoff-date (or on the same day) minus the
quantity of products invoiced before the cut-off date (or on the
same day) is positive, Odoo will generate a cut-off line.

Now, let's take the example of a prepaid expense. When you click on the
button *Re-Generate Lines* of a *Prepaid Expense*:

1. Odoo will look for all vendor bills dated before (or equal to)
*Cut-off Date*. For performance reasons, by default, the vendor
bills dated before *Cut-off Date* minus 30 days will not be taken
into account (this limit is configurable via the field *Picking
Analysis*). It will go to the invoice lines of those vendor bills
and see if they are linked to a purchase order line.
2. Once this analysis is completed, Odoo has a list of purchase order
lines to analyse for potential prepaid expense.
3. For each of these purchase order lines, Odoo will:
- scan the related stock moves in *done* state and check their
transfer date,
- scan the related invoices lines and check their invoice date.
4. If, for a particular purchase order line, the quantity of products
invoiced before the cutoff-date (or on the same day) minus the
quantity of products received before the cut-off date (or on the
same day) is positive, Odoo will generate a cut-off line.

This module should work well with multiple units of measure (including
products purchased and invoiced in different units of measure) and in
multi-currency.
25 changes: 0 additions & 25 deletions account_cutoff_picking/readme/DESCRIPTION.rst

This file was deleted.

Loading

0 comments on commit 57761b8

Please sign in to comment.