mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-26 22:32:05 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
133
odoo-bringout-oca-ocb-sale/sale/wizard/res_config_settings.py
Normal file
133
odoo-bringout-oca-ocb-sale/sale/wizard/res_config_settings.py
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
# Defaults
|
||||
default_invoice_policy = fields.Selection(
|
||||
selection=[
|
||||
('order', "Invoice what is ordered"),
|
||||
('delivery', "Invoice what is delivered")
|
||||
],
|
||||
string="Invoicing Policy",
|
||||
default='order',
|
||||
default_model='product.template')
|
||||
|
||||
# Groups
|
||||
group_auto_done_setting = fields.Boolean(
|
||||
string="Lock Confirmed Sales", implied_group='sale.group_auto_done_setting')
|
||||
group_discount_per_so_line = fields.Boolean(
|
||||
string="Discounts", implied_group='sale.group_discount_per_so_line')
|
||||
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(
|
||||
string="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 "
|
||||
"transaction is confirmed by the payment provider.\nThe invoice is marked as paid and "
|
||||
"the payment is registered in the payment journal defined in the configuration of the "
|
||||
"payment provider.\nThis mode is advised if you issue the final invoice at the order "
|
||||
"and not after the delivery.",
|
||||
config_parameter='sale.automatic_invoice',
|
||||
)
|
||||
|
||||
invoice_mail_template_id = fields.Many2one(
|
||||
comodel_name='mail.template',
|
||||
string="Email Template",
|
||||
domain=[('model', '=', 'account.move')],
|
||||
config_parameter='sale.default_invoice_email_template',
|
||||
help="Email sent to the customer once the invoice is available.",
|
||||
)
|
||||
quotation_validity_days = fields.Integer(
|
||||
related='company_id.quotation_validity_days',
|
||||
readonly=False)
|
||||
portal_confirmation_sign = fields.Boolean(
|
||||
related='company_id.portal_confirmation_sign',
|
||||
readonly=False)
|
||||
portal_confirmation_pay = fields.Boolean(
|
||||
related='company_id.portal_confirmation_pay',
|
||||
readonly=False)
|
||||
prepayment_percent = fields.Float(
|
||||
related='company_id.prepayment_percent',
|
||||
readonly=False)
|
||||
downpayment_account_id = fields.Many2one(related='company_id.downpayment_account_id', 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_envia = fields.Boolean("Envia.com Connector")
|
||||
module_delivery_fedex_rest = fields.Boolean("FedEx Connector")
|
||||
module_delivery_sendcloud = fields.Boolean("Sendcloud Connector")
|
||||
module_delivery_shiprocket = fields.Boolean("Shiprocket Connector")
|
||||
module_delivery_starshipit = fields.Boolean("Starshipit Connector")
|
||||
module_delivery_ups_rest = fields.Boolean("UPS Connector")
|
||||
module_delivery_usps_rest = fields.Boolean("USPS Connector")
|
||||
|
||||
module_product_email_template = fields.Boolean("Specific Email")
|
||||
module_sale_amazon = fields.Boolean("Amazon Sync")
|
||||
module_sale_commission = fields.Boolean("Commissions")
|
||||
module_sale_gelato = fields.Boolean("Gelato")
|
||||
module_sale_loyalty = fields.Boolean("Coupons & Loyalty")
|
||||
module_sale_margin = fields.Boolean("Margins")
|
||||
module_sale_pdf_quote_builder = fields.Boolean("PDF Quote builder")
|
||||
module_sale_product_matrix = fields.Boolean("Sales Grid Entry")
|
||||
module_sale_shopee = fields.Boolean("Shopee Sync")
|
||||
|
||||
#=== ONCHANGE METHODS ===#
|
||||
|
||||
@api.depends('group_discount_per_so_line')
|
||||
def _onchange_group_discount_per_so_line(self):
|
||||
if self.group_discount_per_so_line:
|
||||
self.group_product_pricelist = True
|
||||
|
||||
@api.onchange('group_product_variant')
|
||||
def _onchange_group_product_variant(self):
|
||||
"""The product Configurator requires the product variants activated.
|
||||
If the user disables the product variants -> disable the product configurator as well"""
|
||||
if self.module_sale_product_matrix and not self.group_product_variant:
|
||||
self.module_sale_product_matrix = False
|
||||
|
||||
@api.onchange('portal_confirmation_pay')
|
||||
def _onchange_portal_confirmation_pay(self):
|
||||
self.prepayment_percent = self.prepayment_percent or 1.0
|
||||
|
||||
@api.onchange('prepayment_percent')
|
||||
def _onchange_prepayment_percent(self):
|
||||
if not self.prepayment_percent:
|
||||
self.portal_confirmation_pay = False
|
||||
|
||||
@api.onchange('quotation_validity_days')
|
||||
def _onchange_quotation_validity_days(self):
|
||||
if self.quotation_validity_days < 0:
|
||||
self.quotation_validity_days = self.env['res.company'].default_get(
|
||||
['quotation_validity_days']
|
||||
)['quotation_validity_days']
|
||||
return {
|
||||
'warning': {
|
||||
'title': _("Warning"),
|
||||
'message': _("Quotation Validity is required and must be greater or equal to 0."),
|
||||
},
|
||||
}
|
||||
|
||||
#=== CRUD METHODS ===#
|
||||
|
||||
def set_values(self):
|
||||
super().set_values()
|
||||
if self.default_invoice_policy != 'order':
|
||||
self.env['ir.config_parameter'].set_param(key='sale.automatic_invoice', value=False)
|
||||
|
||||
# === ACTION METHODS === #
|
||||
|
||||
# Unique name to avoid colliding with `website_payment`.
|
||||
def action_sale_start_payment_onboarding(self):
|
||||
menu = self.env.ref('sale.menu_sale_general_settings', raise_if_not_found=False)
|
||||
return self._start_payment_onboarding(menu and menu.id)
|
||||
Loading…
Add table
Add a link
Reference in a new issue