Remove default account from journal
Also add write off method issue7450 review45551002
This commit is contained in:
1 parent
4a27e24c32
commit
344e7047e5
11 files changed
+157
-56
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Add writeoff method
|
||||
* Remove default account from journal
|
||||
* Add replacement account
|
||||
* Add period on account and tax code
|
||||
* Add template override mechanism to tax rules and tax rule lines
|
||||
|
||||
+1
-1
@@ -44,13 +44,13 @@ def register():
|
||||
Period,
|
||||
Journal,
|
||||
JournalSequence,
|
||||
JournalAccount,
|
||||
JournalCashContext,
|
||||
JournalPeriod,
|
||||
Move,
|
||||
Reconciliation,
|
||||
ConfigurationTaxRounding,
|
||||
Line,
|
||||
WriteOff,
|
||||
OpenJournalAsk,
|
||||
ReconcileLinesWriteOff,
|
||||
ReconcileShow,
|
||||
|
||||
+14
-2
@@ -102,12 +102,24 @@ A Journal contains the following fields:
|
||||
- Name
|
||||
- Code
|
||||
- Active: A checkbox that allow to disable the tax.
|
||||
- Default Credit Account, Default Debit Account: Used as default
|
||||
accounts on move lines for journals of *Cash* type.
|
||||
- Type: By default take one of the following values: *General*,
|
||||
*Revenue*, *Expense*, *Cash*, *Situation*.
|
||||
|
||||
|
||||
Reconcile Write Off
|
||||
*******************
|
||||
|
||||
A reconcile write off is used to set the writeoff options when reconciling
|
||||
unbalanced moves. It has the following fields:
|
||||
|
||||
- Name
|
||||
- Company
|
||||
- Journal: Will be used for creating the write off move
|
||||
- Credit Account and Debit Account: The accounts used for the write off move
|
||||
depending on the amount sign.
|
||||
- Active: A checkbox that allow to disable the writeoff.
|
||||
|
||||
|
||||
Move
|
||||
****
|
||||
|
||||
|
||||
+1
-27
@@ -16,7 +16,7 @@ from trytond.tools.multivalue import migrate_property
|
||||
from trytond.modules.company.model import (
|
||||
CompanyMultiValueMixin, CompanyValueMixin)
|
||||
|
||||
__all__ = ['Journal', 'JournalSequence', 'JournalAccount',
|
||||
__all__ = ['Journal', 'JournalSequence',
|
||||
'JournalCashContext',
|
||||
'JournalPeriod']
|
||||
|
||||
@@ -52,32 +52,6 @@ class Journal(
|
||||
}))
|
||||
sequences = fields.One2Many(
|
||||
'account.journal.sequence', 'journal', "Sequences")
|
||||
credit_account = fields.MultiValue(fields.Many2One(
|
||||
'account.account', "Default Credit Account",
|
||||
domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
states={
|
||||
'required': ((Eval('type').in_(['cash', 'write-off']))
|
||||
& (Eval('context', {}).get('company', -1) != -1)),
|
||||
'invisible': ~Eval('context', {}).get('company', -1),
|
||||
},
|
||||
depends=['type']))
|
||||
debit_account = fields.MultiValue(fields.Many2One(
|
||||
'account.account', "Default Debit Account",
|
||||
domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
states={
|
||||
'required': ((Eval('type').in_(['cash', 'write-off']))
|
||||
& (Eval('context', {}).get('company', -1) != -1)),
|
||||
'invisible': ~Eval('context', {}).get('company', -1),
|
||||
},
|
||||
depends=['type']))
|
||||
accounts = fields.One2Many(
|
||||
'account.journal.account', 'journal', "Accounts")
|
||||
debit = fields.Function(fields.Numeric('Debit',
|
||||
digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits']), 'get_debit_credit_balance')
|
||||
|
||||
@@ -10,7 +10,7 @@ from sql import Null, Literal
|
||||
from sql.aggregate import Sum, Max
|
||||
from sql.conditionals import Coalesce, Case
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, fields, Check
|
||||
from trytond.model import ModelView, ModelSQL, fields, Check, DeactivableMixin
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, StateAction, \
|
||||
StateReport, Button
|
||||
from trytond.report import Report
|
||||
@@ -22,7 +22,7 @@ from trytond.rpc import RPC
|
||||
from trytond.tools import reduce_ids, grouped_slice
|
||||
from trytond.config import config
|
||||
|
||||
__all__ = ['Move', 'Reconciliation', 'Line', 'OpenJournalAsk',
|
||||
__all__ = ['Move', 'Reconciliation', 'Line', 'WriteOff', 'OpenJournalAsk',
|
||||
'OpenJournal', 'OpenAccount',
|
||||
'ReconcileLinesWriteOff', 'ReconcileLines',
|
||||
'UnreconcileLines',
|
||||
@@ -1158,10 +1158,11 @@ class Line(ModelSQL, ModelView):
|
||||
return toolbar
|
||||
|
||||
@classmethod
|
||||
def reconcile(cls, *lines_list, **writeoff):
|
||||
def reconcile(
|
||||
cls, *lines_list, date=None, writeoff=None, description=None):
|
||||
"""
|
||||
Reconcile each list of lines together.
|
||||
The writeoff keys are: journal, date, account and description.
|
||||
The writeoff keys are: date, method and description.
|
||||
"""
|
||||
pool = Pool()
|
||||
Reconciliation = pool.get('account.move.reconciliation')
|
||||
@@ -1185,7 +1186,8 @@ class Line(ModelSQL, ModelView):
|
||||
reconcile_party = line.party
|
||||
if amount:
|
||||
move = cls._get_writeoff_move(
|
||||
reconcile_account, reconcile_party, amount, **writeoff)
|
||||
reconcile_account, reconcile_party, amount,
|
||||
date, writeoff, description)
|
||||
move.save()
|
||||
lines += cls.search([
|
||||
('move', '=', move.id),
|
||||
@@ -1203,7 +1205,7 @@ class Line(ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def _get_writeoff_move(cls, reconcile_account, reconcile_party, amount,
|
||||
journal=None, date=None, account=None, description=None):
|
||||
date=None, writeoff=None, description=None):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
Period = pool.get('account.period')
|
||||
@@ -1211,11 +1213,14 @@ class Line(ModelSQL, ModelView):
|
||||
if not date:
|
||||
date = Date.today()
|
||||
period_id = Period.find(reconcile_account.company.id, date=date)
|
||||
if not account and journal:
|
||||
account = None
|
||||
journal = None
|
||||
if writeoff:
|
||||
if amount >= 0:
|
||||
account = journal.debit_account
|
||||
account = writeoff.debit_account
|
||||
else:
|
||||
account = journal.credit_account
|
||||
account = writeoff.credit_account
|
||||
journal = writeoff.journal
|
||||
|
||||
move = Move()
|
||||
move.journal = journal
|
||||
@@ -1243,6 +1248,33 @@ class Line(ModelSQL, ModelView):
|
||||
return move
|
||||
|
||||
|
||||
class WriteOff(DeactivableMixin, ModelSQL, ModelView):
|
||||
'Reconcile Write Off'
|
||||
__name__ = 'account.move.reconcile.write_off'
|
||||
company = fields.Many2One('company.company', "Company", required=True)
|
||||
name = fields.Char("Name", required=True, translate=True)
|
||||
journal = fields.Many2One('account.journal', "Journal", required=True,
|
||||
domain=[('type', '=', 'write-off')])
|
||||
credit_account = fields.Many2One('account.account', "Credit Account",
|
||||
required=True,
|
||||
domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
depends=['company'])
|
||||
debit_account = fields.Many2One('account.account', "Debit Account",
|
||||
required=True,
|
||||
domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
@classmethod
|
||||
def default_company(cls):
|
||||
return Transaction().context.get('company')
|
||||
|
||||
|
||||
class OpenJournalAsk(ModelView):
|
||||
'Open Journal Ask'
|
||||
__name__ = 'account.move.open_journal.ask'
|
||||
@@ -1368,14 +1400,17 @@ class OpenAccount(Wizard):
|
||||
class ReconcileLinesWriteOff(ModelView):
|
||||
'Reconcile Lines Write-Off'
|
||||
__name__ = 'account.move.reconcile_lines.writeoff'
|
||||
journal = fields.Many2One('account.journal', 'Journal', required=True,
|
||||
company = fields.Many2One('company.company', "Company", readonly=True)
|
||||
writeoff = fields.Many2One('account.move.reconcile.write_off', "Write Off",
|
||||
domain=[
|
||||
('type', '=', 'write-off'),
|
||||
])
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
depends=['company'])
|
||||
date = fields.Date('Date', required=True)
|
||||
amount = fields.Numeric('Amount', digits=(16, Eval('currency_digits', 2)),
|
||||
readonly=True, depends=['currency_digits'])
|
||||
currency_digits = fields.Integer('Currency Digits', readonly=True)
|
||||
currency_digits = fields.Function(fields.Integer('Currency Digits'),
|
||||
'on_change_with_currency_digits')
|
||||
description = fields.Char('Description')
|
||||
|
||||
@staticmethod
|
||||
@@ -1383,6 +1418,11 @@ class ReconcileLinesWriteOff(ModelView):
|
||||
Date = Pool().get('ir.date')
|
||||
return Date.today()
|
||||
|
||||
@fields.depends('company')
|
||||
def on_change_with_currency_digits(self, name=None):
|
||||
if self.company:
|
||||
return self.company.currency.digits
|
||||
|
||||
|
||||
class ReconcileLines(Wizard):
|
||||
'Reconcile Lines'
|
||||
@@ -1419,17 +1459,17 @@ class ReconcileLines(Wizard):
|
||||
amount, company = self.get_writeoff()
|
||||
return {
|
||||
'amount': amount,
|
||||
'currency_digits': company.currency.digits,
|
||||
'company': company.id,
|
||||
}
|
||||
|
||||
def transition_reconcile(self):
|
||||
Line = Pool().get('account.move.line')
|
||||
|
||||
journal = getattr(self.writeoff, 'journal', None)
|
||||
writeoff = getattr(self.writeoff, 'writeoff', None)
|
||||
date = getattr(self.writeoff, 'date', None)
|
||||
description = getattr(self.writeoff, 'description', None)
|
||||
Line.reconcile(Line.browse(Transaction().context['active_ids']),
|
||||
journal=journal, date=date, description=description)
|
||||
writeoff=writeoff, date=date, description=description)
|
||||
return 'end'
|
||||
|
||||
|
||||
|
||||
@@ -348,6 +348,50 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">move_cancel_default_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="reconcile_writeoff_view_form">
|
||||
<field name="model">account.move.reconcile.write_off</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">writeoff_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="reconcile_writeoff_view_list">
|
||||
<field name="model">account.move.reconcile.write_off</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">writeoff_tree</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_reconcile_writeoff_form">
|
||||
<field name="name">WriteOff Methods</field>
|
||||
<field name="res_model">account.move.reconcile.write_off</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_reconcile_writeoff_form_view1">
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="view" ref="reconcile_writeoff_view_list"/>
|
||||
<field name="act_window" ref="act_reconcile_writeoff_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_reconcile_writeoff_form_view2">
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="view" ref="reconcile_writeoff_view_form"/>
|
||||
<field name="act_window" ref="act_reconcile_writeoff_form"/>
|
||||
</record>
|
||||
<menuitem parent="menu_journal_configuration"
|
||||
action="act_reconcile_writeoff_form"
|
||||
id="menu_reconcile_writeoff_form"/>
|
||||
|
||||
<record model="ir.model.access" id="access_reconcile_writeoff">
|
||||
<field name="model" search="[('model', '=', 'account.move.reconcile.write_off')]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_delete" eval="False"/>
|
||||
</record>
|
||||
<record model="ir.model.access" id="access_reconcile_writeoff_account_admin">
|
||||
<field name="model" search="[('model', '=', 'account.move.reconcile.write_off')]"/>
|
||||
<field name="group" ref="group_account_admin"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="True"/>
|
||||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="print_general_journal_start_view_form">
|
||||
<field name="model">account.move.print_general_journal.start</field>
|
||||
<field name="type">form</field>
|
||||
|
||||
@@ -124,19 +124,28 @@ Create Moves for writeoff reconciliation::
|
||||
>>> move.save()
|
||||
>>> reconcile2, = [l for l in move.lines if l.account == receivable]
|
||||
|
||||
Reconcile Lines with writeoff::
|
||||
Create a writeof payment method::
|
||||
|
||||
|
||||
>>> Sequence = Model.get('ir.sequence')
|
||||
>>> sequence_journal, = Sequence.find([('code', '=', 'account.journal')])
|
||||
>>> journal_writeoff = Journal(name='Write-Off', type='write-off',
|
||||
... sequence=sequence_journal,
|
||||
... credit_account=revenue, debit_account=expense)
|
||||
... sequence=sequence_journal)
|
||||
>>> journal_writeoff.save()
|
||||
>>> WriteOff = Model.get('account.move.reconcile.write_off')
|
||||
>>> writeoff_method = WriteOff()
|
||||
>>> writeoff_method.name = 'Write Off'
|
||||
>>> writeoff_method.journal = journal_writeoff
|
||||
>>> writeoff_method.debit_account = expense
|
||||
>>> writeoff_method.credit_account = expense
|
||||
>>> writeoff_method.save()
|
||||
|
||||
Reconcile Lines with writeoff::
|
||||
>>> reconcile_lines = Wizard('account.move.reconcile_lines',
|
||||
... [reconcile1, reconcile2])
|
||||
>>> reconcile_lines.form_state == 'writeoff'
|
||||
True
|
||||
>>> reconcile_lines.form.journal = journal_writeoff
|
||||
>>> reconcile_lines.form.writeoff = writeoff_method
|
||||
>>> reconcile_lines.execute('reconcile')
|
||||
>>> reconcile1.reload()
|
||||
>>> reconcile2.reload()
|
||||
|
||||
@@ -14,10 +14,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="type"/>
|
||||
<label name="sequence"/>
|
||||
<field name="sequence"/>
|
||||
<label name="debit_account"/>
|
||||
<field name="debit_account"/>
|
||||
<label name="credit_account"/>
|
||||
<field name="credit_account"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
@@ -6,8 +6,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="amount"/>
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
<label name="journal"/>
|
||||
<field name="journal"/>
|
||||
<label name="writeoff"/>
|
||||
<field name="writeoff"/>
|
||||
<newline/>
|
||||
<label name="description"/>
|
||||
<field name="description" colspan="3"/>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<label name="active"/>
|
||||
<field name="active"/>
|
||||
<label name="journal"/>
|
||||
<field name="journal"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<label name="debit_account"/>
|
||||
<field name="debit_account"/>
|
||||
<label name="credit_account"/>
|
||||
<field name="credit_account"/>
|
||||
</form>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="company"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
Reference in new issue
Block a user