Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
3
sale_product_set/models/__init__.py
Executable file
3
sale_product_set/models/__init__.py
Executable file
@@ -0,0 +1,3 @@
|
||||
from . import product_set_line
|
||||
from . import res_partner
|
||||
from . import res_config
|
||||
22
sale_product_set/models/product_set_line.py
Executable file
22
sale_product_set/models/product_set_line.py
Executable file
@@ -0,0 +1,22 @@
|
||||
# Copyright 2015 Anybox S.A.S
|
||||
# Copyright 2016-2018 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductSetLine(models.Model):
|
||||
_inherit = "product.set.line"
|
||||
|
||||
discount = fields.Float(string="Discount (%)", digits="Discount", default=0.0)
|
||||
|
||||
def prepare_sale_order_line_values(self, order, quantity, max_sequence=0):
|
||||
self.ensure_one()
|
||||
return {
|
||||
"order_id": order.id,
|
||||
"product_id": self.product_id.id,
|
||||
"product_uom_qty": self.quantity * quantity,
|
||||
"product_uom": self.product_id.uom_id.id,
|
||||
"sequence": max_sequence + self.sequence,
|
||||
"discount": self.discount,
|
||||
"company_id": self.company_id.id,
|
||||
}
|
||||
15
sale_product_set/models/res_config.py
Executable file
15
sale_product_set/models/res_config.py
Executable file
@@ -0,0 +1,15 @@
|
||||
# Copyright 2024 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
archive_partner_product_sets = fields.Boolean(
|
||||
config_parameter="sale_product_set.archive_partner_product_sets",
|
||||
string="Sync product sets active state with partner",
|
||||
help="When a partner is archived or un-archived \
|
||||
its product sets are archived or un-archived as well.",
|
||||
)
|
||||
33
sale_product_set/models/res_partner.py
Executable file
33
sale_product_set/models/res_partner.py
Executable file
@@ -0,0 +1,33 @@
|
||||
# Copyright 2024 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import models
|
||||
from odoo.tools import str2bool
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
ir_config_param = self.env["ir.config_parameter"].sudo()
|
||||
|
||||
if "active" in vals and str2bool(
|
||||
ir_config_param.get_param("sale_product_set.archive_partner_product_sets")
|
||||
):
|
||||
partner_product_sets = (
|
||||
self.env["product.set"]
|
||||
.with_context(active_test=False)
|
||||
.search([("partner_id", "in", self.ids)])
|
||||
)
|
||||
partner_product_sets.sudo().write({"active": vals["active"]})
|
||||
_logger.debug(
|
||||
"product.set archive state changed to "
|
||||
"<active | inactive> for partners %s",
|
||||
",".join(str(x) for x in self.ids),
|
||||
)
|
||||
return res
|
||||
Reference in New Issue
Block a user