mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[imp] account_statement_base_completion: put what depends on sale on a separate module
This commit is contained in:
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
1) Match from statement line label (based on partner field 'Bank Statement Label')
|
1) Match from statement line label (based on partner field 'Bank Statement Label')
|
||||||
2) Match from statement line label (based on partner name)
|
2) Match from statement line label (based on partner name)
|
||||||
3) Match from statement line reference (based on SO number)
|
|
||||||
3) Match from statement line reference (based on Invoice number)
|
3) Match from statement line reference (based on Invoice number)
|
||||||
|
|
||||||
You can easily override this module and add your own rules in your own one. The basic rules only
|
You can easily override this module and add your own rules in your own one. The basic rules only
|
||||||
|
|||||||
@@ -14,12 +14,6 @@
|
|||||||
<field name="function_to_call">get_from_label_and_partner_name</field>
|
<field name="function_to_call">get_from_label_and_partner_name</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="bank_statement_completion_rule_1" model="account.statement.completion.rule">
|
|
||||||
<field name="name">Match from line reference (based on SO number)</field>
|
|
||||||
<field name="sequence">50</field>
|
|
||||||
<field name="function_to_call">get_from_ref_and_so</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="bank_statement_completion_rule_4" model="account.statement.completion.rule">
|
<record id="bank_statement_completion_rule_4" model="account.statement.completion.rule">
|
||||||
<field name="name">Match from line reference (based on Invoice number)</field>
|
<field name="name">Match from line reference (based on Invoice number)</field>
|
||||||
<field name="sequence">40</field>
|
<field name="sequence">40</field>
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ class AccountStatementCompletionRule(orm.Model):
|
|||||||
return [
|
return [
|
||||||
('get_from_ref_and_invoice', 'From line reference (based on customer invoice number)'),
|
('get_from_ref_and_invoice', 'From line reference (based on customer invoice number)'),
|
||||||
('get_from_ref_and_supplier_invoice', 'From line reference (based on supplier invoice number)'),
|
('get_from_ref_and_supplier_invoice', 'From line reference (based on supplier invoice number)'),
|
||||||
('get_from_ref_and_so', 'From line reference (based on SO number)'),
|
|
||||||
('get_from_label_and_partner_field', 'From line label (based on partner field)'),
|
('get_from_label_and_partner_field', 'From line label (based on partner field)'),
|
||||||
('get_from_label_and_partner_name', 'From line label (based on partner name)')]
|
('get_from_label_and_partner_name', 'From line label (based on partner name)')]
|
||||||
|
|
||||||
@@ -232,49 +231,6 @@ class AccountStatementCompletionRule(orm.Model):
|
|||||||
"""
|
"""
|
||||||
return self._from_invoice(cr, uid, line, 'customer', context=context)
|
return self._from_invoice(cr, uid, line, 'customer', context=context)
|
||||||
|
|
||||||
# Should be private but data are initialised with no update XML
|
|
||||||
def get_from_ref_and_so(self, cr, uid, st_line, context=None):
|
|
||||||
"""
|
|
||||||
Match the partner based on the SO 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 ErrorTooManyPartner error.
|
|
||||||
|
|
||||||
:param int/long st_line: read of the concerned account.bank.statement.line
|
|
||||||
:return:
|
|
||||||
A dict of value that can be passed directly to the write method of
|
|
||||||
the statement line or {}
|
|
||||||
{'partner_id': value,
|
|
||||||
'account_id': value,
|
|
||||||
|
|
||||||
...}
|
|
||||||
"""
|
|
||||||
st_obj = self.pool.get('account.bank.statement.line')
|
|
||||||
res = {}
|
|
||||||
if st_line:
|
|
||||||
so_obj = self.pool.get('sale.order')
|
|
||||||
so_id = so_obj.search(cr,
|
|
||||||
uid,
|
|
||||||
[('name', '=', st_line['ref'])],
|
|
||||||
context=context)
|
|
||||||
if so_id:
|
|
||||||
if so_id and len(so_id) == 1:
|
|
||||||
so = so_obj.browse(cr, uid, so_id[0], context=context)
|
|
||||||
res['partner_id'] = so.partner_id.id
|
|
||||||
elif so_id and len(so_id) > 1:
|
|
||||||
raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more '
|
|
||||||
'than one partner while looking on SO by ref.') %
|
|
||||||
(st_line['name'], st_line['ref']))
|
|
||||||
st_vals = st_obj.get_values_for_line(cr,
|
|
||||||
uid,
|
|
||||||
profile_id=st_line['profile_id'],
|
|
||||||
master_account_id=st_line['master_account_id'],
|
|
||||||
partner_id=res.get('partner_id', False),
|
|
||||||
line_type='customer',
|
|
||||||
amount=st_line['amount'] if st_line['amount'] else 0.0,
|
|
||||||
context=context)
|
|
||||||
res.update(st_vals)
|
|
||||||
return res
|
|
||||||
|
|
||||||
# Should be private but data are initialised with no update XML
|
# Should be private but data are initialised with no update XML
|
||||||
def get_from_label_and_partner_field(self, cr, uid, st_line, context=None):
|
def get_from_label_and_partner_field(self, cr, uid, st_line, context=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
25
account_statement_so_completion/__init__.py
Normal file
25
account_statement_so_completion/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
###############################################################################
|
||||||
|
# #
|
||||||
|
# Author: Joel Grand-Guillaume
|
||||||
|
# Copyright 2011-2012 Camptocamp SA
|
||||||
|
# #
|
||||||
|
# Author: Leonardo Pistone <leonardo.pistone@camptocamp.com> #
|
||||||
|
# Copyright 2013 Camptocamp SA #
|
||||||
|
# #
|
||||||
|
# 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/>. #
|
||||||
|
# #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
import statement
|
||||||
53
account_statement_so_completion/__openerp__.py
Normal file
53
account_statement_so_completion/__openerp__.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
###############################################################################
|
||||||
|
# #
|
||||||
|
# Author: Joel Grand-Guillaume
|
||||||
|
# Copyright 2011-2012 Camptocamp SA
|
||||||
|
# #
|
||||||
|
# Author: Leonardo Pistone <leonardo.pistone@camptocamp.com> #
|
||||||
|
# Copyright 2013 Camptocamp SA #
|
||||||
|
# #
|
||||||
|
# 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/>. #
|
||||||
|
# #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
{'name': "Bank statement Sale Order completion",
|
||||||
|
'version': '0.1',
|
||||||
|
'author': 'Camptocamp',
|
||||||
|
'maintainer': 'Camptocamp',
|
||||||
|
'category': 'Finance',
|
||||||
|
'complexity': 'easy',
|
||||||
|
'depends': ['account_statement_base_completion', 'sale'],
|
||||||
|
'description': """
|
||||||
|
This module improve the module account_statement_base_completion to add
|
||||||
|
support for completion rules based on Sale Orders. This was initially part of
|
||||||
|
the module account_statement_base_completion, but is now separate to keep
|
||||||
|
dependencies separate.
|
||||||
|
|
||||||
|
This module provides the following rule:
|
||||||
|
|
||||||
|
1) Match from statement line reference (based on SO number)
|
||||||
|
""",
|
||||||
|
'website': 'http://www.camptocamp.com',
|
||||||
|
'init_xml': [],
|
||||||
|
'update_xml': [
|
||||||
|
'data.xml',
|
||||||
|
],
|
||||||
|
'demo_xml': [],
|
||||||
|
'test': [],
|
||||||
|
'installable': True,
|
||||||
|
'images': [],
|
||||||
|
'auto_install': False,
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
}
|
||||||
12
account_statement_so_completion/data.xml
Normal file
12
account_statement_so_completion/data.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data noupdate="1">
|
||||||
|
|
||||||
|
<record id="bank_statement_completion_rule_1" model="account.statement.completion.rule">
|
||||||
|
<field name="name">Match from line reference (based on SO number)</field>
|
||||||
|
<field name="sequence">50</field>
|
||||||
|
<field name="function_to_call">get_from_ref_and_so</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
22
account_statement_so_completion/partner_view.xml
Normal file
22
account_statement_so_completion/partner_view.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<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="type">form</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" position="after">
|
||||||
|
<field name="bank_statement_label"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
98
account_statement_so_completion/statement.py
Normal file
98
account_statement_so_completion/statement.py
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
###############################################################################
|
||||||
|
# #
|
||||||
|
# Author: Joel Grand-Guillaume
|
||||||
|
# Copyright 2011-2012 Camptocamp SA
|
||||||
|
# #
|
||||||
|
# Author: Leonardo Pistone <leonardo.pistone@camptocamp.com> #
|
||||||
|
# Copyright 2013 Camptocamp SA #
|
||||||
|
# #
|
||||||
|
# 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 tools.translate import _
|
||||||
|
|
||||||
|
from openerp.addons.account_statement_base_completion.statement import ErrorTooManyPartner
|
||||||
|
|
||||||
|
|
||||||
|
class account_statement_profile(orm.Model):
|
||||||
|
|
||||||
|
_inherit = "account.statement.profile"
|
||||||
|
|
||||||
|
# Should be private but data are initialised with no update XML
|
||||||
|
def get_from_ref_and_so(self, cr, uid, st_line, context=None):
|
||||||
|
"""
|
||||||
|
Match the partner based on the SO 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
|
||||||
|
ErrorTooManyPartner error.
|
||||||
|
|
||||||
|
:param int/long st_line: read of the concerned
|
||||||
|
account.bank.statement.line
|
||||||
|
|
||||||
|
:return:
|
||||||
|
A dict of value that can be passed directly to the write method of
|
||||||
|
the statement line or {}
|
||||||
|
{'partner_id': value,
|
||||||
|
'account_id': value,
|
||||||
|
|
||||||
|
...}
|
||||||
|
"""
|
||||||
|
st_obj = self.pool.get('account.bank.statement.line')
|
||||||
|
res = {}
|
||||||
|
if st_line:
|
||||||
|
so_obj = self.pool.get('sale.order')
|
||||||
|
so_id = so_obj.search(cr,
|
||||||
|
uid,
|
||||||
|
[('name', '=', st_line['ref'])],
|
||||||
|
context=context)
|
||||||
|
if so_id:
|
||||||
|
if so_id and len(so_id) == 1:
|
||||||
|
so = so_obj.browse(cr, uid, so_id[0], context=context)
|
||||||
|
res['partner_id'] = so.partner_id.id
|
||||||
|
elif so_id and len(so_id) > 1:
|
||||||
|
raise ErrorTooManyPartner(
|
||||||
|
_('Line named "%s" (Ref:%s) was matched by more '
|
||||||
|
'than one partner while looking on SO by ref.') %
|
||||||
|
(st_line['name'], st_line['ref']))
|
||||||
|
st_vals = st_obj.get_values_for_line(
|
||||||
|
cr,
|
||||||
|
uid,
|
||||||
|
profile_id=st_line['profile_id'],
|
||||||
|
master_account_id=st_line['master_account_id'],
|
||||||
|
partner_id=res.get('partner_id', False),
|
||||||
|
line_type='customer',
|
||||||
|
amount=st_line['amount'] if st_line['amount'] else 0.0,
|
||||||
|
context=context)
|
||||||
|
res.update(st_vals)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
class account_statement_completion_rule(orm.Model):
|
||||||
|
|
||||||
|
_name = "account.statement.completion.rule"
|
||||||
|
_inherit = "account.statement.completion.rule"
|
||||||
|
|
||||||
|
def _get_functions(self, cr, uid, context=None):
|
||||||
|
res = super(account_statement_completion_rule, self)._get_functions(
|
||||||
|
cr, uid, context=context)
|
||||||
|
return res.append(
|
||||||
|
('get_from_ref_and_so', 'From line reference (based on SO number)')
|
||||||
|
)
|
||||||
|
|
||||||
|
_columns = {
|
||||||
|
'function_to_call': fields.selection(_get_functions, 'Method'),
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user