formatting
This commit is contained in:
parent
0191db91c3
commit
52eec322b5
5 changed files with 34 additions and 72 deletions
|
@ -56,8 +56,7 @@ class Currency(metaclass=PoolMeta):
|
||||||
(Count(tab_line.id) > 0, True),
|
(Count(tab_line.id) > 0, True),
|
||||||
else_=False,
|
else_=False,
|
||||||
), clause[2]),
|
), clause[2]),
|
||||||
group_by=[tab_cur.id],
|
group_by=[tab_cur.id])
|
||||||
)
|
|
||||||
return [('id', 'in', query)]
|
return [('id', 'in', query)]
|
||||||
|
|
||||||
# end Currency
|
# end Currency
|
||||||
|
|
|
@ -50,8 +50,7 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView):
|
||||||
maincolor = fields.Selection(
|
maincolor = fields.Selection(
|
||||||
string='Color scheme', required=True,
|
string='Color scheme', required=True,
|
||||||
help='The color scheme determines the hue of all ' +
|
help='The color scheme determines the hue of all ' +
|
||||||
'components of the chart.',
|
'components of the chart.', selection=sel_maincolor, sort=False)
|
||||||
selection=sel_maincolor, sort=False)
|
|
||||||
bgcolor = fields.Selection(
|
bgcolor = fields.Selection(
|
||||||
string='Background Color', required=True,
|
string='Background Color', required=True,
|
||||||
help='Background color of the chart area.', sort=False,
|
help='Background color of the chart area.', sort=False,
|
||||||
|
@ -63,28 +62,24 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView):
|
||||||
cashbooks = fields.Many2Many(
|
cashbooks = fields.Many2Many(
|
||||||
string='Cashbooks', relation_name='cashbook_report.eval_line',
|
string='Cashbooks', relation_name='cashbook_report.eval_line',
|
||||||
origin='evaluation', target='cashbook',
|
origin='evaluation', target='cashbook',
|
||||||
states={
|
states={'invisible': ~Eval('dtype', '').in_(cashbook_types)},
|
||||||
'invisible': ~Eval('dtype', '').in_(cashbook_types),
|
depends=['dtype'])
|
||||||
}, depends=['dtype'])
|
|
||||||
types = fields.Many2Many(
|
types = fields.Many2Many(
|
||||||
string='Types', relation_name='cashbook_report.eval_line',
|
string='Types', relation_name='cashbook_report.eval_line',
|
||||||
origin='evaluation', target='dtype',
|
origin='evaluation', target='dtype',
|
||||||
states={
|
states={'invisible': ~Eval('dtype', '').in_(booktype_types)},
|
||||||
'invisible': ~Eval('dtype', '').in_(booktype_types),
|
depends=['dtype'])
|
||||||
}, depends=['dtype'])
|
|
||||||
currencies = fields.Many2Many(
|
currencies = fields.Many2Many(
|
||||||
string='Currencies', relation_name='cashbook_report.eval_line',
|
string='Currencies', relation_name='cashbook_report.eval_line',
|
||||||
origin='evaluation', target='currency',
|
origin='evaluation', target='currency',
|
||||||
filter=[('cashbook_hasbookings', '=', True)],
|
filter=[('cashbook_hasbookings', '=', True)],
|
||||||
states={
|
states={'invisible': Eval('dtype', '') != 'currencies'},
|
||||||
'invisible': Eval('dtype', '') != 'currencies',
|
depends=['dtype'])
|
||||||
}, depends=['dtype'])
|
|
||||||
categories = fields.Many2Many(
|
categories = fields.Many2Many(
|
||||||
string='Categories', relation_name='cashbook_report.eval_line',
|
string='Categories', relation_name='cashbook_report.eval_line',
|
||||||
origin='evaluation', target='category',
|
origin='evaluation', target='category',
|
||||||
states={
|
states={'invisible': ~Eval('dtype', '').in_(category_types)},
|
||||||
'invisible': ~Eval('dtype', '').in_(category_types),
|
depends=['dtype'])
|
||||||
}, depends=['dtype'])
|
|
||||||
|
|
||||||
line_values = fields.One2Many(
|
line_values = fields.One2Many(
|
||||||
string='Line Values', field='evaluation', readonly=True,
|
string='Line Values', field='evaluation', readonly=True,
|
||||||
|
@ -174,10 +169,7 @@ class Evaluation(sequence_ordered(), ModelSQL, ModelView):
|
||||||
else 'color="%s"' % evaluation.maincolor,
|
else 'color="%s"' % evaluation.maincolor,
|
||||||
'lines': template_view_line % {
|
'lines': template_view_line % {
|
||||||
'fill': '1',
|
'fill': '1',
|
||||||
'string': evaluation.dtype_string,
|
'string': evaluation.dtype_string}}}
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def uiview_delete(cls, evaluations):
|
def uiview_delete(cls, evaluations):
|
||||||
|
|
|
@ -28,8 +28,7 @@ class OpenChartWizard(Wizard):
|
||||||
if evaluation.ui_view_chart:
|
if evaluation.ui_view_chart:
|
||||||
action['pyson_context'] = PYSONEncoder().encode({
|
action['pyson_context'] = PYSONEncoder().encode({
|
||||||
'active_evaluation': evaluation.id,
|
'active_evaluation': evaluation.id,
|
||||||
'evaluation': evaluation.id,
|
'evaluation': evaluation.id})
|
||||||
})
|
|
||||||
action['name'] = gettext(
|
action['name'] = gettext(
|
||||||
'cashbook_report.msg_name_graph',
|
'cashbook_report.msg_name_graph',
|
||||||
gname=evaluation.rec_name)
|
gname=evaluation.rec_name)
|
||||||
|
|
|
@ -74,8 +74,7 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
if amount != Decimal('0.0'):
|
if amount != Decimal('0.0'):
|
||||||
return self.convert_to_evalcurrency(
|
return self.convert_to_evalcurrency(
|
||||||
books[0].company.currency,
|
books[0].company.currency,
|
||||||
Decimal('100.0') * value / amount - Decimal('100.0'),
|
Decimal('100.0') * value / amount - Decimal('100.0'))
|
||||||
)
|
|
||||||
return Decimal('0.0')
|
return Decimal('0.0')
|
||||||
|
|
||||||
def get_difference_by_query(self, query):
|
def get_difference_by_query(self, query):
|
||||||
|
@ -150,8 +149,7 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.get_percent_by_query([
|
return self.get_percent_by_query([
|
||||||
('categories.id', '=', self.category.id),
|
('categories.id', '=', self.category.id)])
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_category_gldiff(self):
|
def get_value_category_gldiff(self):
|
||||||
""" get difference amount by category
|
""" get difference amount by category
|
||||||
|
@ -160,8 +158,7 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.get_difference_by_query([
|
return self.get_difference_by_query([
|
||||||
('categories.id', '=', self.category.id),
|
('categories.id', '=', self.category.id)])
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_category_glvalue(self):
|
def get_value_category_glvalue(self):
|
||||||
""" get current value by category
|
""" get current value by category
|
||||||
|
@ -170,8 +167,7 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.get_currentvalue_by_query([
|
return self.get_currentvalue_by_query([
|
||||||
('categories.id', '=', self.category.id),
|
('categories.id', '=', self.category.id)])
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_category_glyield(self):
|
def get_value_category_glyield(self):
|
||||||
""" get total yield by type
|
""" get total yield by type
|
||||||
|
@ -189,9 +185,7 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
if self.dtype is None:
|
if self.dtype is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.get_percent_by_query([
|
return self.get_percent_by_query([('btype.id', '=', self.dtype.id)])
|
||||||
('btype.id', '=', self.dtype.id),
|
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_types_gldiff(self):
|
def get_value_types_gldiff(self):
|
||||||
""" get difference amount by type
|
""" get difference amount by type
|
||||||
|
@ -200,8 +194,7 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.get_difference_by_query([
|
return self.get_difference_by_query([
|
||||||
('btype.id', '=', self.dtype.id),
|
('btype.id', '=', self.dtype.id)])
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_types_glvalue(self):
|
def get_value_types_glvalue(self):
|
||||||
""" get current value by type
|
""" get current value by type
|
||||||
|
@ -210,8 +203,7 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.get_currentvalue_by_query([
|
return self.get_currentvalue_by_query([
|
||||||
('btype.id', '=', self.dtype.id),
|
('btype.id', '=', self.dtype.id)])
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_types_glyield(self):
|
def get_value_types_glyield(self):
|
||||||
""" get total yield by type
|
""" get total yield by type
|
||||||
|
@ -220,8 +212,7 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.get_totalyield_by_query([
|
return self.get_totalyield_by_query([
|
||||||
('btype.id', '=', self.dtype.id),
|
('btype.id', '=', self.dtype.id)])
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_cashbooks_glperc(self):
|
def get_value_cashbooks_glperc(self):
|
||||||
""" percent of profit/loss of cashbooks
|
""" percent of profit/loss of cashbooks
|
||||||
|
@ -263,7 +254,6 @@ class InvestmentLine(metaclass=PoolMeta):
|
||||||
"""
|
"""
|
||||||
if self.cashbook:
|
if self.cashbook:
|
||||||
return self.get_totalyield_by_query([
|
return self.get_totalyield_by_query([
|
||||||
('id', '=', self.cashbook.id)
|
('id', '=', self.cashbook.id)])
|
||||||
])
|
|
||||||
|
|
||||||
# end InvestmentLine
|
# end InvestmentLine
|
||||||
|
|
42
line.py
42
line.py
|
@ -45,8 +45,7 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
|
|
||||||
# dtype + currency of evaluation
|
# dtype + currency of evaluation
|
||||||
eval_dtype = fields.Function(fields.Char(
|
eval_dtype = fields.Function(fields.Char(
|
||||||
string='Data type', readonly=True),
|
string='Data type', readonly=True), 'on_change_with_eval_dtype')
|
||||||
'on_change_with_eval_dtype')
|
|
||||||
eval_currency = fields.Function(fields.Many2One(
|
eval_currency = fields.Function(fields.Many2One(
|
||||||
model_name='currency.currency',
|
model_name='currency.currency',
|
||||||
string="Currency", readonly=True), 'on_change_with_eval_currency')
|
string="Currency", readonly=True), 'on_change_with_eval_currency')
|
||||||
|
@ -67,11 +66,7 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
def set_name_data(cls, lines, name, value):
|
def set_name_data(cls, lines, name, value):
|
||||||
""" store updated name
|
""" store updated name
|
||||||
"""
|
"""
|
||||||
cls.write(*[
|
cls.write(*[lines, {'name_line': value}])
|
||||||
lines,
|
|
||||||
{
|
|
||||||
'name_line': value,
|
|
||||||
}])
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fields_view_get(cls, view_id, view_type='form'):
|
def fields_view_get(cls, view_id, view_type='form'):
|
||||||
|
@ -153,10 +148,7 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
if amount is None:
|
if amount is None:
|
||||||
return Decimal('0.0')
|
return Decimal('0.0')
|
||||||
return Currency.compute(
|
return Currency.compute(
|
||||||
from_currency,
|
from_currency, amount, self.eval_currency).quantize(exp)
|
||||||
amount,
|
|
||||||
self.eval_currency,
|
|
||||||
).quantize(exp)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate(cls, records):
|
def validate(cls, records):
|
||||||
|
@ -168,26 +160,22 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
(record.cashbook is not None):
|
(record.cashbook is not None):
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'cashbook_report.msg_invalid_dtype',
|
'cashbook_report.msg_invalid_dtype',
|
||||||
typename=gettext('cashbook_report.msg_dtype_cashbook'),
|
typename=gettext('cashbook_report.msg_dtype_cashbook')))
|
||||||
))
|
|
||||||
if (record.evaluation.dtype not in booktype_types) and \
|
if (record.evaluation.dtype not in booktype_types) and \
|
||||||
(record.dtype is not None):
|
(record.dtype is not None):
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'cashbook_report.msg_invalid_dtype',
|
'cashbook_report.msg_invalid_dtype',
|
||||||
typename=gettext('cashbook_report.msg_dtype_type'),
|
typename=gettext('cashbook_report.msg_dtype_type')))
|
||||||
))
|
|
||||||
if (record.evaluation.dtype != 'currencies') and \
|
if (record.evaluation.dtype != 'currencies') and \
|
||||||
(record.currency is not None):
|
(record.currency is not None):
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'cashbook_report.msg_invalid_dtype',
|
'cashbook_report.msg_invalid_dtype',
|
||||||
typename=gettext('cashbook_report.msg_dtype_currency'),
|
typename=gettext('cashbook_report.msg_dtype_currency')))
|
||||||
))
|
|
||||||
if (record.evaluation.dtype not in category_types) and \
|
if (record.evaluation.dtype not in category_types) and \
|
||||||
(record.category is not None):
|
(record.category is not None):
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'cashbook_report.msg_invalid_dtype',
|
'cashbook_report.msg_invalid_dtype',
|
||||||
typename=gettext('cashbook_report.msg_dtype_category'),
|
typename=gettext('cashbook_report.msg_dtype_category')))
|
||||||
))
|
|
||||||
|
|
||||||
def get_balance_by_query(self, query):
|
def get_balance_by_query(self, query):
|
||||||
""" run 'query' on Lines, convert used
|
""" run 'query' on Lines, convert used
|
||||||
|
@ -215,8 +203,7 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
).select(
|
).select(
|
||||||
tab_book.currency,
|
tab_book.currency,
|
||||||
Sum(tab_line.credit - tab_line.debit).as_('balance'),
|
Sum(tab_line.credit - tab_line.debit).as_('balance'),
|
||||||
group_by=[tab_book.currency],
|
group_by=[tab_book.currency])
|
||||||
)
|
|
||||||
cursor.execute(*query)
|
cursor.execute(*query)
|
||||||
balances = cursor.fetchall()
|
balances = cursor.fetchall()
|
||||||
|
|
||||||
|
@ -233,9 +220,7 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
"""
|
"""
|
||||||
if self.cashbook:
|
if self.cashbook:
|
||||||
return self.convert_to_evalcurrency(
|
return self.convert_to_evalcurrency(
|
||||||
self.cashbook.currency,
|
self.cashbook.currency, self.cashbook.balance)
|
||||||
self.cashbook.balance,
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_value_categories(self):
|
def get_value_categories(self):
|
||||||
""" get balance of bookings in categories
|
""" get balance of bookings in categories
|
||||||
|
@ -249,8 +234,7 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
return self.get_balance_by_query([
|
return self.get_balance_by_query([
|
||||||
('cashbook.categories.id', '=', self.category.id),
|
('cashbook.categories.id', '=', self.category.id),
|
||||||
('cashbook.state', '=', 'open'),
|
('cashbook.state', '=', 'open'),
|
||||||
('date', '<=', IrDate.today()),
|
('date', '<=', IrDate.today())])
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_types(self):
|
def get_value_types(self):
|
||||||
""" get balance of bookings in cashbooks by 'type',
|
""" get balance of bookings in cashbooks by 'type',
|
||||||
|
@ -264,8 +248,7 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
return self.get_balance_by_query([
|
return self.get_balance_by_query([
|
||||||
('cashbook.btype.id', '=', self.dtype.id),
|
('cashbook.btype.id', '=', self.dtype.id),
|
||||||
('cashbook.state', '=', 'open'),
|
('cashbook.state', '=', 'open'),
|
||||||
('date', '<=', IrDate.today()),
|
('date', '<=', IrDate.today())])
|
||||||
])
|
|
||||||
|
|
||||||
def get_value_currencies(self):
|
def get_value_currencies(self):
|
||||||
""" get balance of bookings in cashbooks by 'currency',
|
""" get balance of bookings in cashbooks by 'currency',
|
||||||
|
@ -279,8 +262,7 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
return self.get_balance_by_query([
|
return self.get_balance_by_query([
|
||||||
('cashbook.currency.id', '=', self.currency.id),
|
('cashbook.currency.id', '=', self.currency.id),
|
||||||
('cashbook.state', '=', 'open'),
|
('cashbook.state', '=', 'open'),
|
||||||
('date', '<=', IrDate.today()),
|
('date', '<=', IrDate.today())])
|
||||||
])
|
|
||||||
|
|
||||||
@fields.depends(
|
@fields.depends(
|
||||||
'eval_dtype', 'eval_currency', 'currency_digits',
|
'eval_dtype', 'eval_currency', 'currency_digits',
|
||||||
|
|
Loading…
Reference in a new issue