mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_secondary_unit: Migration to 16.0
This commit is contained in:
@@ -7,7 +7,7 @@ Stock Secondary Unit
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:592c2a28d87ad4487df90a96904d06388620f0305840bff125f0dbd5c0dcb91a
|
||||
!! source digest: sha256:223ef04b21ff22ef2ebf18865952a5de5099e9a5c643632debfcf530c7e2fea7
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
|
||||
@@ -17,13 +17,13 @@ Stock Secondary Unit
|
||||
: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--warehouse-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_secondary_unit
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_secondary_unit
|
||||
:alt: OCA/stock-logistics-warehouse
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_secondary_unit
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_secondary_unit
|
||||
: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-warehouse&target_branch=15.0
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=16.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -54,7 +54,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/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-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 <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**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
@@ -91,6 +91,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-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_secondary_unit>`_ project on GitHub.
|
||||
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.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{
|
||||
"name": "Stock Secondary Unit",
|
||||
"summary": "Get product quantities in a secondary unit",
|
||||
"version": "15.0.2.1.0",
|
||||
"version": "16.0.1.0.0",
|
||||
"development_status": "Production/Stable",
|
||||
"category": "stock",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
|
||||
@@ -12,7 +12,11 @@ class StockMove(models.Model):
|
||||
}
|
||||
|
||||
product_uom_qty = fields.Float(
|
||||
store=True, readonly=False, compute="_compute_product_uom_qty", copy=True
|
||||
store=True,
|
||||
readonly=False,
|
||||
compute="_compute_product_uom_qty",
|
||||
copy=True,
|
||||
precompute=True,
|
||||
)
|
||||
|
||||
@api.depends("secondary_uom_qty", "secondary_uom_id")
|
||||
@@ -42,7 +46,9 @@ class StockMoveLine(models.Model):
|
||||
_name = "stock.move.line"
|
||||
_secondary_unit_fields = {"qty_field": "qty_done", "uom_field": "product_uom_id"}
|
||||
|
||||
qty_done = fields.Float(store=True, readonly=False, compute="_compute_qty_done")
|
||||
qty_done = fields.Float(
|
||||
store=True, readonly=False, compute="_compute_qty_done", precompute=True
|
||||
)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
@@ -366,9 +367,9 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:592c2a28d87ad4487df90a96904d06388620f0305840bff125f0dbd5c0dcb91a
|
||||
!! source digest: sha256:223ef04b21ff22ef2ebf18865952a5de5099e9a5c643632debfcf530c7e2fea7
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<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&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-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&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 extends the functionality of stock module to allow define
|
||||
other units with their conversion factor.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
@@ -401,7 +402,7 @@ other units with their conversion factor.</p>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/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-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>
|
||||
<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>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -433,7 +434,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
<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-warehouse/tree/15.0/stock_secondary_unit">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
@@ -2,21 +2,14 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo.tests import Form, TransactionCase, tagged
|
||||
|
||||
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
|
||||
|
||||
|
||||
@tagged("-at_install", "post_install")
|
||||
class TestProductSecondaryUnit(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().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))
|
||||
# Active multiple units of measure security group for user
|
||||
cls.env.user.groups_id = [(4, cls.env.ref("uom.group_uom").id)]
|
||||
@@ -148,10 +141,10 @@ class TestProductSecondaryUnit(TransactionCase):
|
||||
delivery_order = StockPicking.create(do_vals)
|
||||
delivery_order.action_confirm()
|
||||
# Move is merged into 1 line for both stock.move and stock.move.line
|
||||
self.assertEqual(len(delivery_order.move_lines), 1)
|
||||
self.assertEqual(len(delivery_order.move_ids), 1)
|
||||
self.assertEqual(len(delivery_order.move_line_ids), 1)
|
||||
# Qty merged to 20, and secondary unit qty is 40line
|
||||
uom_qty = sum(delivery_order.move_lines.mapped("product_uom_qty"))
|
||||
uom_qty = sum(delivery_order.move_ids.mapped("product_uom_qty"))
|
||||
secondary_uom_qty = sum(
|
||||
delivery_order.move_line_ids.mapped("secondary_uom_qty")
|
||||
)
|
||||
@@ -218,7 +211,7 @@ class TestProductSecondaryUnit(TransactionCase):
|
||||
move.secondary_uom_id = product.product_tmpl_id.secondary_uom_ids[1]
|
||||
picking = picking_form.save()
|
||||
picking.action_confirm()
|
||||
self.assertEqual(len(picking.move_lines), 2)
|
||||
self.assertEqual(len(picking.move_ids), 2)
|
||||
|
||||
def test_secondary_unit_merge_move_same_uom(self):
|
||||
product = self.product_template.product_variant_ids[0]
|
||||
@@ -238,5 +231,5 @@ class TestProductSecondaryUnit(TransactionCase):
|
||||
move.secondary_uom_id = product.product_tmpl_id.secondary_uom_ids[0]
|
||||
picking = picking_form.save()
|
||||
picking.action_confirm()
|
||||
self.assertEqual(len(picking.move_lines), 1)
|
||||
self.assertEqual(picking.move_lines.secondary_uom_qty, 2)
|
||||
self.assertEqual(len(picking.move_ids), 1)
|
||||
self.assertEqual(picking.move_ids.secondary_uom_qty, 2)
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
<field name="name">Product template Secondary Unit</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="stock.view_template_property_form" />
|
||||
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='inventory']" position="inside">
|
||||
<group string="Secondary unit">
|
||||
<group string="Secondary unit" groups="stock.group_stock_user">
|
||||
<field
|
||||
name="stock_secondary_uom_id"
|
||||
options="{'no_create': True}"
|
||||
@@ -24,7 +23,6 @@
|
||||
name="inherit_id"
|
||||
ref="stock.product_template_form_view_procurement_button"
|
||||
/>
|
||||
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_open_quants']" position="after">
|
||||
<button
|
||||
@@ -33,6 +31,7 @@
|
||||
attrs="{'invisible':[('type', '!=', 'product')]}"
|
||||
class="oe_stat_button"
|
||||
icon="fa-building-o"
|
||||
groups="stock.group_stock_user"
|
||||
>
|
||||
<div class="o_form_field o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
@@ -53,7 +52,6 @@
|
||||
<record id="product_form_view_procurement_button" model="ir.ui.view">
|
||||
<field name="model">product.product</field>
|
||||
<field name="inherit_id" ref="stock.product_form_view_procurement_button" />
|
||||
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_open_quants']" position="after">
|
||||
<button
|
||||
@@ -62,6 +60,7 @@
|
||||
attrs="{'invisible':[('type', '!=', 'product')]}"
|
||||
class="oe_stat_button"
|
||||
icon="fa-building-o"
|
||||
groups="stock.group_stock_user"
|
||||
>
|
||||
<div class="o_form_field o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
@@ -82,13 +81,16 @@
|
||||
<record id="product_template_tree_view" model="ir.ui.view">
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_tree_view" />
|
||||
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='uom_id']" position="after">
|
||||
<field name="secondary_unit_qty_available" />
|
||||
<field
|
||||
name="secondary_unit_qty_available"
|
||||
groups="stock.group_stock_user"
|
||||
/>
|
||||
<field
|
||||
name="stock_secondary_uom_id"
|
||||
options="{'no_open': True, 'no_create': True}"
|
||||
groups="stock.group_stock_user"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
@@ -96,13 +98,16 @@
|
||||
<record id="product_product_tree_view" model="ir.ui.view">
|
||||
<field name="model">product.product</field>
|
||||
<field name="inherit_id" ref="product.product_product_tree_view" />
|
||||
<field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='uom_id']" position="after">
|
||||
<field name="secondary_unit_qty_available" />
|
||||
<field
|
||||
name="secondary_unit_qty_available"
|
||||
groups="stock.group_stock_user"
|
||||
/>
|
||||
<field
|
||||
name="stock_secondary_uom_id"
|
||||
options="{'no_open': True, 'no_create': True}"
|
||||
groups="stock.group_stock_user"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
<field name="name">Stock Move Secondary Unit</field>
|
||||
<field name="model">stock.move.line</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" />
|
||||
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_uom_qty" position="before">
|
||||
<field name="reserved_uom_qty" position="before">
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"
|
||||
force_save="1"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
<field
|
||||
name="secondary_uom_id"
|
||||
@@ -21,6 +21,7 @@
|
||||
('product_id', '=', False)]"
|
||||
attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}"
|
||||
options="{'no_create': True}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
@@ -32,13 +33,13 @@
|
||||
name="inherit_id"
|
||||
ref="stock.view_stock_move_line_detailed_operation_tree"
|
||||
/>
|
||||
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_uom_qty" position="before">
|
||||
<field name="reserved_uom_qty" position="before">
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"
|
||||
force_save="1"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
<field
|
||||
name="secondary_uom_id"
|
||||
@@ -47,6 +48,7 @@
|
||||
('product_id', '=', False)]"
|
||||
attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}"
|
||||
options="{'no_create': True}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<field name="name">Stock Picking Secondary Unit</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form" />
|
||||
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath
|
||||
expr="//field[@name='move_ids_without_package']/tree/field[@name='product_uom_qty']"
|
||||
@@ -15,6 +14,7 @@
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
attrs="{'column_invisible': [('parent.immediate_transfer', '=', True)], 'readonly': ['|', ('is_initial_demand_editable', '=', False), '&', '&', ('show_operations', '=', True), ('is_locked', '=', True), ('is_initial_demand_editable', '=', False)]}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
<field
|
||||
name="secondary_uom_id"
|
||||
@@ -23,6 +23,7 @@
|
||||
('product_id', '=', False)]"
|
||||
options="{'no_create': True}"
|
||||
attrs="{'column_invisible': [('parent.immediate_transfer', '=', True)], 'readonly': ['|', ('is_initial_demand_editable', '=', False), '&', '&', ('show_operations', '=', True), ('is_locked', '=', True), ('is_initial_demand_editable', '=', False)]}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath
|
||||
@@ -32,6 +33,7 @@
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
<field
|
||||
name="secondary_uom_id"
|
||||
@@ -40,6 +42,7 @@
|
||||
('product_id', '=', False)]"
|
||||
options="{'no_create': True}"
|
||||
attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user