mirror of
https://gitlab.com/datalifeit/trytond-account_bank
synced 2023-12-14 06:23:07 +01:00
Merge account_payment_bank functionality
account_bank originally did not depend on the account_payment module, but since version 4.1 the account_payment_type depends on the account_payment module, and hence the account_bank indirectly depends on it. We now make this dependency explicit and deprecate the account_payment_bank functionality
This commit is contained in:
parent
15d2591bdb
commit
52bb75e13e
16 changed files with 395 additions and 5 deletions
|
@ -3,6 +3,7 @@
|
|||
# the full copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .account import *
|
||||
from . import payment
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -14,6 +15,10 @@ def register():
|
|||
Reconciliation,
|
||||
Line,
|
||||
CompensationMoveStart,
|
||||
payment.Journal,
|
||||
payment.Group,
|
||||
payment.Payment,
|
||||
payment.PayLine,
|
||||
module='account_bank', type_='model')
|
||||
Pool.register(
|
||||
CompensationMove,
|
||||
|
|
|
@ -43,6 +43,12 @@ copyright notices and license terms. -->
|
|||
<field name="model">account.move.line,-1</field>
|
||||
<field name="action" ref="act_compensation_move_lines"/>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="move_line_view_list">
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="priority" eval="20"/>
|
||||
<field name="inherit" ref="account_payment.move_line_view_list"/>
|
||||
<field name="name">move_line_list</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
4
doc/es/account_payment.rst
Normal file
4
doc/es/account_payment.rst
Normal file
|
@ -0,0 +1,4 @@
|
|||
#:after:account_payment/account_payment:paragraph:configuracion#
|
||||
|
||||
A continuación deberá seleccionar el tercero que realizará
|
||||
la orden de pago, la cuenta bancaria y el tipo de pago a realizar.
|
|
@ -4,3 +4,7 @@ Contabilidad con banco
|
|||
|
||||
Añade el banco mediante el que se hace el pago/cobro de las ventas/compras a
|
||||
las facturas y apuntes contables.
|
||||
|
||||
Además proporciona:
|
||||
* Una forma más eficiente de gestionar el pago de facturas.
|
||||
* Un mecanismo básico para conectar fácilmente varios pagos automatizados.
|
||||
|
|
25
locale/ca.po
25
locale/ca.po
|
@ -1,4 +1,4 @@
|
|||
#
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
|
@ -117,6 +117,10 @@ msgctxt "field:account.move.compensation_move.start,party:"
|
|||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "field:account.move.line,netting_moves:"
|
||||
msgid "With Netting Moves"
|
||||
msgstr "Amb movimients a compensar"
|
||||
|
||||
msgctxt "field:account.move.line,reverse_moves:"
|
||||
msgid "With Reverse Moves"
|
||||
msgstr "Amb apunts inversos"
|
||||
|
@ -141,6 +145,21 @@ msgctxt "model:ir.action,name:act_compensation_move_lines"
|
|||
msgid "Create compensation move"
|
||||
msgstr "Crea assentament de compensació"
|
||||
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_move_line_form_domain_netting"
|
||||
msgid "Netting"
|
||||
msgstr "A compensar"
|
||||
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_move_line_form_domain_payable_with_reverse"
|
||||
msgid "Payable with reverse moves"
|
||||
msgstr "A pagar amb apunts inversos"
|
||||
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_move_line_form_domain_receivable_with_reverse"
|
||||
msgid "Receivable with reverse moves"
|
||||
msgstr "A cobrar amb apunts inversos"
|
||||
|
||||
msgctxt "selection:account.invoice,account_bank:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
@ -177,6 +196,10 @@ msgctxt "view:account.move.compensation_move.start:"
|
|||
msgid "Create Compensation Move"
|
||||
msgstr "Crea assentament de compensació"
|
||||
|
||||
msgctxt "view:account.payment.journal:"
|
||||
msgid "Sender data"
|
||||
msgstr "Dades de l'emissor"
|
||||
|
||||
msgctxt "wizard_button:account.move.compensation_move,start,create_move:"
|
||||
msgid "Create"
|
||||
msgstr "Crea"
|
||||
|
|
27
locale/es.po
27
locale/es.po
|
@ -1,4 +1,4 @@
|
|||
#
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
|
@ -98,10 +98,10 @@ msgctxt "field:account.move.compensation_move.start,account:"
|
|||
msgid "Account"
|
||||
msgstr "Cuenta"
|
||||
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,date:"
|
||||
msgid "Date"
|
||||
msgstr "Fecha"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,id:"
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
@ -114,6 +114,10 @@ msgctxt "field:account.move.compensation_move.start,party:"
|
|||
msgid "Party"
|
||||
msgstr "Terceros"
|
||||
|
||||
msgctxt "field:account.move.line,netting_moves:"
|
||||
msgid "With Netting Moves"
|
||||
msgstr "Con movimientos a compensar"
|
||||
|
||||
msgctxt "field:account.move.line,reverse_moves:"
|
||||
msgid "With Reverse Moves"
|
||||
msgstr "Con apuntes inversos"
|
||||
|
@ -138,6 +142,21 @@ msgctxt "model:ir.action,name:act_compensation_move_lines"
|
|||
msgid "Create compensation move"
|
||||
msgstr "Crear efecto de compensación"
|
||||
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_move_line_form_domain_netting"
|
||||
msgid "Netting"
|
||||
msgstr "A compensar"
|
||||
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_move_line_form_domain_payable_with_reverse"
|
||||
msgid "Payable with reverse moves"
|
||||
msgstr "A pagar con apuntes inversos"
|
||||
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_move_line_form_domain_receivable_with_reverse"
|
||||
msgid "Receivable with reverse moves"
|
||||
msgstr "A cobrar con apuntes inversos"
|
||||
|
||||
msgctxt "selection:account.invoice,account_bank:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
@ -174,6 +193,10 @@ msgctxt "view:account.move.compensation_move.start:"
|
|||
msgid "Create Compensation Move"
|
||||
msgstr "Crear efecto de compensación"
|
||||
|
||||
msgctxt "view:account.payment.journal:"
|
||||
msgid "Sender data"
|
||||
msgstr "Datos del emisor"
|
||||
|
||||
msgctxt "wizard_button:account.move.compensation_move,start,create_move:"
|
||||
msgid "Create"
|
||||
msgstr "Crear"
|
||||
|
|
157
payment.py
Normal file
157
payment.py
Normal file
|
@ -0,0 +1,157 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains
|
||||
# the full copyright notices and license terms.
|
||||
from decimal import Decimal
|
||||
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
__all__ = ['Journal', 'Group', 'Payment', 'PayLine']
|
||||
|
||||
_ZERO = Decimal('0.0')
|
||||
|
||||
|
||||
class Journal:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.payment.journal'
|
||||
|
||||
payment_type = fields.Many2One('account.payment.type', 'Payment Type',
|
||||
required=True)
|
||||
party = fields.Many2One('party.party', 'Party',
|
||||
help=('The party who sends the payment group, if it is different from '
|
||||
'the company.'))
|
||||
|
||||
|
||||
class Group:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.payment.group'
|
||||
|
||||
payment_type = fields.Function(fields.Many2One('account.payment.type',
|
||||
'Payment Type'),
|
||||
'on_change_with_payment_type')
|
||||
currency_digits = fields.Function(fields.Integer('Currency Digits'),
|
||||
'on_change_with_currency_digits')
|
||||
amount = fields.Function(fields.Numeric('Total', digits=(16,
|
||||
Eval('currency_digits', 2)), depends=['currency_digits']),
|
||||
'get_amount')
|
||||
|
||||
@classmethod
|
||||
def default_currency_digits(cls):
|
||||
return 2
|
||||
|
||||
@fields.depends('journal')
|
||||
def on_change_with_payment_type(self, name=None):
|
||||
if self.journal and self.journal.payment_type:
|
||||
return self.journal.payment_type.id
|
||||
|
||||
@fields.depends('journal')
|
||||
def on_change_with_currency_digits(self, name=None):
|
||||
if self.journal and self.journal.currency:
|
||||
return self.journal.currency.digits
|
||||
return 2
|
||||
|
||||
def get_amount(self, name):
|
||||
amount = _ZERO
|
||||
for payment in self.payments:
|
||||
amount += payment.amount
|
||||
if self.journal and self.journal.currency:
|
||||
return self.journal.currency.round(amount)
|
||||
else:
|
||||
return amount
|
||||
|
||||
|
||||
class Payment:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.payment'
|
||||
bank_account = fields.Many2One('bank.account', 'Bank Account',
|
||||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
domain=[
|
||||
('owners', '=', Eval('party'))
|
||||
],
|
||||
depends=['party', 'kind'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Payment, cls).__setup__()
|
||||
if 'party' not in cls.kind.on_change:
|
||||
cls.kind.on_change.add('party')
|
||||
if 'kind' not in cls.party.on_change:
|
||||
cls.party.on_change.add('kind')
|
||||
if 'kind' not in cls.line.on_change:
|
||||
cls.line.on_change.add('kind')
|
||||
if 'party' not in cls.line.on_change:
|
||||
cls.line.on_change.add('party')
|
||||
cls._error_messages.update({
|
||||
'no_mandate_for_party': ('No valid mandate for payment '
|
||||
'"%(payment)s" of party "%(party)s" with amount '
|
||||
'"%(amount)s".'),
|
||||
})
|
||||
|
||||
@fields.depends('party', 'kind')
|
||||
def on_change_kind(self):
|
||||
super(Payment, self).on_change_kind()
|
||||
self.bank_account = None
|
||||
party = self.party
|
||||
if self.kind and party:
|
||||
default_bank_account = getattr(party, self.kind + '_bank_account')
|
||||
self.bank_account = (default_bank_account and
|
||||
default_bank_account.id or None)
|
||||
|
||||
@fields.depends('party', 'kind')
|
||||
def on_change_party(self):
|
||||
super(Payment, self).on_change_party()
|
||||
self.bank_account = None
|
||||
party = self.party
|
||||
if party and self.kind:
|
||||
default_bank_account = getattr(party, self.kind + '_bank_account')
|
||||
self.bank_account = (default_bank_account and
|
||||
default_bank_account.id or None)
|
||||
|
||||
@fields.depends('party', 'line')
|
||||
def on_change_line(self):
|
||||
super(Payment, self).on_change_line()
|
||||
self.bank_account = None
|
||||
party = self.party
|
||||
if self.line and self.line.bank_account:
|
||||
self.bank_account = self.line.bank_account.id
|
||||
elif party and self.kind:
|
||||
default_bank_account = getattr(party, self.kind + '_bank_account')
|
||||
self.bank_account = (default_bank_account and
|
||||
default_bank_account.id or None)
|
||||
|
||||
@classmethod
|
||||
def get_sepa_mandates(cls, payments):
|
||||
mandates = super(Payment, cls).get_sepa_mandates(payments)
|
||||
mandates2 = []
|
||||
for payment, mandate in zip(payments, mandates):
|
||||
if not mandate:
|
||||
cls.raise_user_error('no_mandate_for_party', {
|
||||
'payment': payment.rec_name,
|
||||
'party': payment.party.rec_name,
|
||||
'amount': payment.amount,
|
||||
})
|
||||
if payment.bank_account != mandate.account_number.account:
|
||||
mandate = None
|
||||
for mandate2 in payment.party.sepa_mandates:
|
||||
if (mandate2.is_valid and
|
||||
mandate2.account_number.account == payment.bank_account
|
||||
):
|
||||
mandate = mandate2
|
||||
break
|
||||
mandates2.append(mandate)
|
||||
return mandates2
|
||||
|
||||
|
||||
class PayLine:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.move.line.pay'
|
||||
|
||||
def get_payment(self, line, journals):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
payment = super(PayLine, self).get_payment(line, journals)
|
||||
if isinstance(line.origin, Invoice):
|
||||
payment.bank_account = line.origin.bank_account
|
||||
return payment
|
87
payment.xml
Normal file
87
payment.xml
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of account_payment_bank module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<!-- account.payment.journal -->
|
||||
<record model="ir.ui.view" id="payment_journal_view_form">
|
||||
<field name="model">account.payment.journal</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="priority" eval="20"/>
|
||||
<field name="inherit" ref="account_payment.payment_journal_view_form"/>
|
||||
<field name="name">payment_journal_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="payment_journal_view_list">
|
||||
<field name="model">account.payment.journal</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="priority" eval="20"/>
|
||||
<field name="inherit" ref="account_payment.payment_journal_view_list"/>
|
||||
<field name="name">payment_journal_list</field>
|
||||
</record>
|
||||
|
||||
<!-- account.payment.group -->
|
||||
<record model="ir.ui.view" id="payment_group_view_form">
|
||||
<field name="model">account.payment.group</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="priority" eval="20"/>
|
||||
<field name="inherit" ref="account_payment.payment_group_view_form"/>
|
||||
<field name="name">payment_group_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="payment_group_view_list">
|
||||
<field name="model">account.payment.group</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="priority" eval="20"/>
|
||||
<field name="inherit" ref="account_payment.payment_group_view_list"/>
|
||||
<field name="name">payment_group_list</field>
|
||||
</record>
|
||||
|
||||
<!-- account.payment -->
|
||||
<record model="ir.ui.view" id="payment_view_form">
|
||||
<field name="model">account.payment</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="inherit" ref="account_payment.payment_view_form"/>
|
||||
<field name="name">payment_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="payment_view_list">
|
||||
<field name="model">account.payment</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="priority" eval="20"/>
|
||||
<field name="inherit" ref="account_payment.payment_view_list"/>
|
||||
<field name="name">payment_list</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_move_line_form_view2">
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="view" ref="account.move_line_view_form"/>
|
||||
<field name="act_window" ref="account_payment.act_move_line_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_move_line_form_domain_netting">
|
||||
<field name="name">Netting</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="domain"
|
||||
eval="[('account.kind', 'in', ['payable','receivable']), ('netting_moves', '=', True)]"
|
||||
pyson="1"/>
|
||||
<field name="act_window" ref="account_payment.act_move_line_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_move_line_form_domain_payable_with_reverse">
|
||||
<field name="name">Payable with reverse moves</field>
|
||||
<field name="sequence" eval="13"/>
|
||||
<field name="domain"
|
||||
eval="[('account.kind', '=', 'payable'),('reverse_moves', '=', True)]"
|
||||
pyson="1"/>
|
||||
<field name="act_window" ref="account_payment.act_move_line_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_move_line_form_domain_receivable_with_reverse">
|
||||
<field name="name">Receivable with reverse moves</field>
|
||||
<field name="sequence" eval="23"/>
|
||||
<field name="domain"
|
||||
eval="[('account.kind', '=', 'receivable'),('reverse_moves', '=', True)]"
|
||||
pyson="1"/>
|
||||
<field name="act_window" ref="account_payment.act_move_line_form"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -1,11 +1,11 @@
|
|||
[tryton]
|
||||
version=4.1.0
|
||||
depends:
|
||||
ir
|
||||
res
|
||||
account
|
||||
account_invoice
|
||||
account_payment
|
||||
account_payment_type
|
||||
company_bank
|
||||
xml:
|
||||
account.xml
|
||||
payment.xml
|
||||
|
|
11
view/move_line_list.xml
Normal file
11
view/move_line_list.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/tree/field[@name='debit']" position="replace_attributes">
|
||||
<field name="debit" sum="Total Debit"/>
|
||||
</xpath>
|
||||
<xpath expr="/tree/field[@name='credit']" position="replace_attributes">
|
||||
<field name="credit" sum="Total Credit"/>
|
||||
</xpath>
|
||||
</data>
|
11
view/payment_form.xml
Normal file
11
view/payment_form.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of account_payment_bank module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name="currency"]"
|
||||
position="after">
|
||||
<label name="bank_account"/>
|
||||
<field name="bank_account"/>
|
||||
</xpath>
|
||||
</data>
|
14
view/payment_group_form.xml
Normal file
14
view/payment_group_form.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part account_payment_payment_type module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name="kind"]"
|
||||
position="after">
|
||||
<label name="payment_type"/>
|
||||
<field name="payment_type"/>
|
||||
<label name="amount"/>
|
||||
<field name="amount"/>
|
||||
<field name="payments" colspan="4"/>
|
||||
</xpath>
|
||||
</data>
|
11
view/payment_group_list.xml
Normal file
11
view/payment_group_list.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part account_payment_payment_type module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/tree/field[@name="kind"]"
|
||||
position="after">
|
||||
<field name="payment_type"/>
|
||||
<field name="amount"/>
|
||||
</xpath>
|
||||
</data>
|
14
view/payment_journal_form.xml
Normal file
14
view/payment_journal_form.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part account_payment_bank module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name="process_method"]"
|
||||
position="after">
|
||||
<separator string="Sender data" colspan="4" id="presenter_data"/>
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="payment_type"/>
|
||||
<field name="payment_type"/>
|
||||
</xpath>
|
||||
</data>
|
10
view/payment_journal_list.xml
Normal file
10
view/payment_journal_list.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part account_payment_bank module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/tree/field[@name="process_method"]"
|
||||
position="after">
|
||||
<field name="payment_type"/>
|
||||
</xpath>
|
||||
</data>
|
10
view/payment_list.xml
Normal file
10
view/payment_list.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part account_payment_payment_type module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/tree/field[@name="state"]"
|
||||
position="before">
|
||||
<field name="group"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in a new issue