Skip to content

Commit f1525e7

Browse files
[MIG] product_cost_price_avco_sync: Migration to 16.0
1 parent 9779ee5 commit f1525e7

File tree

5 files changed

+37
-72
lines changed

5 files changed

+37
-72
lines changed

product_cost_price_avco_sync/README.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Product cost price avco sync
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:9eb6a763cc30fe3f2fc95c5be5d6451faa46ac5a6b45723ce306e46445fb8db1
10+
!! source digest: sha256:f07176b3a7502ceb2553fc8c5613eb3680f27cd6fa3a28d492b55a6fcee661c1
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
@@ -17,13 +17,13 @@ Product cost price avco sync
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
20-
:target: https://github.com/OCA/stock-logistics-workflow/tree/15.0/product_cost_price_avco_sync
20+
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/product_cost_price_avco_sync
2121
:alt: OCA/stock-logistics-workflow
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-15-0/stock-logistics-workflow-15-0-product_cost_price_avco_sync
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-product_cost_price_avco_sync
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=15.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -42,7 +42,7 @@ Bug Tracker
4242
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/issues>`_.
4343
In case of trouble, please check there if your issue has already been reported.
4444
If you spotted it first, help us to smash it by providing a detailed and welcomed
45-
`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**>`_.
45+
`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**>`_.
4646

4747
Do not contact contributors directly about support or help with technical issues.
4848

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

8888
|maintainer-carlosdauden| |maintainer-sergio-teruel|
8989

90-
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.
90+
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.
9191

9292
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

product_cost_price_avco_sync/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Product cost price avco sync",
66
"summary": "Set product cost price from updated moves",
7-
"version": "15.0.1.0.2",
7+
"version": "16.0.1.0.0",
88
"development_status": "Production/Stable",
99
"category": "Stock",
1010
"website": "https://github.com/OCA/stock-logistics-workflow",

product_cost_price_avco_sync/models/stock_valuation_layer.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ class ProductProduct(models.Model):
1313
_inherit = "product.product"
1414

1515
def _run_fifo_vacuum(self, company=None):
16-
if self.cost_method != "average":
17-
return super()._run_fifo_vacuum()
16+
non_average_products = self.filtered(lambda r: r.cost_method != "average")
17+
if non_average_products:
18+
return super(ProductProduct, non_average_products)._run_fifo_vacuum(
19+
company=company
20+
)
1821

1922

2023
class StockValuationLayer(models.Model):

product_cost_price_avco_sync/static/description/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ <h1 class="title">Product cost price avco sync</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:9eb6a763cc30fe3f2fc95c5be5d6451faa46ac5a6b45723ce306e46445fb8db1
370+
!! source digest: sha256:f07176b3a7502ceb2553fc8c5613eb3680f27cd6fa3a28d492b55a6fcee661c1
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<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>
372+
<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>
373373
<p>This module allows to sync cost price products with average cost method from
374374
stock moves price unit.</p>
375375
<p><strong>Table of contents</strong></p>
@@ -389,7 +389,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
389389
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues">GitHub Issues</a>.
390390
In case of trouble, please check there if your issue has already been reported.
391391
If you spotted it first, help us to smash it by providing a detailed and welcomed
392-
<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>
392+
<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>
393393
<p>Do not contact contributors directly about support or help with technical issues.</p>
394394
</div>
395395
<div class="section" id="credits">
@@ -423,7 +423,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
423423
promote its widespread use.</p>
424424
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
425425
<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>
426-
<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>
426+
<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>
427427
<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>
428428
</div>
429429
</div>

product_cost_price_avco_sync/tests/test_product_cost_price_avco_sync.py

+21-59
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from odoo.tests.common import TransactionCase, tagged
88

9+
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
10+
911
_logger = logging.getLogger(__name__)
1012

1113

@@ -14,15 +16,6 @@ class TestProductCostPriceAvcoSync(TransactionCase):
1416
@classmethod
1517
def setUpClass(cls):
1618
super(TestProductCostPriceAvcoSync, cls).setUpClass()
17-
# Remove this variable in v16 and put instead:
18-
# from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
19-
DISABLED_MAIL_CONTEXT = {
20-
"tracking_disable": True,
21-
"mail_create_nolog": True,
22-
"mail_create_nosubscribe": True,
23-
"mail_notrack": True,
24-
"no_reset_password": True,
25-
}
2619
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
2720
cls.StockPicking = cls.env["stock.picking"]
2821
cls.supplier_location = cls.env.ref("stock.stock_location_suppliers")
@@ -48,7 +41,7 @@ def setUpClass(cls):
4841
"picking_type_id": cls.picking_type_in.id,
4942
"location_id": cls.supplier_location.id,
5043
"location_dest_id": cls.stock_location.id,
51-
"move_lines": [
44+
"move_ids": [
5245
(
5346
0,
5447
0,
@@ -70,7 +63,7 @@ def setUpClass(cls):
7063
"picking_type_id": cls.picking_type_out.id,
7164
"location_id": cls.stock_location.id,
7265
"location_dest_id": cls.customer_location.id,
73-
"move_lines": [
66+
"move_ids": [
7467
(
7568
0,
7669
0,
@@ -88,7 +81,7 @@ def setUpClass(cls):
8881
)
8982

9083
def _test_sync_cost_price(self):
91-
move_in = self.picking_in.move_lines[:1]
84+
move_in = self.picking_in.move_ids[:1]
9285
move_in.product_uom_qty = 100
9386
move_in.price_unit = 5.0
9487
move_in.quantity_done = move_in.product_uom_qty
@@ -104,20 +97,20 @@ def _test_sync_cost_price(self):
10497
sleep(1)
10598

10699
picking_in_2 = self.picking_in.copy()
107-
move_in_2 = picking_in_2.move_lines[:1]
100+
move_in_2 = picking_in_2.move_ids[:1]
108101
move_in_2.product_uom_qty = 10.0
109102
move_in_2.quantity_done = move_in_2.product_uom_qty
110103
picking_in_2._action_done()
111104
move_in_2.date = "2019-10-02 00:00:00"
112105
sleep(1)
113106

114-
move_out = self.picking_out.move_lines[:1]
107+
move_out = self.picking_out.move_ids[:1]
115108
move_out.quantity_done = move_out.product_uom_qty
116109
self.picking_out._action_done()
117110
move_out.date = "2019-10-03 00:00:00"
118111

119112
picking_out_2 = self.picking_out.copy()
120-
move_out_2 = picking_out_2.move_lines[:1]
113+
move_out_2 = picking_out_2.move_ids[:1]
121114
move_out_2.quantity_done = move_out_2.product_uom_qty
122115
picking_out_2._action_done()
123116
move_out_2.date = "2019-10-04 00:00:00"
@@ -154,31 +147,31 @@ def _test_sync_cost_price(self):
154147

155148
def _test_sync_cost_price_and_history(self):
156149
company_id = self.picking_in.company_id.id
157-
move_in = self.picking_in.move_lines[:1]
150+
move_in = self.picking_in.move_ids[:1]
158151
move_in.quantity_done = move_in.product_uom_qty
159152
self.picking_in._action_done()
160153
move_in.date = "2019-10-01 00:00:00"
161154

162-
move_out = self.picking_out.move_lines[:1]
155+
move_out = self.picking_out.move_ids[:1]
163156
move_out.quantity_done = move_out.product_uom_qty
164157
self.picking_out._action_done()
165158
move_out.date = "2019-10-01 01:00:00"
166159

167160
picking_in_2 = self.picking_in.copy()
168-
move_in_2 = picking_in_2.move_lines[:1]
161+
move_in_2 = picking_in_2.move_ids[:1]
169162
move_in_2.quantity_done = move_in_2.product_uom_qty
170163
picking_in_2._action_done()
171164
move_in_2.date = "2019-10-01 02:00:00"
172165

173166
picking_out_2 = self.picking_out.copy()
174-
move_out_2 = picking_out_2.move_lines[:1]
167+
move_out_2 = picking_out_2.move_ids[:1]
175168
move_out_2.product_uom_qty = 15
176169
move_out_2.quantity_done = move_out_2.product_uom_qty
177170
picking_out_2._action_done()
178171
move_out_2.date = "2019-10-01 03:00:00"
179172

180173
picking_in_3 = self.picking_in.copy()
181-
move_in_3 = picking_in_3.move_lines[:1]
174+
move_in_3 = picking_in_3.move_ids[:1]
182175
move_in_3.quantity_done = move_in_3.product_uom_qty
183176
move_in_3.price_unit = 2.0
184177
picking_in_3._action_done()
@@ -215,13 +208,13 @@ def _test_sync_cost_price_and_history(self):
215208
self.assertEqual(svl_count, 4) # TODO: Miralo que no se si es así
216209

217210
def _test_sync_cost_price_multi_moves_done_at_same_time(self):
218-
move_in = self.picking_in.move_lines[:1]
211+
move_in = self.picking_in.move_ids[:1]
219212
move_in.product_uom_qty = 10
220213
move_in.price_unit = 10.0
221214
move_in.quantity_done = move_in.product_uom_qty
222215

223216
picking_in_2 = self.picking_in.copy()
224-
move_in_2 = picking_in_2.move_lines[:1]
217+
move_in_2 = picking_in_2.move_ids[:1]
225218
move_in_2.product_uom_qty = 10.0
226219
move_in_2.price_unit = 5.0
227220
move_in_2.quantity_done = move_in_2.product_uom_qty
@@ -245,13 +238,13 @@ def _test_sync_cost_price_multi_moves_done_at_same_time(self):
245238
def _test_change_quantiy_price(self):
246239
"""Write quantity and price to zero in a stock valuation layer"""
247240
self.picking_in.action_assign()
248-
move_in = self.picking_in.move_lines[:1]
241+
move_in = self.picking_in.move_ids[:1]
249242
self.picking_in.move_line_ids.qty_done = move_in.product_uom_qty
250243
self.picking_in._action_done()
251244

252245
picking_in_2 = self.picking_in.copy()
253246
picking_in_2.action_assign()
254-
move_in_2 = picking_in_2.move_lines[:1]
247+
move_in_2 = picking_in_2.move_ids[:1]
255248
move_in_2.product_uom_qty = 10.0
256249
move_in_2.quantity_done = move_in_2.product_uom_qty
257250
picking_in_2._action_done()
@@ -300,7 +293,7 @@ def create_picking(self, p_type="IN", qty=1.0, confirmed=True):
300293
"picking_type_id": picking_type.id,
301294
"location_id": location_id.id,
302295
"location_dest_id": location_dest_id.id,
303-
"move_lines": [
296+
"move_ids": [
304297
(
305298
0,
306299
0,
@@ -319,7 +312,7 @@ def create_picking(self, p_type="IN", qty=1.0, confirmed=True):
319312
)
320313
if confirmed:
321314
picking.action_assign()
322-
move = picking.move_lines[:1]
315+
move = picking.move_ids[:1]
323316
picking.move_line_ids.qty_done = move.product_uom_qty
324317
picking._action_done()
325318
return picking, move
@@ -455,52 +448,21 @@ def test_change_quantiy_price_xx(self):
455448
quant.quantity, quant.product_id.standard_price
456449
)
457450
)
458-
# Change qty before cost
459-
move_in_01.with_context(keep_avco_inventory=True).quantity_done = 0.0
460-
self.print_svl(
461-
"After force quantity to 0 in first IN move Quant:{} Cost:{}".format(
462-
quant.quantity, quant.product_id.standard_price
463-
)
464-
)
465-
move_in_01.stock_valuation_layer_ids.unit_cost = 0.0
466-
self.print_svl(
467-
"After force unit cost to 0 in first IN move Quant:{}".format(
468-
quant.quantity
469-
)
470-
)
471-
472-
# Restore to initial values
473-
move_in_01.with_context(keep_avco_inventory=True).quantity_done = 10.0
474-
move_in_01.stock_valuation_layer_ids.unit_cost = 2.0
475-
self.print_svl(
476-
"After restore initial values Quant:{} Standard Price:{}".format(
477-
quant.quantity, quant.product_id.standard_price
478-
)
479-
)
480-
481451
# Change cost before quantity
482452
move_in_01.stock_valuation_layer_ids.unit_cost = 0.0
483453
self.print_svl(
484454
"After force unit cost to 0 in first IN move Quant:{}".format(
485455
quant.quantity
486456
)
487457
)
488-
move_in_01.quantity_done = 0.0
458+
# Change qty after cost
459+
move_in_01.with_context(keep_avco_inventory=True).quantity_done = 0.0
489460
self.print_svl(
490461
"After force quantity to 0 in first IN move Quant:{} Cost:{}".format(
491462
quant.quantity, quant.product_id.standard_price
492463
)
493464
)
494465

495-
# Restore to initial values
496-
move_in_01.stock_valuation_layer_ids.unit_cost = 2.0
497-
move_in_01.quantity_done = 10.0
498-
self.print_svl(
499-
"After restore initial values Quant:{} Standard Price:{}".format(
500-
quant.quantity, quant.product_id.standard_price
501-
)
502-
)
503-
504466
def print_svl(self, char_info=""):
505467
msg_list = ["{}".format(char_info)]
506468
total_qty = total_value = 0.0

0 commit comments

Comments
 (0)