Skip to content

Commit 1339609

Browse files
[MIG] hr_expense_petty_cash: Migration to 18.0
1 parent 71554c9 commit 1339609

17 files changed

Lines changed: 379 additions & 232 deletions

hr_expense_petty_cash/README.rst

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Petty Cash
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:a8e609f561678619e4aacdc07e108e03b21d6921467844c68615b6c1a7bcf0b1
10+
!! source digest: sha256:b0ac8e37253106681f342556f00a62710fa4e139ec09806af5b472e7466e9aa5
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Petty Cash
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--expense-lightgray.png?logo=github
20-
:target: https://github.com/OCA/hr-expense/tree/18.0/hr_expense_petty_cash
20+
:target: https://github.com/OCA/hr-expense/tree/16.0/hr_expense_petty_cash
2121
:alt: OCA/hr-expense
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/hr-expense-18-0/hr-expense-18-0-hr_expense_petty_cash
23+
:target: https://translation.odoo-community.org/projects/hr-expense-16-0/hr-expense-16-0-hr_expense_petty_cash
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-expense&target_branch=18.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-expense&target_branch=16.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -32,13 +32,10 @@ This module work about expense that paid by petty cash.
3232

3333
General Process:
3434

35-
1. Create Petty Cash Holder
36-
2. Transfer cash to Petty Cash Holder (by using Vendor Bill)
37-
3. You can create expense paid by petty cash and select petty cash
38-
holder.
39-
4. Then balance of petty cash holder less than amount of expense, you
40-
must transfer cash to petty cash holder before Submit Report to
41-
Manager.
35+
#. Create Petty Cash Holder
36+
#. Transfer cash to Petty Cash Holder (by using Vendor Bill)
37+
#. You can create expense paid by petty cash and select petty cash holder.
38+
#. Then balance of petty cash holder less than amount of expense, you must transfer cash to petty cash holder before Submit Report to Manager.
4239

4340
**Table of contents**
4441

@@ -50,79 +47,77 @@ Configuration
5047

5148
**Create a Petty Cash Account**
5249

53-
1. Go to Invoicing > Accounting > Petty Cash
54-
2. Create a new petty cash account
55-
3. Type = Bank and Cash or Account type that is asset
50+
#. Go to Invoicing > Accounting > Petty Cash
51+
#. Create a new petty cash account
52+
#. Type = Bank and Cash or Account type that is asset
5653

5754
Note:
5855

59-
- You will need the "Show Full Accounting Features" to see accounting
60-
data
56+
* You will need the "Show Full Accounting Features" to see accounting data
6157

6258
Usage
6359
=====
6460

6561
**Create a Petty Cash Holder**
6662

67-
1. Go to Invoicing > Accounting > Petty Cash
68-
2. Create a new petty cash holder
69-
3. Select Petty Cash Account and Journal (optional)
63+
#. Go to Invoicing > Accounting > Petty Cash
64+
#. Create a new petty cash holder
65+
#. Select Petty Cash Account and Journal (optional)
7066

7167
**Add Balance for Petty Cash Holder**
7268

73-
1. Go to Invoicing > Vendor > Bill
74-
2. Create a new vendor bill
75-
3. Select Vendor (Petty Cash Holder)
76-
4. Check Petty Cash will auto line with Unit Price = Max Limit - Balance
69+
#. Go to Invoicing > Vendor > Bill
70+
#. Create a new vendor bill
71+
#. Select Vendor (Petty Cash Holder)
72+
#. Check Petty Cash will auto line with Unit Price = Max Limit - Balance
7773

7874
**Create an Expense paid by Petty Cash**
7975

80-
1. Go to Expenses > My Expenses
81-
2. Create a new expense
82-
3. Select Paid by = Petty Cash and Select Petty Cash Holder
76+
#. Go to Expenses > My Expenses
77+
#. Create a new expense
78+
#. Select Paid by = Petty Cash and Select Petty Cash Holder
8379

8480
**Create an Expense Report paid by Petty Cash**
8581

86-
1. Go to Expenses > My Expense Reports
87-
2. Create a new expense report
88-
3. Select or Create expenses Paid by Petty Cash and same Petty Cash
89-
Holder
82+
#. Go to Expenses > My Expense Reports
83+
#. Create a new expense report
84+
#. Select or Create expenses Paid by Petty Cash and same Petty Cash Holder
9085

91-
Note : Bill and Expense will default journal from petty cash holder, if
92-
you configure journal in petty cash holder.
86+
Note : Bill and Expense will default journal from petty cash holder,
87+
if you configure journal in petty cash holder.
9388

9489
Bug Tracker
9590
===========
9691

9792
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-expense/issues>`_.
9893
In case of trouble, please check there if your issue has already been reported.
9994
If you spotted it first, help us to smash it by providing a detailed and welcomed
100-
`feedback <https://github.com/OCA/hr-expense/issues/new?body=module:%20hr_expense_petty_cash%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
95+
`feedback <https://github.com/OCA/hr-expense/issues/new?body=module:%20hr_expense_petty_cash%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
10196

10297
Do not contact contributors directly about support or help with technical issues.
10398

10499
Credits
105100
=======
106101

107102
Authors
108-
-------
103+
~~~~~~~
109104

110105
* Ecosoft
111106

112107
Contributors
113-
------------
108+
~~~~~~~~~~~~
114109

115-
- `Ecosoft <http://ecosoft.co.th>`__:
110+
* `Ecosoft <http://ecosoft.co.th>`__:
116111

117-
- Pimolnat Suntian <[email protected]>
118-
- Saran Lim. <[email protected]>
112+
* Pimolnat Suntian <[email protected]>
113+
* Saran Lim. <[email protected]>
119114

120-
- `Trinityroots <http://trinityroots.co.th>`__:
115+
* `Trinityroots <http://trinityroots.co.th>`__:
121116

122-
- Santi Techatoo <[email protected]>
117+
* Santi Techatoo <[email protected]>
123118

124119
Maintainers
125-
-----------
120+
~~~~~~~~~~~
126121

127122
This module is maintained by the OCA.
128123

@@ -134,6 +129,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
134129
mission is to support the collaborative development of Odoo features and
135130
promote its widespread use.
136131

137-
This module is part of the `OCA/hr-expense <https://github.com/OCA/hr-expense/tree/18.0/hr_expense_petty_cash>`_ project on GitHub.
132+
This module is part of the `OCA/hr-expense <https://github.com/OCA/hr-expense/tree/16.0/hr_expense_petty_cash>`_ project on GitHub.
138133

139134
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

hr_expense_petty_cash/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "Petty Cash",
6-
"version": "15.0.2.0.0",
6+
"version": "18.0.1.0.0",
77
"category": "Human Resources",
88
"author": "Ecosoft, Odoo Community Association (OCA)",
99
"license": "AGPL-3",

hr_expense_petty_cash/i18n/es.po

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ msgstr "Archivado"
4545
msgid "Balance"
4646
msgstr "Saldo"
4747

48-
#. module: hr_expense_petty_cash
49-
#: model:ir.model.fields,field_description:hr_expense_petty_cash.field_petty_cash__company_id
50-
#: model_terms:ir.ui.view,arch_db:hr_expense_petty_cash.view_petty_cash_search
51-
msgid "Company"
52-
msgstr ""
53-
5448
#. module: hr_expense_petty_cash
5549
#: model_terms:ir.actions.act_window,help:hr_expense_petty_cash.action_petty_cash
5650
msgid "Create a new petty cash holder"
@@ -132,12 +126,11 @@ msgstr "Límite Máximo"
132126
#, python-format
133127
msgid ""
134128
"Not enough money in petty cash holder.\n"
135-
"You are requesting {amount_company}{symbol}, but the balance is {balance}"
136-
"{symbol}."
129+
"You are requesting {amount_company}{symbol}, but the balance is {balance}{symbol}."
137130
msgstr ""
138131
"No hay suficiente dinero en la caja para gastos menores.\n"
139-
"Está solicitando {amount_company}{symbol}, pero el saldo es {balance}"
140-
"{symbol}."
132+
"Está solicitando {amount_company}{symbol}, pero el saldo es "
133+
"{balance}{symbol}."
141134

142135
#. module: hr_expense_petty_cash
143136
#: model:ir.model.fields,field_description:hr_expense_petty_cash.field_hr_expense__payment_mode

hr_expense_petty_cash/i18n/hr_expense_petty_cash.pot

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ msgstr ""
4242
msgid "Balance"
4343
msgstr ""
4444

45-
#. module: hr_expense_petty_cash
46-
#: model:ir.model.fields,field_description:hr_expense_petty_cash.field_petty_cash__company_id
47-
#: model_terms:ir.ui.view,arch_db:hr_expense_petty_cash.view_petty_cash_search
48-
msgid "Company"
49-
msgstr ""
50-
5145
#. module: hr_expense_petty_cash
5246
#: model_terms:ir.actions.act_window,help:hr_expense_petty_cash.action_petty_cash
5347
msgid "Create a new petty cash holder"

hr_expense_petty_cash/i18n/it.po

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ msgstr "In archivio"
4545
msgid "Balance"
4646
msgstr "Saldo"
4747

48-
#. module: hr_expense_petty_cash
49-
#: model:ir.model.fields,field_description:hr_expense_petty_cash.field_petty_cash__company_id
50-
#: model_terms:ir.ui.view,arch_db:hr_expense_petty_cash.view_petty_cash_search
51-
msgid "Company"
52-
msgstr ""
53-
5448
#. module: hr_expense_petty_cash
5549
#: model_terms:ir.actions.act_window,help:hr_expense_petty_cash.action_petty_cash
5650
msgid "Create a new petty cash holder"

hr_expense_petty_cash/models/account_move.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th)
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33

4-
from odoo import _, api, fields, models
4+
from odoo import api, fields, models
55
from odoo.exceptions import UserError, ValidationError
66
from odoo.tools import float_compare
77

88

99
class AccountMove(models.Model):
1010
_inherit = "account.move"
1111

12-
is_petty_cash = fields.Boolean(
13-
string="Petty Cash",
14-
readonly=True,
15-
states={"draft": [("readonly", False)]},
16-
)
12+
is_petty_cash = fields.Boolean(string="Petty Cash")
1713

1814
def action_post(self):
1915
self._check_petty_cash_amount()
@@ -38,30 +34,32 @@ def _check_petty_cash_amount(self):
3834
and account.id in rec.invoice_line_ids.mapped("account_id").ids
3935
):
4036
raise UserError(
41-
_("Please check Petty Cash on {name}.").format(
37+
self.env._("Please check Petty Cash on {name}.").format(
4238
name=rec.display_name
4339
)
4440
)
4541
if rec.is_petty_cash:
4642
if len(rec.invoice_line_ids) > 1:
4743
raise UserError(
48-
_(
44+
self.env._(
4945
"{name} with petty cash checked must contain "
5046
"only 1 line."
5147
).format(name=rec.display_name)
5248
)
5349
if rec.invoice_line_ids.account_id.id != account.id:
5450
raise UserError(
55-
_("Account on invoice line should be {name}.").format(
56-
name=account.display_name
57-
)
51+
self.env._(
52+
"Account on invoice line should be {name}."
53+
).format(name=account.display_name)
5854
)
5955
balance = petty_cash.petty_cash_balance
6056
limit = petty_cash.petty_cash_limit
6157
max_amount = limit - balance
6258
amount = sum(
6359
rec.invoice_line_ids.filtered(
64-
lambda line, acc=account: line.account_id == acc
60+
lambda inv_line, _account=account: (
61+
inv_line.account_id == _account
62+
)
6563
).mapped("price_subtotal")
6664
)
6765
company_currency = rec.company_id.currency_id
@@ -79,7 +77,7 @@ def _check_petty_cash_amount(self):
7977
== 1
8078
):
8179
raise ValidationError(
82-
_(
80+
self.env._(
8381
"Petty Cash balance is {balance} {symbol}.\n"
8482
"Max amount to add is {max_amount} {symbol}."
8583
).format(
@@ -108,6 +106,7 @@ def _add_petty_cash_invoice_line(self, petty_cash):
108106
"partner_id": petty_cash.partner_id.id,
109107
"price_unit": amount_doc_currency,
110108
"quantity": 1,
109+
"tax_ids": [], # no tax need
111110
}
112111
)
113112
return inv_line
@@ -118,7 +117,7 @@ def _onchange_is_petty_cash(self):
118117
self.invoice_line_ids = False
119118
if self.is_petty_cash:
120119
if not self.partner_id:
121-
raise ValidationError(_("Please select petty cash holder"))
120+
raise ValidationError(self.env._("Please select petty cash holder"))
122121
# Selected partner must be petty cash holder
123122
petty_cash = self.env["petty.cash"].search(
124123
[
@@ -129,12 +128,10 @@ def _onchange_is_petty_cash(self):
129128
)
130129
if not petty_cash:
131130
raise ValidationError(
132-
_("%s is not a petty cash holder") % self.partner_id.name
131+
self.env._("%s is not a petty cash holder") % self.partner_id.name
133132
)
134133
self.invoice_line_ids = self._add_petty_cash_invoice_line(petty_cash)
135-
self._onchange_invoice_line_ids()
136-
self.line_ids._onchange_price_subtotal()
137-
self._onchange_recompute_dynamic_lines()
134+
138135
if petty_cash.journal_id:
139136
# Prevent inconsistent journal_id
140137
if (

0 commit comments

Comments
 (0)