Skip to content

Commit

Permalink
[IMP] - rename delay field to shipment_advice_arrival_delay
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Feb 17, 2023
1 parent 87189c9 commit b98ca9d
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

{
"name": "Stock Release Channel Shipment Advice Process End Time",
"summary": """
c""",
"summary": """This module allows to set a delay time (in minutes) between the
release channel process end time and the shipment advice arrival to the dock time.
""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ class ResCompany(models.Model):

_inherit = "res.company"

release_channel_process_end_time_delay = fields.Integer()
release_channel_shipment_advice_arrival_delay = fields.Integer(
help="Global default value for the delay between the release channel process "
"end time and the arrival of shipments to the dock."
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ResConfigSettings(models.TransientModel):

_inherit = "res.config.settings"

release_channel_process_end_time_delay = fields.Integer(
related="company_id.release_channel_process_end_time_delay", readonly=False
release_channel_shipment_advice_arrival_delay = fields.Integer(
related="company_id.release_channel_shipment_advice_arrival_delay",
readonly=False,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,35 @@
class StockReleaseChannel(models.Model):

_inherit = "stock.release.channel"
process_end_time_delay = fields.Integer(
compute="_compute_process_end_time_delay", store=True, readonly=False
shipment_advice_arrival_delay = fields.Integer(
compute="_compute_shipment_advice_arrival_delay",
store=True,
readonly=False,
help="The delay between the release channel process end time and the arrival "
"of shipments to the dock.",
)

@api.depends("warehouse_id")
def _compute_process_end_time_delay(self):
def _compute_shipment_advice_arrival_delay(self):
for rec in self:
if not rec.process_end_time_delay:
rec.process_end_time_delay = (
rec.warehouse_id.release_channel_process_end_time_delay
if not rec.shipment_advice_arrival_delay:
rec.shipment_advice_arrival_delay = (
rec.warehouse_id.release_channel_shipment_advice_arrival_delay
)

def _get_process_end_time_delay(self, warehouse):
def _get_shipment_advice_arrival_delay(self, warehouse):
self.ensure_one()
if self.process_end_time_delay:
return self.process_end_time_delay
if self.shipment_advice_arrival_delay:
return self.shipment_advice_arrival_delay
if not warehouse:
return 0
if warehouse.release_channel_process_end_time_delay:
return warehouse.release_channel_process_end_time_delay
return warehouse.company_id.release_channel_process_end_time_delay
if warehouse.release_channel_shipment_advice_arrival_delay:
return warehouse.release_channel_shipment_advice_arrival_delay
return warehouse.company_id.release_channel_shipment_advice_arrival_delay

def _get_shipment_advice_arrival_date(self, warehouse):
self.ensure_one()
process_end_time_delay = self._get_process_end_time_delay(warehouse)
return self.process_end_date + timedelta(minutes=process_end_time_delay)
shipment_advice_arrival_delay = self._get_shipment_advice_arrival_delay(
warehouse
)
return self.process_end_date + timedelta(minutes=shipment_advice_arrival_delay)
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ class StockWarehouse(models.Model):

_inherit = "stock.warehouse"

release_channel_process_end_time_delay = fields.Integer(
compute="_compute_release_channel_end_time_delay", store=True, readonly=False
release_channel_shipment_advice_arrival_delay = fields.Integer(
compute="_compute_release_channel_end_time_delay",
store=True,
readonly=False,
help="Default value for the delay between the release channel process "
"end time and the arrival of shipments to docks of this warehouse.",
)

@api.depends("company_id")
def _compute_release_channel_end_time_delay(self):
for rec in self:
if not rec.release_channel_process_end_time_delay:
rec.release_channel_process_end_time_delay = (
rec.company_id.release_channel_process_end_time_delay
if not rec.release_channel_shipment_advice_arrival_delay:
rec.release_channel_shipment_advice_arrival_delay = (
rec.company_id.release_channel_shipment_advice_arrival_delay
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def test_plan_shipment_simple_delay_on_company_arrival_date(self):
- warehouse: 0mn
- channel: 0mn
"""
self.wh.company_id.release_channel_process_end_time_delay = 10
self.wh.release_channel_process_end_time_delay = 0
self.channel.process_end_time_delay = 0
self.wh.company_id.release_channel_shipment_advice_arrival_delay = 10
self.wh.release_channel_shipment_advice_arrival_delay = 0
self.channel.shipment_advice_arrival_delay = 0

self.channel.button_plan_shipments()
shipment_advice = self.channel.shipment_advice_ids
Expand All @@ -46,9 +46,9 @@ def test_plan_shipment_simple_delay_on_warehouse_arrival_date(self):
- warehouse: 20mn
- channel: 0mn
"""
self.wh.company_id.release_channel_process_end_time_delay = 10
self.wh.release_channel_process_end_time_delay = 20
self.channel.process_end_time_delay = 0
self.wh.company_id.release_channel_shipment_advice_arrival_delay = 10
self.wh.release_channel_shipment_advice_arrival_delay = 20
self.channel.shipment_advice_arrival_delay = 0

self.channel.button_plan_shipments()
shipment_advice = self.channel.shipment_advice_ids
Expand All @@ -63,9 +63,9 @@ def test_plan_shipment_simple_delay_on_channel_arrival_date(self):
- warehouse: 20mn
- channel: 30mn
"""
self.wh.company_id.release_channel_process_end_time_delay = 10
self.wh.release_channel_process_end_time_delay = 20
self.channel.process_end_time_delay = 30
self.wh.company_id.release_channel_shipment_advice_arrival_delay = 10
self.wh.release_channel_shipment_advice_arrival_delay = 20
self.channel.shipment_advice_arrival_delay = 30

self.channel.button_plan_shipments()
shipment_advice = self.channel.shipment_advice_ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
<xpath expr="//div[@id='stock_reservation']" position="inside">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="release_channel_process_end_time_delay" />
<label
for="release_channel_shipment_advice_arrival_delay"
/>
<div class="text-muted">
Delay added to release channel end time used to set
shipment advice arrival date to the dock
</div>
<div class="content-group">
<div class="mt16">
<field
name="release_channel_process_end_time_delay"
name="release_channel_shipment_advice_arrival_delay"
class="o_light_label"
/> minutes
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
<field name="model">stock.release.channel</field>
<field
name="inherit_id"
ref="stock_release_channel_process_end_time.stock_release_channel_form_view"
ref="stock_release_channel_shipment_advice.stock_release_channel_form_view"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='process_end_time']" position="after">
<label for="process_end_time_delay" />
<div>
<field name="process_end_time_delay" class="oe_inline" />
<xpath expr="//field[@name='shipment_planning_method']" position="after">
<label
for="shipment_advice_arrival_delay"
attrs="{'invisible': [('shipment_planning_method', '=', 'none')]}"
/>
<div attrs="{'invisible': [('shipment_planning_method', '=', 'none')]}">
<field name="shipment_advice_arrival_delay" class="oe_inline" />
<span>minutes</span>
</div>
</xpath>
</field>
</record>



</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<field name="inherit_id" ref="stock.view_warehouse" />
<field name="arch" type="xml">
<xpath expr="//field[@name='code']" position="after">
<label for="release_channel_process_end_time_delay" />
<label for="release_channel_shipment_advice_arrival_delay" />
<div class="o_row">
<field
name="release_channel_process_end_time_delay"
name="release_channel_shipment_advice_arrival_delay"
class="oe_inline"
/>
<span>minutes</span>
Expand Down

0 comments on commit b98ca9d

Please sign in to comment.