Skip to content

Commit

Permalink
Release channel partner window exclusion & commitment date
Browse files Browse the repository at this point in the history
  • Loading branch information
thaolt99 committed Nov 20, 2023
1 parent 833073e commit efd44b4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
"stock_partner_delivery_window",
"stock_release_channel_shipment_lead_time",
],
"data": [],
"data": [
"views/stock_release_channel_view.xml",
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ class StockReleaseChannel(models.Model):

_inherit = "stock.release.channel"

respect_partner_delivery_time_windows = fields.Boolean(
string="Respect Partner Delivery time windows",
default=False,
help=(
"If the delivery has moves linked to SO lines linked to SO that has"
" a commitment_date, then we never respect the partner time window "
"(it is not an exclusion selection criteria anymore)"
),
)

def filter_release_channel_partner_window(self, partner):
channels = self
if (
Expand All @@ -23,6 +33,13 @@ def filter_release_channel_partner_window(self, partner):
hour=channel.process_end_date.hour,
minute=channel.process_end_date.minute,
)
if not partner.is_in_delivery_window(shipment_datetime):
if (
channel.respect_partner_delivery_time_windows
and not any(
picking.sale_id and picking.sale_id.commitment_date
for picking in channel.picking_ids
)
and not partner.is_in_delivery_window(shipment_datetime)
):
channels -= channel
return channels
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="allo_stock_release_channel_form_view" model="ir.ui.view">
<field name="name">stock.release.channel.form</field>
<field name="model">stock.release.channel</field>
<field
name="inherit_id"
ref="stock_release_channel.stock_release_channel_form_view"
/>
<field name="arch" type="xml">
<field name="rule_domain" position="after">
<field name="respect_partner_delivery_time_windows" />
</field>
</field>
</record>

</odoo>

0 comments on commit efd44b4

Please sign in to comment.