[IMP] expense: default expense category on scan

Description of the issue/feature this PR addresses:
- Expenses are automatically created when uploading or scanning receipts. This is a feature often used by employees who have a lot of tickets and upload them in batch. The expenses created have a random category (product_id) specified. Companies may however want to specify the default category for accounting or management purposes. They are currently unable to do so.

Current behavior before PR:
- Companies can't specify default category for scanned/uploaded expenses

Desired behavior after PR is merged:
- In the Expenses setting, combine the "Default Journals" and "Payment" block into one and name the new block "Accounting"
- Add new setting in Expenses for specifying default category for scanned/uploaded expenses
- If that setting is set, use the value inside it for the category field of new scanned/uploaded expenses

closes odoo/odoo#124205

Task-id: 3354763
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
This commit is contained in:
Yosua Nicolaus
2023-07-13 16:52:52 +02:00
parent ea8acc17b4
commit 41d56e2e98
4 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -389,7 +389,7 @@ class HrExpense(models.Model):
vals = {
'name': attachment_name,
'unit_amount': 0,
'product_id': product.id,
'product_id': self.env.company.expense_product_id.id or product.id,
}
if product.property_account_expense_id:
vals['account_id'] = product.property_account_expense_id.id
+6
View File
@@ -6,6 +6,12 @@ from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
expense_product_id = fields.Many2one(
"product.product",
string="Default Expense Category",
check_company=True,
domain="[('can_be_expensed', '=', True), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
)
expense_journal_id = fields.Many2one(
"account.journal",
string="Default Expense Journal",
@@ -15,6 +15,7 @@ class ResConfigSettings(models.TransientModel):
config_parameter='hr_expense.use_mailgateway')
module_hr_payroll_expense = fields.Boolean(string='Reimburse Expenses in Payslip')
module_hr_expense_extract = fields.Boolean(string='Send bills to OCR to generate expenses')
expense_product_id = fields.Many2one('product.product', related='company_id.expense_product_id', readonly=False)
expense_journal_id = fields.Many2one('account.journal', related='company_id.expense_journal_id', readonly=False)
company_expense_allowed_payment_method_line_ids = fields.Many2many(
comodel_name='account.payment.method.line',
@@ -32,13 +32,14 @@
<setting id="expense_extract_settings" string="Expense Digitalization (OCR)" company_dependent="1" help="Digitalize your receipts with OCR and Artificial Intelligence" title="use OCR to fill data from a picture of the bill">
<field name="module_hr_expense_extract" widget="upgrade_boolean"/>
</setting>
<setting company_dependent="1" string="Default Category" help="Default expense categories for uploaded expenses" title="Enable users to choose default category for automatically generated expenses.">
<field name="expense_product_id"/>
</setting>
</block>
<block title="Default Journals">
<block title="Accounting">
<setting company_dependent="1" help="Default accounting journal for expenses paid by employees." string="Employee Expense Journal">
<field name="expense_journal_id"/>
</setting>
</block>
<block title="Payment">
<setting company_dependent="1" string="Company payment methods available" help="Payment method allowed for expenses paid by company.">
<field name="company_expense_allowed_payment_method_line_ids" widget="many2many_tags" placeholder="All payment methods allowed" options="{'no_create': True}" context="{'show_payment_journal_id': 1}"/>
</setting>