port(14.0): env.flush_all() -> env['base'].flush() (Odoo 14 flush API)

Odoo 14 Environment has no flush_all() (added in Odoo 15+). Use the
Odoo 14 global flush via a recordset .flush(). This was raising
AttributeError mid-generation, failing ~10 tests + their downstream
"no blog.post created" assertions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Nicholas Riegel 2026-05-30 11:48:11 -04:00
parent 6635313f58
commit 8f15037c2c

View file

@ -244,7 +244,7 @@ class BlogSchedule(models.Model):
'platform_mastodon': enabled_platforms.get('mastodon', True), 'platform_mastodon': enabled_platforms.get('mastodon', True),
'platform_linkedin': enabled_platforms.get('linkedin', True), 'platform_linkedin': enabled_platforms.get('linkedin', True),
}) })
self.env.flush_all() # persist 'running' log before the API call self.env['base'].flush() # persist 'running' log before the API call
start = time.monotonic() start = time.monotonic()
blog_post = None blog_post = None
@ -323,7 +323,7 @@ class BlogSchedule(models.Model):
'error_message': error_msg, 'error_message': error_msg,
'duration_seconds': elapsed, 'duration_seconds': elapsed,
}) })
self.env.flush_all() self.env['base'].flush()
raise raise
return blog_post return blog_post