Compare commits
6 Commits
a3dfd2bf67
...
18cc0398ce
Author | SHA1 | Date |
---|---|---|
Raimon Esteve | 18cc0398ce | |
Juanjo Garcia | 95425c4534 | |
Juanjo Garcia | b03919d23d | |
Juanjo Garcia | ce762b948f | |
Albert Cervera i Areny | 6afb7d0d0a | |
Raimon Esteve | a9befe116d |
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
|
||||
dbname = sys.argv[1]
|
||||
config_file = sys.argv[2]
|
||||
|
||||
from trytond.config import config as CONFIG
|
||||
CONFIG.update_etc(config_file)
|
||||
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.model.modelstorage import DomainValidationError
|
||||
import logging
|
||||
|
||||
Pool.start()
|
||||
pool = Pool(dbname)
|
||||
pool.init()
|
||||
|
||||
context = {}
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
ch = logging.StreamHandler(sys.stdout)
|
||||
ch.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
with Transaction().start(dbname, 0, context=context) as transaction:
|
||||
Template = pool.get('product.template')
|
||||
Company = pool.get('company.company')
|
||||
cursor = transaction.connection.cursor()
|
||||
|
||||
companys = Company.search([])
|
||||
|
||||
query = 'SELECT id FROM product_template WHERE _temp_supply_on_sale = True;'
|
||||
cursor.execute(query)
|
||||
templates = cursor.fetchall()
|
||||
|
||||
to_save = []
|
||||
for company in companys:
|
||||
for template in templates:
|
||||
query = "insert into product_template_supply_on_sale (template, company, supply_on_sale) values (%s, %s, 'always')" % (template[0], company.id)
|
||||
cursor.execute(query)
|
||||
transaction.commit()
|
|
@ -56,11 +56,16 @@ def get_property_value(field_name, company_id, default=True):
|
|||
return result.split(',')[1]
|
||||
|
||||
def account_configuration():
|
||||
user_obj = pool.get('res.user')
|
||||
user = user_obj.search([('login', '=', 'admin')], limit=1)[0]
|
||||
user_id = user.id
|
||||
|
||||
try:
|
||||
Company = pool.get('company.company')
|
||||
AccountConfiguration = pool.get('account.configuration')
|
||||
Account = pool.get('account.account')
|
||||
Sequence = pool.get('ir.sequence')
|
||||
SequenceType = pool.get('ir.sequence_type')
|
||||
except KeyError:
|
||||
return
|
||||
|
||||
|
@ -72,13 +77,10 @@ def account_configuration():
|
|||
}
|
||||
|
||||
domain=[]
|
||||
child_companies = Company.search([('parent', '!=', None)])
|
||||
if child_companies:
|
||||
domain=[('parent', '!=', None)]
|
||||
|
||||
|
||||
for company in Company.search(domain):
|
||||
user.main_company=company.id
|
||||
logger.info("company %s" % company.id)
|
||||
user.companies += (company,)
|
||||
user.company = company.id
|
||||
user.save()
|
||||
with Transaction().set_context(company=company.id):
|
||||
|
@ -106,10 +108,19 @@ def account_configuration():
|
|||
a.type.save()
|
||||
setattr(accountConfig, mapping[field], int(value))
|
||||
|
||||
asset_sequence = Sequence.search([
|
||||
('code','=', 'account.asset'), ('company', '=', company.id)])
|
||||
asset_sequence2 = Sequence.search([
|
||||
('code','=', 'account.asset'), ('company', '=', None)])
|
||||
asset_sequence_type = SequenceType.search([
|
||||
('code', '=', 'account.asset')
|
||||
], limit=1)
|
||||
|
||||
asset_sequence = None
|
||||
asset_sequence2 = None
|
||||
if asset_sequence_type:
|
||||
asset_sequence = Sequence.search([
|
||||
('sequence_type', '=', asset_sequence_type[0]),
|
||||
('company', '=', company.id)])
|
||||
asset_sequence2 = Sequence.search([
|
||||
('sequence_type', '=', asset_sequence_type[0]),
|
||||
('company', '=', None)])
|
||||
if asset_sequence:
|
||||
accountConfig.asset_sequence = asset_sequence[0]
|
||||
elif asset_sequence2:
|
||||
|
@ -119,6 +130,9 @@ def account_configuration():
|
|||
Transaction().commit()
|
||||
|
||||
def party_configuration():
|
||||
user_obj = pool.get('res.user')
|
||||
user = user_obj.search([('login', '=', 'admin')], limit=1)[0]
|
||||
user_id = user.id
|
||||
try:
|
||||
Company = pool.get('company.company')
|
||||
PartyConfiguration = pool.get('party.configuration')
|
||||
|
@ -140,6 +154,9 @@ def party_configuration():
|
|||
Transaction().commit()
|
||||
|
||||
def sale_configuration():
|
||||
user_obj = pool.get('res.user')
|
||||
user = user_obj.search([('login', '=', 'admin')], limit=1)[0]
|
||||
user_id = user.id
|
||||
mapping = {
|
||||
'sale_invoice_method': 'sale_invoice_method',
|
||||
'sale_shipment_method': 'sale_shipment_method',
|
||||
|
@ -166,6 +183,9 @@ def sale_configuration():
|
|||
|
||||
|
||||
def stock_configuration():
|
||||
user_obj = pool.get('res.user')
|
||||
user = user_obj.search([('login', '=', 'admin')], limit=1)[0]
|
||||
user_id = user.id
|
||||
try:
|
||||
Company = pool.get('company.company')
|
||||
StockConfiguration = pool.get('stock.configuration')
|
||||
|
@ -183,6 +203,9 @@ def stock_configuration():
|
|||
|
||||
|
||||
def purchase_configuration():
|
||||
user_obj = pool.get('res.user')
|
||||
user = user_obj.search([('login', '=', 'admin')], limit=1)[0]
|
||||
user_id = user.id
|
||||
try:
|
||||
Company = pool.get('company.company')
|
||||
PurchaseConfiguration = pool.get('purchase.configuration')
|
||||
|
|
|
@ -62,9 +62,6 @@ with Transaction().start(dbname, 1, context=context) as transaction:
|
|||
cursor.execute('select * from mapping_taxes')
|
||||
|
||||
domain = []
|
||||
child_companies = Company.search([('parent', '!=', None)])
|
||||
if child_companies:
|
||||
domain.append(('parent', '!=', None))
|
||||
for company in Company.search(domain):
|
||||
logger.info("company %s" % company.id)
|
||||
with Transaction().set_context(company=company.id):
|
||||
|
|
|
@ -83,17 +83,14 @@ with Transaction().start(dbname, 1, context=context):
|
|||
|
||||
Account.parent.left = None
|
||||
Account.parent.right = None
|
||||
Account._mptt_fields = set()
|
||||
|
||||
print("domain:", domain)
|
||||
if domain is None:
|
||||
print("Get childs")
|
||||
child_companies = Company.search([('parent', '!=', None)])
|
||||
if child_companies:
|
||||
domain=[('parent', '!=', None)]
|
||||
domain=[]
|
||||
|
||||
for company in Company.search(domain):
|
||||
logger.info("company %s" % company.id)
|
||||
user.main_company=company.id
|
||||
user.companies += (company,)
|
||||
user.company = company.id
|
||||
user.save()
|
||||
with Transaction().set_context(company=company.id):
|
||||
|
@ -147,7 +144,7 @@ with Transaction().start(dbname, 1, context=context):
|
|||
where = 'parent' + '=' + str(root)
|
||||
|
||||
if not root:
|
||||
where = field + 'IS NULL'
|
||||
where = 'parent IS NULL'
|
||||
|
||||
cr.execute('SELECT id FROM %s WHERE %s \
|
||||
ORDER BY %s' % ('account_account', where, 'parent'))
|
||||
|
|
10
config.yml
10
config.yml
|
@ -61,6 +61,7 @@ to_uninstall:
|
|||
- project_auto_timesheet
|
||||
- project_asterisk
|
||||
- project_current_effort
|
||||
- project_menu_tree_remove
|
||||
- project_unittest
|
||||
- project_unittest
|
||||
- product_price_list_category
|
||||
|
@ -96,6 +97,8 @@ to_uninstall:
|
|||
- account_journal_company # Deprecated at 6.4
|
||||
- sale_supply_drop_shipment_manual # Deprecated at 6.4
|
||||
- purchase_contract # Deprecated at 6.4
|
||||
- purchase_lot_cost # Deprecated at 6.4
|
||||
- product_sale_line_relation # Deprecated at 6.8
|
||||
|
||||
# TODO: Add to uninstall to upgrades to v6.4
|
||||
# - account_invoice_prevent_duplicates
|
||||
|
@ -512,6 +515,10 @@ before:
|
|||
query: DELETE from ir_cron where function in ('generate_requests', 'generate_internal_shipment');
|
||||
DELETE from ir_model_data where module = 'stock_supply' and model = 'ir.cron';
|
||||
|
||||
- comment: # Delete unused crons
|
||||
version: 5.2
|
||||
query: ALTER TABLE ir_cron DROP CONSTRAINT ir_cron_user_fkey;
|
||||
|
||||
- comment: # Delete unused crons
|
||||
version: 5.4
|
||||
fields: ir_cron.function
|
||||
|
@ -660,6 +667,7 @@ before:
|
|||
query: ALTER TABLE sale_product_customer rename column product to template;
|
||||
|
||||
- comment: ir.cron set hour 0 where is 24
|
||||
fields: ir_cron.hour
|
||||
version: 5.4
|
||||
query: UPDATE ir_cron set hour = 0 where hour = 24;
|
||||
|
||||
|
@ -752,6 +760,7 @@ before:
|
|||
|
||||
- comment: uninstall stock_update_planned_date
|
||||
version: 5.8
|
||||
fields: ir_cron.method
|
||||
query: delete from ir_cron where method like '%update_planned_date%';
|
||||
|
||||
- comment: rename ir.model.data fs_id
|
||||
|
@ -1051,6 +1060,7 @@ after:
|
|||
|
||||
- comment: replace sequence_type_lot from stock_lot_sequence to sequence_type_stock_lot from stock_lot module
|
||||
version: 5.4
|
||||
fields: ir_sequence.sequence_type
|
||||
query: update ir_sequence set sequence_type = (select db_id from ir_model_data where module = 'stock_lot' and fs_id = 'sequence_type_stock_lot') where sequence_type = (select db_id from ir_model_data where module = 'stock_lot_sequence' and fs_id = 'sequence_type_lot');
|
||||
update ir_sequence set sequence_type = (select db_id from ir_model_data where module = 'farm' and fs_id = 'sequence_type_lot') where sequence_type = (select db_id from ir_model_data where module = 'farm' and fs_id = 'sequence_type_lot');
|
||||
|
||||
|
|
Loading…
Reference in New Issue