mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
Follow-up on migration
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_account_bank_st_cmpl_user,account.statement.completion.rule,model_account_statement_completion_rule,account.group_account_user,1,0,0,0
|
||||
access_account_bank_st_cmpl_manager,account.statement.completion.rule,model_account_statement_completion_rule,account.group_account_manager,1,1,1,1
|
||||
|
@@ -61,6 +61,7 @@
|
||||
""",
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'data': [
|
||||
"security/ir.model.access.csv",
|
||||
"data/completion_rule_data.xml",
|
||||
"wizard/import_statement_view.xml",
|
||||
"views/account_move_view.xml",
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
</record>
|
||||
|
||||
<record id="bank_statement_completion_rule_4" model="account.move.completion.rule">
|
||||
<field name="name">Match from line reference (based on Invoice reference)</field>
|
||||
<field name="name">Match from line label (based on Invoice reference)</field>
|
||||
<field name="sequence">40</field>
|
||||
<field name="function_to_call">get_from_ref_and_invoice</field>
|
||||
<field name="function_to_call">get_from_name_and_invoice</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"ref";"date";"amount";"commission_amount";"label"
|
||||
50969286;2011-03-07 13:45:14;118.4;-11.84;"label a"
|
||||
51065326;2011-03-02 13:45:14;189;-15.12;"label b"
|
||||
51179306;2011-03-02 17:45:14;189;-15.12;"label c"
|
||||
"date";"amount";"commission_amount";"label"
|
||||
2011-03-07 13:45:14;118.4;-11.84;"label a"
|
||||
2011-03-02 13:45:14;189;-15.12;"label b"
|
||||
2011-03-02 17:45:14;189;-15.12;"label c"
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
##############################################################################
|
||||
import sys
|
||||
import traceback
|
||||
import os
|
||||
from openerp import _, api, fields, models
|
||||
from ..parser.parser import new_move_parser
|
||||
from openerp.exceptions import UserError, ValidationError
|
||||
@@ -38,6 +39,9 @@ class AccountJournal(models.Model):
|
||||
""" Call method which can be inherited """
|
||||
return self._get_import_type_selection()
|
||||
|
||||
used_for_import = fields.Boolean(
|
||||
string="Journal used for import")
|
||||
|
||||
commission_account_id = fields.Many2one(
|
||||
comodel_name='account.account',
|
||||
string='Commission account')
|
||||
@@ -173,7 +177,7 @@ class AccountJournal(models.Model):
|
||||
|
||||
def prepare_move_line_vals(self, parser_vals, move):
|
||||
"""Hook to build the values of a line from the parser returned values.
|
||||
At least it fullfill the statement_id. Overide it to add your own
|
||||
At least it fullfill the basic values. Overide it to add your own
|
||||
completion if needed.
|
||||
|
||||
:param dict of vals from parser for account.bank.statement.line
|
||||
@@ -186,6 +190,8 @@ class AccountJournal(models.Model):
|
||||
move_line_obj = self.env['account.move.line']
|
||||
values = parser_vals
|
||||
values['company_id'] = self.company_id.id
|
||||
values['currency_id'] = self.currency_id.id
|
||||
values['company_currency_id'] = self.company_id.currency_id.id
|
||||
values['journal_id'] = self.id
|
||||
values['move_id'] = move.id
|
||||
if values['credit'] > 0.0:
|
||||
@@ -199,7 +205,8 @@ class AccountJournal(models.Model):
|
||||
"""Hook to build the values of the statement from the parser and
|
||||
the profile.
|
||||
"""
|
||||
vals = {'journal_id': self.id}
|
||||
vals = {'journal_id': self.id,
|
||||
'currency_id': self.currency_id.id}
|
||||
vals.update(parser.get_move_vals())
|
||||
return vals
|
||||
|
||||
@@ -212,7 +219,10 @@ class AccountJournal(models.Model):
|
||||
:param char: ftype represent the file exstension (csv by default)
|
||||
:return: list: list of ids of the created account.bank.statemênt
|
||||
"""
|
||||
parser = new_move_parser(self, ftype=ftype)
|
||||
filename = self._context.get('file_name', None)
|
||||
if filename:
|
||||
(filename, __) = os.path.splitext(filename)
|
||||
parser = new_move_parser(self, ftype=ftype, move_ref=filename)
|
||||
res = []
|
||||
for result_row_list in parser.parse(file_stream):
|
||||
move = self._move_import(parser, file_stream, ftype=ftype)
|
||||
|
||||
@@ -64,8 +64,8 @@ class AccountMoveCompletionRule(models.Model):
|
||||
|
||||
Override this to add you own."""
|
||||
return [
|
||||
('get_from_ref_and_invoice',
|
||||
'From line reference (based on invoice reference)'),
|
||||
('get_from_name_and_invoice',
|
||||
'From line name (based on invoice reference)'),
|
||||
('get_from_name_and_partner_field',
|
||||
'From line name (based on partner field)'),
|
||||
('get_from_name_and_partner_name',
|
||||
@@ -91,7 +91,7 @@ class AccountMoveCompletionRule(models.Model):
|
||||
string='Method')
|
||||
|
||||
# Should be private but data are initialised with no update XML
|
||||
def get_from_ref_and_invoice(self, line):
|
||||
def get_from_name_and_invoice(self, line):
|
||||
"""Match the partner based on the invoice number and the reference of
|
||||
the statement line. Then, call the generic get_values_for_line method
|
||||
to complete other values. If more than one partner matched, raise the
|
||||
@@ -107,8 +107,7 @@ class AccountMoveCompletionRule(models.Model):
|
||||
"""
|
||||
res = {}
|
||||
inv_obj = self.env['account.invoice']
|
||||
|
||||
invoices = inv_obj.search([('reference', '=', line.ref.strip())])
|
||||
invoices = inv_obj.search([('name', '=', line.name.strip())])
|
||||
if invoices:
|
||||
if len(invoices) == 1:
|
||||
invoice = invoices[0]
|
||||
@@ -118,7 +117,7 @@ class AccountMoveCompletionRule(models.Model):
|
||||
raise ErrorTooManyPartner(
|
||||
_('Line named "%s" (Ref:%s) was matched by more than one '
|
||||
'partner while looking on invoices') %
|
||||
(line.name, line.ref))
|
||||
(line.name))
|
||||
return res
|
||||
|
||||
# Should be private but data are initialised with no update XML
|
||||
|
||||
@@ -40,7 +40,7 @@ class FileParser(AccountMoveImportParser):
|
||||
"""
|
||||
|
||||
def __init__(self, parse_name, ftype='csv', extra_fields=None, header=None,
|
||||
dialect=None, **kwargs):
|
||||
dialect=None, move_ref=None, **kwargs):
|
||||
"""
|
||||
:param char: parse_name: The name of the parser
|
||||
:param char: ftype: extension of the file (could be csv, xls or
|
||||
@@ -63,6 +63,7 @@ class FileParser(AccountMoveImportParser):
|
||||
# 0 means Windows mode (1900 based dates).
|
||||
# Set in _parse_xls, from the contents of the file
|
||||
self.dialect = dialect
|
||||
self.move_ref = move_ref
|
||||
|
||||
def _custom_format(self, *args, **kwargs):
|
||||
"""No other work on data are needed in this parser."""
|
||||
|
||||
@@ -35,7 +35,6 @@ class GenericFileParser(FileParser):
|
||||
|
||||
def __init__(self, parse_name, ftype='csv', **kwargs):
|
||||
conversion_dict = {
|
||||
'ref': ustr,
|
||||
'label': ustr,
|
||||
'date': datetime.datetime,
|
||||
'amount': float_or_zero,
|
||||
@@ -64,10 +63,9 @@ class GenericFileParser(FileParser):
|
||||
line, it MUST contain at least:
|
||||
{
|
||||
'name':value,
|
||||
'date':value,
|
||||
'amount':value,
|
||||
'ref':value,
|
||||
'label':value,
|
||||
'date_maturity':value,
|
||||
'credit':value,
|
||||
'debit':value
|
||||
}
|
||||
"""
|
||||
amount = line.get('amount', 0.0)
|
||||
|
||||
@@ -61,7 +61,7 @@ class AccountMoveImportParser(object):
|
||||
self.journal = journal
|
||||
self.move_date = None
|
||||
self.move_name = None
|
||||
self.move_ref= None
|
||||
self.move_ref = None
|
||||
|
||||
@classmethod
|
||||
def parser_for(cls, parser_name):
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_account_bank_st_cmpl_user,account.move.completion.rule,model_account_move_completion_rule,account.group_account_user,1,0,0,0
|
||||
access_account_bank_st_cmpl_manager,account.move.completion.rule,model_account_move_completion_rule,account.group_account_manager,1,1,1,1
|
||||
|
@@ -17,4 +17,43 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="move_completion_rule_view_form" model="ir.ui.view">
|
||||
<field name="name">account.move.completion.rule.view</field>
|
||||
<field name="model">account.move.completion.rule</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Move Completion Rule">
|
||||
<group>
|
||||
<field name="sequence"/>
|
||||
<field name="name" select="1" />
|
||||
<field name="function_to_call"/>
|
||||
</group>
|
||||
<separator colspan="4" string="Related Profiles"/>
|
||||
<field name="journal_ids" nolabel="1" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="move_completion_rule_view_tree" model="ir.ui.view">
|
||||
<field name="name">account.move.completion.rule.view</field>
|
||||
<field name="model">account.move.completion.rule</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Statement Completion Rule">
|
||||
<field name="sequence"/>
|
||||
<field name="name" select="1" />
|
||||
<field name="journal_ids" />
|
||||
<field name="function_to_call"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_move_completion_rule_tree" model="ir.actions.act_window">
|
||||
<field name="name">Move Completion Rule</field>
|
||||
<field name="res_model">account.move.completion.rule</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem string="Move Completion Rule" action="action_move_completion_rule_tree"
|
||||
id="menu_action_move_completion_rule_tree_menu" parent="account.account_management_menu"/>
|
||||
</odoo>
|
||||
|
||||
@@ -5,11 +5,14 @@
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="loss_account_id" position="after">
|
||||
<field name="used_for_import"/>
|
||||
</field>
|
||||
<notebook position="inside">
|
||||
<page string="Import related infos">
|
||||
<page string="Import related infos" attrs="{'invisible': [('used_for_import', '=', False)]}">
|
||||
<group>
|
||||
<field name="launch_import_completion"/>
|
||||
<field name="last_import_date"/>
|
||||
<field name="last_import_date" readonly="1"/>
|
||||
<field name="import_type"/>
|
||||
</group>
|
||||
<group>
|
||||
@@ -18,7 +21,7 @@
|
||||
<field name="partner_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<button name="%(account_statement_base_import.statement_importer_action)d"
|
||||
<button name="%(account_statement_base_import.move_importer_action)d"
|
||||
string="Import Bank Statement"
|
||||
type="action" icon="gtk-ok"
|
||||
colspan = "2"/>
|
||||
|
||||
@@ -32,15 +32,16 @@ class CreditPartnerStatementImporter(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
context = self.env.context.copy()
|
||||
ctx = self._context
|
||||
res = {}
|
||||
if (context.get('active_model', False) == 'account.journal' and
|
||||
context.get('active_ids', False)):
|
||||
ids = context['active_ids']
|
||||
if (ctx.get('active_model', False) == 'account.journal' and
|
||||
ctx.get('active_ids', False)):
|
||||
ids = ctx['active_ids']
|
||||
assert len(ids) == 1, \
|
||||
'You cannot use this on more than one profile !'
|
||||
'You cannot use this on more than one journal !'
|
||||
res['journal_id'] = ids[0]
|
||||
self.onchange_journal_id(res['journal_id'])
|
||||
values = self.onchange_journal_id(res['journal_id'])
|
||||
res.update(values.get('value', {}))
|
||||
return res
|
||||
|
||||
journal_id = fields.Many2one(
|
||||
@@ -52,7 +53,7 @@ class CreditPartnerStatementImporter(models.TransientModel):
|
||||
required=True)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name='res.partner',
|
||||
string='Credit insitute partner')
|
||||
string='Credit institute partner')
|
||||
file_name = fields.Char('File Name', size=128)
|
||||
receivable_account_id = fields.Many2one(
|
||||
comodel_name='account.account',
|
||||
@@ -65,10 +66,13 @@ class CreditPartnerStatementImporter(models.TransientModel):
|
||||
def onchange_journal_id(self, journal_id):
|
||||
if journal_id:
|
||||
journal = self.env['account.journal'].browse(journal_id)
|
||||
for importer in self:
|
||||
importer.partner_id = journal.partner_id.id
|
||||
importer.receivable_account_id = journal.receivable_account_id.id
|
||||
importer.commission_account_id = journal.commission_account_id.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,
|
||||
}
|
||||
}
|
||||
|
||||
def _check_extension(self, filename):
|
||||
(__, ftype) = os.path.splitext(filename)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="statement_importer_view" model="ir.ui.view">
|
||||
<record id="move_importer_view" model="ir.ui.view">
|
||||
<field name="name">credit.statement.import.config.view</field>
|
||||
<field name="model">credit.statement.import</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Import statement">
|
||||
<form string="Import move">
|
||||
<group colspan="4" >
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)"/>
|
||||
<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"/>
|
||||
@@ -23,12 +23,14 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="statement_importer_action" model="ir.actions.act_window">
|
||||
<field name="name">Import statement</field>
|
||||
<record id="move_importer_action" model="ir.actions.act_window">
|
||||
<field name="name">Import Move</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="statement_importer_view"/>
|
||||
<field name="view_id" ref="move_importer_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="move_importer_menu" name="Import Bank Statement" action="move_importer_action" parent="account.menu_finance_entries"/>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user