Merge move description with description on general ledger line

By using the move origin as fallback of the line origine, the description is
computed as the move description.

Closes #13696
This commit is contained in:
Cédric Krier
2024-11-20 15:14:49 +01:00
parent 1c9682e7ae
commit fe852af844
3 changed files with 8 additions and 28 deletions
+7 -26
View File
@@ -2409,10 +2409,6 @@ class GeneralLedgerLine(DescriptionOriginMixin, ModelSQL, ModelView):
'get_balance')
origin = fields.Reference('Origin', selection='get_origin')
description = fields.Char('Description')
move_description_used = fields.Function(
fields.Char("Move Description"),
'get_move_field',
searcher='search_move_field')
amount_second_currency = Monetary(
"Amount Second Currency",
currency='second_currency', digits='second_currency')
@@ -2466,10 +2462,11 @@ class GeneralLedgerLine(DescriptionOriginMixin, ModelSQL, ModelView):
'internal_balance')
else:
column = (line.debit - line.credit).as_('internal_balance')
elif fname == 'move_description':
column = Column(move, 'description').as_(fname)
elif fname == 'party_required':
column = Column(account, 'party_required').as_(fname)
elif fname in {'origin', 'description'}:
column = Coalesce(
Column(line, fname), Column(move, fname)).as_(fname)
elif (not field_line
or fname == 'state'
or isinstance(field_line, fields.Function)):
@@ -2484,24 +2481,6 @@ class GeneralLedgerLine(DescriptionOriginMixin, ModelSQL, ModelView):
).join(account, condition=line.account == account.id
).select(*columns, where=line_query)
def get_move_field(self, name):
field = getattr(self.__class__, name)
if name.startswith('move_'):
name = name[5:]
value = getattr(self.move, name)
if isinstance(value, ModelSQL):
if field._type == 'reference':
return str(value)
return value.id
return value
@classmethod
def search_move_field(cls, name, clause):
nested = clause[0][len(name):]
if name.startswith('move_'):
name = name[5:]
return [('move.' + name + nested, *clause[1:])]
def get_currency(self, name):
return self.company.currency.id
@@ -2511,8 +2490,10 @@ class GeneralLedgerLine(DescriptionOriginMixin, ModelSQL, ModelView):
@classmethod
def get_origin(cls):
Line = Pool().get('account.move.line')
return Line.get_origin()
pool = Pool()
Move = pool.get('account.move')
Line = pool.get('account.move.line')
return list(set(Move.get_origin()) | set(Line.get_origin()))
def get_balance(self, name):
pool = Pool()
+1 -1
View File
@@ -910,7 +910,7 @@
<text:p text:style-name="P32"><text:placeholder text:placeholder-type="text">&lt;format_currency(line.balance, user.language, company.currency)&gt;</text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Lines.F6" office:value-type="string">
<text:p text:style-name="Table_20_Contents"><text:placeholder text:placeholder-type="text">&lt;line.description or &apos;&apos;&gt;</text:placeholder><text:line-break/><text:placeholder text:placeholder-type="text">&lt;line.move_description_used or &apos;&apos;&gt;</text:placeholder></text:p>
<text:p text:style-name="Table_20_Contents"><text:placeholder text:placeholder-type="text">&lt;line.description or &apos;&apos;&gt;</text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Lines.G6" office:value-type="string">
<text:p text:style-name="Table_20_Contents"><text:placeholder text:placeholder-type="text">&lt;getattr(line.origin, &apos;rec_name&apos;, &apos;&apos;)&gt;</text:placeholder></text:p>
@@ -6,7 +6,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="account" expand="1"/>
<field name="party" expand="1" optional="0"/>
<field name="move" optional="0"/>
<field name="move_description_used" expand="1" optional="1"/>
<field name="description_used" expand="1" optional="1"/>
<field name="origin" optional="1"/>
<field name="reconciliation" optional="1"/>