Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stock_ux/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _compute_origin_description(self):

@api.constrains("quantity")
def _check_quantity(self):
# TODO: Odoo BTL - lock for AR
precision = self.env["decimal.precision"].precision_get("Product Unit of Measure")
if any(self.filtered(lambda x: x.scrapped)):
return
Expand Down Expand Up @@ -97,6 +98,7 @@ def action_view_linked_record(self):
def default_get(self, fields_list):
# We override the default_get to make stock moves created when the picking
# was confirmed , this way restrict to add more quantity that initial demand
# TODO: Odoo BTL - lock for AR
defaults = super().default_get(fields_list)
if self.env.context.get("default_picking_id"):
picking_id = self.env["stock.picking"].browse(self.env.context["default_picking_id"])
Expand All @@ -108,6 +110,7 @@ def default_get(self, fields_list):

@api.constrains("state")
def check_cancel(self):
# TODO: Odoo BTL - lock for AR
if self._context.get("cancel_from_order") or self.env.is_superuser():
return
if self.filtered(
Expand Down Expand Up @@ -143,6 +146,7 @@ def create(self, vals_list):

@api.depends("state", "picking_id")
def _compute_is_initial_demand_editable(self):
# TODO: Odoo BTL - lock for AR
super(StockMove, self)._compute_is_initial_demand_editable()
for move in self:
if move.picking_id.picking_type_id.block_additional_quantity and move.picking_id.state != "draft":
Expand All @@ -152,6 +156,7 @@ def _trigger_assign(self):
"""To avoid to check_quantity_available when an assing in move is trigger we
send a context that checks if the assign comes from this method
"""
# TODO: Odoo BTL - lock for AR
if not self.env.context.get("trigger_assign"):
return super().with_context(trigger_assign=True)._trigger_assign()
return super()._trigger_assign()
3 changes: 3 additions & 0 deletions stock_ux/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class StockMoveLine(models.Model):

@api.depends_context("location")
def _compute_product_uom_qty_location(self):
# TODO: Odoo BTL - lock for AR
location = self._context.get("location")
if not location:
self.update({"product_uom_qty_location": 0.0})
Expand All @@ -56,6 +57,7 @@ def _compute_product_uom_qty_location(self):

@api.constrains("quantity")
def _check_manual_lines(self):
# TODO: Odoo BTL - lock for AR
if self._context.get("put_in_pack", False):
return
invalid_lines = self.filtered(
Expand Down Expand Up @@ -109,6 +111,7 @@ def create(self, vals_list):
"""This is to solve a bug when create the sml (the value is not completed after creation)
and should be reported to odoo to solve."""
recs = super().create(vals_list)
# TODO: Odoo BTL - lock for AR
for rec in recs:
if rec.picking_id and not rec.description_picking:
product = rec.product_id.with_context(lang=rec.picking_id.partner_id.lang or rec.env.user.lang)
Expand Down
7 changes: 7 additions & 0 deletions stock_ux/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def unlink(self):
To avoid errors we block deletion of pickings in other state than
draft or cancel
"""
# TODO: Odoo BTL - lock for AR
not_del_pickings = self.filtered(
lambda x: x.picking_type_id.block_picking_deletion or x.state not in ("draft", "cancel")
)
Expand All @@ -44,6 +45,7 @@ def unlink(self):
return super().unlink()

def copy(self, default=None):
# TODO: Odoo BTL - lock for AR
for picking in self:
if not default and picking.picking_type_id.block_additional_quantity:
raise UserError(
Expand All @@ -56,17 +58,20 @@ def copy(self, default=None):

@api.onchange("location_id")
def change_location(self):
# TODO: Odoo BTL - lock for AR
# we only change moves locations if picking in draft
if self.state == "draft":
self.move_ids.update({"location_id": self.location_id.id})

@api.onchange("location_dest_id")
def change_location_dest(self):
# TODO: Odoo BTL - lock for AR
# we only change moves locations if picking in draft
if self.state == "draft":
self.move_ids.update({"location_dest_id": self.location_dest_id.id})

def _send_confirmation_email(self):
# TODO: Odoo BTL - lock for AR
for rec in self:
if rec.picking_type_id.mail_template_id:
try:
Expand All @@ -90,6 +95,7 @@ def _send_confirmation_email(self):
super(StockPicking, self)._send_confirmation_email()

def _action_done(self):
# TODO: Odoo BTL - lock for AR
for rec in self.with_context(
mail_notify_force_send=False,
email_notification_force_header=True,
Expand Down Expand Up @@ -155,6 +161,7 @@ def write(self, vals):

if "picking_type_id" in vals:
user = self.env.user
# TODO: Odoo BTL - lock for AR
if user.has_group("stock_ux.group_restrict_edit_picking_type"):
for picking in self:
if picking.picking_type_id:
Expand Down
1 change: 1 addition & 0 deletions stock_ux/models/stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def _run_pull(self, procurements):
# Extract orderpoints from procurements and recompute their qty_to_order_computed
# procurement is a namedtuple:
# (product_id, product_qty, product_uom, location_id, name, origin, company_id, values)
# TODO: Odoo BTL - lock for AR
orderpoints = self.env["stock.warehouse.orderpoint"]
for procurement, rule in procurements:
# Access values dict from the namedtuple (index 7 or .values attribute)
Expand Down
2 changes: 2 additions & 0 deletions stock_ux/models/stock_warehouse_orderpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def write(self, vals):
"""When archive a replenishment rule
set min, max and multiple quantities in 0.
"""
# TODO: Odoo BTL - lock for AR
if "active" in vals and not vals["active"]:
self.write(
{
Expand Down Expand Up @@ -181,6 +182,7 @@ def update_qty_to_order(self):

def _cron_compute_rotation(self):
"""Cron method to compute the rotation of orderpoints."""
# TODO: Odoo BTL - lock for AR
orderpoints = self.with_context(active_test=False).search([])
orderpoints._compute_rotation()
return True
Loading