changeset 6d5b54a35e05 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset&node=6d5b54a35e05
description:
Add company to reconciliation
issue10195
review359321021
diffstat:
move.py | 38 ++++++++++++++++++++++++++++++++------
view/move_reconciliation_form.xml | 4 ++++
view/move_reconciliation_tree.xml | 1 +
3 files changed, 37 insertions(+), 6 deletions(-)
diffs (117 lines):
diff -r 25fa27914f88 -r 6d5b54a35e05 move.py
--- a/move.py Sun Mar 21 16:09:12 2021 +0100
+++ b/move.py Sun Mar 21 22:38:05 2021 +0100
@@ -449,12 +449,21 @@
'Account Move Reconciliation Lines'
__name__ = 'account.move.reconciliation'
name = fields.Char('Name', size=None, required=True)
- lines = fields.One2Many('account.move.line', 'reconciliation',
- 'Lines')
+ company = fields.Many2One('company.company', "Company", required=True)
+ lines = fields.One2Many(
+ 'account.move.line', 'reconciliation', 'Lines',
+ domain=[
+ ('move.company', '=', Eval('company', -1)),
+ ],
+ depends=['company'])
date = fields.Date('Date', required=True, select=True,
help='Highest date of the reconciled lines.')
delegate_to = fields.Many2One(
'account.move.line', "Delegate To", ondelete="RESTRICT", select=True,
+ domain=[
+ ('move.company', '=', Eval('company', -1)),
+ ],
+ depends=['company'],
help="The line to which the reconciliation status is delegated.")
@classmethod
@@ -467,8 +476,10 @@
Line = pool.get('account.move.line')
move = Move.__table__()
line = Line.__table__()
+ line_h = Line.__table_handler__(module_name)
date_exist = table.column_exist('date')
+ company_exist = table.column_exist('company')
super(Reconciliation, cls).__register__(module_name)
@@ -484,6 +495,20 @@
where=line.reconciliation == sql_table.id,
group_by=line.reconciliation)))
+ # Migration from 5.8: add company field
+ if not company_exist and line_h.column_exist('reconciliation'):
+ value = (line
+ .join(move, condition=line.move == move.id)
+ .select(
+ move.company,
+ where=line.reconciliation == sql_table.id,
+ group_by=move.company))
+ cursor.execute(*sql_table.update([sql_table.company], [value]))
+
+ @classmethod
+ def default_company(cls):
+ return Transaction().context.get('company')
+
@classmethod
def create(cls, vlist):
pool = Pool()
@@ -559,11 +584,10 @@
line=line.rec_name,
party1=line.party.rec_name,
party2=party.rec_name))
- if (account
- and not account.company.currency.is_zero(debit - credit)):
+ if not reconciliation.company.currency.is_zero(debit - credit):
lang = Lang.get()
- debit = lang.currency(debit, account.company.currency)
- credit = lang.currency(credit, account.company.currency)
+ debit = lang.currency(debit, reconciliation.company.currency)
+ credit = lang.currency(credit, reconciliation.company.currency)
raise ReconciliationError(
gettext('account.msg_reconciliation_unbalanced',
debit=debit,
@@ -1261,6 +1285,7 @@
or Decimal('0.0')),
], limit=1)
reconciliations.append({
+ 'company': reconcile_account.company,
'lines': [('add', [x.id for x in lines])],
'date': max(l.date for l in lines),
'delegate_to': delegate_to,
@@ -1287,6 +1312,7 @@
journal = writeoff.journal
move = Move()
+ move.company = reconcile_account.company
move.journal = journal
move.period = period_id
move.date = date
diff -r 25fa27914f88 -r 6d5b54a35e05 view/move_reconciliation_form.xml
--- a/view/move_reconciliation_form.xml Sun Mar 21 16:09:12 2021 +0100
+++ b/view/move_reconciliation_form.xml Sun Mar 21 22:38:05 2021 +0100
@@ -4,9 +4,13 @@
<form>
<label name="name"/>
<field name="name"/>
+ <label name="company"/>
+ <field name="company"/>
+
<label name="date"/>
<field name="date"/>
<label name="delegate_to"/>
<field name="delegate_to"/>
+
<field name="lines" colspan="4"/>
</form>
diff -r 25fa27914f88 -r 6d5b54a35e05 view/move_reconciliation_tree.xml
--- a/view/move_reconciliation_tree.xml Sun Mar 21 16:09:12 2021 +0100
+++ b/view/move_reconciliation_tree.xml Sun Mar 21 22:38:05 2021 +0100
@@ -4,5 +4,6 @@
<tree>
<field name="name"/>
<field name="date"/>
+ <field name="company"/>
<field name="delegate_to"/>
</tree>