From 0fc217f504d6beffd2796cd3c350e953d8f9a00f Mon Sep 17 00:00:00 2001 From: aaron Date: Mon, 14 May 2018 11:39:18 +0200 Subject: [PATCH] [FIX]coding mistakes affecting migration --- rma/__openerp__.py | 2 +- rma/post_init_hook.py | 3 ++- rma/pre_init_hook.py | 11 ++++++----- rma_operating_unit/__init__.py | 2 +- rma_sale/models/rma_order_line.py | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/rma/__openerp__.py b/rma/__openerp__.py index 596b0d64..4b25be07 100644 --- a/rma/__openerp__.py +++ b/rma/__openerp__.py @@ -12,7 +12,7 @@ 'author': "Eficent, Odoo Community Association (OCA)", 'website': 'http://www.github.com/OCA/rma', 'depends': ['stock', 'mail', 'procurement'], - 'demo': ['demo/stock_demo.xml', + 'demo': [#'demo/stock_demo.xml', ], 'data': ['security/rma.xml', 'security/ir.model.access.csv', diff --git a/rma/post_init_hook.py b/rma/post_init_hook.py index e84915e0..72e8dc44 100644 --- a/rma/post_init_hook.py +++ b/rma/post_init_hook.py @@ -164,7 +164,8 @@ def assign_name(cr): def assign_partner(cr): cr.execute(""" update rma_order_line set partner_id = ro.partner_id - from rma_order ro inner join rma_order_line rol on rol.rma_id = ro.id + from rma_order_line rol inner join rma_order ro on rol.rma_id = ro.id + where ro.partner_id is not null """) diff --git a/rma/pre_init_hook.py b/rma/pre_init_hook.py index b32071de..886961af 100644 --- a/rma/pre_init_hook.py +++ b/rma/pre_init_hook.py @@ -119,8 +119,9 @@ def drop_indexes(cr): def pre_init_hook(cr): env = Environment(cr, SUPERUSER_ID, {}) - openupgrade.copy_columns(env.cr, column_copies) - openupgrade.rename_columns(env.cr, column_renames) - openupgrade.rename_tables(env.cr, _table_renames) - assign_status(env.cr) - set_default_values(env.cr) + if not openupgrade.table_exists(env.cr, 'rma_order'): + openupgrade.copy_columns(env.cr, column_copies) + openupgrade.rename_columns(env.cr, column_renames) + openupgrade.rename_tables(env.cr, _table_renames) + assign_status(env.cr) + set_default_values(env.cr) diff --git a/rma_operating_unit/__init__.py b/rma_operating_unit/__init__.py index b1f0ac3a..a9929091 100644 --- a/rma_operating_unit/__init__.py +++ b/rma_operating_unit/__init__.py @@ -3,4 +3,4 @@ from . import models from . import tests -from .post_init_hook import migrate +from .post_init_hook import post_init_hook diff --git a/rma_sale/models/rma_order_line.py b/rma_sale/models/rma_order_line.py index 9c617072..6de239d3 100644 --- a/rma_sale/models/rma_order_line.py +++ b/rma_sale/models/rma_order_line.py @@ -27,7 +27,8 @@ class RmaOrderLine(models.Model): @api.depends('sale_line_ids', 'sale_type', 'sales_count', 'sale_line_ids.state') def _compute_qty_sold(self): - self.qty_sold = self._get_rma_sold_qty() + for rec in self: + rec.qty_sold = rec._get_rma_sold_qty() @api.multi def _compute_sales_count(self): @@ -157,4 +158,3 @@ class RmaOrderLine(models.Model): lambda p: p.state not in ('draft', 'sent', 'cancel')): qty += sale_line.product_uom_qty return qty -