[10.0] Improvements (#44)
* [ADD] Display an icon when a note has been encoded in an expense * [CHG] Expense report document smart button counts his own attachments + his lines attachments
This commit is contained in:
committed by
Alexis de Lattre
parent
987e753a54
commit
e6076c3f76
@@ -117,6 +117,7 @@ class HrExpense(models.Model):
|
||||
store=True, string='Tax Amount in Company Currency',
|
||||
currency_field='company_currency_id')
|
||||
# I don't use the native field 'untaxed_amount' (computed, store=True)
|
||||
has_description = fields.Boolean(compute='_compute_has_description', store=True)
|
||||
|
||||
@api.depends(
|
||||
'currency_id', 'company_id', 'total_amount', 'date',
|
||||
@@ -135,6 +136,13 @@ class HrExpense(models.Model):
|
||||
exp.untaxed_amount_company_currency = untaxed_cc
|
||||
exp.tax_amount_company_currency = total_cc - untaxed_cc
|
||||
|
||||
@api.multi
|
||||
@api.depends('description')
|
||||
def _compute_has_description(self):
|
||||
for rec in self:
|
||||
rec.has_description = (
|
||||
rec.description and bool(rec.description.strip()))
|
||||
|
||||
@api.onchange('untaxed_amount_usability')
|
||||
def untaxed_amount_usability_change(self):
|
||||
self.tax_amount = self.total_amount - self.untaxed_amount_usability
|
||||
@@ -331,6 +339,32 @@ class HrExpenseSheet(models.Model):
|
||||
sheet.untaxed_amount_company_currency = untaxed
|
||||
sheet.tax_amount_company_currency = total - untaxed
|
||||
|
||||
@api.multi
|
||||
def _compute_attachment_number(self):
|
||||
AttachmentObj = self.env['ir.attachment']
|
||||
for rec in self:
|
||||
sheet_attachment_count = AttachmentObj.search_count([
|
||||
('res_model', '=', self._name),
|
||||
('res_id', '=', rec.id)])
|
||||
rec.attachment_number = (
|
||||
sum(self.expense_line_ids.mapped('attachment_number')) +
|
||||
sheet_attachment_count)
|
||||
|
||||
@api.multi
|
||||
def action_get_attachment_view(self):
|
||||
self.ensure_one()
|
||||
res = super(HrExpenseSheet, self).action_get_attachment_view()
|
||||
res['domain'] = [
|
||||
'|',
|
||||
'&',
|
||||
('res_model', '=', 'hr.expense'),
|
||||
('res_id', 'in', self.expense_line_ids.ids),
|
||||
'&',
|
||||
('res_model', '=', 'hr.expense.sheet'),
|
||||
('res_id', '=', self.id),
|
||||
]
|
||||
return res
|
||||
|
||||
@api.one
|
||||
@api.constrains('expense_line_ids')
|
||||
def _check_amounts(self):
|
||||
|
||||
@@ -103,6 +103,9 @@
|
||||
<field name="untaxed_amount_company_currency" sum="Untaxed Total"/>
|
||||
<field name="tax_amount_company_currency" sum="Tax Total"/>
|
||||
<field name="total_amount_company_currency" sum="Total"/>
|
||||
<field name="has_description" invisible="1"/>
|
||||
<button readonly="1" icon="fa-info-circle"
|
||||
attrs="{'invisible': [('has_description', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='expense_line_ids']/tree/field[@name='total_amount']" position="attributes">
|
||||
<attribute name="sum"></attribute>
|
||||
|
||||
Reference in New Issue
Block a user