Compare commits
1 Commits
14.0
...
14.0-stock
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61818437b3 |
@@ -1,2 +1,3 @@
|
|||||||
from . import stock_move
|
from . import stock_move
|
||||||
|
from . import stock_picking
|
||||||
|
from . import stock_picking_type
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# @author Kévin Roche <kevin.roche@akretion.com>
|
# @author Kévin Roche <kevin.roche@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
@@ -9,28 +10,35 @@ class StockMove(models.Model):
|
|||||||
_inherit = "stock.move"
|
_inherit = "stock.move"
|
||||||
|
|
||||||
location_dest_list = fields.Text(
|
location_dest_list = fields.Text(
|
||||||
string="Locations", compute="_compute_locations_dest_list"
|
string="Dest. Locations", compute="_compute_locations_list"
|
||||||
|
)
|
||||||
|
|
||||||
|
location_src_list = fields.Text(
|
||||||
|
string="Src. Locations", compute="_compute_locations_list"
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"move_line_ids", "move_line_ids.location_dest_id", "move_line_ids.qty_done"
|
"move_line_ids.location_dest_id",
|
||||||
|
"move_line_ids.location_id",
|
||||||
|
"move_line_ids.qty_done",
|
||||||
)
|
)
|
||||||
def _compute_locations_dest_list(self):
|
def _compute_locations_list(self):
|
||||||
|
def format_loc(data):
|
||||||
|
return "\n ".join([
|
||||||
|
f"{int(qty) if qty.is_integer() else qty}: {location.name}"
|
||||||
|
for location, qty in data.items()
|
||||||
|
])
|
||||||
for move in self:
|
for move in self:
|
||||||
data = []
|
dest = defaultdict(int)
|
||||||
separator = ", "
|
src = defaultdict(int)
|
||||||
dest_list = move.move_line_ids.location_dest_id
|
for line in move.move_line_ids:
|
||||||
for dest in dest_list:
|
dest[line.location_dest_id] += line.qty_done
|
||||||
lines_qty = move.move_line_ids.search(
|
src[line.location_id] += line.qty_done
|
||||||
[("move_id", "=", move.id), ("location_dest_id", "=", dest.id)]
|
move.location_src_list = format_loc(src)
|
||||||
).mapped("qty_done")
|
move.location_dest_list = format_loc(dest)
|
||||||
quantity = int(sum(lines_qty))
|
|
||||||
location = dest.name
|
|
||||||
data.append("{}: {}".format(quantity, location))
|
|
||||||
move.location_dest_list = separator.join(data)
|
|
||||||
|
|
||||||
def _compute_is_quantity_done_editable(self):
|
def _compute_is_quantity_done_editable(self):
|
||||||
super()._compute_is_quantity_done_editable()
|
super()._compute_is_quantity_done_editable()
|
||||||
for move in self:
|
for move in self:
|
||||||
if len(move.move_line_ids) == 1 and move.show_details_visible:
|
if len(move.move_line_ids) <= 1:
|
||||||
move.is_quantity_done_editable = True
|
move.is_quantity_done_editable = True
|
||||||
|
|||||||
26
stock_reception_usability/models/stock_picking.py
Normal file
26
stock_reception_usability/models/stock_picking.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Copyright 2024 Akretion (https://www.akretion.com).
|
||||||
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
|
||||||
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class StockPicking(models.Model):
|
||||||
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
show_src_location = fields.Boolean(compute="_compute_show_location")
|
||||||
|
show_dest_location = fields.Boolean(compute="_compute_show_location")
|
||||||
|
|
||||||
|
@api.depends("picking_type_id.code", "location_id", "location_dest_id")
|
||||||
|
def _compute_show_location(self):
|
||||||
|
for picking in self:
|
||||||
|
picking.show_src_location = (
|
||||||
|
picking.picking_type_id.code != "incoming"
|
||||||
|
and picking.location_id.child_ids
|
||||||
|
)
|
||||||
|
picking.show_dest_location = (
|
||||||
|
picking.picking_type_id.code != "outgoing"
|
||||||
|
and picking.location_dest_id.child_ids
|
||||||
|
)
|
||||||
17
stock_reception_usability/models/stock_picking_type.py
Normal file
17
stock_reception_usability/models/stock_picking_type.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright 2024 Akretion (https://www.akretion.com).
|
||||||
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
|
||||||
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class StockPickingType(models.Model):
|
||||||
|
_inherit = 'stock.picking.type'
|
||||||
|
|
||||||
|
def _default_show_operations(self):
|
||||||
|
# super is not called as we want to always force the value to False
|
||||||
|
# super()._default_show_operations()
|
||||||
|
return False
|
||||||
|
|
||||||
|
show_operations = fields.Boolean(default=lambda s: s._default_show_operations())
|
||||||
@@ -4,8 +4,13 @@
|
|||||||
<field name="model">stock.picking</field>
|
<field name="model">stock.picking</field>
|
||||||
<field name="inherit_id" ref="stock.view_picking_form" />
|
<field name="inherit_id" ref="stock.view_picking_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<field name="picking_type_code" position="after">
|
||||||
|
<field name="show_src_location" invisible="1"/>
|
||||||
|
<field name="show_dest_location" invisible="1"/>
|
||||||
|
</field>
|
||||||
<xpath expr="//field[@name='product_uom']" position="after">
|
<xpath expr="//field[@name='product_uom']" position="after">
|
||||||
<field name="location_dest_list" />
|
<field name="location_src_list" attrs="{'column_invisible': [('parent.show_src_location', '=', False)]}"/>
|
||||||
|
<field name="location_dest_list" attrs="{'column_invisible': [('parent.show_dest_location', '=', False)]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='product_uom_qty']" position="attributes">
|
<xpath expr="//field[@name='product_uom_qty']" position="attributes">
|
||||||
<attribute
|
<attribute
|
||||||
|
|||||||
Reference in New Issue
Block a user