Skip to content

[FIX] utm: fix utm.campaign model creation#2393

Closed
dennybiasiolli wants to merge 1 commit intoOCA:13.0from
dennybiasiolli:fix-utm-models-definition
Closed

[FIX] utm: fix utm.campaign model creation#2393
dennybiasiolli wants to merge 1 commit intoOCA:13.0from
dennybiasiolli:fix-utm-models-definition

Conversation

@dennybiasiolli
Copy link

Before this fix, when trying to upgrade from Odoo 12.0 without
utm.stage table created, the creation follows a "top-down" logic,
creating utm.campaign with stage_id column referencing utm.stage
table in stage_id field default value:

    stage_id = fields.Many2one('utm.stage', string='Stage',
    ondelete='restrict', required=True,
            default=lambda self: self.env['utm.stage'].search([],
            limit=1),
                    group_expand='_group_expand_stage_ids')

This commit prevents errors like
psycopg2.errors.UndefinedTable: relation "utm_stage" does not exist

Ref #2372

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Before this fix, when trying to upgrade from Odoo 12.0 without
`utm.stage` table created, the creation follows a "top-down" logic,
creating `utm.campaign` with `stage_id` column referencing `utm.stage`
table in `stage_id` field default value:

```
    stage_id = fields.Many2one('utm.stage', string='Stage',
    ondelete='restrict', required=True,
            default=lambda self: self.env['utm.stage'].search([],
            limit=1),
                    group_expand='_group_expand_stage_ids')
```

This commit prevents errors like
`psycopg2.errors.UndefinedTable: relation "utm_stage" does not exist`
@pedrobaeza
Copy link
Member

Sorry, but we want to avoid such code diff in Odoo code, so better to continue in the other PR.

@pedrobaeza pedrobaeza closed this Aug 12, 2020
@dennybiasiolli dennybiasiolli deleted the fix-utm-models-definition branch August 12, 2020 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants