10.0 website sale - #968
Conversation
|
Please start the PR with a clean commit history (not 7 commits) |
7d2dd49 to
10e3a3f
Compare
There was a problem hiding this comment.
# now that all the pricelist_ids have their corresponding website_id and selectable
or something similar
|
Where is the analysis work file? |
f6e2164 to
e6e0550
Compare
|
Why my commit of sale_crm is here? 😵 |
|
@mreficent rebase error, fixing |
475b5df to
71ec287
Compare
|
rebased, added defaults, linted, passing. |
There was a problem hiding this comment.
pl_model.search([('id', 'not in', pricelists)]) is simpler
80fbc24 to
0241bc1
Compare
|
improved pricelist scanning and rebased again |
pedrobaeza
left a comment
There was a problem hiding this comment.
This still misses the analysis work file.
| pricelist.write({'website_id': pricelist._default_website().id}) | ||
| # now that all pricelists have a their corresponding website_id | ||
| # and selectable drop support table | ||
| sql = "drop table website_pricelist_openupgrade_10" |
There was a problem hiding this comment.
Don't drop this table, as it can be used for other modules that inherit old website.pricelist model and needs to make a migration.
| sql = """select pricelist_id, website_id, selectable from | ||
| website_pricelist_openupgrade_10""" | ||
| cr.execute(sql) | ||
| pricelists = [] |
| cr.execute(sql) | ||
| pricelists = [] | ||
| for pricelist_id, website_id, selectable in cr.fetchall(): | ||
| pl_model.search([('id', '=', pricelist_id)]).write({ |
There was a problem hiding this comment.
Don't make a search, but a browse.
There was a problem hiding this comment.
I'm thinking that this is better done with an update query:
UPDATE product_pricelist pp
SET website_id = wp.id,
selectable = wp.selectable
FROM website_pricelist_openupgrade_10 wp
WHERE wp.pricelist_id = pp.id
(and make it with openupgrade.logged_query)
There was a problem hiding this comment.
this query does not consider those pricelists that need to be set at the current default website, so anyways we are just copying the old column so we can save the first loop with the same query , but we still need the second to update all those possible pricelist ids not in the website_pricelist_openupgrade_10 column with the default website. addressed in 20c76159af016f73e7b271727ae9bba0cfb962ba waiting for checks to pass.
| for pricelist_id, website_id, selectable in cr.fetchall(): | ||
| pl_model.search([('id', '=', pricelist_id)]).write({ | ||
| 'website_id': website_id, | ||
| 'selectable': selectable |
There was a problem hiding this comment.
end comma for reducing possible future diffs.
|
@pedrobaeza used your query for the mig of the non-default pricelists. |
legacy column pricelists and assign default website to them
cd6645b to
7ae4728
Compare
| FROM website_pricelist_openupgrade_10 wp | ||
| WHERE wp.pricelist_id = pp.id | ||
| """ | ||
| cr.execute(sql) |
There was a problem hiding this comment.
This is not done with openupgrade.logged_query.
| cr.execute(sql) | ||
| pricelist_ids = cr.fetchall() | ||
| for pricelist in pl_model.search([('id', 'not in', pricelist_ids)]): | ||
| pricelist.write({'website_id': pricelist._default_website().id}) |
There was a problem hiding this comment.
Cache the default website in a previous variable for avoiding successive calls to the method.
There was a problem hiding this comment.
I did this in case the default calculation became more complex in a near future (e.g. per-pricelists default websites) , as things stand, you are right, but wouldn't you agree to sacrifice performance to increase modularity in a one-time run like a migration?
|
Hey, I'm seeing a problem with Travis: |
5046b27 to
d5a2cd6
Compare
|
ready to be merged 👍 |
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr