GL detail
This commit is contained in:
@@ -2661,51 +2661,39 @@ class GeneralLedgerDetail(DescriptionOriginMixin, ModelSQL, ModelView):
|
|||||||
posting_date = fields.Date("Posting Date")
|
posting_date = fields.Date("Posting Date")
|
||||||
journal = fields.Many2One('account.journal', "Journal")
|
journal = fields.Many2One('account.journal', "Journal")
|
||||||
journal_entry_number = fields.Char("Journal Entry Number")
|
journal_entry_number = fields.Char("Journal Entry Number")
|
||||||
document_number = fields.Char("Document Number")
|
document_number = fields.Function(
|
||||||
|
fields.Char("Document Number"), 'get_document_field')
|
||||||
voucher_number = fields.Char("Voucher Number")
|
voucher_number = fields.Char("Voucher Number")
|
||||||
document_type = fields.Char("Document Type")
|
document_type = fields.Function(
|
||||||
|
fields.Char("Document Type"), 'get_document_field')
|
||||||
document_date = fields.Date("Document Date")
|
document_date = fields.Date("Document Date")
|
||||||
supplier_invoice_number = fields.Char("Supplier Invoice Number")
|
|
||||||
posting_status = fields.Selection([
|
posting_status = fields.Selection([
|
||||||
('draft', "Draft"),
|
('draft', "Draft"),
|
||||||
('posted', "Posted"),
|
('posted', "Posted"),
|
||||||
], "Posting Status", sort=False)
|
], "Posting Status", sort=False)
|
||||||
|
|
||||||
party = fields.Many2One('party.party', "Party")
|
party = fields.Many2One('party.party', "Party")
|
||||||
counterparty = fields.Function(
|
|
||||||
fields.Char("Counterparty"), 'get_counterparty')
|
|
||||||
move = fields.Many2One('account.move', "Move")
|
move = fields.Many2One('account.move', "Move")
|
||||||
|
move_line = fields.Many2One('account.move.line', "Move Line")
|
||||||
origin = fields.Reference('Origin', selection='get_origin')
|
origin = fields.Reference('Origin', selection='get_origin')
|
||||||
description = fields.Char("Description")
|
description = fields.Char("Line Desc.")
|
||||||
|
move_description = fields.Char("Description")
|
||||||
reference = fields.Char("Reference")
|
reference = fields.Char("Reference")
|
||||||
|
|
||||||
debit_base_currency = Monetary(
|
debit_base_currency = fields.Numeric("Debit Base Currency")
|
||||||
"Debit Base Currency", currency='base_currency',
|
credit_base_currency = fields.Numeric("Credit Base Currency")
|
||||||
digits='base_currency')
|
balance_base_currency = fields.Numeric("Balance Base Currency")
|
||||||
credit_base_currency = Monetary(
|
running_balance_base_currency = fields.Numeric(
|
||||||
"Credit Base Currency", currency='base_currency',
|
"Running Balance Base Currency")
|
||||||
digits='base_currency')
|
|
||||||
balance_base_currency = Monetary(
|
|
||||||
"Balance Base Currency", currency='base_currency',
|
|
||||||
digits='base_currency')
|
|
||||||
running_balance_base_currency = Monetary(
|
|
||||||
"Running Balance Base Currency", currency='base_currency',
|
|
||||||
digits='base_currency')
|
|
||||||
|
|
||||||
debit_transaction_currency = Monetary(
|
debit_transaction_currency = fields.Numeric("Debit Transaction Currency")
|
||||||
"Debit Transaction Currency", currency='transaction_currency',
|
credit_transaction_currency = fields.Numeric("Credit Transaction Currency")
|
||||||
digits='transaction_currency')
|
balance_transaction_currency = fields.Numeric(
|
||||||
credit_transaction_currency = Monetary(
|
"Balance Transaction Currency")
|
||||||
"Credit Transaction Currency", currency='transaction_currency',
|
running_balance_transaction_currency = fields.Numeric(
|
||||||
digits='transaction_currency')
|
"Running Balance Transaction Currency")
|
||||||
balance_transaction_currency = Monetary(
|
|
||||||
"Balance Transaction Currency", currency='transaction_currency',
|
|
||||||
digits='transaction_currency')
|
|
||||||
running_balance_transaction_currency = Monetary(
|
|
||||||
"Running Balance Transaction Currency",
|
|
||||||
currency='transaction_currency', digits='transaction_currency')
|
|
||||||
|
|
||||||
payable_qty = fields.Numeric("Payable Qty")
|
payable_qty = fields.Numeric("Quantity")
|
||||||
uom = fields.Char("UoM")
|
uom = fields.Char("UoM")
|
||||||
|
|
||||||
entered_by = fields.Many2One('res.user', "Entered By")
|
entered_by = fields.Many2One('res.user', "Entered By")
|
||||||
@@ -2851,9 +2839,37 @@ class GeneralLedgerDetail(DescriptionOriginMixin, ModelSQL, ModelView):
|
|||||||
company = Company.__table__()
|
company = Company.__table__()
|
||||||
return Line, line, move, account, company
|
return Line, line, move, account, company
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _lot_tables(cls, Line):
|
||||||
|
if 'lot' not in Line._fields:
|
||||||
|
return None, None
|
||||||
|
pool = Pool()
|
||||||
|
try:
|
||||||
|
Lot = pool.get('lot.lot')
|
||||||
|
Uom = pool.get('product.uom')
|
||||||
|
except KeyError:
|
||||||
|
return None, None
|
||||||
|
return Lot.__table__(), Uom.__table__()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _line_query(cls, name, context):
|
def _line_query(cls, name, context):
|
||||||
Line, line, move, account, company = cls._tables()
|
Line, line, move, account, company = cls._tables()
|
||||||
|
lot, uom = cls._lot_tables(Line)
|
||||||
|
account_label = (
|
||||||
|
Coalesce(account.code, '')
|
||||||
|
+ Literal(' - ')
|
||||||
|
+ Coalesce(account.name, ''))
|
||||||
|
quantity = Literal(None)
|
||||||
|
unit = Literal(None)
|
||||||
|
from_ = (line.join(move, condition=line.move == move.id)
|
||||||
|
.join(account, condition=line.account == account.id)
|
||||||
|
.join(company, condition=move.company == company.id))
|
||||||
|
if lot is not None:
|
||||||
|
from_ = (from_
|
||||||
|
.join(lot, 'LEFT', condition=Column(line, 'lot') == lot.id)
|
||||||
|
.join(uom, 'LEFT', condition=lot.lot_unit_line == uom.id))
|
||||||
|
quantity = lot.lot_qt
|
||||||
|
unit = uom.symbol
|
||||||
tx_currency = Coalesce(line.second_currency, company.currency)
|
tx_currency = Coalesce(line.second_currency, company.currency)
|
||||||
base_amount = Coalesce(line.debit, 0) - Coalesce(line.credit, 0)
|
base_amount = Coalesce(line.debit, 0) - Coalesce(line.credit, 0)
|
||||||
second_amount = Coalesce(line.amount_second_currency, 0)
|
second_amount = Coalesce(line.amount_second_currency, 0)
|
||||||
@@ -2879,10 +2895,7 @@ class GeneralLedgerDetail(DescriptionOriginMixin, ModelSQL, ModelView):
|
|||||||
[line.account, tx_currency],
|
[line.account, tx_currency],
|
||||||
order_by=[move.date.asc, move.number.asc, line.id.asc])
|
order_by=[move.date.asc, move.number.asc, line.id.asc])
|
||||||
|
|
||||||
return (line.join(move, condition=line.move == move.id)
|
return from_.select(
|
||||||
.join(account, condition=line.account == account.id)
|
|
||||||
.join(company, condition=move.company == company.id)
|
|
||||||
.select(
|
|
||||||
(line.id * 3).as_('id'),
|
(line.id * 3).as_('id'),
|
||||||
line.create_uid.as_('create_uid'),
|
line.create_uid.as_('create_uid'),
|
||||||
line.create_date.as_('create_date'),
|
line.create_date.as_('create_date'),
|
||||||
@@ -2892,24 +2905,22 @@ class GeneralLedgerDetail(DescriptionOriginMixin, ModelSQL, ModelView):
|
|||||||
Literal(1).as_('row_sequence'),
|
Literal(1).as_('row_sequence'),
|
||||||
move.company.as_('company'),
|
move.company.as_('company'),
|
||||||
line.account.as_('account'),
|
line.account.as_('account'),
|
||||||
account.code.as_('account_code'),
|
account_label.as_('account_code'),
|
||||||
account.name.as_('account_name'),
|
account.name.as_('account_name'),
|
||||||
tx_currency.as_('transaction_currency'),
|
tx_currency.as_('transaction_currency'),
|
||||||
company.currency.as_('base_currency'),
|
company.currency.as_('base_currency'),
|
||||||
move.date.as_('posting_date'),
|
move.date.as_('posting_date'),
|
||||||
move.journal.as_('journal'),
|
move.journal.as_('journal'),
|
||||||
Coalesce(move.post_number, move.number).as_(
|
move.number.as_('journal_entry_number'),
|
||||||
'journal_entry_number'),
|
move.post_number.as_('voucher_number'),
|
||||||
Coalesce(move.ext_ref, move.number).as_('document_number'),
|
|
||||||
move.number.as_('voucher_number'),
|
|
||||||
move.origin.as_('document_type'),
|
|
||||||
move.date.as_('document_date'),
|
move.date.as_('document_date'),
|
||||||
Literal(None).as_('supplier_invoice_number'),
|
|
||||||
move.state.as_('posting_status'),
|
move.state.as_('posting_status'),
|
||||||
line.party.as_('party'),
|
line.party.as_('party'),
|
||||||
line.move.as_('move'),
|
line.move.as_('move'),
|
||||||
line.origin.as_('origin'),
|
line.id.as_('move_line'),
|
||||||
|
move.origin.as_('origin'),
|
||||||
line.description.as_('description'),
|
line.description.as_('description'),
|
||||||
|
move.description.as_('move_description'),
|
||||||
Coalesce(move.ext_ref, move.description).as_('reference'),
|
Coalesce(move.ext_ref, move.description).as_('reference'),
|
||||||
line.debit.as_('debit_base_currency'),
|
line.debit.as_('debit_base_currency'),
|
||||||
line.credit.as_('credit_base_currency'),
|
line.credit.as_('credit_base_currency'),
|
||||||
@@ -2921,17 +2932,21 @@ class GeneralLedgerDetail(DescriptionOriginMixin, ModelSQL, ModelView):
|
|||||||
tx_amount.as_('balance_transaction_currency'),
|
tx_amount.as_('balance_transaction_currency'),
|
||||||
Sum(tx_amount, window=window).as_(
|
Sum(tx_amount, window=window).as_(
|
||||||
'running_balance_transaction_currency'),
|
'running_balance_transaction_currency'),
|
||||||
Literal(None).as_('payable_qty'),
|
quantity.as_('payable_qty'),
|
||||||
Literal(None).as_('uom'),
|
unit.as_('uom'),
|
||||||
line.create_uid.as_('entered_by'),
|
line.create_uid.as_('entered_by'),
|
||||||
line.create_date.as_('entered_date'),
|
line.create_date.as_('entered_date'),
|
||||||
line.write_uid.as_('modified_by'),
|
line.write_uid.as_('modified_by'),
|
||||||
line.write_date.as_('modified_date'),
|
line.write_date.as_('modified_date'),
|
||||||
where=where))
|
where=where)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _summary_query(cls, name, context):
|
def _summary_query(cls, name, context):
|
||||||
Line, line, move, account, company = cls._tables()
|
Line, line, move, account, company = cls._tables()
|
||||||
|
account_label = (
|
||||||
|
Coalesce(account.code, '')
|
||||||
|
+ Literal(' - ')
|
||||||
|
+ Coalesce(account.name, ''))
|
||||||
tx_currency = Coalesce(line.second_currency, company.currency)
|
tx_currency = Coalesce(line.second_currency, company.currency)
|
||||||
base_amount = Coalesce(line.debit, 0) - Coalesce(line.credit, 0)
|
base_amount = Coalesce(line.debit, 0) - Coalesce(line.credit, 0)
|
||||||
tx_amount = Case(
|
tx_amount = Case(
|
||||||
@@ -2962,23 +2977,22 @@ class GeneralLedgerDetail(DescriptionOriginMixin, ModelSQL, ModelView):
|
|||||||
Literal(row_sequence).as_('row_sequence'),
|
Literal(row_sequence).as_('row_sequence'),
|
||||||
move.company.as_('company'),
|
move.company.as_('company'),
|
||||||
line.account.as_('account'),
|
line.account.as_('account'),
|
||||||
account.code.as_('account_code'),
|
account_label.as_('account_code'),
|
||||||
account.name.as_('account_name'),
|
account.name.as_('account_name'),
|
||||||
tx_currency.as_('transaction_currency'),
|
tx_currency.as_('transaction_currency'),
|
||||||
company.currency.as_('base_currency'),
|
company.currency.as_('base_currency'),
|
||||||
Literal(None).as_('posting_date'),
|
Literal(None).as_('posting_date'),
|
||||||
Literal(None).as_('journal'),
|
Literal(None).as_('journal'),
|
||||||
Literal(None).as_('journal_entry_number'),
|
Literal(None).as_('journal_entry_number'),
|
||||||
Literal(None).as_('document_number'),
|
|
||||||
Literal(None).as_('voucher_number'),
|
Literal(None).as_('voucher_number'),
|
||||||
Literal(None).as_('document_type'),
|
|
||||||
Literal(None).as_('document_date'),
|
Literal(None).as_('document_date'),
|
||||||
Literal(None).as_('supplier_invoice_number'),
|
|
||||||
Literal(None).as_('posting_status'),
|
Literal(None).as_('posting_status'),
|
||||||
Literal(None).as_('party'),
|
Literal(None).as_('party'),
|
||||||
Literal(None).as_('move'),
|
Literal(None).as_('move'),
|
||||||
|
Literal(None).as_('move_line'),
|
||||||
Literal(None).as_('origin'),
|
Literal(None).as_('origin'),
|
||||||
Literal(name.title()).as_('description'),
|
Literal(name.title()).as_('description'),
|
||||||
|
Literal(None).as_('move_description'),
|
||||||
Literal(None).as_('reference'),
|
Literal(None).as_('reference'),
|
||||||
Literal(0).as_('debit_base_currency'),
|
Literal(0).as_('debit_base_currency'),
|
||||||
Literal(0).as_('credit_base_currency'),
|
Literal(0).as_('credit_base_currency'),
|
||||||
@@ -3012,12 +3026,58 @@ class GeneralLedgerDetail(DescriptionOriginMixin, ModelSQL, ModelView):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_origin(cls):
|
def get_origin(cls):
|
||||||
Line = Pool().get('account.move.line')
|
Move = Pool().get('account.move')
|
||||||
return Line.get_origin()
|
return Move.get_origin()
|
||||||
|
|
||||||
def get_counterparty(self, name):
|
def _get_related_payment(self):
|
||||||
if self.party:
|
if not self.move_line:
|
||||||
return self.party.rec_name
|
return None
|
||||||
|
try:
|
||||||
|
Payment = Pool().get('account.payment')
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
payments = Payment.search([('line', '=', self.move_line.id)], limit=1)
|
||||||
|
return payments[0] if payments else None
|
||||||
|
|
||||||
|
def get_document_field(self, name):
|
||||||
|
origin = self.move.origin if self.move else None
|
||||||
|
if origin:
|
||||||
|
model_name = origin.__name__
|
||||||
|
if model_name == 'account.invoice':
|
||||||
|
if name == 'document_number':
|
||||||
|
return origin.number or origin.reference
|
||||||
|
side = {
|
||||||
|
'out': 'Customer',
|
||||||
|
'in': 'Supplier',
|
||||||
|
}.get(origin.type, '')
|
||||||
|
stage = ''
|
||||||
|
reference = (origin.reference or '').lower()
|
||||||
|
if 'provisional' in reference:
|
||||||
|
stage = 'Provisional'
|
||||||
|
elif 'final' in reference:
|
||||||
|
stage = 'Final'
|
||||||
|
return ' '.join(filter(None, ['Invoice', side, stage]))
|
||||||
|
if model_name == 'account.payment':
|
||||||
|
if name == 'document_number':
|
||||||
|
return origin.number
|
||||||
|
side = {
|
||||||
|
'receivable': 'Customer',
|
||||||
|
'payable': 'Supplier',
|
||||||
|
}.get(origin.kind, '')
|
||||||
|
return ' '.join(filter(None, ['Payment', side]))
|
||||||
|
if name == 'document_number':
|
||||||
|
return getattr(origin, 'number', None) or getattr(
|
||||||
|
origin, 'reference', None)
|
||||||
|
return getattr(origin, 'rec_name', None) or model_name
|
||||||
|
payment = self._get_related_payment()
|
||||||
|
if payment:
|
||||||
|
if name == 'document_number':
|
||||||
|
return payment.number
|
||||||
|
side = {
|
||||||
|
'receivable': 'Customer',
|
||||||
|
'payable': 'Supplier',
|
||||||
|
}.get(payment.kind, '')
|
||||||
|
return ' '.join(filter(None, ['Payment', side]))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<tree>
|
<tree>
|
||||||
<field name="row_type"/>
|
<field name="row_type"/>
|
||||||
<field name="account_code"/>
|
<field name="account_code" expand="1"/>
|
||||||
<field name="account_name" expand="1"/>
|
|
||||||
<field name="transaction_currency"/>
|
<field name="transaction_currency"/>
|
||||||
|
<field name="base_currency" optional="1"/>
|
||||||
<field name="posting_date"/>
|
<field name="posting_date"/>
|
||||||
<field name="journal"/>
|
<field name="journal"/>
|
||||||
<field name="journal_entry_number"/>
|
<field name="journal_entry_number"/>
|
||||||
@@ -13,11 +13,10 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<field name="voucher_number" optional="1"/>
|
<field name="voucher_number" optional="1"/>
|
||||||
<field name="document_type" optional="1"/>
|
<field name="document_type" optional="1"/>
|
||||||
<field name="document_date" optional="1"/>
|
<field name="document_date" optional="1"/>
|
||||||
<field name="supplier_invoice_number" optional="1"/>
|
|
||||||
<field name="posting_status" optional="1"/>
|
<field name="posting_status" optional="1"/>
|
||||||
<field name="party" optional="1"/>
|
<field name="party" optional="1"/>
|
||||||
<field name="counterparty" optional="1"/>
|
|
||||||
<field name="description" expand="1" optional="1"/>
|
<field name="description" expand="1" optional="1"/>
|
||||||
|
<field name="move_description" expand="1" optional="1"/>
|
||||||
<field name="reference" optional="1"/>
|
<field name="reference" optional="1"/>
|
||||||
<field name="origin" optional="1"/>
|
<field name="origin" optional="1"/>
|
||||||
<field name="debit_base_currency" sum="1"/>
|
<field name="debit_base_currency" sum="1"/>
|
||||||
@@ -35,6 +34,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<field name="modified_by" optional="1"/>
|
<field name="modified_by" optional="1"/>
|
||||||
<field name="modified_date" optional="1"/>
|
<field name="modified_date" optional="1"/>
|
||||||
<field name="move" optional="1"/>
|
<field name="move" optional="1"/>
|
||||||
|
<field name="move_line" optional="1"/>
|
||||||
<field name="company" optional="1"/>
|
<field name="company" optional="1"/>
|
||||||
<field name="base_currency" optional="1"/>
|
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
Reference in New Issue
Block a user