[IMP] sale: clean res config settings fields ordering
Part-of: odoo/odoo#81510
This commit is contained in:
@@ -7,40 +7,23 @@ from odoo import api, fields, models
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
group_auto_done_setting = fields.Boolean("Lock Confirmed Sales", implied_group='sale.group_auto_done_setting')
|
||||
module_sale_margin = fields.Boolean("Margins")
|
||||
quotation_validity_days = fields.Integer(related='company_id.quotation_validity_days', string="Default Quotation Validity (Days)", readonly=False)
|
||||
use_quotation_validity_days = fields.Boolean("Default Quotation Validity", config_parameter='sale.use_quotation_validity_days')
|
||||
group_warning_sale = fields.Boolean("Sale Order Warnings", implied_group='sale.group_warning_sale')
|
||||
portal_confirmation_sign = fields.Boolean(related='company_id.portal_confirmation_sign', string='Online Signature', readonly=False)
|
||||
portal_confirmation_pay = fields.Boolean(related='company_id.portal_confirmation_pay', string='Online Payment', readonly=False)
|
||||
group_proforma_sales = fields.Boolean(string="Pro-Forma Invoice", implied_group='sale.group_proforma_sales',
|
||||
help="Allows you to send pro-forma invoice.")
|
||||
# Defaults
|
||||
default_invoice_policy = fields.Selection([
|
||||
('order', 'Invoice what is ordered'),
|
||||
('delivery', 'Invoice what is delivered')
|
||||
], 'Invoicing Policy',
|
||||
default='order',
|
||||
default_model='product.template')
|
||||
deposit_default_product_id = fields.Many2one(
|
||||
'product.product',
|
||||
'Deposit Product',
|
||||
domain="[('type', '=', 'service')]",
|
||||
config_parameter='sale.default_deposit_product_id',
|
||||
help='Default product used for payment advances')
|
||||
|
||||
module_delivery = fields.Boolean("Delivery Methods")
|
||||
module_delivery_dhl = fields.Boolean("DHL Express Connector")
|
||||
module_delivery_fedex = fields.Boolean("FedEx Connector")
|
||||
module_delivery_ups = fields.Boolean("UPS Connector")
|
||||
module_delivery_usps = fields.Boolean("USPS Connector")
|
||||
module_delivery_bpost = fields.Boolean("bpost Connector")
|
||||
module_delivery_easypost = fields.Boolean("Easypost Connector")
|
||||
|
||||
module_product_email_template = fields.Boolean("Specific Email")
|
||||
module_sale_coupon = fields.Boolean("Coupons & Promotions")
|
||||
module_sale_amazon = fields.Boolean("Amazon Sync")
|
||||
# Groups
|
||||
group_auto_done_setting = fields.Boolean(
|
||||
string="Lock Confirmed Sales", implied_group='sale.group_auto_done_setting')
|
||||
group_proforma_sales = fields.Boolean(
|
||||
string="Pro-Forma Invoice", implied_group='sale.group_proforma_sales',
|
||||
help="Allows you to send pro-forma invoice.")
|
||||
group_warning_sale = fields.Boolean("Sale Order Warnings", implied_group='sale.group_warning_sale')
|
||||
|
||||
# Config params
|
||||
automatic_invoice = fields.Boolean(
|
||||
string="Automatic Invoice",
|
||||
help="The invoice is generated automatically and available in the customer portal when the "
|
||||
@@ -50,13 +33,6 @@ class ResConfigSettings(models.TransientModel):
|
||||
"and not after the delivery.",
|
||||
config_parameter='sale.automatic_invoice',
|
||||
)
|
||||
invoice_mail_template_id = fields.Many2one(
|
||||
comodel_name='mail.template',
|
||||
string='Invoice Email Template',
|
||||
domain="[('model', '=', 'account.move')]",
|
||||
config_parameter='sale.default_invoice_email_template',
|
||||
help="Email sent to the customer once the invoice is available.",
|
||||
)
|
||||
confirmation_mail_template_id = fields.Many2one(
|
||||
comodel_name='mail.template',
|
||||
string='Confirmation Email Template',
|
||||
@@ -64,15 +40,47 @@ class ResConfigSettings(models.TransientModel):
|
||||
config_parameter='sale.default_confirmation_template',
|
||||
help="Email sent to the customer once the order is paid."
|
||||
)
|
||||
deposit_default_product_id = fields.Many2one(
|
||||
'product.product',
|
||||
'Deposit Product',
|
||||
domain="[('type', '=', 'service')]",
|
||||
config_parameter='sale.default_deposit_product_id',
|
||||
help='Default product used for payment advances')
|
||||
|
||||
def set_values(self):
|
||||
super().set_values()
|
||||
if self.default_invoice_policy != 'order':
|
||||
self.env['ir.config_parameter'].set_param('sale.automatic_invoice', False)
|
||||
invoice_mail_template_id = fields.Many2one(
|
||||
comodel_name='mail.template',
|
||||
string='Invoice Email Template',
|
||||
domain="[('model', '=', 'account.move')]",
|
||||
config_parameter='sale.default_invoice_email_template',
|
||||
help="Email sent to the customer once the invoice is available.",
|
||||
)
|
||||
|
||||
send_invoice_cron = self.env.ref('sale.send_invoice_cron', raise_if_not_found=False)
|
||||
if send_invoice_cron and send_invoice_cron.active != self.automatic_invoice:
|
||||
send_invoice_cron.active = self.automatic_invoice
|
||||
use_quotation_validity_days = fields.Boolean(
|
||||
"Default Quotation Validity", config_parameter='sale.use_quotation_validity_days')
|
||||
|
||||
# Company setup
|
||||
quotation_validity_days = fields.Integer(
|
||||
related='company_id.quotation_validity_days', string="Default Quotation Validity (Days)", readonly=False)
|
||||
portal_confirmation_sign = fields.Boolean(
|
||||
related='company_id.portal_confirmation_sign', string='Online Signature', readonly=False)
|
||||
portal_confirmation_pay = fields.Boolean(
|
||||
related='company_id.portal_confirmation_pay', string='Online Payment', readonly=False)
|
||||
|
||||
# Modules
|
||||
module_delivery = fields.Boolean("Delivery Methods")
|
||||
module_delivery_bpost = fields.Boolean("bpost Connector")
|
||||
module_delivery_dhl = fields.Boolean("DHL Express Connector")
|
||||
module_delivery_easypost = fields.Boolean("Easypost Connector")
|
||||
module_delivery_fedex = fields.Boolean("FedEx Connector")
|
||||
module_delivery_ups = fields.Boolean("UPS Connector")
|
||||
module_delivery_usps = fields.Boolean("USPS Connector")
|
||||
|
||||
module_product_email_template = fields.Boolean("Specific Email")
|
||||
module_sale_amazon = fields.Boolean("Amazon Sync")
|
||||
module_sale_coupon = fields.Boolean("Coupons & Promotions")
|
||||
module_sale_margin = fields.Boolean("Margins")
|
||||
|
||||
#=== ONCHANGE METHODS ===#
|
||||
|
||||
@api.onchange('use_quotation_validity_days')
|
||||
def _onchange_use_quotation_validity_days(self):
|
||||
@@ -86,3 +94,14 @@ class ResConfigSettings(models.TransientModel):
|
||||
return {
|
||||
'warning': {'title': "Warning", 'message': "Quotation Validity is required and must be greater than 0."},
|
||||
}
|
||||
|
||||
#=== CRUD METHODS ===#
|
||||
|
||||
def set_values(self):
|
||||
super().set_values()
|
||||
if self.default_invoice_policy != 'order':
|
||||
self.env['ir.config_parameter'].set_param('sale.automatic_invoice', False)
|
||||
|
||||
send_invoice_cron = self.env.ref('sale.send_invoice_cron', raise_if_not_found=False)
|
||||
if send_invoice_cron and send_invoice_cron.active != self.automatic_invoice:
|
||||
send_invoice_cron.active = self.automatic_invoice
|
||||
|
||||
Reference in New Issue
Block a user