FIX get accounting amount because active account is now function field (ActivePeriodMixin)

This commit is contained in:
Raimon Esteve 2018-09-19 00:03:49 +02:00
parent 460ce14037
commit a3a382a116
2 changed files with 16 additions and 5 deletions

View File

@ -71,6 +71,7 @@ class Party(metaclass=PoolMeta):
company_id = user.company.id
amount = Coalesce(line.debit, 0) - Coalesce(line.credit, 0)
# TODO where account active with ActivePeriodMixin
cursor.execute(*line.join(account,
condition=account.id == line.account
).select(line.party,
@ -79,8 +80,7 @@ class Party(metaclass=PoolMeta):
Sum(Case((line.maturity_date == None or
line.maturity_date >= today, amount),
else_=Literal(0))).as_('pending_amount'),
where=account.active
& (account.kind == 'receivable')
where=(account.kind == 'receivable')
& (line.reconciliation == None)
& (account.company == company_id)
& line_query,

View File

@ -98,6 +98,19 @@ Create party::
>>> party.amount_to_limit == Decimal('1000.0')
True
Create account categories::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_expense = expense
>>> account_category.account_revenue = revenue
>>> account_category.save()
>>> account_category_tax, = account_category.duplicate()
>>> account_category_tax.customer_taxes.append(tax)
>>> account_category_tax.save()
Create product::
>>> ProductUom = Model.get('product.uom')
@ -111,9 +124,7 @@ Create product::
>>> template.purchasable = True
>>> template.salable = True
>>> template.list_price = Decimal('10')
>>> template.account_expense = expense
>>> template.account_revenue = revenue
>>> template.customer_taxes.append(tax)
>>> template.account_category = account_category_tax
>>> template.save()
>>> product, = template.products