| 1 |
|
| 2 |
from odoo import api, SUPERUSER_ID |
| 3 |
|
| 4 |
|
| 5 |
def migrate(cr, version): |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
env = api.Environment(cr, SUPERUSER_ID, {}) |
| 11 |
country = env['res.country'].search([('code', '=', 'DE')], limit=1) |
| 12 |
tags_68 = env['account.account.tag']._get_tax_tags('68', country.id) |
| 13 |
tags_60 = env['account.account.tag']._get_tax_tags('60', country.id) |
| 14 |
|
| 15 |
if tags_68.filtered(lambda tag: tag.tax_negate): |
| 16 |
cr.execute( |
| 17 |
""" |
| 18 |
UPDATE account_account_tag_account_move_line_rel |
| 19 |
SET account_account_tag_id = %s |
| 20 |
WHERE account_account_tag_id IN %s; |
| 21 |
""", |
| 22 |
[ |
| 23 |
tags_60.filtered(lambda tag: tag.tax_negate)[0].id, |
| 24 |
tuple(tags_68.filtered(lambda tag: tag.tax_negate).ids) |
| 25 |
] |
| 26 |
) |
| 27 |
|
| 28 |
if tags_68.filtered(lambda tag: not tag.tax_negate): |
| 29 |
cr.execute( |
| 30 |
""" |
| 31 |
UPDATE account_account_tag_account_move_line_rel |
| 32 |
SET account_account_tag_id = %s |
| 33 |
WHERE account_account_tag_id IN %s; |
| 34 |
""", |
| 35 |
[ |
| 36 |
tags_60.filtered(lambda tag: not tag.tax_negate)[0].id, |
| 37 |
tuple(tags_68.filtered(lambda tag: not tag.tax_negate).ids) |
| 38 |
] |
| 39 |
) |