fix(jobs): guard res.partner.mobile read in delivery defaults (Odoo 19)
res.partner has no `mobile` field in this Odoo 19 build, so _fp_resolve_delivery_defaults crashed with AttributeError when a job's last shop step finished and auto-created a delivery (button_finish -> _fp_check_advance_post_shop -> _fp_create_delivery). This blocked operators from finishing the step at all. Guard the read with the codebase's 'x' in obj._fields pattern so it falls back to phone, and still picks up mobile on instances that define it. Deployed + verified on entech (restart, no -u; pure Python change). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2379,7 +2379,14 @@ class FpJob(models.Model):
|
|||||||
if 'contact_name' in Delivery._fields and ship_to.name:
|
if 'contact_name' in Delivery._fields and ship_to.name:
|
||||||
vals['contact_name'] = ship_to.name
|
vals['contact_name'] = ship_to.name
|
||||||
if 'contact_phone' in Delivery._fields:
|
if 'contact_phone' in Delivery._fields:
|
||||||
vals['contact_phone'] = ship_to.phone or ship_to.mobile or ''
|
# res.partner has no `mobile` field in this Odoo 19 build —
|
||||||
|
# guard it so the read can't AttributeError (and still picks
|
||||||
|
# up mobile on instances that do define it).
|
||||||
|
vals['contact_phone'] = (
|
||||||
|
ship_to.phone
|
||||||
|
or (ship_to.mobile if 'mobile' in ship_to._fields else '')
|
||||||
|
or ''
|
||||||
|
)
|
||||||
# Scheduled date — operator can adjust; this just primes it
|
# Scheduled date — operator can adjust; this just primes it
|
||||||
# so they're not staring at a blank field.
|
# so they're not staring at a blank field.
|
||||||
if so and so.commitment_date and 'scheduled_date' in Delivery._fields:
|
if so and so.commitment_date and 'scheduled_date' in Delivery._fields:
|
||||||
|
|||||||
Reference in New Issue
Block a user