Server IP : 127.0.0.2 / Your IP : 3.144.6.159 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/l10n_mx/models/ |
Upload File : |
# coding: utf-8 # Copyright 2016 Vauxoo (https://www.vauxoo.com) <info@vauxoo.com> # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). import re from odoo import models, api, fields, _ class AccountJournal(models.Model): _inherit = 'account.journal' @api.model def _prepare_liquidity_account(self, name, company, currency_id, type): ''' When preparing the values to use when creating the default debit and credit accounts of a liquidity journal, set the correct tags for the mexican localization. ''' res = super(AccountJournal, self)._prepare_liquidity_account(name, company, currency_id, type) if company.country_id.id == self.env.ref('base.mx').id: mx_tags = self.env['account.account'].mx_search_tags(res.get('code', '')) if mx_tags: res.update({ 'tag_ids': [(6, 0, [tag.id for tag in mx_tags])] }) return res class AccountAccount(models.Model): _inherit = 'account.account' @api.model def mx_search_tags(self, code): account_tag = self.env['account.account.tag'] #search if the code is compliant with the regexp we have for tags auto-assignation re_res = re.search( '^(?P<first>[1-8][0-9][0-9])[,.]' '(?P<second>[0-9][0-9])[,.]' '(?P<third>[0-9]{2,3})$', code) if not re_res: return account_tag #get the elements of that code divided with separation declared in the regexp account = re_res.groups() return account_tag.search([ ('name', '=like', "%s.%s%%" % (account[0], account[1])), ('color', '=', 4)], limit=1) @api.onchange('code') def _onchange_code(self): if self.company_id.country_id.id == self.env.ref('base.mx').id and self.code: tags = self.mx_search_tags(self.code) self.tag_ids = tags class AccountAccountTag(models.Model): _inherit = 'account.account.tag' nature = fields.Selection([ ('D', _('Debitable Account')), ('A', _('Creditable Account'))], help='Used in Mexican report of electronic accounting (account nature).')