forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpurchase.py
More file actions
26 lines (21 loc) · 880 Bytes
/
purchase.py
File metadata and controls
26 lines (21 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from odoo import api, fields, models
class PurchaseOrder(models.Model):
_inherit = "purchase.order"
force_invoiced = fields.Boolean(
readonly=True,
states={"done": [("readonly", False)]},
copy=False,
help="When you set this field, the purchase order will be "
"considered as fully billed, even when there may be ordered "
"or delivered quantities pending to bill. To use this field, "
"the order must be in 'Locked' state",
)
@api.depends("force_invoiced")
def _get_invoiced(self):
res = super(PurchaseOrder, self)._get_invoiced()
for order in self.filtered(
lambda po: po.force_invoiced and po.invoice_status == "to invoice"
):
order.invoice_status = "invoiced"
return res