[IMP]: Added Upstream patch for HR Expense

This commit is contained in:
Hansa Rathod 2018-07-09 11:18:45 +05:30
parent 9fdbf4b78e
commit 98a6ee1337

View File

@ -370,7 +370,9 @@ class HrExpense(models.Model):
product = default_product product = default_product
else: else:
expense_description = expense_description.replace(product_code.group(), '') expense_description = expense_description.replace(product_code.group(), '')
product = self.env['product.product'].search([('default_code', 'ilike', product_code.group(1))]) or default_product products = self.env['product.product'].search([('default_code', 'ilike', product_code.group(1))]) or default_product
product = products.filtered(lambda p: p.default_code == product_code.group(1)) or products[0]
account = product.product_tmpl_id._get_product_accounts()['expense']
pattern = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?' pattern = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?'
# Match the last occurence of a float in the string # Match the last occurence of a float in the string
@ -397,6 +399,8 @@ class HrExpense(models.Model):
'unit_amount': price, 'unit_amount': price,
'company_id': employee.company_id.id, 'company_id': employee.company_id.id,
}) })
if account:
custom_values['account_id'] = account.id
return super(HrExpense, self).message_new(msg_dict, custom_values) return super(HrExpense, self).message_new(msg_dict, custom_values)
class HrExpenseSheet(models.Model): class HrExpenseSheet(models.Model):
@ -512,7 +516,7 @@ class HrExpenseSheet(models.Model):
@api.onchange('employee_id') @api.onchange('employee_id')
def _onchange_employee_id(self): def _onchange_employee_id(self):
self.address_id = self.employee_id.address_home_id self.address_id = self.employee_id.sudo().address_home_id
self.department_id = self.employee_id.department_id self.department_id = self.employee_id.department_id
@api.one @api.one