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,48 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class MaintenanceEquipment(models.Model):
_inherit = "maintenance.equipment"
product_id = fields.Many2one(
comodel_name="product.product",
string="Product",
tracking=True,
domain="""
[
('categ_id', 'child_of', product_category_id),
('maintenance_ok', '=', True),
]
""",
)
product_category_id = fields.Many2one(
comodel_name="product.category", related="category_id.product_category_id"
)
@api.onchange("product_id")
def _onchange_product_id(self):
"""If product is set, equipment name, seller, seller ref and cost defaults
to product ones.
"""
if self.product_id:
self.name = self.product_id.name
self.cost = self.product_id.standard_price
if self.product_id.seller_ids:
first_seller = fields.first(self.product_id.seller_ids)
self.partner_id = first_seller.partner_id
self.partner_ref = first_seller.product_code
class MaintenanceEquipmentCategory(models.Model):
_inherit = "maintenance.equipment.category"
product_category_id = fields.Many2one(
comodel_name="product.category", string="Product Category", tracking=True
)
@api.onchange("product_category_id")
def _onchange_product_category_id(self):
if self.product_category_id:
self.name = self.product_category_id.name