add context shops in reports
This commit is contained in:
parent
0afb52531a
commit
6e1e23ce15
|
@ -16,6 +16,7 @@ def register():
|
|||
sale.SaleGoalAnnualRankingStart,
|
||||
sale.SaleDetailedStart,
|
||||
sale.ShopDailySummaryStart,
|
||||
sale.InvoicesStart,
|
||||
account.PrintBalanceSheetCOLGAAPStart,
|
||||
account.PrintIncomeStatementCOLGAAPStart,
|
||||
module='syncronize_companies', type_='model')
|
||||
|
@ -23,6 +24,9 @@ def register():
|
|||
sale.SaleDailyReport,
|
||||
sale.SaleDetailedReport,
|
||||
sale.PortfolioDetailedReport,
|
||||
sale.ExpiredPortfolioReport,
|
||||
sale.PortfolioBySalesmanReport,
|
||||
sale.MovesInvoicesReport,
|
||||
account.BalanceSheetCOLGAAP,
|
||||
account.IncomeStatementCOLGAAP,
|
||||
module='syncronize_companies', type_='report')
|
||||
|
|
67
sale.py
67
sale.py
|
@ -16,12 +16,21 @@ from trytond.report import Report
|
|||
__all__ = [
|
||||
'SaleIncomeDailyStart', 'SaleDailyReport',
|
||||
'SaleMonthByShopStart', 'SaleGoalMonthRankingReport', 'SaleDetailedStart',
|
||||
'SaleDetailedReport', 'ShopDailySummaryStart', 'PortfolioDetailedReport'
|
||||
'SaleDetailedReport', 'ShopDailySummaryStart', 'PortfolioDetailedReport',
|
||||
'ExpiredPortfolioReport', 'InvoicesStart', 'PortfolioBySalesmanReport',
|
||||
'MovesInvoicesReport'
|
||||
]
|
||||
|
||||
_ZERO = Decimal('0.00')
|
||||
|
||||
|
||||
def get_shops_user():
|
||||
User = Pool().get('res.user')
|
||||
user = User(Transaction().user)
|
||||
shops = [s.id for s in user.shops]
|
||||
return shops
|
||||
|
||||
|
||||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
|
||||
|
@ -237,14 +246,62 @@ class ShopDailySummaryStart(metaclass=PoolMeta):
|
|||
)
|
||||
|
||||
|
||||
class PortfolioDetailedReport(Report):
|
||||
class PortfolioDetailedReport(metaclass=PoolMeta):
|
||||
__name__ = 'party.portfolio_detailed.report'
|
||||
|
||||
@classmethod
|
||||
def get_domain_invoice(cls, domain, data):
|
||||
User = Pool().get('res.user')
|
||||
user = User(Transaction().user)
|
||||
shops = [s.id for s in user.shops]
|
||||
shops = get_shops_user()
|
||||
dom = [('shop', 'in', shops)]
|
||||
domain.extend(dom)
|
||||
return domain
|
||||
|
||||
|
||||
class ExpiredPortfolioReport(metaclass=PoolMeta):
|
||||
__name__ = 'invoice_report.expired_portfolio_report'
|
||||
|
||||
@classmethod
|
||||
def get_domain_invoice(cls, data):
|
||||
domain = super(ExpiredPortfolioReport, cls).get_domain_invoice(data)
|
||||
shops = get_shops_user()
|
||||
if shops:
|
||||
dom = [('shop', 'in', shops)]
|
||||
domain.extend(dom)
|
||||
return domain
|
||||
|
||||
|
||||
class InvoicesStart(metaclass=PoolMeta):
|
||||
__name__ = 'invoice_report.print_invoices.start'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(InvoicesStart, cls).__setup__()
|
||||
cls.shop.domain.append(
|
||||
('id', 'in', Eval('context', {}).get('shops', -1))
|
||||
)
|
||||
|
||||
|
||||
class PortfolioBySalesmanReport(metaclass=PoolMeta):
|
||||
__name__ = 'sale_salesman.portfolio_by_salesman.report'
|
||||
|
||||
# Overwrite method what generated domain of invoices
|
||||
@classmethod
|
||||
def get_domain_invoice(cls, domain, data):
|
||||
domain = super(PortfolioBySalesmanReport, cls).get_domain_invoice(
|
||||
domain, data)
|
||||
shops = get_shops_user()
|
||||
if shops:
|
||||
domain.append(('shop', 'in', shops))
|
||||
return domain
|
||||
|
||||
|
||||
class MovesInvoicesReport(metaclass=PoolMeta):
|
||||
__name__ = 'account_invoice.moves_report'
|
||||
|
||||
@classmethod
|
||||
def get_domain_invoice(cls, data):
|
||||
dom_invoices = super(MovesInvoicesReport, cls).get_domain_invoice(data)
|
||||
shops = get_shops_user()
|
||||
if shops:
|
||||
dom_invoices.append(('shop', 'in', shops))
|
||||
return dom_invoices
|
||||
|
|
Loading…
Reference in New Issue