Initial commit: Odoo 18.0-20251222 extra-addons
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

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import sale_order

View File

@@ -0,0 +1,73 @@
# Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2023 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
pricelist_id = fields.Many2one(related="order_id.pricelist_id")
force_company_id = fields.Many2one(
comodel_name="res.company",
string="Forced company",
compute="_compute_force_company_id",
readonly=False,
help="Technical field to force company or get it "
"from env user if order don't exist.",
)
company_price_amount = fields.Monetary(compute="_compute_company_price_amount")
company_price_tax_incl_excl = fields.Monetary(
compute="_compute_company_price_tax_incl_excl"
)
@api.depends("order_id")
def _compute_force_company_id(self):
"""Related company is not computed already when we click create new line"""
for line in self:
line.force_company_id = line.order_id.company_id or self.env.company
@api.depends("force_company_id", "price_total", "price_subtotal")
def _compute_company_price_amount(self):
for line in self:
if line.force_company_id.account_price_include == "tax_included":
line.company_price_amount = line.price_total
else:
line.company_price_amount = line.price_subtotal
@api.depends("force_company_id", "price_total", "price_subtotal")
def _compute_company_price_tax_incl_excl(self):
for line in self:
if line.force_company_id.account_price_include == "tax_included":
line.company_price_tax_incl_excl = line.price_subtotal
else:
line.company_price_tax_incl_excl = line.price_total
def _compute_name(self):
# A NewId is needed to set the product for the parent method to set
# the language correctly. Empty id leads to error in _get_lang.
for line in self:
if not line.order_id and line.product_id:
SaleOrder = self.env["sale.order"]
line.order_id = SaleOrder.new({})
return super()._compute_name()
@api.onchange("force_company_id")
def _onchange_force_company_id(self):
"""Assign company_id because is used in domains as partner,
product, taxes..."""
for line in self:
line.company_id = line.force_company_id
@api.onchange("order_partner_id")
def _onchange_order_partner_id(self):
"""Create order to correct compute of taxes"""
if not self.order_partner_id or self.order_id:
return
SaleOrder = self.env["sale.order"]
new_so = SaleOrder.new({"partner_id": self.order_partner_id})
for onchange_method in new_so._onchange_methods["partner_id"]:
onchange_method(new_so)
order_vals = new_so._convert_to_write(new_so._cache)
self.order_id = SaleOrder.create(order_vals)