Skip to content

Commit

Permalink
product_lot_sequence: port fix from 15.0 to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vvrossem committed Mar 21, 2024
1 parent c4fefff commit 8d070b3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
9 changes: 7 additions & 2 deletions product_lot_sequence/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Product Lot Sequence
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c497d170778ffa1220e7cd95c340001c2d7caad3c29559a226d0bd3bc9d5d6fb
!! source digest: sha256:568bfc6b73360be36291cdcf8aa0d184a57b2701e2ff2798311977a8be099b31
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -111,7 +111,12 @@ Contributors

* Adria Gil Sorribes <[email protected]>
* Domantas Girdžiūnas <[email protected]>
* Akim Juillerat <[email protected]>

* `Camptocamp <https://www.camptocamp.com>`__:

* Akim Juillerat <[email protected]>
* Vincent Van Rossem <[email protected]>

* `Quartile <https://www.quartile.co>`__:

* Yoshi Tashiro
Expand Down
12 changes: 4 additions & 8 deletions product_lot_sequence/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ class StockMove(models.Model):

def action_show_details(self):
"""Avoid calling and incrementing the sequence if not needed or already done"""
seq_policy = self.env["stock.production.lot"]._get_sequence_policy()
seq_policy = self.env["stock.lot"]._get_sequence_policy()
if seq_policy in ("product", "global"):
# If move is not supposed to assign serial pass empty string for next serial
if not self.display_assign_serial:
return super(
StockMove, self.with_context(force_next_serial="")
).action_show_details()
self = self.with_context(force_next_serial="")
# If the sequence was already called once, avoid calling it another time
elif self.next_serial:
return super(
StockMove, self.with_context(force_next_serial=self.next_serial)
).action_show_details()
return super().action_show_details()
self = self.with_context(force_next_serial=self.next_serial)
return super(StockMove, self).action_show_details()
7 changes: 6 additions & 1 deletion product_lot_sequence/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
* Adria Gil Sorribes <[email protected]>
* Domantas Girdžiūnas <[email protected]>
* Akim Juillerat <[email protected]>

* `Camptocamp <https://www.camptocamp.com>`__:

* Akim Juillerat <[email protected]>
* Vincent Van Rossem <[email protected]>

* `Quartile <https://www.quartile.co>`__:

* Yoshi Tashiro
6 changes: 5 additions & 1 deletion product_lot_sequence/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Product Lot Sequence</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c497d170778ffa1220e7cd95c340001c2d7caad3c29559a226d0bd3bc9d5d6fb
!! source digest: sha256:568bfc6b73360be36291cdcf8aa0d184a57b2701e2ff2798311977a8be099b31
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/product-attribute/tree/16.0/product_lot_sequence"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_lot_sequence"><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/product-attribute&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds ability to define a lot sequence from the product which will be proposed upon creating new lots.</p>
Expand Down Expand Up @@ -460,7 +460,11 @@ <h2><a class="toc-backref" href="#toc-entry-9">Contributors</a></h2>
<ul class="simple">
<li>Adria Gil Sorribes &lt;<a class="reference external" href="mailto:adria.gil&#64;forgeflow.com">adria.gil&#64;forgeflow.com</a>&gt;</li>
<li>Domantas Girdžiūnas &lt;<a class="reference external" href="mailto:domantas&#64;vialaurea.lt">domantas&#64;vialaurea.lt</a>&gt;</li>
<li><a class="reference external" href="https://www.camptocamp.com">Camptocamp</a>:<ul>
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li>Vincent Van Rossem &lt;<a class="reference external" href="mailto:vincent.vanrossem&#64;camptocamp.com">vincent.vanrossem&#64;camptocamp.com</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.quartile.co">Quartile</a>:<ul>
<li>Yoshi Tashiro</li>
</ul>
Expand Down
7 changes: 5 additions & 2 deletions product_lot_sequence/tests/test_product_lot_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def test_lot_onchange_product_id_global(self):
self.assertEqual(lot.name, next_sequence_number)

def test_open_detailed_operations(self):
# Required for `product_uom` to be visible in the view
self.env.user.groups_id += self.env.ref("uom.group_uom")

self.env["ir.config_parameter"].set_param(
"product_lot_sequence.policy", "global"
)
Expand All @@ -115,7 +118,7 @@ def test_open_detailed_operations(self):
delivery_picking = self._create_picking(
self.delivery_type, [{"product_id": product}]
)
delivery_move = delivery_picking.move_lines
delivery_move = delivery_picking.move_ids
self.assertFalse(delivery_move.next_serial)
delivery_move.action_show_details()
self.assertFalse(delivery_move.next_serial)
Expand All @@ -125,7 +128,7 @@ def test_open_detailed_operations(self):
receipt_picking = self._create_picking(
self.receipt_type, [{"product_id": product}]
)
receipt_move = receipt_picking.move_lines
receipt_move = receipt_picking.move_ids
self.assertFalse(receipt_move.next_serial)
receipt_move.action_show_details()
self.assertEqual(receipt_move.next_serial, first_next_sequence_number)
Expand Down

0 comments on commit 8d070b3

Please sign in to comment.