mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
Start work to port account_move_base_import and base_transaction_id to v10
This commit is contained in:
committed by
Florian da Costa
parent
0bfaa2d044
commit
1e77fa88ae
@@ -52,10 +52,7 @@ both.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
|
||||
|
||||
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
|
||||
.. branch is "8.0" for example
|
||||
:target: https://runbot.odoo-community.org/runbot/98/10.0
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from . import parser
|
||||
from . import wizard
|
||||
from . import models
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
{
|
||||
'name': "Journal Entry base import",
|
||||
'version': '9.0.1.0.0',
|
||||
'version': '10.0.1.0.0',
|
||||
'author': "Akretion,Camptocamp,Odoo Community Association (OCA)",
|
||||
'category': 'Finance',
|
||||
'depends': ['account'],
|
||||
@@ -26,7 +26,6 @@
|
||||
'test/refund.yml',
|
||||
'test/completion_test.yml'
|
||||
],
|
||||
'installable': False,
|
||||
'auto_install': False,
|
||||
'installable': True,
|
||||
'license': 'AGPL-3',
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from . import account_journal
|
||||
from . import account_move
|
||||
from . import partner
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
@@ -7,9 +7,9 @@
|
||||
import sys
|
||||
import traceback
|
||||
import os
|
||||
from openerp import _, api, fields, models
|
||||
from odoo import _, api, fields, models
|
||||
from ..parser.parser import new_move_parser
|
||||
from openerp.exceptions import UserError, ValidationError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from operator import attrgetter
|
||||
|
||||
|
||||
@@ -289,10 +289,11 @@ class AccountJournal(models.Model):
|
||||
"The file is empty"))
|
||||
parsed_cols = parser.get_move_line_vals(result_row_list[0]).keys()
|
||||
for col in parsed_cols:
|
||||
if col not in move_line_obj._columns:
|
||||
print dir(move_line_obj)
|
||||
if col not in move_line_obj._fields:
|
||||
raise UserError(
|
||||
_("Missing column! Column %s you try to import is not "
|
||||
"present in the bank statement line!") % col)
|
||||
"present in the move line!") % col)
|
||||
move_vals = self.prepare_move_vals(result_row_list, parser)
|
||||
move = move_obj.create(move_vals)
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
@@ -10,8 +10,8 @@ import logging
|
||||
|
||||
import psycopg2
|
||||
|
||||
from openerp import _, api, fields, models
|
||||
from openerp.exceptions import ValidationError
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -260,12 +260,13 @@ class AccountMoveLine(models.Model):
|
||||
|
||||
def _get_available_columns(self, move_store):
|
||||
"""Return writeable by SQL columns"""
|
||||
model_cols = self._columns
|
||||
model_cols = self._fields
|
||||
avail = [
|
||||
k for k, col in model_cols.iteritems() if not hasattr(col, '_fnct')
|
||||
]
|
||||
keys = [k for k in move_store[0].keys() if k in avail]
|
||||
keys.sort()
|
||||
print "keys==================", keys
|
||||
return keys
|
||||
|
||||
def _prepare_insert(self, move, cols):
|
||||
@@ -275,7 +276,9 @@ class AccountMoveLine(models.Model):
|
||||
move_copy = move
|
||||
for k, col in move_copy.iteritems():
|
||||
if k in cols:
|
||||
move_copy[k] = self._columns[k]._symbol_set[1](col)
|
||||
print "DIR self._fields[k]=", dir(self._fields[k])
|
||||
move_copy[k] = self._fields[k]._symbol_set[1](col)
|
||||
print "move_copy[k]==========", move_copy[k]
|
||||
return move_copy
|
||||
|
||||
def _prepare_manyinsert(self, move_store, cols):
|
||||
@@ -333,17 +336,19 @@ class AccountMove(models.Model):
|
||||
related='journal_id.used_for_completion',
|
||||
readonly=True)
|
||||
completion_logs = fields.Text(string='Completion Log', readonly=True)
|
||||
# partner_id is a native field of the account module
|
||||
# (related='line_ids.partner_id', store=True, readonly=True)
|
||||
partner_id = fields.Many2one(related=False, compute='_compute_partner_id')
|
||||
import_partner_id = fields.Many2one('res.partner',
|
||||
string="Partner from import")
|
||||
|
||||
@api.one
|
||||
@api.depends('line_ids.partner_id', 'import_partner_id')
|
||||
def _compute_partner_id(self):
|
||||
for move in self:
|
||||
if move.import_partner_id:
|
||||
move.partner_id = move.import_partner_id
|
||||
elif move.line_ids:
|
||||
move.partner_id = move.line_ids[0].partner_id
|
||||
if self.import_partner_id:
|
||||
self.partner_id = self.import_partner_id
|
||||
elif self.line_ids:
|
||||
self.partner_id = self.line_ids[0].partner_id
|
||||
|
||||
def write_completion_log(self, error_msg, number_imported):
|
||||
"""Write the log in the completion_logs field of the bank statement to
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
from openerp import fields, models
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
from openerp import fields, tools
|
||||
from openerp.modules import get_module_resource
|
||||
from openerp.tests import common
|
||||
from odoo import fields, tools
|
||||
from odoo.modules import get_module_resource
|
||||
from odoo.tests import common
|
||||
from collections import namedtuple
|
||||
|
||||
name_completion_case = namedtuple(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
@@ -8,9 +8,9 @@ import base64
|
||||
import inspect
|
||||
import os
|
||||
from operator import attrgetter
|
||||
from openerp.tests import common
|
||||
from openerp import tools
|
||||
from openerp.modules import get_module_resource
|
||||
from odoo.tests import common
|
||||
from odoo import tools
|
||||
from odoo.modules import get_module_resource
|
||||
|
||||
|
||||
class TestCodaImport(common.TransactionCase):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_move_importer_form" model="ir.ui.view">
|
||||
<field name="name">account.move.view</field>
|
||||
@@ -56,9 +57,8 @@
|
||||
</record>
|
||||
|
||||
<record id="action_move_completion_rule_tree" model="ir.actions.act_window">
|
||||
<field name="name">Move Completion Rule</field>
|
||||
<field name="name">Move Completion Rules</field>
|
||||
<field name="res_model">account.move.completion.rule</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -28,14 +28,13 @@
|
||||
<group>
|
||||
<button name="%(account_move_base_import.move_importer_action)d"
|
||||
string="Import batch file"
|
||||
type="action" icon="gtk-ok"
|
||||
type="action"
|
||||
colspan = "2"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Auto-Completion related infos" attrs="{'invisible': [('used_for_completion', '=', False)]}">
|
||||
<group>
|
||||
<separator colspan="4" string="Auto-Completion Rules"/>
|
||||
<field name="rule_ids" colspan="4" nolabel="1"/>
|
||||
<group string="Auto-Completion Rules" name="completion_rules">
|
||||
<field name="rule_ids" colspan="2" nolabel="1"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="bk_view_partner_form" model="ir.ui.view">
|
||||
<field name="name">account_bank_statement_import.view.partner.form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="priority">20</field>
|
||||
<field name="inherit_id" ref="account.view_partner_property_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="property_account_payable_id" position="after">
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from . import import_statement
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011 Akretion
|
||||
# © 2011-2016 Akretion
|
||||
# © 2011-2016 Camptocamp SA
|
||||
# © 2013 Savoir-faire Linux
|
||||
# © 2014 ACSONE SA/NV
|
||||
@@ -8,25 +8,26 @@
|
||||
Wizard to import financial institute date in bank statement
|
||||
"""
|
||||
|
||||
from openerp import _, api, fields, models
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
import os
|
||||
|
||||
|
||||
class CreditPartnerStatementImporter(models.TransientModel):
|
||||
_name = "credit.statement.import"
|
||||
_description = 'Import Batch File wizard'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
ctx = self._context
|
||||
res = {}
|
||||
if (ctx.get('active_model', False) == 'account.journal' and
|
||||
ctx.get('active_ids', False)):
|
||||
if (
|
||||
ctx.get('active_model') == 'account.journal' and
|
||||
ctx.get('active_ids')):
|
||||
ids = ctx['active_ids']
|
||||
assert len(ids) == 1, \
|
||||
'You cannot use this on more than one journal !'
|
||||
res['journal_id'] = ids[0]
|
||||
values = self.onchange_journal_id(res['journal_id'])
|
||||
res.update(values.get('value', {}))
|
||||
return res
|
||||
|
||||
journal_id = fields.Many2one(
|
||||
@@ -38,34 +39,21 @@ class CreditPartnerStatementImporter(models.TransientModel):
|
||||
required=True)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name='res.partner',
|
||||
string='Credit institute partner')
|
||||
related='journal_id.partner_id', readonly=True)
|
||||
file_name = fields.Char()
|
||||
receivable_account_id = fields.Many2one(
|
||||
comodel_name='account.account',
|
||||
string='Force Receivable/Payable Account')
|
||||
related='journal_id.receivable_account_id', readonly=True)
|
||||
commission_account_id = fields.Many2one(
|
||||
comodel_name='account.account',
|
||||
string='Commission account')
|
||||
|
||||
@api.multi
|
||||
def onchange_journal_id(self, journal_id):
|
||||
if journal_id:
|
||||
journal = self.env['account.journal'].browse(journal_id)
|
||||
return {
|
||||
'value': {
|
||||
'partner_id': journal.partner_id.id,
|
||||
'receivable_account_id': journal.receivable_account_id.id,
|
||||
'commission_account_id': journal.commission_account_id.id,
|
||||
}
|
||||
}
|
||||
related='journal_id.commission_account_id', readonly=True)
|
||||
|
||||
@api.multi
|
||||
def _check_extension(self):
|
||||
self.ensure_one()
|
||||
(__, ftype) = os.path.splitext(self.file_name)
|
||||
if not ftype:
|
||||
# We do not use osv exception we do not want to have it logged
|
||||
raise Exception(_('Please use a file with an extension'))
|
||||
raise UserError(_('Please use a file with an extension'))
|
||||
return ftype
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -5,18 +5,19 @@
|
||||
<field name="model">credit.statement.import</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Import move">
|
||||
<group colspan="4" >
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" domain="[('used_for_import', '=', True)]"/>
|
||||
<field name="input_statement" filename="file_name" colspan="2"/>
|
||||
<field name="file_name" colspan="2" invisible="1"/>
|
||||
<separator string="Import Parameters Summary" colspan="4"/>
|
||||
<field name="partner_id" readonly="1"/>
|
||||
<field name="receivable_account_id" readonly="1"/>
|
||||
<field name="commission_account_id" readonly="1"/>
|
||||
<group name="main">
|
||||
<field name="journal_id" domain="[('used_for_import', '=', True)]"/>
|
||||
<field name="input_statement" filename="file_name"/>
|
||||
<field name="file_name" invisible="1"/>
|
||||
</group>
|
||||
<group string="Import Parameters Summary" name="params">
|
||||
<field name="partner_id"/>
|
||||
<field name="receivable_account_id"/>
|
||||
<field name="commission_account_id"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button icon="gtk-ok" name="import_statement" string="Import file" type="object" class="oe_highlight"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button name="import_statement" string="Import file" type="object" class="oe_highlight"/>
|
||||
<button special="cancel" string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
@@ -25,9 +26,7 @@
|
||||
<record id="move_importer_action" model="ir.actions.act_window">
|
||||
<field name="name">Import Batch File</field>
|
||||
<field name="res_model">credit.statement.import</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="move_importer_view"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user