[MIG] stock_quant_manual_assign to v16

This commit is contained in:
Alexis de Lattre
2022-10-29 21:54:56 +02:00
committed by Maksym Yankin
parent 82e3c47723
commit c8911588f8
9 changed files with 63 additions and 63 deletions

View File

@@ -0,0 +1 @@
../../../../stock_quant_manual_assign

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@@ -14,13 +14,13 @@ Stock - Manual Quant Assignment
: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_quant_manual_assign
:target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_quant_manual_assign
: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_quant_manual_assign
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_quant_manual_assign
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/15.0
:target: https://runbot.odoo-community.org/runbot/153/16.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -47,7 +47,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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_quant_manual_assign%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_quant_manual_assign%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.
@@ -96,6 +96,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_quant_manual_assign>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_quant_manual_assign>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -7,7 +7,7 @@
{
"name": "Stock - Manual Quant Assignment",
"version": "15.0.1.2.0",
"version": "16.0.1.0.0",
"category": "Warehouse",
"license": "AGPL-3",
"author": "AvanzOSC, "

View File

@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_quant_manual_assign"><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" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_quant_manual_assign"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" 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" href="https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_quant_manual_assign"><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" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_quant_manual_assign"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to manually change the automatic quant selection.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@@ -396,7 +396,7 @@ ul.auto-toc {
<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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_quant_manual_assign%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_quant_manual_assign%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">
@@ -440,7 +440,7 @@ If you spotted it first, help us smashing 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_quant_manual_assign">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_quant_manual_assign">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>

View File

@@ -6,80 +6,82 @@ from odoo.tests.common import TransactionCase
class TestStockQuantManualAssign(TransactionCase):
def setUp(self):
super(TestStockQuantManualAssign, self).setUp()
self.quant_model = self.env["stock.quant"]
self.picking_model = self.env["stock.picking"]
self.location_model = self.env["stock.location"]
self.move_model = self.env["stock.move"]
self.quant_assign_wizard = self.env["assign.manual.quants"]
self.ModelDataObj = self.env["ir.model.data"]
self.product = self.env["product.product"].create(
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.quant_model = cls.env["stock.quant"]
cls.picking_model = cls.env["stock.picking"]
cls.location_model = cls.env["stock.location"]
cls.move_model = cls.env["stock.move"]
cls.quant_assign_wizard = cls.env["assign.manual.quants"]
cls.ModelDataObj = cls.env["ir.model.data"]
cls.product = cls.env["product.product"].create(
{"name": "Product 4 test", "type": "product"}
)
self.location_src = self.env.ref("stock.stock_location_locations_virtual")
self.location_dst = self.env.ref("stock.stock_location_customers")
self.picking_type_out = self.ModelDataObj._xmlid_to_res_id(
cls.location_src = cls.env.ref("stock.stock_location_locations_virtual")
cls.location_dst = cls.env.ref("stock.stock_location_customers")
cls.picking_type_out = cls.ModelDataObj._xmlid_to_res_id(
"stock.picking_type_out"
)
self.env["stock.picking.type"].browse(
self.picking_type_out
cls.env["stock.picking.type"].browse(
cls.picking_type_out
).reservation_method = "manual"
self.location1 = self.location_model.create(
cls.location1 = cls.location_model.create(
{
"name": "Location 1",
"usage": "internal",
"location_id": self.location_src.id,
"location_id": cls.location_src.id,
}
)
self.location2 = self.location_model.create(
cls.location2 = cls.location_model.create(
{
"name": "Location 2",
"usage": "internal",
"location_id": self.location_src.id,
"location_id": cls.location_src.id,
}
)
self.location3 = self.location_model.create(
cls.location3 = cls.location_model.create(
{
"name": "Location 3",
"usage": "internal",
"location_id": self.location_src.id,
"location_id": cls.location_src.id,
}
)
self.picking_type = self.env.ref("stock.picking_type_out")
self.quant1 = self.quant_model.sudo().create(
cls.picking_type = cls.env.ref("stock.picking_type_out")
cls.quant1 = cls.quant_model.sudo().create(
{
"product_id": self.product.id,
"product_id": cls.product.id,
"quantity": 100.0,
"location_id": self.location1.id,
"location_id": cls.location1.id,
}
)
self.quant2 = self.quant_model.sudo().create(
cls.quant2 = cls.quant_model.sudo().create(
{
"product_id": self.product.id,
"product_id": cls.product.id,
"quantity": 100.0,
"location_id": self.location2.id,
"location_id": cls.location2.id,
}
)
self.quant3 = self.quant_model.sudo().create(
cls.quant3 = cls.quant_model.sudo().create(
{
"product_id": self.product.id,
"product_id": cls.product.id,
"quantity": 100.0,
"location_id": self.location3.id,
"location_id": cls.location3.id,
}
)
self.move = self.move_model.create(
cls.move = cls.move_model.create(
{
"name": self.product.name,
"product_id": self.product.id,
"name": cls.product.name,
"product_id": cls.product.id,
"product_uom_qty": 400.0,
"product_uom": self.product.uom_id.id,
"location_id": self.location_src.id,
"location_dest_id": self.location_dst.id,
"picking_type_id": self.picking_type.id,
"product_uom": cls.product.uom_id.id,
"location_id": cls.location_src.id,
"location_dest_id": cls.location_dst.id,
"picking_type_id": cls.picking_type.id,
}
)
self.move._action_confirm()
cls.move._action_confirm()
def test_quant_assign_wizard(self):
wizard = self.quant_assign_wizard.with_context(active_id=self.move.id).create(

View File

@@ -83,8 +83,8 @@ class AssignManualQuants(models.TransientModel):
return self.env["stock.quant"].search(domain)
@api.model
def default_get(self, fields):
res = super(AssignManualQuants, self).default_get(fields)
def default_get(self, fields_list):
res = super().default_get(fields_list)
move = self.env["stock.move"].browse(self.env.context["active_id"])
available_quants = self._get_available_quants(move)
q_lines = []
@@ -137,37 +137,28 @@ class AssignManualQuantsLines(models.TransientModel):
required=True,
ondelete="cascade",
)
# Fields below are storable in order to be able to order by them. However,
# there is a side effect: It is not possible to directly read the related
# fields, e.g `self.lot_id`, because they are stored fields and have a group
# restriction, so an access error would raise. To work around it, we should
# access these fields from the quant: `self.quant_id.lot_id`.
location_id = fields.Many2one(
comodel_name="stock.location",
string="Location",
related="quant_id.location_id",
groups="stock.group_stock_multi_locations",
store=True,
)
lot_id = fields.Many2one(
comodel_name="stock.production.lot",
comodel_name="stock.lot",
string="Lot",
related="quant_id.lot_id",
groups="stock.group_production_lot",
store=True,
)
package_id = fields.Many2one(
comodel_name="stock.quant.package",
string="Package",
related="quant_id.package_id",
groups="stock.group_tracking_lot",
store=True,
)
owner_id = fields.Many2one(
comodel_name="res.partner",
string="Owner",
related="quant_id.owner_id",
groups="stock.group_tracking_owner",
store=True,
)
# This is not correctly shown as related or computed, so we make it regular

View File

@@ -7,10 +7,10 @@
<form>
<field name='quants_lines' colspan="4">
<tree editable="top" delete="0" create="0">
<field name="lot_id" />
<field name="lot_id" groups="stock.group_production_lot" />
<field name="quant_id" invisible="1" />
<field name="package_id" />
<field name="owner_id" />
<field name="package_id" groups="stock.group_tracking_lot" />
<field name="owner_id" groups="stock.group_tracking_owner" />
<field name="location_id" />
<field name="on_hand" />
<field name="reserved" />