110 lines
3.5 KiB
Python
110 lines
3.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2024-2025 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
# Part of the Fusion Claim Assistant product family.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class ProductTemplate(models.Model):
|
|
_inherit = 'product.template'
|
|
|
|
# ==========================================================================
|
|
# ADP PRODUCT FIELDS
|
|
# These are the module's own fields - independent of Odoo Studio
|
|
# ==========================================================================
|
|
|
|
x_fc_adp_device_code = fields.Char(
|
|
string='ADP Device Code',
|
|
help='Device code used for ADP claims export',
|
|
copy=True,
|
|
tracking=True,
|
|
)
|
|
|
|
x_fc_adp_price = fields.Float(
|
|
string='ADP Price',
|
|
digits='Product Price',
|
|
help='ADP retail price for this product. Used in ADP reports and claims.',
|
|
copy=True,
|
|
tracking=True,
|
|
)
|
|
|
|
x_fc_is_adp_product = fields.Boolean(
|
|
string='Is ADP Product',
|
|
compute='_compute_is_adp_product',
|
|
store=True,
|
|
help='Indicates if this product has ADP pricing set up',
|
|
)
|
|
|
|
# ==========================================================================
|
|
# LOANER PRODUCT FIELDS
|
|
# ==========================================================================
|
|
|
|
x_fc_can_be_loaned = fields.Boolean(
|
|
string='Can be Loaned',
|
|
default=False,
|
|
help='If checked, this product can be loaned out to clients',
|
|
)
|
|
x_fc_loaner_period_days = fields.Integer(
|
|
string='Loaner Period (Days)',
|
|
default=7,
|
|
help='Default number of free loaner days before rental conversion',
|
|
)
|
|
x_fc_rental_price_weekly = fields.Float(
|
|
string='Weekly Rental Price',
|
|
digits='Product Price',
|
|
help='Rental price per week if loaner converts to rental',
|
|
)
|
|
x_fc_rental_price_monthly = fields.Float(
|
|
string='Monthly Rental Price',
|
|
digits='Product Price',
|
|
help='Rental price per month if loaner converts to rental',
|
|
)
|
|
|
|
# ==========================================================================
|
|
# COMPUTED FIELDS
|
|
# ==========================================================================
|
|
|
|
@api.depends('x_fc_adp_device_code', 'x_fc_adp_price')
|
|
def _compute_is_adp_product(self):
|
|
"""Determine if this is an ADP product based on having device code or price."""
|
|
for product in self:
|
|
product.x_fc_is_adp_product = bool(
|
|
product.x_fc_adp_device_code or product.x_fc_adp_price
|
|
)
|
|
|
|
# ==========================================================================
|
|
# HELPER METHODS
|
|
# ==========================================================================
|
|
|
|
def get_adp_price(self):
|
|
"""
|
|
Get ADP price with fallback to Studio field.
|
|
|
|
Checks in order:
|
|
1. x_fc_adp_price (module field)
|
|
2. list_price (default product price)
|
|
"""
|
|
self.ensure_one()
|
|
|
|
if self.x_fc_adp_price:
|
|
return self.x_fc_adp_price
|
|
|
|
return self.list_price or 0.0
|
|
|
|
def get_adp_device_code(self):
|
|
"""
|
|
Get ADP device code.
|
|
|
|
Checks in order:
|
|
1. x_fc_adp_device_code (module field)
|
|
2. default_code (internal reference)
|
|
"""
|
|
self.ensure_one()
|
|
|
|
if self.x_fc_adp_device_code:
|
|
return self.x_fc_adp_device_code
|
|
|
|
return self.default_code or ''
|
|
|