diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/hr_expense/models/product_template.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/hr_expense/models/product_template.py')
| -rw-r--r-- | addons/hr_expense/models/product_template.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/addons/hr_expense/models/product_template.py b/addons/hr_expense/models/product_template.py new file mode 100644 index 00000000..d053a800 --- /dev/null +++ b/addons/hr_expense/models/product_template.py @@ -0,0 +1,24 @@ +# -*- 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", compute='_compute_can_be_expensed', + store=True, readonly=False, help="Specify whether the product can be selected in an expense.") + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + # When creating an expense product on the fly, you don't expect to + # have taxes on it + if vals.get('can_be_expensed', False) and not self.env.context.get('import_file'): + vals.update({'supplier_taxes_id': False}) + return super(ProductTemplate, self).create(vals_list) + + @api.depends('type') + def _compute_can_be_expensed(self): + self.filtered(lambda p: p.type not in ['consu', 'service']).update({'can_be_expensed': False}) |
