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