Merge pull request #101 from tafaRU/8.0-account_move_template-migr

[ADD] [8.0] Port the module 'account_move_template' to the new API
This commit is contained in:
Lorenzo Battistini
2015-01-05 14:36:45 +01:00
18 changed files with 981 additions and 1324 deletions

View File

@@ -1,4 +0,0 @@
Davide Corio <davide.corio@agilebg.com>
Lorenzo Battistini <lorenzo.battistini@agilebg.com>
Paolo Chiara <p.chiara@isa.it>
Franco Tampieri <franco.tampieri@agilebg.com>

View File

@@ -1,123 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, orm
from openerp.tools.translate import _
import re
class account_document_template(orm.Model):
_computed_lines = {}
_current_template_id = 0
_cr = None
_uid = None
_name = 'account.document.template'
_columns = {
'name': fields.char('Name', size=64, required=True),
}
def _input_lines(self, cr, uid, template):
count = 0
for line in template.template_line_ids:
if line.type == 'input':
count += 1
return count
def _get_template_line(self, cr, uid, template_id, line_number):
for line in self.browse(cr, uid, template_id).template_line_ids:
if line.sequence == line_number:
return line
return False
def _generate_empty_lines(self, cr, uid, template_id):
lines = {}
t_lines = self.browse(cr, uid, template_id).template_line_ids
for template_line in t_lines:
lines[template_line.sequence] = None
return lines
def lines(self, line_number):
if self._computed_lines[line_number] is not None:
return self._computed_lines[line_number]
line = self._get_template_line(self._cr,
self._uid,
self._current_template_id,
line_number)
if re.match(r'L\( *' + str(line_number) + r' *\)', line.python_code):
raise orm.except_orm(
_('Error'),
_('Line %s can\'t refer to itself') % str(line_number)
)
try:
self._computed_lines[line_number] = eval(
line.python_code.replace('L', 'self.lines')
)
except KeyError:
raise orm.except_orm(
_('Error'),
_('Code "%s" refers to non existing line') % line.python_code)
return self._computed_lines[line_number]
def compute_lines(self, cr, uid, template_id, input_lines):
# input_lines: dictionary in the form {line_number: line_amount}
# returns all the lines (included input lines)
# in the form {line_number: line_amount}
template = self.browse(cr, uid, template_id)
if len(input_lines) != self._input_lines(cr, uid, template):
raise orm.except_orm(
_('Error'),
_('Inconsistency between input lines and '
'filled lines for template %s') % template.name
)
self._current_template_id = template.id
self._cr = cr
self._uid = uid
self._computed_lines = self._generate_empty_lines(cr, uid, template_id)
self._computed_lines.update(input_lines)
for line_number in self._computed_lines:
self.lines(line_number)
return self._computed_lines
def check_zero_lines(self, cr, uid, wizard):
if not wizard.line_ids:
return True
for template_line in wizard.line_ids:
if template_line.amount:
return True
return False
class account_document_template_line(orm.Model):
_name = 'account.document.template.line'
_columns = {
'name': fields.char('Name', size=64, required=True),
'sequence': fields.integer('Sequence', required=True),
'type': fields.selection(
[('computed', 'Computed'), ('input', 'User input')],
'Type',
required=True
),
'python_code': fields.text('Python Code'),
}

View File

@@ -1,119 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, orm
class account_move_template(orm.Model):
_inherit = 'account.document.template'
_name = 'account.move.template'
_columns = {
'company_id': fields.many2one(
'res.company',
'Company',
required=True,
change_default=True
),
'template_line_ids': fields.one2many(
'account.move.template.line',
'template_id',
'Template Lines'
),
'cross_journals': fields.boolean('Cross-Journals'),
'transitory_acc_id': fields.many2one(
'account.account',
'Transitory account',
required=False
),
}
def _get_default(self, cr, uid, context=None):
self.pool.get('res.company')._company_default_get(
cr, uid, 'account.move.template', context=context
)
_defaults = {
'company_id': _get_default
}
def _check_different_journal(self, cr, uid, ids, context=None):
# Check that the journal on these lines are different/same in the case
# of cross journals/single journal
journal_ids = []
all_journal_ids = []
move_template = self.pool.get('account.move.template').browse(
cr, uid, ids)[0]
if not move_template.template_line_ids:
return True
for template_line in move_template.template_line_ids:
all_journal_ids.append(template_line.journal_id.id)
if template_line.journal_id.id not in journal_ids:
journal_ids.append(template_line.journal_id.id)
if move_template.cross_journals:
return len(all_journal_ids) == len(journal_ids)
else:
return len(journal_ids) == 1
_constraints = [
(_check_different_journal,
'If the template is "cross-journals", the Journals must be different,'
'if the template does not "cross-journals" '
'the Journals must be the same!',
['journal_id'])
]
class account_move_template_line(orm.Model):
_name = 'account.move.template.line'
_inherit = 'account.document.template.line'
_columns = {
'journal_id': fields.many2one(
'account.journal',
'Journal',
required=True
),
'account_id': fields.many2one(
'account.account',
'Account',
required=True,
ondelete="cascade"
),
'move_line_type': fields.selection(
[('cr', 'Credit'),
('dr', 'Debit')],
'Move Line Type',
required=True
),
'analytic_account_id': fields.many2one(
'account.analytic.account',
'Analytic Account',
ondelete="cascade"
),
'template_id': fields.many2one('account.move.template', 'Template'),
'account_tax_id': fields.many2one('account.tax', 'Tax'),
}
_sql_constraints = [
('sequence_template_uniq', 'unique (template_id,sequence)',
'The sequence of the line must be unique per template !')
]

View File

@@ -1,316 +0,0 @@
# Brazilian Portuguese translation for account-financial-tools
# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014
# This file is distributed under the same license as the account-financial-tools package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: account-financial-tools\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2013-10-18 17:49+0000\n"
"PO-Revision-Date: 2014-01-10 11:33+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Brazilian Portuguese <pt_BR@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-12 06:31+0000\n"
"X-Generator: Launchpad (build 17041)\n"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:68
#, python-format
msgid "Code \"%s\" refers to non existing line"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,move_line_type:0
#: field:wizard.select.move.template.line,move_line_type:0
msgid "Move Line Type"
msgstr ""
#. module: account_move_template
#: selection:wizard.select.move.template,state:0
msgid "Template selected"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:0
#: field:wizard.select.move.template,template_id:0
msgid "Move Template"
msgstr ""
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template
msgid "Select Move Template"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_wizard_select_move_template
msgid "wizard.select.move.template"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Next"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template,state:0
msgid "State"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:150
#: code:addons/account_move_template/wizard/select_template.py:180
#, python-format
msgid "You have to define an analytic journal on the '%s' journal!"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,template_id:0
#: field:wizard.select.move.template.line,template_id:0
msgid "Template"
msgstr ""
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Debit"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:106
#, python-format
msgid "No period found !"
msgstr ""
#. module: account_move_template
#: field:account.document.template.line,type:0
#: field:account.move.template.line,type:0
msgid "Type"
msgstr ""
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template_by_move
#: model:ir.ui.menu,name:account_move_template.menu_action_wizard_select_template
msgid "Create Move from Template"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:98
#, python-format
msgid "Error !"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:106
#, python-format
msgid "Unable to find a valid period !"
msgstr ""
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_move_template_form
#: model:ir.ui.menu,name:account_move_template.menu_action_move_template_form
msgid "Move Templates"
msgstr ""
#. module: account_move_template
#: field:account.move.template,company_id:0
msgid "Company"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template.line:0
msgid "Move Template Line"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_move_template
msgid "account.move.template"
msgstr ""
#. module: account_move_template
#: field:account.move.template,transitory_acc_id:0
msgid "Transitory account"
msgstr ""
#. module: account_move_template
#: constraint:account.move.template:0
msgid ""
"If the template is \"cross-journals\", the Journals must be different,if the "
"template does not \"cross-journals\" the Journals must be the same!"
msgstr ""
#. module: account_move_template
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "User input"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,account_id:0
#: field:wizard.select.move.template.line,account_id:0
msgid "Account"
msgstr ""
#. module: account_move_template
#: field:account.document.template,name:0
#: field:account.document.template.line,name:0
#: field:account.move.template,name:0
#: field:account.move.template.line,name:0
#: field:wizard.select.move.template.line,name:0
msgid "Name"
msgstr ""
#. module: account_move_template
#: field:account.move.template,cross_journals:0
msgid "Cross-Journals"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template,line_ids:0
msgid "Lines"
msgstr ""
#. module: account_move_template
#: view:account.move.template.line:0
msgid "Journal Entry Template Line"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_move_template_line
msgid "account.move.template.line"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:98
#, python-format
msgid "At least one amount has to be non-zero!"
msgstr ""
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Credit"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template.line,amount:0
msgid "Amount"
msgstr ""
#. module: account_move_template
#: view:account.move.template:0
msgid "Journal Entry Template"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:62
#: code:addons/account_move_template/account_document_template.py:67
#: code:addons/account_move_template/account_document_template.py:76
#, python-format
msgid "Error"
msgstr ""
#. module: account_move_template
#: sql_constraint:account.move.template.line:0
msgid "The sequence of the line must be unique per template !"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Load"
msgstr ""
#. module: account_move_template
#: view:account.move.template.line:0
msgid ""
"You can refer to other lines using their sequence number (e.g. 'L(1)' for "
"first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + "
"L(3)'; '1250'"
msgstr ""
#. module: account_move_template
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "Computed"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:149
#: code:addons/account_move_template/wizard/select_template.py:179
#, python-format
msgid "No Analytic Journal !"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_document_template_line
msgid "account.document.template.line"
msgstr ""
#. module: account_move_template
#: field:account.document.template.line,python_code:0
#: view:account.move.template.line:0
#: field:account.move.template.line,python_code:0
msgid "Python Code"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:77
#, python-format
msgid "Inconsistency between input lines and filled lines for template %s"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,account_tax_id:0
msgid "Tax"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template.line,sequence:0
msgid "Number"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,analytic_account_id:0
msgid "Analytic Account"
msgstr ""
#. module: account_move_template
#: field:account.document.template.line,sequence:0
#: field:account.move.template.line,sequence:0
msgid "Sequence"
msgstr ""
#. module: account_move_template
#: field:account.move.template,template_line_ids:0
#: model:ir.model,name:account_move_template.model_wizard_select_move_template_line
msgid "Template Lines"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Cancel"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template,partner_id:0
msgid "Partner"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_document_template
msgid "account.document.template"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,journal_id:0
msgid "Journal"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:63
#, python-format
msgid "Line %s can't refer to itself"
msgstr ""

View File

@@ -1,270 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, orm
import time
from openerp.tools.translate import _
class wizard_select_template(orm.TransientModel):
_name = "wizard.select.move.template"
_columns = {
'template_id': fields.many2one(
'account.move.template',
'Move Template',
required=True
),
'partner_id': fields.many2one('res.partner', 'Partner'),
'line_ids': fields.one2many(
'wizard.select.move.template.line',
'template_id',
'Lines'
),
'state': fields.selection(
[
('template_selected', 'Template selected'),
],
'State'
),
}
def on_change_template_id(self, cr, uid, ids, template_id):
res = {}
if template_id:
res['value'] = {'line_ids': []}
template_pool = self.pool.get('account.move.template')
template = template_pool.browse(cr, uid, template_id)
for line in template.template_line_ids:
if line.type == 'input':
res['value']['line_ids'].append({
'sequence': line.sequence,
'name': line.name,
'account_id': line.account_id.id,
'move_line_type': line.move_line_type,
})
return res
def load_lines(self, cr, uid, ids, context=None):
wizard = self.browse(cr, uid, ids, context=context)[0]
template_pool = self.pool.get('account.move.template')
wizard_line_pool = self.pool.get('wizard.select.move.template.line')
model_data_obj = self.pool.get('ir.model.data')
template = template_pool.browse(cr, uid, wizard.template_id.id)
for line in template.template_line_ids:
if line.type == 'input':
wizard_line_pool.create(cr, uid, {
'template_id': wizard.id,
'sequence': line.sequence,
'name': line.name,
'amount': 0.0,
'account_id': line.account_id.id,
'move_line_type': line.move_line_type,
})
if not wizard.line_ids:
return self.load_template(cr, uid, ids)
wizard.write({'state': 'template_selected'})
view_rec = model_data_obj.get_object_reference(
cr, uid, 'account_move_template', 'wizard_select_template')
view_id = view_rec and view_rec[1] or False
return {
'view_type': 'form',
'view_id': [view_id],
'view_mode': 'form',
'res_model': 'wizard.select.move.template',
'res_id': wizard.id,
'type': 'ir.actions.act_window',
'target': 'new',
'context': context,
}
def load_template(self, cr, uid, ids, context=None):
template_obj = self.pool.get('account.move.template')
account_period_obj = self.pool.get('account.period')
wizard = self.browse(cr, uid, ids, context=context)[0]
if not template_obj.check_zero_lines(cr, uid, wizard):
raise orm.except_orm(
_('Error !'),
_('At least one amount has to be non-zero!')
)
input_lines = {}
for template_line in wizard.line_ids:
input_lines[template_line.sequence] = template_line.amount
period_id = account_period_obj.find(cr, uid, context=context)
if not period_id:
raise orm.except_orm(
_('No period found !'),
_('Unable to find a valid period !')
)
period_id = period_id[0]
computed_lines = template_obj.compute_lines(
cr, uid, wizard.template_id.id, input_lines)
moves = {}
for line in wizard.template_id.template_line_ids:
if line.journal_id.id not in moves:
moves[line.journal_id.id] = self._make_move(
cr, uid,
wizard.template_id.name,
period_id,
line.journal_id.id,
wizard.partner_id.id
)
self._make_move_line(
cr, uid,
line,
computed_lines,
moves[line.journal_id.id],
period_id,
wizard.partner_id.id
)
if wizard.template_id.cross_journals:
trans_account_id = wizard.template_id.transitory_acc_id.id
self._make_transitory_move_line(
cr,
uid,
line,
computed_lines,
moves[line.journal_id.id],
period_id,
trans_account_id,
wizard.partner_id.id
)
return {
'domain': "[('id','in', " + str(moves.values()) + ")]",
'name': 'Entries',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move',
'type': 'ir.actions.act_window',
'target': 'current',
}
def _make_move(self, cr, uid, ref, period_id, journal_id, partner_id):
account_move_obj = self.pool.get('account.move')
move_id = account_move_obj.create(cr, uid, {
'ref': ref,
'period_id': period_id,
'journal_id': journal_id,
'partner_id': partner_id,
})
return move_id
def _make_move_line(self, cr, uid, line, computed_lines,
move_id, period_id, partner_id):
account_move_line_obj = self.pool.get('account.move.line')
analytic_account_id = False
if line.analytic_account_id:
if not line.journal_id.analytic_journal_id:
raise orm.except_orm(
_('No Analytic Journal !'),
_("You have to define an analytic "
"journal on the '%s' journal!")
% (line.journal_id.name,)
)
analytic_account_id = line.analytic_account_id.id
val = {
'name': line.name,
'move_id': move_id,
'journal_id': line.journal_id.id,
'period_id': period_id,
'analytic_account_id': analytic_account_id,
'account_id': line.account_id.id,
'date': time.strftime('%Y-%m-%d'),
'account_tax_id': line.account_tax_id.id,
'credit': 0.0,
'debit': 0.0,
'partner_id': partner_id,
}
if line.move_line_type == 'cr':
val['credit'] = computed_lines[line.sequence]
if line.move_line_type == 'dr':
val['debit'] = computed_lines[line.sequence]
id_line = account_move_line_obj.create(cr, uid, val)
return id_line
def _make_transitory_move_line(self, cr, uid, line,
computed_lines, move_id, period_id,
trans_account_id, partner_id):
account_move_line_obj = self.pool.get('account.move.line')
analytic_account_id = False
if line.analytic_account_id:
if not line.journal_id.analytic_journal_id:
raise orm.except_orm(
_('No Analytic Journal !'),
_("You have to define an analytic journal "
"on the '%s' journal!")
% (line.template_id.journal_id.name,)
)
analytic_account_id = line.analytic_account_id.id
val = {
'name': 'transitory',
'move_id': move_id,
'journal_id': line.journal_id.id,
'period_id': period_id,
'analytic_account_id': analytic_account_id,
'account_id': trans_account_id,
'date': time.strftime('%Y-%m-%d'),
'partner_id': partner_id,
}
if line.move_line_type != 'cr':
val['credit'] = computed_lines[line.sequence]
if line.move_line_type != 'dr':
val['debit'] = computed_lines[line.sequence]
id_line = account_move_line_obj.create(cr, uid, val)
return id_line
class wizard_select_template_line(orm.TransientModel):
_description = 'Template Lines'
_name = "wizard.select.move.template.line"
_columns = {
'template_id': fields.many2one('wizard.select.move.template',
'Template'),
'sequence': fields.integer('Number', required=True),
'name': fields.char('Name', size=64, required=True, readonly=True),
'account_id': fields.many2one(
'account.account',
'Account',
required=True,
readonly=True
),
'move_line_type': fields.selection(
[('cr', 'Credit'),
('dr', 'Debit')],
'Move Line Type',
required=True,
readonly=True
),
'amount': fields.float('Amount', required=True),
}

View File

@@ -0,0 +1,29 @@
Account Move Template - Templates for Journal Entries
=====================================================
The user can configure journal entries templates, useful for recurring entries.
The amount of each template line can be computed (through python code)
or kept as user input.
If user input, when using the template, user has to fill
the amount of every input lines.
The journal entry form allows lo load, through a wizard,
the template to use and the amounts to fill.
Credits
-------
Authors:
~~~~~~~~
* Davide Corio <davide.corio@agilebg.com>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Paolo Chiara <p.chiara@isa.it>
* Franco Tampieri <franco.tampieri@agilebg.com>
Contributors:
~~~~~~~~~~~~~
* Alex Comba <alex.comba@agilebg.com> (Port to V8)
* Guewen Baconnier <guewen.baconnier@camptocamp.com>

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2011 - 2014 Agile Business Group sagl
# (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify

View File

@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2011 - 2014 Agile Business Group sagl
# (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
@@ -20,36 +21,21 @@
##############################################################################
{
'name': "Account Move Template",
'version': '0.1',
'version': '1.0',
'category': 'Generic Modules/Accounting',
'summary': "Templates for recurring Journal Entries",
'description': """
Templates for Journal Entries
User can configure journal entries templates, useful for recurring entries.
The amount of each template line can be computed (through python code)
or kept as user input.
If user input, when using the template, user has to fill
the amount of every input lines.
The journal entry form allows lo load, through a wizard,
the template to use and the amounts to fill.
""",
'author': 'Agile Business Group',
'website': 'http://www.agilebg.com',
'license': 'AGPL-3',
'depends': ['account_accountant', 'analytic'],
'data': [
'move_template.xml',
'wizard/select_template.xml',
'security/ir.model.access.csv',
'view/move_template.xml',
'wizard/select_template.xml',
],
'test': [
'test/generate_move.yml',
],
'active': False,
'installable': False,
'installable': True,
}

View File

@@ -0,0 +1,106 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 - 2014 Agile Business Group sagl
# (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, exceptions, _
from openerp.tools.safe_eval import safe_eval as eval
from functools import partial
import re
class AccountDocumentTemplate(models.Model):
_name = 'account.document.template'
name = fields.Char(required=True)
@api.multi
def _input_lines(self):
count = 0
for line in self.template_line_ids:
if line.type == 'input':
count += 1
return count
@api.multi
def _get_template_line(self, line_number):
for line in self.template_line_ids:
if line.sequence == line_number:
return line
return False
@api.multi
def _generate_empty_lines(self):
lines = {}
for line in self.template_line_ids:
lines[line.sequence] = None
return lines
@api.multi
def lines(self, line_number, computed_lines=None):
if computed_lines is None:
computed_lines = {}
if computed_lines[line_number] is not None:
return computed_lines[line_number]
line = self._get_template_line(line_number)
if re.match(r'L\( *' + str(line_number) + r' *\)', line.python_code):
raise exceptions.Warning(
_('Line %s can\'t refer to itself') % str(line_number)
)
try:
recurse_lines = partial(self.lines, computed_lines=computed_lines)
computed_lines[line_number] = eval(
line.python_code.replace('L', 'recurse_lines'),
locals_dict={'recurse_lines': recurse_lines}
)
except KeyError:
raise exceptions.Warning(
_('Code "%s" refers to non existing line') % line.python_code)
return computed_lines[line_number]
@api.multi
def compute_lines(self, input_lines):
# input_lines: dictionary in the form {line_number: line_amount}
# returns all the lines (included input lines)
# in the form {line_number: line_amount}
if len(input_lines) != self._input_lines():
raise exceptions.Warning(
_('Inconsistency between input lines and '
'filled lines for template %s') % self.name
)
computed_lines = self._generate_empty_lines()
computed_lines.update(input_lines)
for line_number in computed_lines:
computed_lines[line_number] = self.lines(
line_number, computed_lines)
return computed_lines
class AccountDocumentTemplateLine(models.Model):
_name = 'account.document.template.line'
name = fields.Char(required=True)
sequence = fields.Integer(string='Sequence', required=True)
type = fields.Selection(
[('computed', 'Computed'), ('input', 'User input')],
string='Type',
required=True
)
python_code = fields.Text(string='Python Code')

View File

@@ -0,0 +1,117 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 - 2014 Agile Business Group sagl
# (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
from openerp.exceptions import ValidationError
class AccountMoveTemplate(models.Model):
_name = 'account.move.template'
_inherit = 'account.document.template'
@api.model
def _company_get(self):
return self.env['res.company']._company_default_get(
object='account.move.template'
)
company_id = fields.Many2one(
comodel_name='res.company',
string='Company',
required=True,
change_default=True,
default=_company_get,
)
template_line_ids = fields.One2many(
comodel_name='account.move.template.line',
inverse_name='template_id',
string='Template Lines'
)
cross_journals = fields.Boolean(string='Cross-Journals')
transitory_acc_id = fields.Many2one(
comodel_name='account.account',
string='Transitory account',
required=False
)
@api.constrains('journal_id')
def _check_different_journal(self):
# Check that the journal on these lines are different/same in the case
# of cross journals/single journal
journal_ids = []
all_journal_ids = []
error_message = (
u'If the template is "cross-journals", the Journals must be '
u'different, if the template does not "cross-journals" the '
u'Journals must be the same!'
)
for move_template in self:
if move_template.template_line_ids:
for template_line in move_template.template_line_ids:
all_journal_ids.append(template_line.journal_id.id)
if template_line.journal_id.id not in journal_ids:
journal_ids.append(template_line.journal_id.id)
if move_template.cross_journals:
if len(all_journal_ids) != len(journal_ids):
raise ValidationError(error_message)
elif len(journal_ids) != 1:
raise ValidationError(error_message)
class AccountMoveTemplateLine(models.Model):
_name = 'account.move.template.line'
_inherit = 'account.document.template.line'
journal_id = fields.Many2one(
comodel_name='account.journal',
string='Journal',
required=True
)
account_id = fields.Many2one(
comodel_name='account.account',
string='Account',
required=True,
ondelete="cascade"
)
move_line_type = fields.Selection(
[('cr', 'Credit'), ('dr', 'Debit')],
string='Move Line Type',
required=True
)
analytic_account_id = fields.Many2one(
comodel_name='account.analytic.account',
string='Analytic Account',
ondelete="cascade"
)
template_id = fields.Many2one(
comodel_name='account.move.template',
string='Template'
)
account_tax_id = fields.Many2one(
comodel_name='account.tax',
string='Tax'
)
_sql_constraints = [
('sequence_template_uniq', 'unique (template_id,sequence)',
'The sequence of the line must be unique per template !')
]

View File

@@ -1,13 +1,13 @@
# Translation of OpenERP Server.
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_template
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-18 17:49+0000\n"
"PO-Revision-Date: 2013-10-18 17:49+0000\n"
"POT-Creation-Date: 2014-12-18 14:44+0000\n"
"PO-Revision-Date: 2014-12-18 14:44+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -16,77 +16,47 @@ msgstr ""
"Plural-Forms: \n"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:68
#: field:account.move.template.line,account_id:0
#: field:wizard.select.move.template.line,account_id:0
msgid "Account"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template.line,amount:0
msgid "Amount"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,analytic_account_id:0
msgid "Analytic Account"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:96
#, python-format
msgid "At least one amount has to be non-zero!"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:account_move_template.wizard_select_template
msgid "Cancel"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:75
#, python-format
msgid "Code \"%s\" refers to non existing line"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,move_line_type:0
#: field:wizard.select.move.template.line,move_line_type:0
msgid "Move Line Type"
#: field:account.move.template,company_id:0
msgid "Company"
msgstr ""
#. module: account_move_template
#: selection:wizard.select.move.template,state:0
msgid "Template selected"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:0
#: field:wizard.select.move.template,template_id:0
msgid "Move Template"
msgstr ""
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template
msgid "Select Move Template"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_wizard_select_move_template
msgid "wizard.select.move.template"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Next"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template,state:0
msgid "State"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:150
#: code:addons/account_move_template/wizard/select_template.py:180
#, python-format
msgid "You have to define an analytic journal on the '%s' journal!"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,template_id:0
#: field:wizard.select.move.template.line,template_id:0
msgid "Template"
msgstr ""
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Debit"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:106
#, python-format
msgid "No period found !"
msgstr ""
#. module: account_move_template
#: field:account.document.template.line,type:0
#: field:account.move.template.line,type:0
msgid "Type"
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "Computed"
msgstr ""
#. module: account_move_template
@@ -96,15 +66,128 @@ msgid "Create Move from Template"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:98
#, python-format
msgid "Error !"
#: field:account.document.template,create_uid:0
#: field:account.document.template.line,create_uid:0
#: field:account.move.template,create_uid:0
#: field:account.move.template.line,create_uid:0
#: field:wizard.select.move.template,create_uid:0
#: field:wizard.select.move.template.line,create_uid:0
msgid "Created by"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:106
#: field:account.document.template,create_date:0
#: field:account.document.template.line,create_date:0
#: field:account.move.template,create_date:0
#: field:account.move.template.line,create_date:0
#: field:wizard.select.move.template,create_date:0
#: field:wizard.select.move.template.line,create_date:0
msgid "Created on"
msgstr ""
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Credit"
msgstr ""
#. module: account_move_template
#: field:account.move.template,cross_journals:0
msgid "Cross-Journals"
msgstr ""
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Debit"
msgstr ""
#. module: account_move_template
#: field:account.document.template,id:0
#: field:account.document.template.line,id:0
#: field:account.move.template,id:0
#: field:account.move.template.line,id:0
#: field:wizard.select.move.template,id:0
#: field:wizard.select.move.template.line,id:0
msgid "ID"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:85
#, python-format
msgid "Unable to find a valid period !"
msgid "Inconsistency between input lines and filled lines for template %s"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,journal_id:0
msgid "Journal"
msgstr ""
#. module: account_move_template
#: view:account.move.template:account_move_template.view_move_template_form
#: view:account.move.template:account_move_template.view_move_template_search
#: view:account.move.template:account_move_template.view_move_template_tree
msgid "Journal Entry Template"
msgstr ""
#. module: account_move_template
#: view:account.move.template.line:account_move_template.view_move_template_line_form
#: view:account.move.template.line:account_move_template.view_move_template_line_tree
msgid "Journal Entry Template Line"
msgstr ""
#. module: account_move_template
#: field:account.document.template,write_uid:0
#: field:account.document.template.line,write_uid:0
#: field:account.move.template,write_uid:0
#: field:account.move.template.line,write_uid:0
#: field:wizard.select.move.template,write_uid:0
#: field:wizard.select.move.template.line,write_uid:0
msgid "Last Updated by"
msgstr ""
#. module: account_move_template
#: field:account.document.template,write_date:0
#: field:account.document.template.line,write_date:0
#: field:account.move.template,write_date:0
#: field:account.move.template.line,write_date:0
#: field:wizard.select.move.template,write_date:0
#: field:wizard.select.move.template.line,write_date:0
msgid "Last Updated on"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:65
#, python-format
msgid "Line %s can't refer to itself"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template,line_ids:0
msgid "Lines"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:account_move_template.wizard_select_template
msgid "Load"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,move_line_type:0
#: field:wizard.select.move.template.line,move_line_type:0
msgid "Move Line Type"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:account_move_template.wizard_select_template
#: field:wizard.select.move.template,template_id:0
msgid "Move Template"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template.line:account_move_template.wizard_select_template_line
#: view:wizard.select.move.template.line:account_move_template.wizard_select_template_line_tree
msgid "Move Template Line"
msgstr ""
#. module: account_move_template
@@ -113,43 +196,6 @@ msgstr ""
msgid "Move Templates"
msgstr ""
#. module: account_move_template
#: field:account.move.template,company_id:0
msgid "Company"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template.line:0
msgid "Move Template Line"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_move_template
msgid "account.move.template"
msgstr ""
#. module: account_move_template
#: field:account.move.template,transitory_acc_id:0
msgid "Transitory account"
msgstr ""
#. module: account_move_template
#: constraint:account.move.template:0
msgid "If the template is \"cross-journals\", the Journals must be different,if the template does not \"cross-journals\" the Journals must be the same!"
msgstr ""
#. module: account_move_template
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "User input"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,account_id:0
#: field:wizard.select.move.template.line,account_id:0
msgid "Account"
msgstr ""
#. module: account_move_template
#: field:account.document.template,name:0
#: field:account.document.template.line,name:0
@@ -160,114 +206,36 @@ msgid "Name"
msgstr ""
#. module: account_move_template
#: field:account.move.template,cross_journals:0
msgid "Cross-Journals"
#: view:wizard.select.move.template:account_move_template.wizard_select_template
msgid "Next"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template,line_ids:0
msgid "Lines"
msgstr ""
#. module: account_move_template
#: view:account.move.template.line:0
msgid "Journal Entry Template Line"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_move_template_line
msgid "account.move.template.line"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:98
#, python-format
msgid "At least one amount has to be non-zero!"
msgstr ""
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Credit"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template.line,amount:0
msgid "Amount"
msgstr ""
#. module: account_move_template
#: view:account.move.template:0
msgid "Journal Entry Template"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:62
#: code:addons/account_move_template/account_document_template.py:67
#: code:addons/account_move_template/account_document_template.py:76
#, python-format
msgid "Error"
msgstr ""
#. module: account_move_template
#: sql_constraint:account.move.template.line:0
msgid "The sequence of the line must be unique per template !"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Load"
msgstr ""
#. module: account_move_template
#: view:account.move.template.line:0
msgid "You can refer to other lines using their sequence number (e.g. 'L(1)' for first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
msgstr ""
#. module: account_move_template
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "Computed"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:149
#: code:addons/account_move_template/wizard/select_template.py:179
#: code:addons/account_move_template/wizard/select_template.py:199
#, python-format
msgid "No Analytic Journal !"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_document_template_line
msgid "account.document.template.line"
msgstr ""
#. module: account_move_template
#: field:account.document.template.line,python_code:0
#: view:account.move.template.line:0
#: field:account.move.template.line,python_code:0
msgid "Python Code"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:77
#, python-format
msgid "Inconsistency between input lines and filled lines for template %s"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,account_tax_id:0
msgid "Tax"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template.line,sequence:0
msgid "Number"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,analytic_account_id:0
msgid "Analytic Account"
#: field:wizard.select.move.template,partner_id:0
msgid "Partner"
msgstr ""
#. module: account_move_template
#: field:account.document.template.line,python_code:0
#: view:account.move.template.line:account_move_template.view_move_template_line_form
#: field:account.move.template.line,python_code:0
msgid "Python Code"
msgstr ""
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template
msgid "Select Move Template"
msgstr ""
#. module: account_move_template
@@ -276,6 +244,22 @@ msgstr ""
msgid "Sequence"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template,state:0
msgid "State"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,account_tax_id:0
msgid "Tax"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,template_id:0
#: field:wizard.select.move.template.line,template_id:0
msgid "Template"
msgstr ""
#. module: account_move_template
#: field:account.move.template,template_line_ids:0
#: model:ir.model,name:account_move_template.model_wizard_select_move_template_line
@@ -283,28 +267,47 @@ msgid "Template Lines"
msgstr ""
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Cancel"
#: selection:wizard.select.move.template,state:0
msgid "Template selected"
msgstr ""
#. module: account_move_template
#: field:wizard.select.move.template,partner_id:0
msgid "Partner"
#: sql_constraint:account.move.template.line:0
msgid "The sequence of the line must be unique per template !"
msgstr ""
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_document_template
msgid "account.document.template"
#: field:account.move.template,transitory_acc_id:0
msgid "Transitory account"
msgstr ""
#. module: account_move_template
#: field:account.move.template.line,journal_id:0
msgid "Journal"
#: field:account.document.template.line,type:0
#: field:account.move.template.line,type:0
msgid "Type"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:63
#: code:addons/account_move_template/wizard/select_template.py:104
#, python-format
msgid "Line %s can't refer to itself"
msgid "Unable to find a valid period !"
msgstr ""
#. module: account_move_template
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "User input"
msgstr ""
#. module: account_move_template
#: view:account.move.template.line:account_move_template.view_move_template_line_form
msgid "You can refer to other lines using their sequence number (e.g. 'L(1)' for first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
msgstr ""
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:164
#: code:addons/account_move_template/wizard/select_template.py:200
#, python-format
msgid "You have to define an analytic journal on the '%s' journal!"
msgstr ""

View File

@@ -1,95 +1,63 @@
# Translation of OpenERP Server.
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_template
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-18 17:49+0000\n"
"PO-Revision-Date: 2013-10-18 17:39+0000\n"
"Last-Translator: Lorenzo Battistini - Agile BG "
"<lorenzo.battistini@agilebg.com>\n"
"POT-Creation-Date: 2014-12-18 14:45+0000\n"
"PO-Revision-Date: 2014-12-18 14:45+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-12 06:31+0000\n"
"X-Generator: Launchpad (build 17041)\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:68
#: field:account.move.template.line,account_id:0
#: field:wizard.select.move.template.line,account_id:0
msgid "Account"
msgstr "Conto"
#. module: account_move_template
#: field:wizard.select.move.template.line,amount:0
msgid "Amount"
msgstr "Importo"
#. module: account_move_template
#: field:account.move.template.line,analytic_account_id:0
msgid "Analytic Account"
msgstr "Conto analitico"
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:96
#, python-format
msgid "At least one amount has to be non-zero!"
msgstr "Almeno un importo deve essere diverso da zero!"
#. module: account_move_template
#: view:wizard.select.move.template:account_move_template.wizard_select_template
msgid "Cancel"
msgstr "Annulla"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:75
#, python-format
msgid "Code \"%s\" refers to non existing line"
msgstr ""
msgstr "Il codice \"%s\" fa riferimento ad una riga inesistente"
#. module: account_move_template
#: field:account.move.template.line,move_line_type:0
#: field:wizard.select.move.template.line,move_line_type:0
msgid "Move Line Type"
msgstr "Tipo di movimento"
#: field:account.move.template,company_id:0
msgid "Company"
msgstr "Azienda"
#. module: account_move_template
#: selection:wizard.select.move.template,state:0
msgid "Template selected"
msgstr "Template selezionato"
#. module: account_move_template
#: view:wizard.select.move.template:0
#: field:wizard.select.move.template,template_id:0
msgid "Move Template"
msgstr "Template di registrazione"
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template
msgid "Select Move Template"
msgstr "Scegli template di registrazione"
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_wizard_select_move_template
msgid "wizard.select.move.template"
msgstr "wizard.select.move.template"
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Next"
msgstr "Avanti"
#. module: account_move_template
#: field:wizard.select.move.template,state:0
msgid "State"
msgstr "State"
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:150
#: code:addons/account_move_template/wizard/select_template.py:180
#, python-format
msgid "You have to define an analytic journal on the '%s' journal!"
msgstr "E' necessario definire un giornale analitico sul sezionale '%s'!"
#. module: account_move_template
#: field:account.move.template.line,template_id:0
#: field:wizard.select.move.template.line,template_id:0
msgid "Template"
msgstr "Template"
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Debit"
msgstr "Dare"
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:106
#, python-format
msgid "No period found !"
msgstr "Nessun periodo trovato!"
#. module: account_move_template
#: field:account.document.template.line,type:0
#: field:account.move.template.line,type:0
msgid "Type"
msgstr "Tipo"
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "Computed"
msgstr "Calcolato"
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template_by_move
@@ -98,16 +66,129 @@ msgid "Create Move from Template"
msgstr "Crea registrazione da template"
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:98
#, python-format
msgid "Error !"
msgstr "Errore !"
#: field:account.document.template,create_uid:0
#: field:account.document.template.line,create_uid:0
#: field:account.move.template,create_uid:0
#: field:account.move.template.line,create_uid:0
#: field:wizard.select.move.template,create_uid:0
#: field:wizard.select.move.template.line,create_uid:0
msgid "Created by"
msgstr "Creato da"
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:106
#: field:account.document.template,create_date:0
#: field:account.document.template.line,create_date:0
#: field:account.move.template,create_date:0
#: field:account.move.template.line,create_date:0
#: field:wizard.select.move.template,create_date:0
#: field:wizard.select.move.template.line,create_date:0
msgid "Created on"
msgstr "Creato il"
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Credit"
msgstr "Avere"
#. module: account_move_template
#: field:account.move.template,cross_journals:0
msgid "Cross-Journals"
msgstr "Multi-sezionale"
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Debit"
msgstr "Dare"
#. module: account_move_template
#: field:account.document.template,id:0
#: field:account.document.template.line,id:0
#: field:account.move.template,id:0
#: field:account.move.template.line,id:0
#: field:wizard.select.move.template,id:0
#: field:wizard.select.move.template.line,id:0
msgid "ID"
msgstr "ID"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:85
#, python-format
msgid "Unable to find a valid period !"
msgstr "Impossibile trovare un periodo valido!"
msgid "Inconsistency between input lines and filled lines for template %s"
msgstr "Inconsistenza fra le righe di input previste ed inserite per il template %s"
#. module: account_move_template
#: field:account.move.template.line,journal_id:0
msgid "Journal"
msgstr "Sezionale"
#. module: account_move_template
#: view:account.move.template:account_move_template.view_move_template_form
#: view:account.move.template:account_move_template.view_move_template_search
#: view:account.move.template:account_move_template.view_move_template_tree
msgid "Journal Entry Template"
msgstr "Template di registrazione contabile"
#. module: account_move_template
#: view:account.move.template.line:account_move_template.view_move_template_line_form
#: view:account.move.template.line:account_move_template.view_move_template_line_tree
msgid "Journal Entry Template Line"
msgstr "Riga del template di registrazione"
#. module: account_move_template
#: field:account.document.template,write_uid:0
#: field:account.document.template.line,write_uid:0
#: field:account.move.template,write_uid:0
#: field:account.move.template.line,write_uid:0
#: field:wizard.select.move.template,write_uid:0
#: field:wizard.select.move.template.line,write_uid:0
msgid "Last Updated by"
msgstr "Last Updated by"
#. module: account_move_template
#: field:account.document.template,write_date:0
#: field:account.document.template.line,write_date:0
#: field:account.move.template,write_date:0
#: field:account.move.template.line,write_date:0
#: field:wizard.select.move.template,write_date:0
#: field:wizard.select.move.template.line,write_date:0
msgid "Last Updated on"
msgstr "Last Updated on"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:65
#, python-format
msgid "Line %s can't refer to itself"
msgstr "La riga %s non può fare riferimento a se stessa"
#. module: account_move_template
#: field:wizard.select.move.template,line_ids:0
msgid "Lines"
msgstr "Righe"
#. module: account_move_template
#: view:wizard.select.move.template:account_move_template.wizard_select_template
msgid "Load"
msgstr "Carica"
#. module: account_move_template
#: field:account.move.template.line,move_line_type:0
#: field:wizard.select.move.template.line,move_line_type:0
msgid "Move Line Type"
msgstr "Tipo di movimento"
#. module: account_move_template
#: view:wizard.select.move.template:account_move_template.wizard_select_template
#: field:wizard.select.move.template,template_id:0
msgid "Move Template"
msgstr "Template di registrazione"
#. module: account_move_template
#: view:wizard.select.move.template.line:account_move_template.wizard_select_template_line
#: view:wizard.select.move.template.line:account_move_template.wizard_select_template_line_tree
msgid "Move Template Line"
msgstr "Riga template di registrazione"
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_move_template_form
@@ -115,45 +196,6 @@ msgstr "Impossibile trovare un periodo valido!"
msgid "Move Templates"
msgstr "Template di registrazioni"
#. module: account_move_template
#: field:account.move.template,company_id:0
msgid "Company"
msgstr "Azienda"
#. module: account_move_template
#: view:wizard.select.move.template.line:0
msgid "Move Template Line"
msgstr "Riga template di registrazione"
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_move_template
msgid "account.move.template"
msgstr "account.move.template"
#. module: account_move_template
#: field:account.move.template,transitory_acc_id:0
msgid "Transitory account"
msgstr "Transitory account"
#. module: account_move_template
#: constraint:account.move.template:0
msgid ""
"If the template is \"cross-journals\", the Journals must be different,if the "
"template does not \"cross-journals\" the Journals must be the same!"
msgstr ""
#. module: account_move_template
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "User input"
msgstr "Input utente"
#. module: account_move_template
#: field:account.move.template.line,account_id:0
#: field:wizard.select.move.template.line,account_id:0
msgid "Account"
msgstr "Conto"
#. module: account_move_template
#: field:account.document.template,name:0
#: field:account.document.template.line,name:0
@@ -164,122 +206,37 @@ msgid "Name"
msgstr "Nome"
#. module: account_move_template
#: field:account.move.template,cross_journals:0
msgid "Cross-Journals"
msgstr "Cross-Journals"
#: view:wizard.select.move.template:account_move_template.wizard_select_template
msgid "Next"
msgstr "Avanti"
#. module: account_move_template
#: field:wizard.select.move.template,line_ids:0
msgid "Lines"
msgstr "Righe"
#. module: account_move_template
#: view:account.move.template.line:0
msgid "Journal Entry Template Line"
msgstr "Riga del template di registrazione"
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_move_template_line
msgid "account.move.template.line"
msgstr "account.move.template.line"
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:98
#, python-format
msgid "At least one amount has to be non-zero!"
msgstr "Almeno un importo deve essere diverso da zero!"
#. module: account_move_template
#: selection:account.move.template.line,move_line_type:0
#: selection:wizard.select.move.template.line,move_line_type:0
msgid "Credit"
msgstr "Avere"
#. module: account_move_template
#: field:wizard.select.move.template.line,amount:0
msgid "Amount"
msgstr "Importo"
#. module: account_move_template
#: view:account.move.template:0
msgid "Journal Entry Template"
msgstr "Template di registrazione contabile"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:62
#: code:addons/account_move_template/account_document_template.py:67
#: code:addons/account_move_template/account_document_template.py:76
#, python-format
msgid "Error"
msgstr "Errore"
#. module: account_move_template
#: sql_constraint:account.move.template.line:0
msgid "The sequence of the line must be unique per template !"
msgstr "Il numero della riga deve essere unico per template!"
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Load"
msgstr "Carica"
#. module: account_move_template
#: view:account.move.template.line:0
msgid ""
"You can refer to other lines using their sequence number (e.g. 'L(1)' for "
"first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + "
"L(3)'; '1250'"
msgstr ""
"Si può fare riferimento alle altre righe usando il loro numero di sequenza "
"(ad es. 'L(1)' per la prima riga). Esempi di codice: 'L(1) * 0.2'; 'L(2) - "
"L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
#. module: account_move_template
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "Computed"
msgstr "Calcolato"
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:149
#: code:addons/account_move_template/wizard/select_template.py:179
#: code:addons/account_move_template/wizard/select_template.py:199
#, python-format
msgid "No Analytic Journal !"
msgstr "Nessun giornale analitico!"
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_document_template_line
msgid "account.document.template.line"
msgstr "account.document.template.line"
#. module: account_move_template
#: field:account.document.template.line,python_code:0
#: view:account.move.template.line:0
#: field:account.move.template.line,python_code:0
msgid "Python Code"
msgstr "Codice python"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:77
#, python-format
msgid "Inconsistency between input lines and filled lines for template %s"
msgstr ""
"Inconsistenza fra le righe di input previste ed inserite per il template %s"
#. module: account_move_template
#: field:account.move.template.line,account_tax_id:0
msgid "Tax"
msgstr "Imposta"
#. module: account_move_template
#: field:wizard.select.move.template.line,sequence:0
msgid "Number"
msgstr "Numero"
#. module: account_move_template
#: field:account.move.template.line,analytic_account_id:0
msgid "Analytic Account"
msgstr "Conto analitico"
#: field:wizard.select.move.template,partner_id:0
msgid "Partner"
msgstr "Partner"
#. module: account_move_template
#: field:account.document.template.line,python_code:0
#: view:account.move.template.line:account_move_template.view_move_template_line_form
#: field:account.move.template.line,python_code:0
msgid "Python Code"
msgstr "Codice python"
#. module: account_move_template
#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template
msgid "Select Move Template"
msgstr "Scegli template di registrazione"
#. module: account_move_template
#: field:account.document.template.line,sequence:0
@@ -287,6 +244,22 @@ msgstr "Conto analitico"
msgid "Sequence"
msgstr "Numero Sequenza"
#. module: account_move_template
#: field:wizard.select.move.template,state:0
msgid "State"
msgstr "Stato"
#. module: account_move_template
#: field:account.move.template.line,account_tax_id:0
msgid "Tax"
msgstr "Imposta"
#. module: account_move_template
#: field:account.move.template.line,template_id:0
#: field:wizard.select.move.template.line,template_id:0
msgid "Template"
msgstr "Template"
#. module: account_move_template
#: field:account.move.template,template_line_ids:0
#: model:ir.model,name:account_move_template.model_wizard_select_move_template_line
@@ -294,27 +267,47 @@ msgid "Template Lines"
msgstr "Righe template"
#. module: account_move_template
#: view:wizard.select.move.template:0
msgid "Cancel"
msgstr "Annulla"
#: selection:wizard.select.move.template,state:0
msgid "Template selected"
msgstr "Template selezionato"
#. module: account_move_template
#: field:wizard.select.move.template,partner_id:0
msgid "Partner"
msgstr "Partner"
#: sql_constraint:account.move.template.line:0
msgid "The sequence of the line must be unique per template !"
msgstr "Il numero della riga deve essere unico per template!"
#. module: account_move_template
#: model:ir.model,name:account_move_template.model_account_document_template
msgid "account.document.template"
msgstr "account.document.template"
#: field:account.move.template,transitory_acc_id:0
msgid "Transitory account"
msgstr "Conto transitorio"
#. module: account_move_template
#: field:account.move.template.line,journal_id:0
msgid "Journal"
msgstr "Sezionale"
#: field:account.document.template.line,type:0
#: field:account.move.template.line,type:0
msgid "Type"
msgstr "Tipo"
#. module: account_move_template
#: code:addons/account_move_template/account_document_template.py:63
#: code:addons/account_move_template/wizard/select_template.py:104
#, python-format
msgid "Line %s can't refer to itself"
msgstr ""
msgid "Unable to find a valid period !"
msgstr "Impossibile trovare un periodo valido!"
#. module: account_move_template
#: selection:account.document.template.line,type:0
#: selection:account.move.template.line,type:0
msgid "User input"
msgstr "Input utente"
#. module: account_move_template
#: view:account.move.template.line:account_move_template.view_move_template_line_form
msgid "You can refer to other lines using their sequence number (e.g. 'L(1)' for first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
msgstr "Si può fare riferimento alle altre righe usando il loro numero di sequenza (ad es. 'L(1)' per la prima riga). Esempi di codice: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
#. module: account_move_template
#: code:addons/account_move_template/wizard/select_template.py:164
#: code:addons/account_move_template/wizard/select_template.py:200
#, python-format
msgid "You have to define an analytic journal on the '%s' journal!"
msgstr "E' necessario definire un giornale analitico sul sezionale '%s'!"

View File

@@ -20,23 +20,28 @@
</field>
</record>
<record id="view_move_template_line_form" model="ir.ui.view">
<field name="name">account.move.template.line.form</field>
<field name="model">account.move.template.line</field>
<field name="arch" type="xml">
<form string="Journal Entry Template Line">
<field colspan="4" name="name" select="1"/>
<field name="sequence"/>
<field name="journal_id"/>
<field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
<field name="type"/>
<field name="move_line_type"/>
<field name="account_tax_id"/>
<separator string="Python Code" colspan="4"/>
<field name="python_code" colspan="4" attrs="{'readonly': [('type', '!=', 'computed')]}" nolabel="1"/>
<label string="You can refer to other lines using their sequence number (e.g. 'L(1)' for first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'" colspan="4"/>
<group>
<group>
<field name="name" select="1"/>
<field name="sequence"/>
<field name="journal_id"/>
<field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
</group>
<group>
<field name="type"/>
<field name="move_line_type"/>
<field name="account_tax_id"/>
</group>
<separator string="Python Code" colspan="4"/>
<field name="python_code" colspan="4" attrs="{'readonly': [('type', '!=', 'computed')]}" nolabel="1"/>
<label string="You can refer to other lines using their sequence number (e.g. 'L(1)' for first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'" colspan="4"/>
</group>
</form>
</field>
</record>
@@ -46,11 +51,13 @@
<field name="model">account.move.template</field>
<field name="arch" type="xml">
<form string="Journal Entry Template">
<field name="name"/>
<field name="company_id" widget='selection' groups="base.group_multi_company"/>
<field name="cross_journals" />
<field name="transitory_acc_id" attrs="{'invisible':[('cross_journals','!=',True)],'required':[('cross_journals','==',True)]}"/>
<field colspan="4" nolabel="1" name="template_line_ids"/>
<group>
<field name="name"/>
<field name="company_id" widget='selection' groups="base.group_multi_company"/>
<field name="cross_journals" />
<field name="transitory_acc_id" attrs="{'invisible':[('cross_journals','!=',True)],'required':[('cross_journals','==',True)]}"/>
<field colspan="4" nolabel="1" name="template_line_ids"/>
</group>
</form>
</field>
</record>
@@ -87,8 +94,10 @@
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_move_template_search"/>
</record>
<menuitem
action="action_move_template_form" id="menu_action_move_template_form" sequence="5"
parent="account.menu_configuration_misc" groups="account.group_account_manager"/>
</data>
</openerp>

View File

@@ -0,0 +1,245 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, exceptions, _
import time
class WizardSelectMoveTemplate(models.TransientModel):
_name = "wizard.select.move.template"
template_id = fields.Many2one(
comodel_name='account.move.template',
string='Move Template',
required=True
)
partner_id = fields.Many2one(
comodel_name='res.partner',
string='Partner'
)
line_ids = fields.One2many(
comodel_name='wizard.select.move.template.line',
inverse_name='template_id',
string='Lines'
)
state = fields.Selection(
[('template_selected', 'Template selected')],
string='State'
)
@api.multi
def check_zero_lines(self):
if not self.line_ids:
return True
for template_line in self.line_ids:
if template_line.amount:
return True
return False
@api.multi
def load_lines(self):
self.ensure_one()
template = self.template_id
for line in template.template_line_ids:
if line.type == 'input':
self.env['wizard.select.move.template.line'].create({
'template_id': self.id,
'sequence': line.sequence,
'name': line.name,
'amount': 0.0,
'account_id': line.account_id.id,
'move_line_type': line.move_line_type,
})
if not self.line_ids:
return self.load_template()
self.state = 'template_selected'
view_rec = self.env['ir.model.data'].get_object_reference(
'account_move_template', 'wizard_select_template')
view_id = view_rec and view_rec[1] or False
return {
'view_type': 'form',
'view_id': [view_id],
'view_mode': 'form',
'res_model': 'wizard.select.move.template',
'res_id': self.id,
'type': 'ir.actions.act_window',
'target': 'new',
'context': self.env.context,
}
@api.multi
def load_template(self):
self.ensure_one()
account_period_model = self.env['account.period']
if not self.check_zero_lines():
raise exceptions.Warning(
_('At least one amount has to be non-zero!')
)
input_lines = {}
for template_line in self.line_ids:
input_lines[template_line.sequence] = template_line.amount
period = account_period_model.find()
if not period:
raise exceptions.Warning(_('Unable to find a valid period !'))
computed_lines = self.template_id.compute_lines(input_lines)
moves = {}
for line in self.template_id.template_line_ids:
if line.journal_id.id not in moves:
moves[line.journal_id.id] = self._make_move(
self.template_id.name,
period.id,
line.journal_id.id,
self.partner_id.id
)
self._make_move_line(
line,
computed_lines,
moves[line.journal_id.id],
period.id,
self.partner_id.id
)
if self.template_id.cross_journals:
trans_account_id = self.template_id.transitory_acc_id.id
self._make_transitory_move_line(
line,
computed_lines,
moves[line.journal_id.id],
period.id,
trans_account_id,
self.partner_id.id
)
return {
'domain': "[('id','in', " + str(moves.values()) + ")]",
'name': 'Entries',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move',
'type': 'ir.actions.act_window',
'target': 'current',
}
@api.model
def _make_move(self, ref, period_id, journal_id, partner_id):
move = self.env['account.move'].create({
'ref': ref,
'period_id': period_id,
'journal_id': journal_id,
'partner_id': partner_id,
})
return move.id
@api.model
def _make_move_line(self, line, computed_lines,
move_id, period_id, partner_id):
account_move_line_model = self.env['account.move.line']
analytic_account_id = False
if line.analytic_account_id:
if not line.journal_id.analytic_journal_id:
raise exceptions.Warning(
_("You have to define an analytic "
"journal on the '%s' journal!")
% (line.journal_id.name,)
)
analytic_account_id = line.analytic_account_id.id
vals = {
'name': line.name,
'move_id': move_id,
'journal_id': line.journal_id.id,
'period_id': period_id,
'analytic_account_id': analytic_account_id,
'account_id': line.account_id.id,
'date': time.strftime('%Y-%m-%d'),
'account_tax_id': line.account_tax_id.id,
'credit': 0.0,
'debit': 0.0,
'partner_id': partner_id,
}
if line.move_line_type == 'cr':
vals['credit'] = computed_lines[line.sequence]
if line.move_line_type == 'dr':
vals['debit'] = computed_lines[line.sequence]
id_line = account_move_line_model.create(vals)
return id_line
@api.model
def _make_transitory_move_line(self, line,
computed_lines, move_id, period_id,
trans_account_id, partner_id):
account_move_line_model = self.env['account.move.line']
analytic_account_id = False
if line.analytic_account_id:
if not line.journal_id.analytic_journal_id:
raise exceptions.Warning(
_('No Analytic Journal !'),
_("You have to define an analytic journal "
"on the '%s' journal!")
% (line.template_id.journal_id.name,)
)
analytic_account_id = line.analytic_account_id.id
vals = {
'name': 'transitory',
'move_id': move_id,
'journal_id': line.journal_id.id,
'period_id': period_id,
'analytic_account_id': analytic_account_id,
'account_id': trans_account_id,
'date': time.strftime('%Y-%m-%d'),
'partner_id': partner_id,
}
if line.move_line_type != 'cr':
vals['credit'] = computed_lines[line.sequence]
if line.move_line_type != 'dr':
vals['debit'] = computed_lines[line.sequence]
id_line = account_move_line_model.create(vals)
return id_line
class WizardSelectMoveTemplateLine(models.TransientModel):
_description = 'Template Lines'
_name = "wizard.select.move.template.line"
template_id = fields.Many2one(
comodel_name='wizard.select.move.template',
string='Template'
)
sequence = fields.Integer(string='Number', required=True)
name = fields.Char(required=True, readonly=True)
account_id = fields.Many2one(
comodel_name='account.account',
string='Account',
required=True,
readonly=True
)
move_line_type = fields.Selection(
[('cr', 'Credit'), ('dr', 'Debit')],
string='Move Line Type',
required=True,
readonly=True
)
amount = fields.Float(required=True)