changes
This commit is contained in:
@@ -160,14 +160,14 @@ class FusionShipment(models.Model):
|
||||
vals['packing_list_attachment_id'] = (
|
||||
delivery.packing_list_attachment_id.id
|
||||
)
|
||||
# Once a tracking number exists, the parts have been picked
|
||||
# by the carrier (or are about to be) — advance the portal
|
||||
# state to 'shipped' so the customer sees their order is
|
||||
# on its way. The 'delivered' status flips when FedEx
|
||||
# tracking reports the delivery.
|
||||
if self.tracking_number and portal.state in (
|
||||
'received', 'in_progress', 'ready_to_ship',
|
||||
):
|
||||
vals['state'] = 'shipped'
|
||||
if vals:
|
||||
portal.sudo().write(vals)
|
||||
# State is now derived centrally — see
|
||||
# fusion.plating.portal.job._fp_recompute_portal_state. It
|
||||
# only promotes to 'shipped' when every linked WO is done
|
||||
# AND the shipment.status is 'shipped' or 'delivered'. A
|
||||
# FedEx label booked early (tracking number without the
|
||||
# carrier actually picking up) no longer leapfrogs the
|
||||
# shop floor.
|
||||
if hasattr(portal, '_fp_recompute_portal_state'):
|
||||
portal.sudo()._fp_recompute_portal_state()
|
||||
|
||||
@@ -15,12 +15,29 @@ class SaleOrder(models.Model):
|
||||
x_fc_receiving_count = fields.Integer(
|
||||
string='Receiving Count', compute='_compute_receiving_count',
|
||||
)
|
||||
x_fc_show_receive_parts_btn = fields.Boolean(
|
||||
string='Show Receive Parts Button',
|
||||
compute='_compute_show_receive_parts_btn',
|
||||
help='True once the SO is confirmed and there is still at least '
|
||||
'one receiving record that is not yet closed. Hidden again '
|
||||
'when every receiving record has been closed.',
|
||||
)
|
||||
|
||||
@api.depends('x_fc_receiving_ids')
|
||||
def _compute_receiving_count(self):
|
||||
for rec in self:
|
||||
rec.x_fc_receiving_count = len(rec.x_fc_receiving_ids)
|
||||
|
||||
@api.depends('state', 'x_fc_receiving_ids.state')
|
||||
def _compute_show_receive_parts_btn(self):
|
||||
for rec in self:
|
||||
if rec.state not in ('sale', 'done'):
|
||||
rec.x_fc_show_receive_parts_btn = False
|
||||
continue
|
||||
rec.x_fc_show_receive_parts_btn = any(
|
||||
r.state != 'closed' for r in rec.x_fc_receiving_ids
|
||||
)
|
||||
|
||||
def action_confirm(self):
|
||||
"""Override to auto-create receiving record on SO confirmation.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user