mirror of
https://gitlab.com/datalifeit/trytond-account_bank
synced 2023-12-14 06:23:07 +01:00
Remove bank account from account move line
This commit is contained in:
parent
2f2ca55fe0
commit
38a1d6cd87
8 changed files with 22 additions and 283 deletions
|
@ -1,3 +1,5 @@
|
|||
* Remove bank_account from Account Move Lines
|
||||
|
||||
Version 4.0.0 - 2016-05-03
|
||||
* Correctly read bank accounts from company
|
||||
|
||||
|
|
87
account.py
87
account.py
|
@ -68,7 +68,6 @@ class BankAccount:
|
|||
super(BankAccount, cls).__setup__()
|
||||
cls._check_owners_fields = set(['owners'])
|
||||
cls._check_owners_related_models = set([
|
||||
('account.move.line', 'bank_account'),
|
||||
('account.invoice', 'bank_account'),
|
||||
])
|
||||
cls._error_messages.update({
|
||||
|
@ -250,15 +249,6 @@ class Invoice(BankMixin):
|
|||
'"%(payment_type)s" requires it.'),
|
||||
})
|
||||
|
||||
def _get_move_line(self, date, amount):
|
||||
'''
|
||||
Add account bank to move line when post invoice.
|
||||
'''
|
||||
res = super(Invoice, self)._get_move_line(date, amount)
|
||||
if self.bank_account:
|
||||
res['bank_account'] = self.bank_account
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def compute_default_bank_account(cls, values):
|
||||
pool = Pool()
|
||||
|
@ -388,26 +378,13 @@ class Reconciliation:
|
|||
Invoice.process(invoices)
|
||||
|
||||
|
||||
class Line(BankMixin):
|
||||
class Line:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.move.line'
|
||||
|
||||
reverse_moves = fields.Function(fields.Boolean('With Reverse Moves'),
|
||||
'get_reverse_moves', searcher='search_reverse_moves')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Line, cls).__setup__()
|
||||
if hasattr(cls, '_check_modify_exclude'):
|
||||
cls._check_modify_exclude.add('bank_account')
|
||||
readonly = Bool(Eval('reconciliation'))
|
||||
previous_readonly = cls.bank_account.states.get('readonly')
|
||||
if previous_readonly:
|
||||
readonly = readonly | previous_readonly
|
||||
cls.bank_account.states.update({
|
||||
'readonly': readonly,
|
||||
})
|
||||
|
||||
def get_reverse_moves(self, name):
|
||||
if (not self.account
|
||||
or self.account.kind not in ['receivable', 'payable']):
|
||||
|
@ -457,36 +434,12 @@ class Line(BankMixin):
|
|||
cursor.execute(query)
|
||||
return [('id', operator, [x[0] for x in cursor.fetchall()])]
|
||||
|
||||
@fields.depends('party', 'payment_type')
|
||||
def on_change_party(self):
|
||||
'''
|
||||
Add account bank to account move line when changes party.
|
||||
'''
|
||||
super(Line, self).on_change_party()
|
||||
if self.payment_type and self.party:
|
||||
self._get_bank_account()
|
||||
|
||||
@classmethod
|
||||
def copy(cls, lines, default=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
if (Transaction().context.get('cancel_move')
|
||||
and 'bank_account' not in default):
|
||||
default['bank_account'] = None
|
||||
return super(Line, cls).copy(lines, default)
|
||||
|
||||
|
||||
class CompensationMoveStart(ModelView, BankMixin):
|
||||
class CompensationMoveStart(ModelView):
|
||||
'Create Compensation Move Start'
|
||||
__name__ = 'account.move.compensation_move.start'
|
||||
maturity_date = fields.Date('Maturity Date')
|
||||
party = fields.Many2One('party.party', 'Party', readonly=True)
|
||||
payment_kind = fields.Char('Payment Kind')
|
||||
payment_type = fields.Many2One('account.payment.type', 'Payment Type',
|
||||
domain=[
|
||||
('kind', '=', Eval('payment_kind'))
|
||||
],
|
||||
depends=['payment_kind'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -508,9 +461,8 @@ class CompensationMoveStart(ModelView, BankMixin):
|
|||
def default_get(cls, fields, with_rec_name=True):
|
||||
pool = Pool()
|
||||
Line = pool.get('account.move.line')
|
||||
PaymentType = pool.get('account.payment.type')
|
||||
|
||||
res = super(CompensationMoveStart, cls).default_get(fields,
|
||||
defaults = super(CompensationMoveStart, cls).default_get(fields,
|
||||
with_rec_name)
|
||||
|
||||
party = None
|
||||
|
@ -528,32 +480,7 @@ class CompensationMoveStart(ModelView, BankMixin):
|
|||
company = line.account.company
|
||||
if company and company.currency.is_zero(amount):
|
||||
cls.raise_user_error('normal_reconcile')
|
||||
if amount > 0:
|
||||
res['payment_kind'] = 'receivable'
|
||||
else:
|
||||
res['payment_kind'] = 'payable'
|
||||
res['bank_account'] = None
|
||||
if party:
|
||||
res['party'] = party.id
|
||||
if (res['payment_kind'] == 'receivable' and
|
||||
party.customer_payment_type):
|
||||
res['payment_type'] = party.customer_payment_type.id
|
||||
elif (res['payment_kind'] == 'payable' and
|
||||
party.supplier_payment_type):
|
||||
res['payment_type'] = party.supplier_payment_type.id
|
||||
if 'payment_type' in res:
|
||||
payment_type = PaymentType(res['payment_type'])
|
||||
res['account_bank'] = payment_type.account_bank
|
||||
|
||||
self = cls()
|
||||
self.payment_type = payment_type
|
||||
self.party = party
|
||||
self._get_bank_account()
|
||||
res['account_bank_from'] = (
|
||||
self.on_change_with_account_bank_from())
|
||||
res['bank_account'] = self.bank_account.id \
|
||||
if self.bank_account else None
|
||||
return res
|
||||
return defaults
|
||||
|
||||
|
||||
class CompensationMove(Wizard):
|
||||
|
@ -607,9 +534,7 @@ class CompensationMove(Wizard):
|
|||
" Returns true if both lines are equal"
|
||||
return (line.debit == extra_line.debit and
|
||||
line.credit == extra_line.credit and
|
||||
line.maturity_date == extra_line.maturity_date and
|
||||
line.payment_type == extra_line.payment_type and
|
||||
line.bank_account == extra_line.bank_account)
|
||||
line.maturity_date == extra_line.maturity_date)
|
||||
|
||||
def get_counterpart_line(self, line):
|
||||
'Returns the counterpart line to create from line'
|
||||
|
@ -670,8 +595,6 @@ class CompensationMove(Wizard):
|
|||
extra_line.account = account
|
||||
extra_line.party = party
|
||||
extra_line.maturity_date = self.start.maturity_date
|
||||
extra_line.payment_type = self.start.payment_type
|
||||
extra_line.bank_account = self.start.bank_account
|
||||
extra_line.credit = extra_line.debit = Decimal('0.0')
|
||||
if amount > 0:
|
||||
extra_line.debit = amount
|
||||
|
|
16
account.xml
16
account.xml
|
@ -27,22 +27,6 @@ copyright notices and license terms. -->
|
|||
<field name="name">invoice_form</field>
|
||||
</record>
|
||||
|
||||
<!-- account.move.line -->
|
||||
<record model="ir.ui.view" id="move_line_view_form">
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="inherit" ref="account.move_line_view_form"/>
|
||||
<field name="priority" eval="40"/>
|
||||
<field name="name">move_line_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="move_line_view_form_move">
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="type" eval="None"/>
|
||||
<field name="inherit" ref="account.move_line_view_form_move"/>
|
||||
<field name="priority" eval="45"/>
|
||||
<field name="name">move_line_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="compensation_move_lines_start_view_form">
|
||||
<field name="model">account.move.compensation_move.start</field>
|
||||
<field name="type">form</field>
|
||||
|
|
|
@ -34,14 +34,6 @@ msgstr ""
|
|||
"Els apunts seleccionats estan balancejats. Utilitzeu l'assistent de "
|
||||
"conciliació per a conciliar-los enlloc de crear un efecte de compensació."
|
||||
|
||||
msgctxt "error:account.move.line:"
|
||||
msgid ""
|
||||
"%s has no any %s bank account.\n"
|
||||
"Please set up one if you want to use this payment type."
|
||||
msgstr ""
|
||||
"%s no té cap compte bancari %s.\n"
|
||||
"Si us plau, establiu un si voleu utilitzar aquest tipus de pagament."
|
||||
|
||||
msgctxt "error:account.move.line:"
|
||||
msgid "Line \"%s\" (%d) already reconciled."
|
||||
msgstr "L'apunt \"%s\" (%d) ja està conciliat."
|
||||
|
@ -97,18 +89,6 @@ msgctxt "field:account.invoice,bank_account:"
|
|||
msgid "Bank Account"
|
||||
msgstr "Compte bancari"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,account_bank:"
|
||||
msgid "Account Bank"
|
||||
msgstr "Compte bancari"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,account_bank_from:"
|
||||
msgid "Account Bank From"
|
||||
msgstr "Compte bancari de"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,bank_account:"
|
||||
msgid "Bank Account"
|
||||
msgstr "Compte bancari"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,id:"
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
@ -121,26 +101,6 @@ msgctxt "field:account.move.compensation_move.start,party:"
|
|||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,payment_kind:"
|
||||
msgid "Payment Kind"
|
||||
msgstr "Classe de pagament"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,payment_type:"
|
||||
msgid "Payment Type"
|
||||
msgstr "Tipus de pagament"
|
||||
|
||||
msgctxt "field:account.move.line,account_bank:"
|
||||
msgid "Account Bank"
|
||||
msgstr "Compte bancari"
|
||||
|
||||
msgctxt "field:account.move.line,account_bank_from:"
|
||||
msgid "Account Bank From"
|
||||
msgstr "Compte bancari de"
|
||||
|
||||
msgctxt "field:account.move.line,bank_account:"
|
||||
msgid "Bank Account"
|
||||
msgstr "Compte bancari"
|
||||
|
||||
msgctxt "field:account.move.line,reverse_moves:"
|
||||
msgid "With Reverse Moves"
|
||||
msgstr "Amb apunts inversos"
|
||||
|
@ -181,42 +141,6 @@ msgctxt "selection:account.invoice,account_bank:"
|
|||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "selection:account.move.compensation_move.start,account_bank:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "selection:account.move.compensation_move.start,account_bank:"
|
||||
msgid "None"
|
||||
msgstr "Cap"
|
||||
|
||||
msgctxt "selection:account.move.compensation_move.start,account_bank:"
|
||||
msgid "Other"
|
||||
msgstr "Un altre"
|
||||
|
||||
msgctxt "selection:account.move.compensation_move.start,account_bank:"
|
||||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "selection:account.move.line,account_bank:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "selection:account.move.line,account_bank:"
|
||||
msgid "None"
|
||||
msgstr "Cap"
|
||||
|
||||
msgctxt "selection:account.move.line,account_bank:"
|
||||
msgid "Other"
|
||||
msgstr "Un altre"
|
||||
|
||||
msgctxt "selection:account.move.line,account_bank:"
|
||||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "selection:account.move.line,account_kind:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
|
||||
msgctxt "selection:account.payment.type,account_bank:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
|
|
@ -34,14 +34,6 @@ msgstr ""
|
|||
"Los apuntes seleccionados están balanceados. Utilize el asistente de "
|
||||
"conciliación para conciliarlos en lugar de crear un efecto de compensación."
|
||||
|
||||
msgctxt "error:account.move.line:"
|
||||
msgid ""
|
||||
"%s has no any %s bank account.\n"
|
||||
"Please set up one if you want to use this payment type."
|
||||
msgstr ""
|
||||
"%s no tiene ninguna cuenta bancaria %s.\n"
|
||||
"Por favor establezca una si quiere utilizar este tipo de pago."
|
||||
|
||||
msgctxt "error:account.move.line:"
|
||||
msgid "Line \"%s\" (%d) already reconciled."
|
||||
msgstr "El apunte \"%s\" (%d) ya está conciliado."
|
||||
|
@ -94,18 +86,6 @@ msgctxt "field:account.invoice,bank_account:"
|
|||
msgid "Bank Account"
|
||||
msgstr "Cuenta bancaria"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,account_bank:"
|
||||
msgid "Account Bank"
|
||||
msgstr "Cuenta bancaria"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,account_bank_from:"
|
||||
msgid "Account Bank From"
|
||||
msgstr "Cuenta bancaria de"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,bank_account:"
|
||||
msgid "Bank Account"
|
||||
msgstr "Cuenta bancaria"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,id:"
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
@ -118,26 +98,6 @@ msgctxt "field:account.move.compensation_move.start,party:"
|
|||
msgid "Party"
|
||||
msgstr "Terceros"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,payment_kind:"
|
||||
msgid "Payment Kind"
|
||||
msgstr "Clase de pago"
|
||||
|
||||
msgctxt "field:account.move.compensation_move.start,payment_type:"
|
||||
msgid "Payment Type"
|
||||
msgstr "Tipo de pago"
|
||||
|
||||
msgctxt "field:account.move.line,account_bank:"
|
||||
msgid "Account Bank"
|
||||
msgstr "Cuenta bancaria"
|
||||
|
||||
msgctxt "field:account.move.line,account_bank_from:"
|
||||
msgid "Account Bank From"
|
||||
msgstr "Cuenta bancaria de"
|
||||
|
||||
msgctxt "field:account.move.line,bank_account:"
|
||||
msgid "Bank Account"
|
||||
msgstr "Cuenta bancaria"
|
||||
|
||||
msgctxt "field:account.move.line,reverse_moves:"
|
||||
msgid "With Reverse Moves"
|
||||
msgstr "Con apuntes inversos"
|
||||
|
@ -178,42 +138,6 @@ msgctxt "selection:account.invoice,account_bank:"
|
|||
msgid "Party"
|
||||
msgstr "Tercero"
|
||||
|
||||
msgctxt "selection:account.move.compensation_move.start,account_bank:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "selection:account.move.compensation_move.start,account_bank:"
|
||||
msgid "None"
|
||||
msgstr "Ninguno"
|
||||
|
||||
msgctxt "selection:account.move.compensation_move.start,account_bank:"
|
||||
msgid "Other"
|
||||
msgstr "Otro"
|
||||
|
||||
msgctxt "selection:account.move.compensation_move.start,account_bank:"
|
||||
msgid "Party"
|
||||
msgstr "Tercero"
|
||||
|
||||
msgctxt "selection:account.move.line,account_bank:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "selection:account.move.line,account_bank:"
|
||||
msgid "None"
|
||||
msgstr "Ninguno"
|
||||
|
||||
msgctxt "selection:account.move.line,account_bank:"
|
||||
msgid "Other"
|
||||
msgstr "Otro"
|
||||
|
||||
msgctxt "selection:account.move.line,account_bank:"
|
||||
msgid "Party"
|
||||
msgstr "Tercero"
|
||||
|
||||
msgctxt "selection:account.move.line,account_kind:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
|
||||
msgctxt "selection:account.payment.type,account_bank:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
|
|
@ -119,12 +119,12 @@ Create invoice::
|
|||
>>> line.description = 'Test'
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal(20)
|
||||
>>> invoice.untaxed_amount == Decimal(220)
|
||||
True
|
||||
>>> invoice.tax_amount == Decimal(20)
|
||||
True
|
||||
>>> invoice.total_amount == Decimal(240)
|
||||
True
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('220.00')
|
||||
>>> invoice.tax_amount
|
||||
Decimal('20.00')
|
||||
>>> invoice.total_amount
|
||||
Decimal('240.00')
|
||||
>>> invoice.payment_type == receivable_payment_type
|
||||
True
|
||||
>>> invoice.save()
|
||||
|
@ -172,15 +172,13 @@ Partialy reconcile both lines::
|
|||
>>> compensation_move = Wizard('account.move.compensation_move',
|
||||
... models=lines)
|
||||
>>> compensation_move.form.maturity_date = today
|
||||
>>> compensation_move.form.payment_type = receivable_payment_type
|
||||
>>> compensation_move.form.bank_account = None
|
||||
>>> compensation_move.execute('create_move')
|
||||
>>> credit_note.reload()
|
||||
>>> credit_note.amount_to_pay == Decimal('0.0')
|
||||
True
|
||||
>>> credit_note.amount_to_pay
|
||||
Decimal('0.0')
|
||||
>>> invoice.reload()
|
||||
>>> invoice.amount_to_pay == Decimal('196.0')
|
||||
True
|
||||
>>> invoice.amount_to_pay
|
||||
Decimal('196.00')
|
||||
|
||||
|
||||
Create a move that pays the pending amount::
|
||||
|
@ -207,11 +205,10 @@ Create a move that pays the pending amount::
|
|||
>>> line.account = cash
|
||||
>>> line.debit = Decimal('196.0')
|
||||
>>> line.credit = Decimal('0.0')
|
||||
>>> move.save()
|
||||
>>> Move.post([move.id], config.context)
|
||||
>>> move.click('post')
|
||||
>>> invoice.reload()
|
||||
>>> invoice.amount_to_pay == Decimal('196.0')
|
||||
True
|
||||
>>> invoice.amount_to_pay
|
||||
Decimal('196.00')
|
||||
>>> lines = MoveLine.find([
|
||||
... ('account', '=', receivable.id)])
|
||||
>>> to_reconcile = [l for l in lines if not l.reconciliation]
|
||||
|
@ -220,7 +217,7 @@ Create a move that pays the pending amount::
|
|||
>>> reconcile_lines.state == 'end'
|
||||
True
|
||||
>>> invoice.reload()
|
||||
>>> invoice.amount_to_pay == Decimal('0.0')
|
||||
True
|
||||
>>> invoice.amount_to_pay
|
||||
Decimal('0.0')
|
||||
>>> invoice.state
|
||||
u'paid'
|
||||
|
|
|
@ -6,8 +6,4 @@
|
|||
<field name="party"/>
|
||||
<label name="maturity_date"/>
|
||||
<field name="maturity_date"/>
|
||||
<label name="payment_type"/>
|
||||
<field name="payment_type"/>
|
||||
<label name="bank_account"/>
|
||||
<field name="bank_account"/>
|
||||
</form>
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part account_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/notebook/page/field[@name='payment_type']"
|
||||
position="after">
|
||||
<label name="bank_account"/>
|
||||
<field name="bank_account"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in a new issue