Skip to content

Commit

Permalink
[UPD] Update migration files
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Jun 18, 2014
1 parent aecd2d5 commit 5cdd22d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ point_of_sale / pos.config / company_id (many2one) : NEW r
point_of_sale / pos.config / iface_big_scrollbars (boolean): NEW
point_of_sale / pos.config / iface_invoicing (boolean) : NEW
point_of_sale / pos.config / iface_scan_via_proxy (boolean): NEW
# TODO
# TODO: Create a new picking_type_id for each active pos_config.
point_of_sale / pos.config / picking_type_id (many2one) : NEW relation: stock.picking.type
# TODO keep the pricelist_id of the old sale_shop.
# TODO: keep the pricelist_id of the old sale_shop.
point_of_sale / pos.config / pricelist_id (many2one) : NEW relation: product.pricelist, required: required, req_default: function
# TODO: [MAYBE] in v7. hardcoded value with http://localhost:8069. could be the default value.
# In v7. Value was hardcoded with http://localhost:8069. Done.
point_of_sale / pos.config / proxy_ip (char) : NEW
# [2 lines] 'receipt_footer' and 'receipt_header'. New text field. NTD.
point_of_sale / pos.config / receipt_footer (text) : NEW
point_of_sale / pos.config / receipt_header (text) : NEW
# TODO [MAYBE] deferred 8.0. Write a function that change reference from shop_id to stock_location_id and use it.
# TODO: Select the stock_location_id (internal) of the stock_warehouse of the old shop_id;
point_of_sale / pos.config / shop_id (many2one) : DEL relation: sale.shop, required: required, req_default: function
point_of_sale / pos.config / stock_location_id (many2one) : NEW relation: stock.location, required: required, req_default: function

# TODO deffered 8.0. Write a function to move field from product.product to product.template and use it.
# [10 lines] 5 fields have move from product.product to product.template. --> Done.
point_of_sale / product.product / available_in_pos (boolean) : DEL
point_of_sale / product.product / expense_pdt (boolean) : DEL
point_of_sale / product.product / income_pdt (boolean) : DEL
Expand Down
70 changes: 69 additions & 1 deletion addons/point_of_sale/migrations/8.0.1.0.1/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,75 @@

from openerp.openupgrade import openupgrade

def set_stock_location_id(cr, pool):
for pc in pc_obj.browse(cr, SUPERUSER_ID, pc_ids):
cr.execute(
"SELECT
pc.write({'proxy_ip': 'http://localhost:8069'})



def available_in_pos_field_func(cr, pool, id, vals):
logger.warning(
'available_in_pos of product.template %d has been set to True '
'whereas at least one of its product_product was False', id)
return any(vals)


def expense_pdt_field_func(cr, pool, id, vals):
logger.warning(
'expense_pdt of product.template %d has been set to True '
'whereas at least one of its product_product was False', id)
return any(vals)


def income_pdt_field_func(cr, pool, id, vals):
logger.warning(
'income_pdt of product.template %d has been set to True '
'whereas at least one of its product_product was False', id)
return any(vals)


def to_weight_field_func(cr, pool, id, vals):
logger.warning(
'to_weight of product.template %d has been set to True '
'whereas at least one of its product_product was False', id)
return any(vals)


def set_proxy_ip(cr, pool):
pc_obj = pool['pos.config']
pc_ids = pc_obj.search(cr, SUPERUSER_ID, [])
for pc in pc_obj.browse(cr, SUPERUSER_ID, pc_ids):
if pc.iface_cashdrawer or pc.iface_payment_terminal \
or pc.iface_electronic_scale or pc.iface_print_via_proxy:
pc.write({'proxy_ip': 'http://localhost:8069'})

@openupgrade.migrate()
def migrate(cr, version):
pass
pool = pooler.get_pool(cr.dbname)
get_legacy_name = openupgrade.get_legacy_name
openupgrade.move_field_many_values_to_one(
cr, pool,
'product.product', openupgrade.get_legacy_name('available_in_pos'),
'product_tmpl_id', 'product.template', 'available_in_pos',
compute_func=available_in_pos_field_func)
openupgrade.move_field_many_values_to_one(
cr, pool,
'product.product', openupgrade.get_legacy_name('expense_pdt'),
'product_tmpl_id', 'product.template', 'expense_pdt',
compute_func=expense_pdt_field_func)
openupgrade.move_field_many_values_to_one(
cr, pool, 'product.product', openupgrade.get_legacy_name('income_pdt'),
'product_tmpl_id', 'product.template', 'income_pdt',
compute_func=income_pdt_field_func)
openupgrade.move_field_many_values_to_one(
cr, pool,
'product.product', openupgrade.get_legacy_name('pos_categ_id'),
'product_tmpl_id', 'product.template', 'pos_categ_id')
openupgrade.move_field_many_values_to_one(
cr, pool, 'product.product', openupgrade.get_legacy_name('to_weight'),
'product_tmpl_id', 'product.template', 'to_weight',
compute_func=to_weight_field_func)
set_proxy_ip(cr, pool)

9 changes: 8 additions & 1 deletion addons/point_of_sale/migrations/8.0.1.0.1/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@
'pos_config': [
('shop_id', None),
],
}
'product_product': [
('available_in_pos', None),
('expense_pdt', None),
('income_pdt', None),
('pos_categ_id', None),
('to_weight', None),
],
}


@openupgrade.migrate(no_version=True)
Expand Down

0 comments on commit 5cdd22d

Please sign in to comment.