@@ -0,0 +1,38 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from sql import Literal
|
||||
|
||||
from trytond.pool import Pool
|
||||
|
||||
|
||||
class AbstractMixin:
|
||||
__slots__ = ()
|
||||
|
||||
@classmethod
|
||||
def _joins(cls):
|
||||
pool = Pool()
|
||||
Product = pool.get('product.product')
|
||||
Template = pool.get('product.template')
|
||||
from_item, tables, withs = super()._joins()
|
||||
if 'line.product' not in tables:
|
||||
product = Product.__table__()
|
||||
tables['line.product'] = product
|
||||
line = tables['line']
|
||||
from_item = (from_item
|
||||
.join(product, condition=line.product == product.id))
|
||||
else:
|
||||
product = tables['line.product']
|
||||
if 'line.product.template' not in tables:
|
||||
template = Template.__table__()
|
||||
tables['line.product.template'] = template
|
||||
from_item = (from_item
|
||||
.join(template, condition=product.template == template.id))
|
||||
return from_item, tables, withs
|
||||
|
||||
@classmethod
|
||||
def _where(cls, tables, withs):
|
||||
template = tables['line.product.template']
|
||||
where = super()._where(tables, withs)
|
||||
where &= template.gift_card != Literal(True)
|
||||
return where
|
||||
@@ -31,6 +31,7 @@ Activate modules::
|
||||
>>> ProductUoM = Model.get('product.uom')
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> SaleConfig = Model.get('sale.configuration')
|
||||
>>> SaleReporting = Model.get('sale.reporting.main')
|
||||
>>> Sequence = Model.get('ir.sequence')
|
||||
>>> SequenceType = Model.get('ir.sequence.type')
|
||||
|
||||
@@ -182,3 +183,9 @@ Check the invoice::
|
||||
>>> gift_card_line.quantity
|
||||
-1.0
|
||||
>>> assertEqual(gift_card_line.account, gift_card_revenue)
|
||||
|
||||
Check sale reporting::
|
||||
|
||||
>>> report, = SaleReporting.find([])
|
||||
>>> report.revenue
|
||||
Decimal('100.00')
|
||||
|
||||
@@ -45,3 +45,6 @@ model:
|
||||
sale.POSPayGiftCard
|
||||
wizard:
|
||||
sale.POSPay
|
||||
|
||||
[register_mixin]
|
||||
sale_reporting.AbstractMixin: trytond.modules.sale.sale_reporting.Abstract
|
||||
|
||||
Reference in New Issue
Block a user