Skip to content

Commit b3f956c

Browse files
committed
[MIG] stock_secondary_unit: Migration to 16.0
1 parent 5606970 commit b3f956c

File tree

10 files changed

+57
-40
lines changed

10 files changed

+57
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../stock_secondary_unit

setup/stock_secondary_unit/setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

stock_secondary_unit/README.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Stock Secondary Unit
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:592c2a28d87ad4487df90a96904d06388620f0305840bff125f0dbd5c0dcb91a
10+
!! source digest: sha256:223ef04b21ff22ef2ebf18865952a5de5099e9a5c643632debfcf530c7e2fea7
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
@@ -17,13 +17,13 @@ Stock Secondary Unit
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--warehouse-lightgray.png?logo=github
20-
:target: https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_secondary_unit
20+
:target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_secondary_unit
2121
:alt: OCA/stock-logistics-warehouse
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_secondary_unit
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_secondary_unit
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-warehouse&target_branch=15.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=16.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -54,7 +54,7 @@ Bug Tracker
5454
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
5555
In case of trouble, please check there if your issue has already been reported.
5656
If you spotted it first, help us to smash it by providing a detailed and welcomed
57-
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_secondary_unit%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
57+
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_secondary_unit%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5858

5959
Do not contact contributors directly about support or help with technical issues.
6060

@@ -91,6 +91,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
9191
mission is to support the collaborative development of Odoo features and
9292
promote its widespread use.
9393

94-
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_secondary_unit>`_ project on GitHub.
94+
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_secondary_unit>`_ project on GitHub.
9595

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

stock_secondary_unit/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Stock Secondary Unit",
55
"summary": "Get product quantities in a secondary unit",
6-
"version": "15.0.2.1.0",
6+
"version": "16.0.1.0.0",
77
"development_status": "Production/Stable",
88
"category": "stock",
99
"website": "https://github.com/OCA/stock-logistics-warehouse",

stock_secondary_unit/models/stock_move.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ class StockMove(models.Model):
1212
}
1313

1414
product_uom_qty = fields.Float(
15-
store=True, readonly=False, compute="_compute_product_uom_qty", copy=True
15+
store=True,
16+
readonly=False,
17+
compute="_compute_product_uom_qty",
18+
copy=True,
19+
precompute=True,
1620
)
1721

1822
@api.depends("secondary_uom_qty", "secondary_uom_id")
@@ -42,7 +46,9 @@ class StockMoveLine(models.Model):
4246
_name = "stock.move.line"
4347
_secondary_unit_fields = {"qty_field": "qty_done", "uom_field": "product_uom_id"}
4448

45-
qty_done = fields.Float(store=True, readonly=False, compute="_compute_qty_done")
49+
qty_done = fields.Float(
50+
store=True, readonly=False, compute="_compute_qty_done", precompute=True
51+
)
4652

4753
@api.model
4854
def create(self, vals):

stock_secondary_unit/static/description/index.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
23
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
34
<head>
@@ -366,9 +367,9 @@ <h1 class="title">Stock Secondary Unit</h1>
366367
!! This file is generated by oca-gen-addon-readme !!
367368
!! changes will be overwritten. !!
368369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
369-
!! source digest: sha256:592c2a28d87ad4487df90a96904d06388620f0305840bff125f0dbd5c0dcb91a
370+
!! source digest: sha256:223ef04b21ff22ef2ebf18865952a5de5099e9a5c643632debfcf530c7e2fea7
370371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
371-
<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-warehouse/tree/15.0/stock_secondary_unit"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_secondary_unit"><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-warehouse&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-warehouse/tree/16.0/stock_secondary_unit"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_secondary_unit"><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-warehouse&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372373
<p>This module extends the functionality of stock module to allow define
373374
other units with their conversion factor.</p>
374375
<p><strong>Table of contents</strong></p>
@@ -401,7 +402,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
401402
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
402403
In case of trouble, please check there if your issue has already been reported.
403404
If you spotted it first, help us to smash it by providing a detailed and welcomed
404-
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_secondary_unit%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
405+
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_secondary_unit%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
405406
<p>Do not contact contributors directly about support or help with technical issues.</p>
406407
</div>
407408
<div class="section" id="credits">
@@ -433,7 +434,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
433434
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
434435
mission is to support the collaborative development of Odoo features and
435436
promote its widespread use.</p>
436-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_secondary_unit">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
437+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_secondary_unit">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
437438
<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>
438439
</div>
439440
</div>

stock_secondary_unit/tests/test_stock_secondary_unit.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33
from odoo.tests import Form, TransactionCase, tagged
44

5+
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
6+
57

68
@tagged("-at_install", "post_install")
79
class TestProductSecondaryUnit(TransactionCase):
810
@classmethod
911
def setUpClass(cls):
1012
super().setUpClass()
11-
# Remove this variable in v16 and put instead:
12-
# from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
13-
DISABLED_MAIL_CONTEXT = {
14-
"tracking_disable": True,
15-
"mail_create_nolog": True,
16-
"mail_create_nosubscribe": True,
17-
"mail_notrack": True,
18-
"no_reset_password": True,
19-
}
2013
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
2114
# Active multiple units of measure security group for user
2215
cls.env.user.groups_id = [(4, cls.env.ref("uom.group_uom").id)]
@@ -148,10 +141,10 @@ def test_03_stock_picking_secondary_unit(self):
148141
delivery_order = StockPicking.create(do_vals)
149142
delivery_order.action_confirm()
150143
# Move is merged into 1 line for both stock.move and stock.move.line
151-
self.assertEqual(len(delivery_order.move_lines), 1)
144+
self.assertEqual(len(delivery_order.move_ids), 1)
152145
self.assertEqual(len(delivery_order.move_line_ids), 1)
153146
# Qty merged to 20, and secondary unit qty is 40line
154-
uom_qty = sum(delivery_order.move_lines.mapped("product_uom_qty"))
147+
uom_qty = sum(delivery_order.move_ids.mapped("product_uom_qty"))
155148
secondary_uom_qty = sum(
156149
delivery_order.move_line_ids.mapped("secondary_uom_qty")
157150
)
@@ -218,7 +211,7 @@ def test_secondary_unit_merge_move_diff_uom(self):
218211
move.secondary_uom_id = product.product_tmpl_id.secondary_uom_ids[1]
219212
picking = picking_form.save()
220213
picking.action_confirm()
221-
self.assertEqual(len(picking.move_lines), 2)
214+
self.assertEqual(len(picking.move_ids), 2)
222215

223216
def test_secondary_unit_merge_move_same_uom(self):
224217
product = self.product_template.product_variant_ids[0]
@@ -238,5 +231,5 @@ def test_secondary_unit_merge_move_same_uom(self):
238231
move.secondary_uom_id = product.product_tmpl_id.secondary_uom_ids[0]
239232
picking = picking_form.save()
240233
picking.action_confirm()
241-
self.assertEqual(len(picking.move_lines), 1)
242-
self.assertEqual(picking.move_lines.secondary_uom_qty, 2)
234+
self.assertEqual(len(picking.move_ids), 1)
235+
self.assertEqual(picking.move_ids.secondary_uom_qty, 2)

stock_secondary_unit/views/product_views.xml

+13-8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
<field name="name">Product template Secondary Unit</field>
77
<field name="model">product.template</field>
88
<field name="inherit_id" ref="stock.view_template_property_form" />
9-
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
109
<field name="arch" type="xml">
1110
<xpath expr="//group[@name='inventory']" position="inside">
12-
<group string="Secondary unit">
11+
<group string="Secondary unit" groups="stock.group_stock_user">
1312
<field
1413
name="stock_secondary_uom_id"
1514
options="{'no_create': True}"
@@ -24,7 +23,6 @@
2423
name="inherit_id"
2524
ref="stock.product_template_form_view_procurement_button"
2625
/>
27-
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
2826
<field name="arch" type="xml">
2927
<xpath expr="//button[@name='action_open_quants']" position="after">
3028
<button
@@ -33,6 +31,7 @@
3331
attrs="{'invisible':[('type', '!=', 'product')]}"
3432
class="oe_stat_button"
3533
icon="fa-building-o"
34+
groups="stock.group_stock_user"
3635
>
3736
<div class="o_form_field o_stat_info">
3837
<span class="o_stat_value">
@@ -53,7 +52,6 @@
5352
<record id="product_form_view_procurement_button" model="ir.ui.view">
5453
<field name="model">product.product</field>
5554
<field name="inherit_id" ref="stock.product_form_view_procurement_button" />
56-
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
5755
<field name="arch" type="xml">
5856
<xpath expr="//button[@name='action_open_quants']" position="after">
5957
<button
@@ -62,6 +60,7 @@
6260
attrs="{'invisible':[('type', '!=', 'product')]}"
6361
class="oe_stat_button"
6462
icon="fa-building-o"
63+
groups="stock.group_stock_user"
6564
>
6665
<div class="o_form_field o_stat_info">
6766
<span class="o_stat_value">
@@ -82,27 +81,33 @@
8281
<record id="product_template_tree_view" model="ir.ui.view">
8382
<field name="model">product.template</field>
8483
<field name="inherit_id" ref="product.product_template_tree_view" />
85-
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
8684
<field name="arch" type="xml">
8785
<xpath expr="//field[@name='uom_id']" position="after">
88-
<field name="secondary_unit_qty_available" />
86+
<field
87+
name="secondary_unit_qty_available"
88+
groups="stock.group_stock_user"
89+
/>
8990
<field
9091
name="stock_secondary_uom_id"
9192
options="{'no_open': True, 'no_create': True}"
93+
groups="stock.group_stock_user"
9294
/>
9395
</xpath>
9496
</field>
9597
</record>
9698
<record id="product_product_tree_view" model="ir.ui.view">
9799
<field name="model">product.product</field>
98100
<field name="inherit_id" ref="product.product_product_tree_view" />
99-
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
100101
<field name="arch" type="xml">
101102
<xpath expr="//field[@name='uom_id']" position="after">
102-
<field name="secondary_unit_qty_available" />
103+
<field
104+
name="secondary_unit_qty_available"
105+
groups="stock.group_stock_user"
106+
/>
103107
<field
104108
name="stock_secondary_uom_id"
105109
options="{'no_open': True, 'no_create': True}"
110+
groups="stock.group_stock_user"
106111
/>
107112
</xpath>
108113
</field>

stock_secondary_unit/views/stock_move_views.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<field name="name">Stock Move Secondary Unit</field>
77
<field name="model">stock.move.line</field>
88
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" />
9-
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]" />
109
<field name="arch" type="xml">
11-
<field name="product_uom_qty" position="before">
10+
<field name="reserved_uom_qty" position="before">
1211
<field
1312
name="secondary_uom_qty"
1413
attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"
1514
force_save="1"
15+
groups="uom.group_uom"
1616
/>
1717
<field
1818
name="secondary_uom_id"
@@ -21,6 +21,7 @@
2121
('product_id', '=', False)]"
2222
attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}"
2323
options="{'no_create': True}"
24+
groups="uom.group_uom"
2425
/>
2526
</field>
2627
</field>
@@ -32,13 +33,13 @@
3233
name="inherit_id"
3334
ref="stock.view_stock_move_line_detailed_operation_tree"
3435
/>
35-
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]" />
3636
<field name="arch" type="xml">
37-
<field name="product_uom_qty" position="before">
37+
<field name="reserved_uom_qty" position="before">
3838
<field
3939
name="secondary_uom_qty"
4040
attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"
4141
force_save="1"
42+
groups="uom.group_uom"
4243
/>
4344
<field
4445
name="secondary_uom_id"
@@ -47,6 +48,7 @@
4748
('product_id', '=', False)]"
4849
attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}"
4950
options="{'no_create': True}"
51+
groups="uom.group_uom"
5052
/>
5153
</field>
5254
</field>

0 commit comments

Comments
 (0)