Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
3
sale_force_invoiced/model/__init__.py
Executable file
3
sale_force_invoiced/model/__init__.py
Executable file
@@ -0,0 +1,3 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import sale_order
|
||||
45
sale_force_invoiced/model/sale_order.py
Executable file
45
sale_force_invoiced/model/sale_order.py
Executable file
@@ -0,0 +1,45 @@
|
||||
# Copyright 2017 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
force_invoiced = fields.Boolean(
|
||||
help="When you set this field, the sales order will be considered as "
|
||||
"fully invoiced, even when there may be ordered or delivered "
|
||||
"quantities pending to invoice.",
|
||||
readonly=True,
|
||||
tracking=20,
|
||||
copy=False,
|
||||
)
|
||||
|
||||
@api.depends("force_invoiced")
|
||||
def _compute_invoice_status(self):
|
||||
res = super()._compute_invoice_status()
|
||||
self.filtered(lambda so: so.force_invoiced and so.state == "sale").update(
|
||||
{"invoice_status": "invoiced"}
|
||||
)
|
||||
return res
|
||||
|
||||
@api.depends("force_invoiced")
|
||||
def _compute_amount_to_invoice(self):
|
||||
# force_invoiced causes the amount to invoice to be zero
|
||||
res = super()._compute_amount_to_invoice()
|
||||
for so in self.filtered("force_invoiced"):
|
||||
so.amount_to_invoice = 0
|
||||
return res
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
@api.depends("order_id.force_invoiced")
|
||||
def _compute_invoice_status(self):
|
||||
res = super()._compute_invoice_status()
|
||||
self.filtered(
|
||||
lambda sol: sol.order_id.force_invoiced
|
||||
).invoice_status = "invoiced"
|
||||
return res
|
||||
Reference in New Issue
Block a user