Files
odoo_source/addons/hr_expense/models/product_template.py
T
Prakash Prajapati 4b5265b9b9 [IMP] contact, product, various: improve labels and tooltips of partner and product fields
Purpose: improve understanding of partner and product models as well as their
daily use. This is done by improving tooltips and labels of some fields
according to business logic.

This commit is related to task ID 1880696 and closes PR #27133 .

Thanks to @xmo-odoo for its in-depth review.
2018-09-21 10:57:58 +02:00

24 lines
838 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class ProductTemplate(models.Model):
_inherit = "product.template"
can_be_expensed = fields.Boolean(string="Can be Expensed", help="Specify whether the product can be selected in an expense.")
@api.model
def create(self, vals):
# When creating an expense product on the fly, you don't expect to
# have taxes on it
if vals.get('can_be_expensed', False):
vals.update({'supplier_taxes_id': False})
return super(ProductTemplate, self).create(vals)
@api.onchange('type')
def _onchange_type_for_expense(self):
if self.type not in ['consu', 'service']: # storable can not be expensed.
self.can_be_expensed = False