Skip to content

Commit

Permalink
[MIG] stock_move_backdating: Migration to 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
toita86 committed Mar 22, 2024
1 parent 71f64fb commit 8a49d4e
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 45 deletions.
14 changes: 8 additions & 6 deletions stock_move_backdating/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stock Move Backdating
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b01459fc2cfe44edb3291c0126f76a77538671b64c4ab62ec70e6a0fd79acf77
!! source digest: sha256:3d865cfee3c716c65055a8ba08634b3c64370a0ee55e681a92ff434b36aab00e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Stock Move Backdating
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/12.0/stock_move_backdating
:target: https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_move_backdating
:alt: OCA/stock-logistics-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-12-0/stock-logistics-workflow-12-0-stock_move_backdating
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-14-0/stock-logistics-workflow-14-0-stock_move_backdating
: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/stock-logistics-workflow&target_branch=12.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -46,7 +46,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/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/stock-logistics-workflow/issues/new?body=module:%20stock_move_backdating%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_move_backdating%0Aversion:%2014.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.

Expand All @@ -70,6 +70,8 @@ Contributors
* `TAKOBI <https://takobi.online>`_:

* Simone Rubino <sir@takobi.online>
* `Ooops404 <https://www.ooops404.com/>_`:
* Eduard Brahas <eduardbrhas@outlook.it>

Maintainers
~~~~~~~~~~~
Expand All @@ -84,6 +86,6 @@ 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.

This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/12.0/stock_move_backdating>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_move_backdating>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 3 additions & 1 deletion stock_move_backdating/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{
"name": "Stock Move Backdating",
"version": "12.0.1.0.1",
"version": "14.0.1.0.0",
"category": "Stock Logistics",
"license": "AGPL-3",
"author": "Marco Dieckhoff, BREMSKERL, Agile Business Group, "
Expand All @@ -18,9 +18,11 @@
"stock_account",
],
"data": [
"security/ir.model.access.csv",
"wizards/fill_date_backdating.xml",
"views/stock_inventory_views.xml",
"views/stock_picking.xml",
"views/stock_move_line_views.xml",
],
"installable": True,
}
2 changes: 1 addition & 1 deletion stock_move_backdating/models/stock_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from odoo import api, fields, models

from .stock_move_line import check_date
from ..utils import check_date


class StockInventory(models.Model):
Expand Down
1 change: 0 additions & 1 deletion stock_move_backdating/models/stock_inventory_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class StockInventoryLine(models.Model):

def _get_move_values(self, qty, location_id, location_dest_id, out):
res = super()._get_move_values(qty, location_id, location_dest_id, out)
self.ensure_one()
date_backdating = self.inventory_id.date_backdating
if date_backdating:
move_line_ids = res.get("move_line_ids", list())
Expand Down
10 changes: 5 additions & 5 deletions stock_move_backdating/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# Copyright 2023 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models
from odoo import models
from odoo.fields import first

from .stock_move_line import check_date
from ..utils import check_date


class StockMove(models.Model):
Expand All @@ -27,6 +27,7 @@ def _backdating_account_moves(self):
)
move_account_moves.update(
{
"name": False,
"date": stock_move.date.date(),
}
)
Expand Down Expand Up @@ -57,12 +58,11 @@ def _backdating_action_done(self, moves_todo):
)
return self.browse(moves_todo_ids)

@api.multi
def _action_done(self):
def _action_done(self, cancel_backorder=False):
moves_todo = self.env["stock.move"]
has_move_lines_to_backdate = any(self.mapped("move_line_ids.date_backdating"))
if not has_move_lines_to_backdate:
moves_todo |= super()._action_done()
moves_todo |= super()._action_done(cancel_backorder=cancel_backorder)
else:
moves_todo = self._backdating_action_done(moves_todo)
return moves_todo
11 changes: 2 additions & 9 deletions stock_move_backdating/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@
# Copyright 2023 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

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


def check_date(date):
now = fields.Datetime.now()
if date and date > now:
raise UserError(
_("You can not process an actual " "movement date in the future.")
)
from ..utils import check_date


class StockMoveLine(models.Model):
Expand Down
10 changes: 4 additions & 6 deletions stock_move_backdating/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,18 @@ def _backdating_update_account_moves_date(self):
stock_moves._backdating_account_moves()
return True

@api.multi
def action_done(self):
result = super().action_done()
def _action_done(self):
result = super()._action_done()
for picking in self:
picking._backdating_update_picking_date()
picking._backdating_update_account_moves_date()
return result

# Disable pylint to match the exact signature in super
# pylint: disable=dangerous-default-value
@api.multi
def _create_backorder(self, backorder_moves=[]):
def _create_backorder(self):
# When a move needs backdating,
# we are processing the moves of a picking one by one,
# so we don't have to create a backorder if a move is missing
if "date_backdating" not in self.env.context:
return super()._create_backorder(backorder_moves=backorder_moves)
return super()._create_backorder()
2 changes: 2 additions & 0 deletions stock_move_backdating/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
* `TAKOBI <https://takobi.online>`_:

* Simone Rubino <sir@takobi.online>
* `Ooops404 <https://www.ooops404.com/>_`:
* Eduard Brahas <eduardbrhas@outlook.it>
2 changes: 2 additions & 0 deletions stock_move_backdating/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_fill_date_backdating,access_fill_date_backdating,model_fill_date_backdating,stock.group_stock_user,1,1,1,1
10 changes: 6 additions & 4 deletions stock_move_backdating/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Stock Move Backdating</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b01459fc2cfe44edb3291c0126f76a77538671b64c4ab62ec70e6a0fd79acf77
!! source digest: sha256:3d865cfee3c716c65055a8ba08634b3c64370a0ee55e681a92ff434b36aab00e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-workflow/tree/12.0/stock_move_backdating"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-12-0/stock-logistics-workflow-12-0-stock_move_backdating"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&amp;target_branch=12.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_move_backdating"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-14-0/stock-logistics-workflow-14-0-stock_move_backdating"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to register old stock moves (with date != now).
On each operation, user can specify the <strong>Actual Movement Date</strong>, that will be
used as movements date. That date can also be set by using the button <strong>Fill Actual Movement Date</strong>, shown in the header form when state is <em>Partially Available</em> or <em>Available</em>. As a result, all operations get automatically filled in with the date chosen.
Expand All @@ -392,7 +392,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_move_backdating%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_move_backdating%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -416,6 +416,8 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:sir&#64;takobi.online">sir&#64;takobi.online</a>&gt;</li>
</ul>
</li>
<li><cite>Ooops404 &lt;https://www.ooops404.com/&gt;_</cite>:
* Eduard Brahas &lt;<a class="reference external" href="mailto:eduardbrhas&#64;outlook.it">eduardbrhas&#64;outlook.it</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -425,7 +427,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/tree/12.0/stock_move_backdating">OCA/stock-logistics-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_move_backdating">OCA/stock-logistics-workflow</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions stock_move_backdating/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def _create_real_time_products(cls, products_values_list):
for field_name, field_value in products_values.items():
setattr(product_form, field_name, field_value)
product_form.type = "product"
product_form.property_valuation = "real_time"
cls.env["product.category"].browse(
product_form.categ_id.id
).property_valuation = "real_time"
product = product_form.save()
products |= product
return products
Expand Down Expand Up @@ -144,7 +146,7 @@ def _check_stock_moves(self, stock_moves):
)
account_moves = self.env["account.move"].search(
[
("stock_move_id", "in", stock_moves.ids),
("stock_move_id.id", "in", stock_moves.ids),
],
)
self._check_account_moves(account_moves, stock_moves)
Expand Down Expand Up @@ -204,7 +206,7 @@ def _transfer_picking_with_dates(self, *datetime_backdating_list):
for stock_move, datetime_backdating in stock_move_lines_dates_zip:
stock_move.date_backdating = datetime_backdating

picking.action_done()
picking._action_done()
self.assertEqual(picking.state, "done")
self._check_stock_moves(stock_moves)
self._check_picking_date(picking, datetime_backdating_list)
3 changes: 1 addition & 2 deletions stock_move_backdating/tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def test_inventory_yesterday(self):
{
"name": "Test backdating",
"date_backdating": yesterday,
"filter": "product",
"product_id": product.id,
"product_ids": [(6, 0, [product.id])],
}
)
inventory.action_start()
Expand Down
8 changes: 8 additions & 0 deletions stock_move_backdating/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import _, fields
from odoo.exceptions import UserError


def check_date(date):
now = fields.Datetime.now()
if date and date > now:
raise UserError(_("You can not process an actual movement date in the future."))
2 changes: 1 addition & 1 deletion stock_move_backdating/views/stock_inventory_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form" />
<field name="arch" type="xml">
<field name="date" position="after">
<field name="company_id" position="after">
<field
name="date_backdating"
attrs="{'readonly': [('state', '!=', 'draft')]}"
Expand Down
19 changes: 19 additions & 0 deletions stock_move_backdating/views/stock_move_line_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2018 Alex Comba - Agile Business Group
Copyright 2023 Simone Rubino - TAKOBI
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<record id="view_stock_move_line_detailed_operation_tree" model="ir.ui.view">
<field name="name">stock.move.line.operations.tree</field>
<field name="model">stock.move.line</field>
<field
name="inherit_id"
ref="stock.view_stock_move_line_detailed_operation_tree"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">
<field name="date_backdating" />
</xpath>
</field>
</record>
</odoo>
6 changes: 0 additions & 6 deletions stock_move_backdating/views/stock_picking.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
help="Fill Actual Movement Date of all operations"
/>
</xpath>
<xpath
expr="//field[@name='move_line_ids_without_package']//field[@name='product_id']"
position="after"
>
<field name="date_backdating" />
</xpath>
<field name="date_done" position="after">
<field
name="date_backdating"
Expand Down

0 comments on commit 8a49d4e

Please sign in to comment.