This commit is contained in:
gsinghpal
2026-04-27 00:11:18 -04:00
parent d9f58b9851
commit f08f328688
116 changed files with 9891 additions and 359 deletions

View File

@@ -125,6 +125,7 @@ class FpReceiving(models.Model):
rec.state = 'counted'
rec.received_by_id = self.env.user
rec.received_date = fields.Datetime.now()
rec._update_so_receiving_status()
rec.message_post(body=_(
'%(user)s counted %(n)d box(es) at receiving.'
) % {'user': self.env.user.name, 'n': rec.box_count_in})
@@ -219,12 +220,28 @@ class FpReceiving(models.Model):
rec.message_post(body=_('Discrepancy resolved.'))
def _update_so_receiving_status(self):
"""Update the linked sale order's receiving status."""
"""Update the linked sale order's receiving status.
Sub 8 maps the new box-count-only states (`counted`, `staged`,
`closed`) onto the SO's `x_fc_receiving_status`:
- draft -> not_received (no rows or just-created)
- counted / staged -> partial (boxes on dock, parts not yet
racked / inspected)
- closed -> received (all boxes opened, racking done)
Legacy states (inspecting / accepted / discrepancy / resolved) keep
their original mapping for back-compat with pre-Sub-8 records.
"""
for rec in self:
if rec.sale_order_id:
if rec.state in ('accepted', 'resolved'):
rec.sale_order_id.x_fc_receiving_status = 'received'
elif rec.state == 'discrepancy':
rec.sale_order_id.x_fc_receiving_status = 'partial'
elif rec.state == 'inspecting':
rec.sale_order_id.x_fc_receiving_status = 'partial'
if not rec.sale_order_id:
continue
if rec.state == 'closed':
rec.sale_order_id.x_fc_receiving_status = 'received'
elif rec.state in ('counted', 'staged'):
rec.sale_order_id.x_fc_receiving_status = 'partial'
# Legacy states preserved.
elif rec.state in ('accepted', 'resolved'):
rec.sale_order_id.x_fc_receiving_status = 'received'
elif rec.state in ('discrepancy', 'inspecting'):
rec.sale_order_id.x_fc_receiving_status = 'partial'
elif rec.state == 'draft':
rec.sale_order_id.x_fc_receiving_status = 'not_received'