Skip to content

Commit

Permalink
[IMP] stock_release_channel_shipment_advice_deliver: Add option auto_…
Browse files Browse the repository at this point in the history
…delivery and allow to print in-process shipment advice
  • Loading branch information
tuantrantg committed Apr 2, 2024
1 parent 184f859 commit eae0e05
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class StockReleaseChannel(models.Model):
in_process_shipment_advice_ids = fields.One2many(
"shipment.advice", compute="_compute_in_process_shipment_advice_ids"
)
auto_deliver = fields.Boolean()

@api.depends("shipment_advice_ids")
def _compute_in_process_shipment_advice_ids(self):
Expand All @@ -63,6 +64,7 @@ def _compute_is_action_deliver_allowed(self):
)
and bool(rec.picking_to_plan_ids)
and rec.shipment_planning_method != "none"
and rec.auto_deliver
)

@api.depends("state")
Expand Down Expand Up @@ -291,3 +293,15 @@ def unrelease_backorders(self):
self.in_process_shipment_advice_ids.loaded_picking_ids.backorder_ids
)
backorders.unrelease(safe_unrelease=True)

@api.depends("shipment_advice_ids")
def _compute_shipment_advice_to_print_ids(self):
res = super()._compute_shipment_advice_to_print_ids()
for rec in self:
if rec.auto_deliver:
rec.shipment_advice_to_print_ids = fields.first(
rec.in_process_shipment_advice_ids.filtered(
lambda r: r.state == "done"
).sorted("id", reverse=True)
)
return res
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def setUpClass(cls):
cls.dock.warehouse_id = cls.wh
cls.warehouse2 = cls.env.ref("stock.stock_warehouse_shop0")
cls.channel.dock_id = cls.dock
cls.channel.auto_deliver = True
cls.channel.action_lock()
cls.channel.shipment_planning_method = "simple"
cls.internal_pickings = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<field name="delivering_error" />
</div>
</xpath>
<field name="release_forbidden" position="after">
<field name="auto_deliver" />
</field>
</field>
</record>
<record model="ir.ui.view" id="stock_release_channel_search_view">
Expand Down

0 comments on commit eae0e05

Please sign in to comment.