-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[17.0][MIG] hr_expense_invoice: Migration to 17.0 #256
[17.0][MIG] hr_expense_invoice: Migration to 17.0 #256
Conversation
Set supplier invoices on HR expenses ==================================== This module should be used when a supplier invoice is paid by an employee. It allows to set a supplier invoice for each expense line, adding the corresponding journal items to transfer the debt to the employee. Installation ============ Install the module the regular way. Configuration ============= You don't need to configure anything more to use this module. Usage ===== Instead of coding a full expense line, select an existing supplier invoice, and then the rest of the fields will be auto-filled and grayed. When you generate the expenses account entries, lines with invoices filled will be generated as opposite of the payable move line of the invoice, and both will be reconciled, letting the employee payable account as the only open balance. Known issues / Roadmap ====================== * Multiple payment terms for a supplier invoice are not handled correctly. * Partial reconcile supplier invoices are also not correctly handled. OCA Transbot updated translations from Transifex
…se view OCA Transbot updated translations from Transifex
…l amount (OCA#237) On the same expense, when we have 2 or more lines with different invoices, and each invoices have the same total amount, reconcile is not possible. The fix is to exclude reconcile account.move.line, and the first time if we have more than one line to reconcile on the same amount, we keep the first. OCA Transbot updated translations from Transifex
OCA Transbot updated translations from Transifex
[UPD] Update hr_expense_invoice.pot
Currently translated at 100.0% (4 of 4 strings) Translation: hr-11.0/hr-11.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-11-0/hr-11-0-hr_expense_invoice/de/ Update translation files Updated by Update PO files to match POT (msgmerge) hook in Weblate.
[UPD] Update hr_expense_invoice.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: hr-12.0/hr-12.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice/
Add expense info to invoice info or create/edit
From expense sheet, add action "Create Invoice" from multiple expenses Change the way reference invoice_id is checked. - No more onchange invoice_id that set values to expense - Instead, check amount on expense and invoice during post entry - Change the way to allow reconcile with > 2 account move lines
Currently translated at 100.0% (4 of 4 strings) Translation: hr-12.0/hr-12.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice/de/
Currently translated at 100.0% (4 of 4 strings) Translation: hr-12.0/hr-12.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice/es/ [UPD] README.rst [UPD] Update hr_expense_invoice.pot [UPD] README.rst hr_expense_invoice 12.0.1.3.0 Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: hr-12.0/hr-12.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice/
hr_expense_invoice 12.0.1.3.1
[UPD] Update hr_expense_invoice.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/ Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/
If not, the total amount of the expense won't match to invoices with taxes. [UPD] README.rst
[UPD] README.rst hr_expense_invoice 13.0.1.1.0
… partners. - Intercept properly the sheet paid action for not marking it as paid when reconciling the expense lines that belongs to invoices. - Prevent set invoices paid when sheet paid by company. - Some docstring. Co-authored-by: Pedro M. Baeza <[email protected]> Co-authored-by: Víctor Martínez <[email protected]> hr_expense_invoice 13.0.1.1.2 [UPD] Update hr_expense_invoice.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/
…ing to sheet hr_expense_invoice 13.0.1.2.0 [UPD] Update hr_expense_invoice.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/
…ent models (hr.expense.create.invoice)
…ted with expense and improve domain to prevent set same invoice in different expenses.
…e is set) hr_expense_invoice 13.0.1.3.0 [UPD] Update hr_expense_invoice.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/
be6e661
to
1a6445b
Compare
@pedrobaeza @luisg123v all comments were applied, please review again. |
return action | ||
|
||
def _compute_state(self): | ||
"""Set proper state according linked invoices.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"according to"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -27,6 +27,9 @@ class HrExpense(models.Model): | |||
comodel_name="account.move", | |||
inverse_name="source_invoice_expense_id", | |||
) | |||
amount_residual = fields.Monetary( | |||
string="Amount Due", compute="_compute_amount_residual", store="True" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The store
attribute should be a boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -112,3 +143,30 @@ def action_view_invoices(self): | |||
action["view_mode"] = "tree,form" | |||
action["domain"] = [("id", "in", invoice_ids)] | |||
return action | |||
|
|||
def _compute_state(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing api.depends
, it could be an empty one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's needed if you are overriding an existing one.
sheets_with_paid_invoices = ( | ||
sheets_with_invoices - company_account_sheets | ||
).filtered( | ||
lambda sheet: all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could filter by previous state to discard invalid candidates, e.g. draft ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already filtered in line 155. This is the original compute.
company_account_sheets = sheets_with_invoices.filtered( | ||
lambda sheet: sheet.payment_mode == "company_account" | ||
) | ||
company_account_sheets.write({"state": "done"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not write inside compute methods
company_account_sheets.state = "done"
Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -140,8 +113,8 @@ | |||
icon="fa-book" | |||
name="action_view_invoices" | |||
groups="account.group_account_invoice" | |||
invisible="invoice_count == 0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not invoice_count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
1a6445b
to
6c9a848
Compare
@luisg123v please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xmglord we're almost done, just only one pending comment.
5b2214b
to
e69abe3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
CC @pedrobaeza
@pedrobaeza friendly reminder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, sorry for the delay. In a test in runboat, everything seems to work better.
Functionally, I only miss the journal entries smart-button to navigate to the created "transfer entries" in a expense report with expenses paid by employee linked to vendor bills. Is it possible to have it?
Technically, I have put several comments inline.
@@ -27,56 +27,31 @@ class HrExpense(models.Model): | |||
comodel_name="account.move", | |||
inverse_name="source_invoice_expense_id", | |||
) | |||
amount_residual = fields.Monetary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this extra field? If there's a strong reason, put a comment above documenting the reason to add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already add the reason.
@@ -88,7 +63,7 @@ def _prepare_own_account_transfer_move_vals(self): | |||
], | |||
limit=1, | |||
) | |||
employee_partner = self.employee_id.sudo().address_home_id.commercial_partner_id | |||
employee_partner = self.employee_id.sudo().work_contact_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I understand the reason for this change (as the private address has been removed), this is not truly correct, as the work contact is not really representing the employee, and you can't put a journal entry linked to a children contact. How Odoo handles this in other parts where the debt is to the employee?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -153,27 +128,26 @@ def _onchange_invoice_id(self): | |||
""" | |||
if self.invoice_id: | |||
self.quantity = 1 | |||
self.reference = self.invoice_id.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add the vendor bill number in the expense name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done but since both models, hr.expense
and account.move
have smart buttons to go from one to another and since in v17 the filtering is more robust. I think is not necessary to have it. Maybe something like:
self.name = self.name or self.invoice_id.name
What do you think?
@@ -112,3 +143,30 @@ def action_view_invoices(self): | |||
action["view_mode"] = "tree,form" | |||
action["domain"] = [("id", "in", invoice_ids)] | |||
return action | |||
|
|||
def _compute_state(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's needed if you are overriding an existing one.
Actions performed: - Deprecated `hr.expense.reference` field as part of [1]. - Merged the `hr.expense.is_editable` and `hr.expense.sheet_is_editable` fields as part of [1]. - Renamed `hr.expense.unit_amount` to `hr.expense.price_unit`. - Renamed `hr.expense.attachment_number` to `hr.expense.nb_attachment`. - Renamed `hr.expense.approve_expense_sheets()` to `hr.expense.action_approve_expense_sheets()`. - Renamed `hr.expense.account_move_id` to `hr.expense.account_move_ids`. - Renamed `hr.expense.total_amount` to `hr.expense.total_amount_currency`. - Inherit compute of `hr.expense.sheet.state` to consider expenses with linked invoices. - Switched from old %-based string formatting to f-strings. - Replaced the use of `attrs` in views with their equivalent Python expressions as part of [2]. - Adapted the `hr.expense.sheet` records creation in tests. - Updated to use the employee partner from `hr.employee.work_contact_id` instead of `hr.employee.address_home_id` since it has been split into multiple fields. - Added the `hr.expense.amount_residual` field to maintain the one invoice per expense functionality. - Adapted test assertions for `hr.expense.sheet.state` since it is now a computed field. Co-authored-by: desdelinux <[email protected]> [1]: odoo/odoo#130244 [2]: odoo/odoo#104741
e69abe3
to
bef9479
Compare
Hi @pedrobaeza In v16 was not possible to have the smart button since the field related to it was a one2many field but in this version is possible and I already add it. Could you please test it functionally again? |
@pedrobaeza friendly reminder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's move on. The contact associated to the move doesn't convince me, as it's not correct, but is the same on Vanilla Odoo, so let's not block it for now.
/ocabot merge nobump
Hey, thanks for contributing! Proceeding to merge this for you. |
Congratulations, your PR was merged at 38e6859. Thanks a lot for contributing to OCA. ❤️ |
Actions performed:
- Deprecated hr.expense.reference field as part of 1.
- Merged the hr.expense.is_editable and hr.expense.sheet_is_editable
fields as part of 1.
- Renamed hr.expense.unit_amount to hr.expense.price_unit.
- Renamed hr.expense.attachment_number to hr.expense.nb_attachment.
- Renamed hr.expense.approve_expense_sheets() to
hr.expense.action_approve_expense_sheets().
- Renamed hr.expense.account_move_id to hr.expense.account_move_ids.
- Renamed hr.expense.total_amount to
hr.expense.total_amount_currency.
- Inherit compute of hr.expense.sheet.state to consider expenses with
linked invoices.
- Switched from old %-based string formatting to f-strings.
- Replaced the use of attrs in views with their equivalent Python
expressions as part of 2.
- Adapted the hr.expense.sheet records creation in tests.
- Updated to use the employee partner from hr.employee.work_contact_id
instead of hr.employee.address_home_id since it has been split into
multiple fields.
- Added the hr.expense.amount_residual field to maintain the one
invoice per expense functionality.
- Adapted test assertions for hr.expense.sheet.state since it is now
a computed field.