Files
Odoo-18.0-20251222/stock_picking_invoicing/models/stock_invoice_state_mixin.py
tocmo0nlord adbe430761
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled
Initial commit: Odoo 18.0-20251222 extra-addons
2026-03-13 20:43:25 +00:00

60 lines
1.9 KiB
Python

# Copyright (C) 2019-Today: Odoo Community Association (OCA)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class StockInvoiceStateMixin(models.AbstractModel):
"""
Abstract model used to define invoice state with selection choices
"""
_name = "stock.invoice.state.mixin"
_description = "Stock Invoice State Mixin"
invoice_state = fields.Selection(
selection=[
("invoiced", "Invoiced"),
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable"),
],
string="Invoice Status",
default="none",
help="Invoiced: an invoice already exists\n"
"To Be Invoiced: need to be invoiced\n"
"Not Applicable: no invoice to create",
copy=False,
)
def _set_as_invoiced(self):
"""
Update invoice_state on current recordset to 'invoiced'
:return: self recordset (where the updated has been executed)
"""
return self._update_invoice_state("invoiced")
def _set_as_2binvoiced(self):
"""
Update invoice_state on current recordset to '2binvoiced'
:return: self recordset (where the updated has been executed)
"""
return self._update_invoice_state("2binvoiced")
def _set_as_not_billable(self):
"""
Update invoice_state on current recordset to 'invoiced'
:return: self recordset (where the updated has been executed)
"""
return self._update_invoice_state("none")
def _update_invoice_state(self, invoice_state):
"""
Execute the write
:param invoice_state: str
:return: self recordset (where the updated has been executed)
"""
records = self.filtered(lambda r: r.invoice_state != invoice_state)
if records:
records.write({"invoice_state": invoice_state})
return records