Skip to content

Commit

Permalink
[MIG] product_cost_price_avco_sync: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 committed Jun 12, 2024
1 parent 0969dc1 commit 32f5cef
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 70 deletions.
12 changes: 6 additions & 6 deletions product_cost_price_avco_sync/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Product cost price avco sync
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9eb6a763cc30fe3f2fc95c5be5d6451faa46ac5a6b45723ce306e46445fb8db1
!! source digest: sha256:f07176b3a7502ceb2553fc8c5613eb3680f27cd6fa3a28d492b55a6fcee661c1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand All @@ -17,13 +17,13 @@ Product cost price avco sync
: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/15.0/product_cost_price_avco_sync
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/product_cost_price_avco_sync
: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-15-0/stock-logistics-workflow-15-0-product_cost_price_avco_sync
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-product_cost_price_avco_sync
: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=15.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -42,7 +42,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:%20product_cost_price_avco_sync%0Aversion:%2015.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:%20product_cost_price_avco_sync%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.

Expand Down Expand Up @@ -87,6 +87,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-carlosdauden| |maintainer-sergio-teruel|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion product_cost_price_avco_sync/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Product cost price avco sync",
"summary": "Set product cost price from updated moves",
"version": "15.0.1.0.2",
"version": "16.0.1.0.0",
"development_status": "Production/Stable",
"category": "Stock",
"website": "https://github.com/OCA/stock-logistics-workflow",
Expand Down
8 changes: 4 additions & 4 deletions product_cost_price_avco_sync/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Product cost price avco sync</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9eb6a763cc30fe3f2fc95c5be5d6451faa46ac5a6b45723ce306e46445fb8db1
!! source digest: sha256:f07176b3a7502ceb2553fc8c5613eb3680f27cd6fa3a28d492b55a6fcee661c1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/15.0/product_cost_price_avco_sync"><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-15-0/stock-logistics-workflow-15-0-product_cost_price_avco_sync"><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=15.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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/16.0/product_cost_price_avco_sync"><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-16-0/stock-logistics-workflow-16-0-product_cost_price_avco_sync"><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=16.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 sync cost price products with average cost method from
stock moves price unit.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -389,7 +389,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:%20product_cost_price_avco_sync%0Aversion:%2015.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:%20product_cost_price_avco_sync%0Aversion:%2016.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 Down Expand Up @@ -423,7 +423,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/carlosdauden"><img alt="carlosdauden" src="https://github.com/carlosdauden.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/sergio-teruel"><img alt="sergio-teruel" src="https://github.com/sergio-teruel.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/tree/15.0/product_cost_price_avco_sync">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/16.0/product_cost_price_avco_sync">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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from odoo.tests.common import TransactionCase, tagged

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT

_logger = logging.getLogger(__name__)


Expand All @@ -14,15 +16,6 @@ class TestProductCostPriceAvcoSync(TransactionCase):
@classmethod
def setUpClass(cls):
super(TestProductCostPriceAvcoSync, cls).setUpClass()
# Remove this variable in v16 and put instead:
# from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
DISABLED_MAIL_CONTEXT = {
"tracking_disable": True,
"mail_create_nolog": True,
"mail_create_nosubscribe": True,
"mail_notrack": True,
"no_reset_password": True,
}
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
cls.StockPicking = cls.env["stock.picking"]
cls.supplier_location = cls.env.ref("stock.stock_location_suppliers")
Expand All @@ -48,7 +41,7 @@ def setUpClass(cls):
"picking_type_id": cls.picking_type_in.id,
"location_id": cls.supplier_location.id,
"location_dest_id": cls.stock_location.id,
"move_lines": [
"move_ids": [
(
0,
0,
Expand All @@ -70,7 +63,7 @@ def setUpClass(cls):
"picking_type_id": cls.picking_type_out.id,
"location_id": cls.stock_location.id,
"location_dest_id": cls.customer_location.id,
"move_lines": [
"move_ids": [
(
0,
0,
Expand All @@ -88,7 +81,7 @@ def setUpClass(cls):
)

def _test_sync_cost_price(self):
move_in = self.picking_in.move_lines[:1]
move_in = self.picking_in.move_ids[:1]
move_in.product_uom_qty = 100
move_in.price_unit = 5.0
move_in.quantity_done = move_in.product_uom_qty
Expand All @@ -104,20 +97,20 @@ def _test_sync_cost_price(self):
sleep(1)

picking_in_2 = self.picking_in.copy()
move_in_2 = picking_in_2.move_lines[:1]
move_in_2 = picking_in_2.move_ids[:1]
move_in_2.product_uom_qty = 10.0
move_in_2.quantity_done = move_in_2.product_uom_qty
picking_in_2._action_done()
move_in_2.date = "2019-10-02 00:00:00"
sleep(1)

move_out = self.picking_out.move_lines[:1]
move_out = self.picking_out.move_ids[:1]
move_out.quantity_done = move_out.product_uom_qty
self.picking_out._action_done()
move_out.date = "2019-10-03 00:00:00"

picking_out_2 = self.picking_out.copy()
move_out_2 = picking_out_2.move_lines[:1]
move_out_2 = picking_out_2.move_ids[:1]
move_out_2.quantity_done = move_out_2.product_uom_qty
picking_out_2._action_done()
move_out_2.date = "2019-10-04 00:00:00"
Expand Down Expand Up @@ -154,31 +147,31 @@ def _test_sync_cost_price(self):

def _test_sync_cost_price_and_history(self):
company_id = self.picking_in.company_id.id
move_in = self.picking_in.move_lines[:1]
move_in = self.picking_in.move_ids[:1]
move_in.quantity_done = move_in.product_uom_qty
self.picking_in._action_done()
move_in.date = "2019-10-01 00:00:00"

move_out = self.picking_out.move_lines[:1]
move_out = self.picking_out.move_ids[:1]
move_out.quantity_done = move_out.product_uom_qty
self.picking_out._action_done()
move_out.date = "2019-10-01 01:00:00"

picking_in_2 = self.picking_in.copy()
move_in_2 = picking_in_2.move_lines[:1]
move_in_2 = picking_in_2.move_ids[:1]
move_in_2.quantity_done = move_in_2.product_uom_qty
picking_in_2._action_done()
move_in_2.date = "2019-10-01 02:00:00"

picking_out_2 = self.picking_out.copy()
move_out_2 = picking_out_2.move_lines[:1]
move_out_2 = picking_out_2.move_ids[:1]
move_out_2.product_uom_qty = 15
move_out_2.quantity_done = move_out_2.product_uom_qty
picking_out_2._action_done()
move_out_2.date = "2019-10-01 03:00:00"

picking_in_3 = self.picking_in.copy()
move_in_3 = picking_in_3.move_lines[:1]
move_in_3 = picking_in_3.move_ids[:1]
move_in_3.quantity_done = move_in_3.product_uom_qty
move_in_3.price_unit = 2.0
picking_in_3._action_done()
Expand Down Expand Up @@ -215,13 +208,13 @@ def _test_sync_cost_price_and_history(self):
self.assertEqual(svl_count, 4) # TODO: Miralo que no se si es así

def _test_sync_cost_price_multi_moves_done_at_same_time(self):
move_in = self.picking_in.move_lines[:1]
move_in = self.picking_in.move_ids[:1]
move_in.product_uom_qty = 10
move_in.price_unit = 10.0
move_in.quantity_done = move_in.product_uom_qty

picking_in_2 = self.picking_in.copy()
move_in_2 = picking_in_2.move_lines[:1]
move_in_2 = picking_in_2.move_ids[:1]
move_in_2.product_uom_qty = 10.0
move_in_2.price_unit = 5.0
move_in_2.quantity_done = move_in_2.product_uom_qty
Expand All @@ -245,13 +238,13 @@ def _test_sync_cost_price_multi_moves_done_at_same_time(self):
def _test_change_quantiy_price(self):
"""Write quantity and price to zero in a stock valuation layer"""
self.picking_in.action_assign()
move_in = self.picking_in.move_lines[:1]
move_in = self.picking_in.move_ids[:1]
self.picking_in.move_line_ids.qty_done = move_in.product_uom_qty
self.picking_in._action_done()

picking_in_2 = self.picking_in.copy()
picking_in_2.action_assign()
move_in_2 = picking_in_2.move_lines[:1]
move_in_2 = picking_in_2.move_ids[:1]
move_in_2.product_uom_qty = 10.0
move_in_2.quantity_done = move_in_2.product_uom_qty
picking_in_2._action_done()
Expand Down Expand Up @@ -300,7 +293,7 @@ def create_picking(self, p_type="IN", qty=1.0, confirmed=True):
"picking_type_id": picking_type.id,
"location_id": location_id.id,
"location_dest_id": location_dest_id.id,
"move_lines": [
"move_ids": [
(
0,
0,
Expand All @@ -319,7 +312,7 @@ def create_picking(self, p_type="IN", qty=1.0, confirmed=True):
)
if confirmed:
picking.action_assign()
move = picking.move_lines[:1]
move = picking.move_ids[:1]
picking.move_line_ids.qty_done = move.product_uom_qty
picking._action_done()
return picking, move
Expand Down Expand Up @@ -455,52 +448,21 @@ def test_change_quantiy_price_xx(self):
quant.quantity, quant.product_id.standard_price
)
)
# Change qty before cost
move_in_01.with_context(keep_avco_inventory=True).quantity_done = 0.0
self.print_svl(
"After force quantity to 0 in first IN move Quant:{} Cost:{}".format(
quant.quantity, quant.product_id.standard_price
)
)
move_in_01.stock_valuation_layer_ids.unit_cost = 0.0
self.print_svl(
"After force unit cost to 0 in first IN move Quant:{}".format(
quant.quantity
)
)

# Restore to initial values
move_in_01.with_context(keep_avco_inventory=True).quantity_done = 10.0
move_in_01.stock_valuation_layer_ids.unit_cost = 2.0
self.print_svl(
"After restore initial values Quant:{} Standard Price:{}".format(
quant.quantity, quant.product_id.standard_price
)
)

# Change cost before quantity
move_in_01.stock_valuation_layer_ids.unit_cost = 0.0
self.print_svl(
"After force unit cost to 0 in first IN move Quant:{}".format(
quant.quantity
)
)
move_in_01.quantity_done = 0.0
# Change qty after cost
move_in_01.with_context(keep_avco_inventory=True).quantity_done = 0.0
self.print_svl(
"After force quantity to 0 in first IN move Quant:{} Cost:{}".format(
quant.quantity, quant.product_id.standard_price
)
)

# Restore to initial values
move_in_01.stock_valuation_layer_ids.unit_cost = 2.0
move_in_01.quantity_done = 10.0
self.print_svl(
"After restore initial values Quant:{} Standard Price:{}".format(
quant.quantity, quant.product_id.standard_price
)
)

def print_svl(self, char_info=""):
msg_list = ["{}".format(char_info)]
total_qty = total_value = 0.0
Expand Down

0 comments on commit 32f5cef

Please sign in to comment.