| 1 |
|
| 2 |
|
| 3 |
from odoo import api, fields, models |
| 4 |
|
| 5 |
|
| 6 |
class ResConfigSettings(models.TransientModel): |
| 7 |
_inherit = 'res.config.settings' |
| 8 |
|
| 9 |
|
| 10 |
group_show_uom_price = fields.Boolean( |
| 11 |
string="Base Unit Price", |
| 12 |
default=False, |
| 13 |
implied_group="website_sale.group_show_uom_price", |
| 14 |
group='base.group_user', |
| 15 |
) |
| 16 |
group_product_price_comparison = fields.Boolean( |
| 17 |
string="Comparison Price", |
| 18 |
implied_group="website_sale.group_product_price_comparison", |
| 19 |
group='base.group_user', |
| 20 |
help="Add a strikethrough price to your /shop and product pages for comparison purposes." |
| 21 |
"It will not be displayed if pricelists apply." |
| 22 |
) |
| 23 |
group_gmc_feed = fields.Boolean( |
| 24 |
string="Google Merchant Center", |
| 25 |
implied_group='website_sale.group_product_feed', |
| 26 |
group='base.group_user', |
| 27 |
related='website_id.enabled_gmc_src', |
| 28 |
readonly=False, |
| 29 |
) |
| 30 |
|
| 31 |
|
| 32 |
module_website_sale_autocomplete = fields.Boolean("Address Autocomplete") |
| 33 |
module_website_sale_collect = fields.Boolean("Click & Collect") |
| 34 |
|
| 35 |
|
| 36 |
add_to_cart_action = fields.Selection(related='website_id.add_to_cart_action', readonly=False) |
| 37 |
cart_recovery_mail_template = fields.Many2one( |
| 38 |
related='website_id.cart_recovery_mail_template_id', |
| 39 |
readonly=False, |
| 40 |
) |
| 41 |
cart_abandoned_delay = fields.Float( |
| 42 |
related='website_id.cart_abandoned_delay', |
| 43 |
readonly=False, |
| 44 |
) |
| 45 |
send_abandoned_cart_email = fields.Boolean( |
| 46 |
string="Abandoned Email", |
| 47 |
related='website_id.send_abandoned_cart_email', |
| 48 |
readonly=False, |
| 49 |
) |
| 50 |
salesperson_id = fields.Many2one( |
| 51 |
related='website_id.salesperson_id', |
| 52 |
readonly=False, |
| 53 |
) |
| 54 |
salesteam_id = fields.Many2one(related='website_id.salesteam_id', readonly=False) |
| 55 |
website_sale_prevent_zero_price_sale = fields.Boolean( |
| 56 |
string="Prevent Sale of Zero Priced Product", |
| 57 |
related='website_id.prevent_zero_price_sale', |
| 58 |
readonly=False, |
| 59 |
) |
| 60 |
website_sale_contact_us_button_url = fields.Char( |
| 61 |
string="Button Url", |
| 62 |
related='website_id.contact_us_button_url', |
| 63 |
readonly=False, |
| 64 |
) |
| 65 |
show_line_subtotals_tax_selection = fields.Selection( |
| 66 |
related='website_id.show_line_subtotals_tax_selection', |
| 67 |
readonly=False, |
| 68 |
) |
| 69 |
confirmation_email_template_id = fields.Many2one( |
| 70 |
related='website_id.confirmation_email_template_id', readonly=False |
| 71 |
) |
| 72 |
|
| 73 |
|
| 74 |
account_on_checkout = fields.Selection( |
| 75 |
string="Customer Accounts", |
| 76 |
selection=[ |
| 77 |
("optional", "Optional"), |
| 78 |
("disabled", "Disabled"), |
| 79 |
("mandatory", "Mandatory"), |
| 80 |
], |
| 81 |
compute="_compute_account_on_checkout", |
| 82 |
inverse="_inverse_account_on_checkout", |
| 83 |
readonly=False, |
| 84 |
required=True, |
| 85 |
) |
| 86 |
ecommerce_access = fields.Selection( |
| 87 |
related='website_id.ecommerce_access', |
| 88 |
readonly=False, |
| 89 |
) |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
@api.depends('website_id.account_on_checkout') |
| 94 |
def _compute_account_on_checkout(self): |
| 95 |
for record in self: |
| 96 |
record.account_on_checkout = record.website_id.account_on_checkout or 'disabled' |
| 97 |
|
| 98 |
def _inverse_account_on_checkout(self): |
| 99 |
for record in self: |
| 100 |
if not record.website_id: |
| 101 |
continue |
| 102 |
|
| 103 |
if record.website_id.account_on_checkout != record.account_on_checkout: |
| 104 |
if self.account_on_checkout in ['optional', 'mandatory']: |
| 105 |
record.website_id.auth_signup_uninvited = 'b2c' |
| 106 |
else: |
| 107 |
record.website_id.auth_signup_uninvited = 'b2b' |
| 108 |
record.website_id.account_on_checkout = record.account_on_checkout |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
def set_values(self): |
| 113 |
super().set_values() |
| 114 |
if self.website_id: |
| 115 |
website = self.with_context(website_id=self.website_id.id).website_id |
| 116 |
|
| 117 |
|
| 118 |
if ( |
| 119 |
self.group_gmc_feed |
| 120 |
and not self.env['product.feed'].search_count( |
| 121 |
[('website_id', '=', website.id)], limit=1 |
| 122 |
) |
| 123 |
): |
| 124 |
website._populate_product_feeds() |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
self.env['website'].sudo().search_fetch([], []).enabled_gmc_src = self.group_gmc_feed |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
def action_view_delivery_provider_modules(self): |
| 136 |
return self.env['delivery.carrier'].install_more_provider() |
| 137 |
|
| 138 |
@api.readonly |
| 139 |
def action_open_abandoned_cart_mail_template(self): |
| 140 |
return { |
| 141 |
'name': self.env._("Customize Email Templates"), |
| 142 |
'type': 'ir.actions.act_window', |
| 143 |
'res_model': 'mail.template', |
| 144 |
'view_id': False, |
| 145 |
'view_mode': 'form', |
| 146 |
'res_id': self.env['ir.model.data']._xmlid_to_res_id("website_sale.mail_template_sale_cart_recovery"), |
| 147 |
} |
| 148 |
|
| 149 |
def action_open_extra_info(self): |
| 150 |
self.ensure_one() |
| 151 |
|
| 152 |
|
| 153 |
return self.env["website"].get_client_action( |
| 154 |
'/shop/extra_info?open_editor=true', mode_edit=True, website_id=self.website_id.id) |
| 155 |
|
| 156 |
@api.readonly |
| 157 |
def action_open_sale_mail_templates(self): |
| 158 |
return { |
| 159 |
'name': self.env._("Customize Email Templates"), |
| 160 |
'type': 'ir.actions.act_window', |
| 161 |
'domain': [('model', '=', 'sale.order')], |
| 162 |
'res_model': 'mail.template', |
| 163 |
'view_id': False, |
| 164 |
'view_mode': 'list,form', |
| 165 |
} |
| 166 |
|
| 167 |
@api.readonly |
| 168 |
def action_open_product_feeds(self): |
| 169 |
"""Open the list view to manage the feed specific to the current website.""" |
| 170 |
self.ensure_one() |
| 171 |
return { |
| 172 |
'name': self.env._("Product Feeds"), |
| 173 |
'type': 'ir.actions.act_window', |
| 174 |
'res_model': 'product.feed', |
| 175 |
'views': [(False, 'list')], |
| 176 |
'target': 'new', |
| 177 |
'context': { |
| 178 |
'default_website_id': self.website_id.id, |
| 179 |
'hide_website_column': True, |
| 180 |
}, |
| 181 |
'domain': [('website_id', '=', self.website_id.id)], |
| 182 |
} |