<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="res_config_settings_view_form" model="ir.ui.view">
        <field name="name">res.config.settings.view.form.inherit.sale</field>
        <field name="model">res.config.settings</field>
        <field name="priority" eval="10"/>
        <field name="inherit_id" ref="base.res_config_settings_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//form" position="inside">
                <app notApp="1" string="Sales" data-string="Sales" name="sale_management" groups="sales_team.group_sale_manager">
                    <block title="Product Catalog" name="catalog_setting_container">
                        <setting id="variant_options" help="Sell variants of a product using attributes (size, color, etc.)" documentation="/applications/sales/sales/products_prices/products/variants.html">
                            <field name="group_product_variant"/>
                            <div class="content-group" invisible="not group_product_variant">
                                <div class="mt8">
                                    <button name="%(product.attribute_action)d" icon="oi-arrow-right" type="action" string="Attributes" class="btn-link"/>
                                </div>
                            </div>
                        </setting>
                        <setting string="Variant Grid Entry" help="Add several variants to an order from a grid" id="product_matrix">
                            <field name="module_sale_product_matrix"/>
                        </setting>
                        <setting id="uom_settings" help="Sell and purchase products in different units of measure">
                            <field name="group_uom"/>
                            <div class="content-group" invisible="not group_uom">
                                <div class="mt8">
                                    <button name="%(uom.product_uom_categ_form_action)d" icon="oi-arrow-right" type="action" string="Units of Measure" class="btn-link"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="email_template" title="Sending an email is useful if you need to share specific information or content about a product (instructions, rules, links, media, etc.). Create and set the email template from the product detail form (in Accounting tab)." string="Deliver Content by Email" help="Send a product-specific email once the invoice is validated">
                            <field name="module_product_email_template"/>
                        </setting>
                        <setting id="stock_packaging" title="Ability to select a package type in sales orders and to force a quantity that is a multiple of the number of units per package." help="Sell products by multiple of unit # per package">
                            <field name="group_stock_packaging"/>
                        </setting>
                    </block>
                    <block title="Pricing" id="pricing_setting_container">
                      <setting id="discount_sale_order_lines" title="Apply manual discounts on sales order lines or display discounts computed from pricelists (option to activate in the pricelist configuration)." help="Grant discounts on sales order lines">
                            <field name="group_discount_per_so_line"/>
                       </setting>
                        <setting id="coupon_settings" title="Boost your sales with multiple kinds of programs: Coupons, Promotions, Gift Card, Loyalty. Specific conditions can be set (products, customers, minimum purchase amount, period). Rewards can be discounts (% or amount) or free products." string="Discounts, Loyalty &amp; Gift Card" help="Manage Promotions, coupons, loyalty cards, Gift cards &amp; eWallet">
                            <field name="module_loyalty"/>
                        </setting>
                        <setting id="pricelist_configuration" documentation="/applications/sales/sales/products_prices/prices/pricing.html" help="Set multiple prices per product, automated discounts, etc.">
                            <field name="group_product_pricelist"/>
                            <div class="content-group" invisible="not group_product_pricelist">
                                <div class="mt16">
                                    <field name="group_sale_pricelist" invisible="1"/>
                                    <field name="product_pricelist_setting" widget="radio" class="o_light_label"/>
                                </div>
                                <div class="mt8">
                                    <button name="%(product.product_pricelist_action2)d" icon="oi-arrow-right" type="action" string="Pricelists" groups="product.group_product_pricelist" class="btn-link"/>
                                </div>
                            </div>
                        </setting>
                        <setting id="auth_signup_documents" title=" To send invitations in B2B mode, open a contact or select several ones in list view and click on 'Portal Access Management' option in the dropdown menu *Action*." help="Let your customers log in to see their documents">
                            <field name="auth_signup_uninvited" class="o_light_label" widget="radio" options="{'horizontal': true}" required="True"/>
                        </setting>
                        <setting id="show_margins" help="Show margins on orders" title="The margin is computed as the sum of product sales prices minus the cost set in their detail form.">
                            <field name="module_sale_margin"/>
                        </setting>
                    </block>
                    <block title="Quotations &amp; Orders" name="quotation_order_setting_container">
                        <setting id="order_default_values"
                            string="Default values"
                            help="Default values used when creating new quotations. Those can still be changed on each quotation."
                            company_dependent="1">
                            <div class="mt16" id="order_default_values_div">
                                <div>
                                    <field name="portal_confirmation_sign" class="w-auto"/>
                                    <label for="portal_confirmation_sign"/>
                                    <a href="https://www.odoo.com/documentation/17.0/applications/sales/sales/send_quotations/get_signature_to_validate.html"
                                        title="Documentation"
                                        class="me-2 o_doc_link"
                                        target="_blank"/>
                                </div>
                                <div class="text-muted">
                                    Request an online signature to confirm orders
                                </div>
                                <div class="mt16">
                                    <field name="portal_confirmation_pay" class="col-lg-4 oe_inline"/>
                                    <label for="portal_confirmation_pay"/>
                                    <a href="https://www.odoo.com/documentation/17.0/applications/sales/sales/send_quotations/get_paid_to_validate.html"
                                           title="Documentation"
                                           class="me-2 o_doc_link"
                                           target="_blank"/>
                                </div>
                                <div class="text-muted">
                                    Request an online prepayment from your customers to confirm orders. You can ask them to fully pay the order or partially with a downpayment
                                </div>
                                <div invisible="not portal_confirmation_pay" class="text-nowrap fw-bold">
                                    Prepayment amount
                                    <field name="prepayment_percent" widget="percentage" style="width: 3rem"/>
                                </div>
                                <div class="mt8" invisible="not portal_confirmation_pay">
                                    <button name='%(payment.action_payment_provider)d' icon="oi-arrow-right" type="action" string="Payment Providers" class="btn-link"/>
                                </div>
                                <div class="mt16" title="Days between quotation proposal and expiration. 0 days means automatic expiration is disabled">
                                    <label for="quotation_validity_days"/>
                                    <field name="quotation_validity_days" class="text-center" style="width: 5rem;"/>
                                    <div class="d-inline-block">days</div>
                                </div>
                            </div>
                        </setting>
                        <setting id="order_warnings" string="Sale Warnings" help="Get warnings in orders for products or customers">
                            <field name="group_warning_sale"/>
                        </setting>
                        <setting id="sale_pdf_quote_builder" string="PDF Quote builder" help="Make your quote attractive by adding header pages, product descriptions and footer pages to your quote.">
                            <field name="module_sale_pdf_quote_builder"/>
                        </setting>
                        <setting id="no_edit_order" help="No longer edit orders once confirmed">
                            <field name="group_auto_done_setting"/>
                        </setting>
                        <setting id="proforma_configuration" help="Allows you to send Pro-Forma Invoice to your customers">
                            <field name="group_proforma_sales"/>
                        </setting>
                    </block>
                    <block title="Shipping" name="sale_shipping_setting_container">
                        <setting id="delivery" help="Compute shipping costs on orders">
                            <field name="module_delivery"/>
                        </setting>
                        <setting id="ups" help="Compute shipping costs and ship with UPS"
                                 documentation="/applications/inventory_and_mrp/inventory/shipping/setup/third_party_shipper.html">
                            <field name="module_delivery_ups" widget="upgrade_boolean"/>
                        </setting>
                        <setting id="shipping_costs_dhl" help="Compute shipping costs and ship with DHL"
                                 documentation="/applications/inventory_and_mrp/inventory/shipping/setup/third_party_shipper.html">
                            <field name="module_delivery_dhl" widget="upgrade_boolean"/>
                        </setting>
                        <setting id="shipping_costs_fedex" help="Compute shipping costs and ship with FedEx"
                                 documentation="/applications/inventory_and_mrp/inventory/shipping/setup/third_party_shipper.html">
                            <field name="module_delivery_fedex" widget="upgrade_boolean"/>
                        </setting>
                        <setting id="shipping_costs_usps" help="Compute shipping costs and ship with USPS"
                                 documentation="/applications/inventory_and_mrp/inventory/shipping/setup/third_party_shipper.html">
                            <field name="module_delivery_usps" widget="upgrade_boolean"/>
                        </setting>
                        <setting id="shipping_costs_bpost" help="Compute shipping costs and ship with bpost"
                                 documentation="/applications/inventory_and_mrp/inventory/shipping/setup/third_party_shipper.html">
                            <field name="module_delivery_bpost" widget="upgrade_boolean"/>
                        </setting>
                        <setting id="shipping_costs_easypost" help="Compute shipping costs and ship with Easypost"
                                 documentation="/applications/inventory_and_mrp/inventory/shipping/setup/third_party_shipper.html">
                            <field name="module_delivery_easypost" widget="upgrade_boolean"/>
                        </setting>
                        <setting id="shipping_costs_sendcloud" help="Compute shipping costs and ship with Sendcloud"
                                 documentation="/applications/inventory_and_mrp/inventory/shipping/setup/third_party_shipper.html">
                            <field name="module_delivery_sendcloud" widget="upgrade_boolean"/>
                        </setting>
                        <setting id="shipping_costs_shiprocket" help="Compute shipping costs and ship with Shiprocket"
                                 documentation="/applications/inventory_and_mrp/inventory/shipping/setup/third_party_shipper.html">
                            <field name="module_delivery_shiprocket" widget="upgrade_boolean"/>
                        </setting>
                    </block>
                    <block title="Invoicing" name="invoicing_setting_container">
                        <setting id="sales_settings_invoicing_policy" title="This default value is applied to any new product created. This can be changed in the product detail form." documentation="/applications/sales/sales/invoicing/invoicing_policy.html" help="Quantities to invoice from sales orders">
                            <field name="default_invoice_policy" class="o_light_label" widget="radio"/>
                        </setting>
                        <setting id="automatic_invoicing" help="Generate the invoice automatically when the online payment is confirmed" invisible="default_invoice_policy != 'order' or not portal_confirmation_pay">
                            <field name="automatic_invoice"/>
                            <div  invisible="not automatic_invoice" groups="base.group_no_one">
                                <label for="invoice_mail_template_id" class="o_light_label me-2"/>
                                <field name="invoice_mail_template_id" class="oe_inline" options="{'no_create': True}"/>
                            </div>
                        </setting>
                        <setting id="down_payments"
                            string="Down Payments"
                            help="Product used for down payments"
                            documentation="/applications/sales/sales/invoicing/down_payment.html"
                            company_dependent="1">
                            <field name="deposit_default_product_id" context="{'default_detailed_type': 'service'}"/>
                        </setting>
                    </block>
                    <block title="Connectors" id="connectors_setting_container">
                        <setting id="amazon_connector" documentation="/applications/sales/sales/amazon_connector/setup.html" help="Import Amazon orders and sync deliveries">
                            <field name="module_sale_amazon" widget="upgrade_boolean"/>
                            <div class="content-group" name="amazon_connector" invisible="not module_sale_amazon"/>
                        </setting>
                    </block>
                    <div id="sale_ebay"/>
                </app>
            </xpath>
        </field>
    </record>

    <record id="action_sale_config_settings" model="ir.actions.act_window">
        <field name="name">Settings</field>
        <field name="res_model">res.config.settings</field>
        <field name="view_id" ref="res_config_settings_view_form"/>
        <field name="view_mode">form</field>
        <field name="target">inline</field>
        <field name="context">{'module' : 'sale_management', 'bin_size': False}</field>
    </record>

</odoo>