Release v6.0
This commit is contained in:
parent
b643e57e58
commit
4aad55a17d
16
__init__.py
16
__init__.py
|
@ -1,19 +1,19 @@
|
|||
# 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 trytond.pool import Pool
|
||||
from .sale import (Sale, SaleProfitJournalStart, SaleProfitJournal,
|
||||
SaleProfitJournalReport)
|
||||
from .product import Template
|
||||
from . import sale
|
||||
from . import product
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Sale,
|
||||
Template,
|
||||
SaleProfitJournalStart,
|
||||
sale.Sale,
|
||||
product.Template,
|
||||
sale.SaleProfitJournalStart,
|
||||
module='sale_cost', type_='model')
|
||||
Pool.register(
|
||||
SaleProfitJournalReport,
|
||||
sale.SaleProfitJournalReport,
|
||||
module='sale_cost', type_='report')
|
||||
Pool.register(
|
||||
SaleProfitJournal,
|
||||
sale.SaleProfitJournal,
|
||||
module='sale_cost', type_='wizard')
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
__all__ = ['Template']
|
||||
|
||||
|
||||
class Template:
|
||||
__metaclass__ = PoolMeta
|
||||
class Template(metaclass=PoolMeta):
|
||||
__name__ = 'product.template'
|
||||
|
|
19
sale.py
19
sale.py
|
@ -9,9 +9,6 @@ from trytond.report import Report
|
|||
from trytond.wizard import Wizard, StateView, Button, StateReport
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['Sale', 'SaleProfitJournalStart', 'SaleProfitJournal',
|
||||
'SaleProfitJournalReport']
|
||||
|
||||
STATES = {
|
||||
'readonly': Eval('state').in_(['confirmed', 'processing', 'done']),
|
||||
'required': Eval('state') == 'quotation',
|
||||
|
@ -24,7 +21,8 @@ class Sale(metaclass=PoolMeta):
|
|||
__name__ = 'sale.sale'
|
||||
cost = fields.Function(fields.Numeric('Sale Cost',
|
||||
digits=(16,2)), 'get_sale_cost')
|
||||
|
||||
profit_amount = fields.Function(fields.Numeric('Profit Amount',
|
||||
digits=(16,2)), 'get_profit_amount')
|
||||
|
||||
def get_sale_cost(self, name=None):
|
||||
res = []
|
||||
|
@ -35,6 +33,10 @@ class Sale(metaclass=PoolMeta):
|
|||
res.append((line.product.template.cost_price + expense) * Decimal(line.quantity))
|
||||
return sum(res)
|
||||
|
||||
def get_profit_amount(self, name=None):
|
||||
res = self.total_amount - self.get_sale_cost()
|
||||
return res
|
||||
|
||||
|
||||
class SaleProfitJournalStart(ModelView):
|
||||
'Sale Profit Journal Start'
|
||||
|
@ -76,8 +78,8 @@ class SaleProfitJournalReport(Report):
|
|||
__name__ = 'sale_cost.profit_journal_report'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(SaleProfitJournalReport, cls).get_context(records, data)
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
Sale = pool.get('sale.sale')
|
||||
Tax = pool.get('account.tax')
|
||||
|
@ -91,7 +93,6 @@ class SaleProfitJournalReport(Report):
|
|||
amount = line.amount
|
||||
return (line.amount if amount else _ZERO) + tax_amount
|
||||
|
||||
|
||||
total_profit = _ZERO
|
||||
sales = Sale.search([
|
||||
('sale_date', '=', data['sale_date']),
|
||||
|
@ -103,9 +104,7 @@ class SaleProfitJournalReport(Report):
|
|||
tax_amount = []
|
||||
total_amount = []
|
||||
for sale in sales:
|
||||
profit_amount = sale.total_amount - sale.get_sale_cost()
|
||||
setattr(sale, 'profit_amount', profit_amount)
|
||||
total_profit.append(profit_amount)
|
||||
total_profit.append(sale.profit_amount)
|
||||
untaxed_amount.append(sale.untaxed_amount)
|
||||
tax_amount.append(sale.tax_amount)
|
||||
total_amount.append(sale.total_amount)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=5.0.0
|
||||
version=6.0.0
|
||||
depends:
|
||||
product
|
||||
sale
|
||||
|
|
Loading…
Reference in New Issue