Skip to content

Commit 2b7f3d1

Browse files
Merge pull request #69 from hbrunn/14.0-147-charged-flag-move-line
[ADD] #147 customer_expense_charged flag for move lines
2 parents 1744d6f + 0387439 commit 2b7f3d1

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

ps_expense/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
"hr_expense_operating_unit",
1212
"invoice_line_revenue_distribution_operating_unit",
1313
"sale_expense",
14+
"ps_timesheet_invoicing",
1415
],
1516
"data": [
1617
"security/ir_rule.xml",
18+
"views/account_move_line.xml",
1719
"views/hr_expense.xml",
1820
"views/hr_expense_sheet.xml",
1921
"views/res_company_view.xml",

ps_expense/models/account_move_line.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
# Copyright 2018 The Open Source Company ((www.tosc.nl).)
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33

4-
from odoo import fields, models
4+
from odoo import api, fields, models
55

66

77
class AccountMoveLine(models.Model):
88
_inherit = "account.move.line"
99

1010
customer_charge_expense = fields.Boolean("Charge Expense To Customer", index=True)
11+
customer_expense_charged = fields.Boolean(
12+
"Charged",
13+
store=True,
14+
readonly=False,
15+
compute="_compute_customer_expense_charged",
16+
help="Indicates whether this expense has been charged to the customer. "
17+
"The flag is set automatically when this line's analytic line is added to an analytic "
18+
"invoice, or set manually for other means of invoicing an expense",
19+
)
20+
21+
@api.depends("analytic_line_ids.ps_invoice_id")
22+
def _compute_customer_expense_charged(self):
23+
for this in self:
24+
this.customer_expense_charged = bool(this.analytic_line_ids.ps_invoice_id)
1125

1226
def _prepare_analytic_line(self):
1327
result = super()._prepare_analytic_line()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<odoo>
2+
<record id="view_move_line_tree" model="ir.ui.view">
3+
<field name="model">account.move.line</field>
4+
<field name="inherit_id" ref="account.view_move_line_tree" />
5+
<field name="arch" type="xml">
6+
<tree position="inside">
7+
<field name="customer_expense_charged" optional="hide" />
8+
</tree>
9+
</field>
10+
</record>
11+
<record id="view_move_line_form" model="ir.ui.view">
12+
<field name="model">account.move.line</field>
13+
<field name="inherit_id" ref="account.view_move_line_form" />
14+
<field name="arch" type="xml">
15+
<field name="blocked" position="after">
16+
<field name="customer_expense_charged" />
17+
</field>
18+
</field>
19+
</record>
20+
<record id="view_account_move_line_filter" model="ir.ui.view">
21+
<field name="model">account.move.line</field>
22+
<field name="inherit_id" ref="account.view_account_move_line_filter" />
23+
<field name="arch" type="xml">
24+
<filter name="misc_filter" position="after">
25+
<filter
26+
name="ps_expense_uncharged"
27+
string="Uncharged Expenses"
28+
domain="[('expense_id', '!=', False), ('customer_expense_charged', '=', False)]"
29+
/>
30+
</filter>
31+
</field>
32+
</record>
33+
</odoo>

0 commit comments

Comments
 (0)