-
-
Notifications
You must be signed in to change notification settings - Fork 679
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48e9a8d
commit 85f767c
Showing
5 changed files
with
126 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<openerp> | ||
<data> | ||
<!--Changes in noupdate data--> | ||
<record id="mt_salesteam_order_sent" model="mail.message.subtype"> | ||
<field name="relation_field">team_id</field> | ||
<field name="res_model">crm.team</field> | ||
</record> | ||
<record id="mt_salesteam_order_confirmed" model="mail.message.subtype"> | ||
<field name="relation_field">team_id</field> | ||
<field name="res_model">crm.team</field> | ||
</record> | ||
</data> | ||
</openerp> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,77 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. - | ||
# © 2016 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# © 2016 Opener B.V. - Stefan Rijnhart | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
import logging | ||
from openerp import api, pooler, SUPERUSER_ID | ||
from datetime import datetime | ||
from openerp import api, SUPERUSER_ID | ||
|
||
|
||
def set_invoice_policy(cr): | ||
# used to generate the invoice, set it to 'order' which will create the invoice as per ordered quantities. | ||
openupgrade.logged_query(cr, """ | ||
UPDATE product_template | ||
SET invoice_policy = 'order' | ||
WHERE invoice_policy IS NULL; | ||
""") | ||
def set_invoice_policy(env): | ||
value = env['ir.values'].get_default('sale.order', 'order_policy') | ||
policy = 'delivery' if value == 'picking' else 'order' | ||
env['ir.values'].set_default('product.template', 'invoice_policy', policy) | ||
openupgrade.logged_query( | ||
env.cr, | ||
"""UPDATE product_template | ||
SET invoice_policy = %s | ||
WHERE invoice_policy IS NULL AND type != 'service';""", | ||
(policy,)) | ||
openupgrade.logged_query( | ||
env.cr, | ||
"""UPDATE product_template | ||
SET invoice_policy = 'order' | ||
WHERE invoice_policy IS NULL""") | ||
|
||
|
||
def set_track_service(cr): | ||
# Set all records to manual. | ||
""" Set all records to manual """ | ||
openupgrade.logged_query(cr, """ | ||
UPDATE product_template | ||
SET track_service = 'manual' | ||
WHERE track_service IS NULL; | ||
UPDATE product_template | ||
SET track_service = 'manual' | ||
WHERE track_service IS NULL; | ||
""") | ||
|
||
def map_order_state(cr): | ||
# Mapping values for state field in sale.order and sale.order.line | ||
openupgrade.map_values( | ||
cr, openupgrade.get_legacy_name('state'), 'state', | ||
[('waiting_date', 'sale'), ('progress', 'sale'), ('manual', 'sale'), ('shipping_except', 'sale'), ('invoice_except', 'sale')], | ||
table='sale_order') | ||
|
||
openupgrade.map_values( | ||
cr, openupgrade.get_legacy_name('state'), 'state', | ||
[('confirmed', 'sale'), ('exception', 'sale')], | ||
table='sale_order_line') | ||
def set_dummy_product(env): | ||
product = env['product.product'].create({ | ||
'name': 'Any product', | ||
'type': 'service', | ||
'order_policy': 'manual', | ||
}) | ||
env.cr.execute( | ||
"""UPDATE sale_order_line | ||
SET product_id = %s WHERE product_id IS NULL""", | ||
(product.id,)) | ||
|
||
|
||
def set_incoterm(env): | ||
""" Set the new Incoterm configuration option if incoterms | ||
are used at all in this database. """ | ||
env.cr.execute("SELECT incoterm FROM sale_order " | ||
"WHERE incoterm IS NOT NULL") | ||
if env.cr.fetchone(): | ||
env.ref('base.group_employee').write({ | ||
'implied_ids': [(4, env.ref('sale.group_display_incoterm').id)]}) | ||
|
||
|
||
def set_crm_team_message_types(env): | ||
""" Add two new default message types to existing subscriptions """ | ||
env['mail.followers'].search([('res_model', '=', 'crm.team')]).write( | ||
{'subtype_ids': [ | ||
(4, env.ref('sale.mt_salesteam_invoice_confirmed').id), | ||
(4, env.ref('sale.mt_salesteam_invoice_created').id)]}) | ||
|
||
def product_id_env(env): | ||
product = env['product.product'].create({'name': 'Service Product', 'type': 'service'}) | ||
env.cr.execute("""UPDATE sale_order_line SET product_id = %s WHERE product_id IS NULL""" % product.id) | ||
|
||
@openupgrade.migrate() | ||
def migrate(cr, version): | ||
pool = pooler.get_pool(cr.dbname) | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
product_id_env(env) | ||
set_invoice_policy(cr) | ||
set_dummy_product(env) | ||
set_invoice_policy(env) | ||
set_track_service(cr) | ||
map_order_state(cr) | ||
set_incoterm(env) | ||
set_crm_team_message_types(env) | ||
openupgrade.load_data( | ||
cr, 'sale', 'migrations/9.0.1.0/noupdate_changes.xml') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters