Server IP : 127.0.0.2 / Your IP : 18.219.250.4 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/addons/stock_account/data/ |
Upload File : |
- Setting journal and property field (if needed) - !python {model: account.journal, id: False} : | #if we already have a coa installed, create journal and set property field company_obj = self.env['res.company'] company_ids = company_obj.search([('chart_template_id', '!=', False)]).ids for company_id in company_ids: from odoo.tools.translate import _ #Check if property exists for stock account journal exists PropertyObj = self.env['ir.property'] properties = PropertyObj.search([('name', '=', 'property_stock_journal'), ('company_id', '=', company_id)]) AccountJournal = self.env['account.journal'] #If not, check if you can find a journal that is already there with the same name, otherwise create one if not properties: journal_id = AccountJournal.search([('name', '=', _('Stock Journal')), ('company_id', '=', company_id), ('type', '=', 'general')], limit=1).id if not journal_id: journal_id = AccountJournal.create({ 'name': _('Stock Journal'), 'type': 'general', 'code': 'STJ', 'company_id': company_id, 'show_on_dashboard': False }).id vals = {'name': 'property_stock_journal', 'fields_id': self.env['ir.model.fields'].search([ ('name', '=', 'property_stock_journal'), ('model', '=', 'product.category'), ('relation', '=', 'account.journal')], limit=1).id, 'company_id': company_id, 'value': 'account.journal,' + str(journal_id)} PropertyObj.create(vals) todo_list = [ # Property Stock Accounts 'property_stock_account_input_categ_id', 'property_stock_account_output_categ_id', 'property_stock_valuation_account_id', ] company = company_obj.browse(company_id) for record in todo_list: account = getattr(company, record) value = account and 'account.account,' + str(account.id) or False if value: field_id = self.env['ir.model.fields'].search([ ('name', '=', record), ('model', '=', 'product.category'), ('relation', '=', 'account.account') ], limit=1).id vals = { 'name': record, 'company_id': company_id, 'fields_id': field_id, 'value': value, 'res_id': 'product.category,'+str(ref('product.product_category_all')), } properties = PropertyObj.search([('name', '=', record), ('company_id', '=', company.id), ('value_reference', '!=', False)]) if not properties: #create the property PropertyObj.create(vals)