mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_quant_manual_assign: Migration to 13.0
This commit is contained in:
@@ -79,6 +79,10 @@ Contributors
|
||||
* Jordi Ballester <jordi.ballester@eficent.com>
|
||||
* Lois Rilo <lois.rilo@eficent.com>
|
||||
|
||||
* `Shine IT <https://www.openerp.cn>`_:
|
||||
|
||||
* Tony Gu <tony@openerp.cn>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -11,3 +11,7 @@
|
||||
|
||||
* Jordi Ballester <jordi.ballester@eficent.com>
|
||||
* Lois Rilo <lois.rilo@eficent.com>
|
||||
|
||||
* `Shine IT <https://www.openerp.cn>`_:
|
||||
|
||||
* Tony Gu <tony@openerp.cn>
|
||||
|
||||
@@ -9,6 +9,7 @@ class TestStockQuantManualAssign(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestStockQuantManualAssign, self).setUp()
|
||||
self.quant_model = self.env["stock.quant"]
|
||||
self.location_model = self.env["stock.location"]
|
||||
self.move_model = self.env["stock.move"]
|
||||
self.quant_assign_wizard = self.env["assign.manual.quants"]
|
||||
self.product = self.env["product.product"].create(
|
||||
@@ -16,9 +17,27 @@ class TestStockQuantManualAssign(TransactionCase):
|
||||
)
|
||||
self.location_src = self.env.ref("stock.stock_location_locations_virtual")
|
||||
self.location_dst = self.env.ref("stock.stock_location_customers")
|
||||
self.location1 = self.env.ref("stock.location_inventory")
|
||||
self.location2 = self.env.ref("stock.location_procurement")
|
||||
self.location3 = self.env.ref("stock.location_production")
|
||||
self.location1 = self.location_model.create(
|
||||
{
|
||||
"name": "Location 1",
|
||||
"usage": "internal",
|
||||
"location_id": self.location_src.id,
|
||||
}
|
||||
)
|
||||
self.location2 = self.location_model.create(
|
||||
{
|
||||
"name": "Location 2",
|
||||
"usage": "internal",
|
||||
"location_id": self.location_src.id,
|
||||
}
|
||||
)
|
||||
self.location3 = self.location_model.create(
|
||||
{
|
||||
"name": "Location 3",
|
||||
"usage": "internal",
|
||||
"location_id": self.location_src.id,
|
||||
}
|
||||
)
|
||||
self.quant1 = self.quant_model.sudo().create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
|
||||
@@ -9,14 +9,11 @@ from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tools.float_utils import float_compare
|
||||
|
||||
from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class AssignManualQuants(models.TransientModel):
|
||||
_name = "assign.manual.quants"
|
||||
_description = "Assign Manual Quants"
|
||||
|
||||
@api.multi
|
||||
@api.constrains("quants_lines")
|
||||
def _check_qty(self):
|
||||
precision_digits = self.env["decimal.precision"].precision_get(
|
||||
@@ -44,19 +41,18 @@ class AssignManualQuants(models.TransientModel):
|
||||
lines_qty = fields.Float(
|
||||
string="Reserved qty",
|
||||
compute="_compute_qties",
|
||||
digits=dp.get_precision("Product Unit of Measure"),
|
||||
digits="Product Unit of Measure",
|
||||
)
|
||||
move_qty = fields.Float(
|
||||
string="Remaining qty",
|
||||
compute="_compute_qties",
|
||||
digits=dp.get_precision("Product Unit of Measure"),
|
||||
digits="Product Unit of Measure",
|
||||
)
|
||||
quants_lines = fields.One2many(
|
||||
"assign.manual.quants.lines", "assign_wizard", string="Quants"
|
||||
)
|
||||
move_id = fields.Many2one(comodel_name="stock.move", string="Move",)
|
||||
|
||||
@api.multi
|
||||
def assign_quants(self):
|
||||
move = self.move_id
|
||||
move._do_unreserve()
|
||||
@@ -82,14 +78,15 @@ class AssignManualQuants(models.TransientModel):
|
||||
)
|
||||
quants_lines = []
|
||||
for quant in available_quants:
|
||||
line = {}
|
||||
line["quant_id"] = quant.id
|
||||
line["on_hand"] = quant.quantity
|
||||
line["location_id"] = quant.location_id.id
|
||||
line["lot_id"] = quant.lot_id.id
|
||||
line["package_id"] = quant.package_id.id
|
||||
line["owner_id"] = quant.owner_id.id
|
||||
line["selected"] = False
|
||||
line = {
|
||||
"quant_id": quant.id,
|
||||
"on_hand": quant.quantity,
|
||||
"location_id": quant.location_id.id,
|
||||
"lot_id": quant.lot_id.id,
|
||||
"package_id": quant.package_id.id,
|
||||
"owner_id": quant.owner_id.id,
|
||||
"selected": False,
|
||||
}
|
||||
move_lines = move.move_line_ids.filtered(
|
||||
lambda ml: (
|
||||
ml.location_id == quant.location_id
|
||||
@@ -120,11 +117,7 @@ class AssignManualQuantsLines(models.TransientModel):
|
||||
ondelete="cascade",
|
||||
)
|
||||
quant_id = fields.Many2one(
|
||||
comodel_name="stock.quant",
|
||||
string="Quant",
|
||||
required=True,
|
||||
ondelete="cascade",
|
||||
oldname="quant",
|
||||
comodel_name="stock.quant", string="Quant", required=True, ondelete="cascade",
|
||||
)
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="stock.location",
|
||||
@@ -152,15 +145,11 @@ class AssignManualQuantsLines(models.TransientModel):
|
||||
)
|
||||
# This is not correctly shown as related or computed, so we make it regular
|
||||
on_hand = fields.Float(
|
||||
readonly=True,
|
||||
string="On Hand",
|
||||
digits=dp.get_precision("Product Unit of Measure"),
|
||||
)
|
||||
reserved = fields.Float(
|
||||
string="Others Reserved", digits=dp.get_precision("Product Unit of Measure")
|
||||
readonly=True, string="On Hand", digits="Product Unit of Measure",
|
||||
)
|
||||
reserved = fields.Float(string="Others Reserved", digits="Product Unit of Measure")
|
||||
selected = fields.Boolean(string="Select")
|
||||
qty = fields.Float(string="QTY", digits=dp.get_precision("Product Unit of Measure"))
|
||||
qty = fields.Float(string="QTY", digits="Product Unit of Measure")
|
||||
|
||||
@api.onchange("selected")
|
||||
def _onchange_selected(self):
|
||||
@@ -177,7 +166,6 @@ class AssignManualQuantsLines(models.TransientModel):
|
||||
remaining_qty = record.assign_wizard.move_qty
|
||||
record.qty = min(quant_qty, remaining_qty)
|
||||
|
||||
@api.multi
|
||||
@api.constrains("qty")
|
||||
def _check_qty(self):
|
||||
precision_digits = self.env["decimal.precision"].precision_get(
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<act_window
|
||||
name="Manual assignment"
|
||||
res_model="assign.manual.quants"
|
||||
src_model="stock.move"
|
||||
binding_model="stock.move"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
id="assign_manual_quants_action"
|
||||
|
||||
Reference in New Issue
Block a user