[MERGE][CLN] website_sale(_*): cleanup(s)
* Correct file & class names * Code simplification * Imports cleanup * privatize method not meant to be called in rpc * wrong view inheritance target (not containing the targeted hook) * ... closes odoo/odoo#116026 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
@@ -75,6 +75,12 @@
|
||||
<menuitem id="menu_ecommerce_payment_transactions"
|
||||
action="payment.action_payment_transaction"
|
||||
groups="base.group_no_one"/>
|
||||
<menuitem id="menu_ecommerce_delivery"
|
||||
action="delivery.action_delivery_carrier_form"/>
|
||||
<menuitem id="menu_delivery_zip_prefix"
|
||||
action="delivery.action_delivery_zip_prefix_list"
|
||||
groups="base.group_no_one"
|
||||
sequence="100"/>
|
||||
|
||||
</menuitem>
|
||||
|
||||
@@ -91,17 +97,4 @@
|
||||
parent="website.menu_content"
|
||||
sequence="30"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_ecommerce_delivery"
|
||||
parent="website_sale.menu_ecommerce_settings"
|
||||
name="Shipping Methods"
|
||||
action="delivery.action_delivery_carrier_form"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_delivery_zip_prefix"
|
||||
parent="website_sale.menu_ecommerce_settings"
|
||||
groups="base.group_no_one"
|
||||
sequence="100"
|
||||
action="delivery.action_delivery_zip_prefix_list"/>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import base64
|
||||
import io
|
||||
import os
|
||||
import mimetypes
|
||||
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
from odoo.http import request, route
|
||||
from odoo.addons.sale.controllers.portal import CustomerPortal
|
||||
|
||||
|
||||
class WebsiteSaleDigital(CustomerPortal):
|
||||
orders_page = '/my/orders'
|
||||
|
||||
@http.route()
|
||||
@route()
|
||||
def portal_order_page(self, order_id=None, **post):
|
||||
response = super(WebsiteSaleDigital, self).portal_order_page(order_id=order_id, **post)
|
||||
response = super().portal_order_page(order_id=order_id, **post)
|
||||
if not 'sale_order' in response.qcontext:
|
||||
return response
|
||||
order = response.qcontext['sale_order']
|
||||
@@ -50,9 +43,7 @@ class WebsiteSaleDigital(CustomerPortal):
|
||||
})
|
||||
return response
|
||||
|
||||
@http.route([
|
||||
'/my/download',
|
||||
], type='http', auth='public')
|
||||
@route(['/my/download'], type='http', auth='public')
|
||||
def download_attachment(self, attachment_id):
|
||||
# Check if this is a valid attachment id
|
||||
attachment = request.env['ir.attachment'].sudo().search_read(
|
||||
@@ -68,7 +59,7 @@ class WebsiteSaleDigital(CustomerPortal):
|
||||
# Check if the user has bought the associated product
|
||||
res_model = attachment['res_model']
|
||||
res_id = attachment['res_id']
|
||||
purchased_products = request.env['account.move.line'].get_digital_purchases()
|
||||
purchased_products = request.env['account.move.line']._get_digital_purchases()
|
||||
|
||||
if res_model == 'product.product':
|
||||
if res_id not in purchased_products:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="website_sale_digital.product_1" model="product.template">
|
||||
<record id="product_1" model="product.template">
|
||||
<field name="name">eBook: Office Renovation for Dummies</field>
|
||||
<field name="standard_price">2</field>
|
||||
<field name="list_price">4.50</field>
|
||||
@@ -11,7 +11,7 @@
|
||||
<field name="categ_id" ref="product.product_category_6"/>
|
||||
</record>
|
||||
|
||||
<record id="website_sale_digital.attach1" model="ir.attachment">
|
||||
<record id="attach1" model="ir.attachment">
|
||||
<field name="name">ebook.pdf</field>
|
||||
<field name="type">binary</field>
|
||||
<field name="datas" type="base64" file="website_sale_digital/static/ebook.pdf"/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import account_move_line
|
||||
from . import ir_attachment
|
||||
from . import account_invoice
|
||||
from . import product
|
||||
from . import product_product
|
||||
from . import product_template
|
||||
|
||||
+2
-4
@@ -1,14 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class AccountInvoiceLine(models.Model):
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = ['account.move.line']
|
||||
|
||||
def get_digital_purchases(self):
|
||||
def _get_digital_purchases(self):
|
||||
partner = self.env.user.partner_id
|
||||
|
||||
# Get paid invoices
|
||||
@@ -1,63 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = ['product.template']
|
||||
|
||||
attachment_count = fields.Integer(compute='_compute_attachment_count', string="File")
|
||||
|
||||
def _compute_attachment_count(self):
|
||||
attachment_data = self.env['ir.attachment']._read_group([('res_model', '=', self._name), ('res_id', 'in', self.ids), ('product_downloadable', '=', True)], ['res_id'], ['res_id'])
|
||||
mapped_data = dict([(data['res_id'], data['res_id_count']) for data in attachment_data])
|
||||
for product_template in self:
|
||||
product_template.attachment_count = mapped_data.get(product_template.id, 0)
|
||||
|
||||
def action_open_attachments(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': _('Digital Attachments'),
|
||||
'domain': [('res_model', '=', self._name), ('res_id', '=', self.id), ('product_downloadable', '=', True)],
|
||||
'res_model': 'ir.attachment',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'kanban,form',
|
||||
'context': "{'default_res_model': '%s','default_res_id': %d, 'default_product_downloadable': True}" % (self._name, self.id),
|
||||
'help': """
|
||||
<p class="o_view_nocontent_smiling_face">%s</p>
|
||||
<p>%s</p>
|
||||
""" % (_("Add attachments for this digital product"),
|
||||
_("The attached files are the ones that will be purchased and sent to the customer.")),
|
||||
}
|
||||
|
||||
|
||||
class Product(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
attachment_count = fields.Integer(compute='_compute_attachment_count', string="File")
|
||||
|
||||
def _compute_attachment_count(self):
|
||||
for product in self:
|
||||
product.attachment_count = self.env['ir.attachment'].search_count([
|
||||
'|',
|
||||
'&', '&', ('res_model', '=', 'product.template'), ('res_id', '=', product.product_tmpl_id.id), ('product_downloadable', '=', True),
|
||||
'&', '&', ('res_model', '=', 'product.product'), ('res_id', '=', product.id), ('product_downloadable', '=', True)])
|
||||
|
||||
def action_open_attachments(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': _('Digital Attachments'),
|
||||
'domain': [('product_downloadable', '=', True), '|',
|
||||
'&', ('res_model', '=', 'product.template'), ('res_id', '=', self.product_tmpl_id.id),
|
||||
'&', ('res_model', '=', self._name), ('res_id', '=', self.id)],
|
||||
'res_model': 'ir.attachment',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'kanban,form',
|
||||
'context': "{'default_res_model': '%s','default_res_id': %d, 'default_product_downloadable': True}" % (self._name, self.id),
|
||||
'help': """
|
||||
<p class="o_view_nocontent_smiling_face">%s</p>
|
||||
<p>%s</p>
|
||||
""" % (_("Add attachments for this digital product"),
|
||||
_("The attached files are the ones that will be purchased and sent to the customer.")),
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
attachment_count = fields.Integer(compute='_compute_attachment_count', string="File")
|
||||
|
||||
def _compute_attachment_count(self):
|
||||
for product in self:
|
||||
product.attachment_count = self.env['ir.attachment'].search_count([
|
||||
'|',
|
||||
'&', '&', ('res_model', '=', 'product.template'), ('res_id', '=', product.product_tmpl_id.id), ('product_downloadable', '=', True),
|
||||
'&', '&', ('res_model', '=', 'product.product'), ('res_id', '=', product.id), ('product_downloadable', '=', True)])
|
||||
|
||||
def action_open_attachments(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': _('Digital Attachments'),
|
||||
'domain': [('product_downloadable', '=', True), '|',
|
||||
'&', ('res_model', '=', 'product.template'), ('res_id', '=', self.product_tmpl_id.id),
|
||||
'&', ('res_model', '=', self._name), ('res_id', '=', self.id)],
|
||||
'res_model': 'ir.attachment',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'kanban,form',
|
||||
'context': "{'default_res_model': '%s','default_res_id': %d, 'default_product_downloadable': True}" % (self._name, self.id),
|
||||
'help': """
|
||||
<p class="o_view_nocontent_smiling_face">{}</p>
|
||||
<p>{}</p>
|
||||
""".format(_("Add attachments for this digital product"),
|
||||
_("The attached files are the ones that will be purchased and sent to the customer.")),
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
attachment_count = fields.Integer(compute='_compute_attachment_count', string="File")
|
||||
|
||||
def _compute_attachment_count(self):
|
||||
attachment_data = self.env['ir.attachment']._read_group([('res_model', '=', self._name), ('res_id', 'in', self.ids), ('product_downloadable', '=', True)], ['res_id'], ['res_id'])
|
||||
mapped_data = {data['res_id']: data['res_id_count'] for data in attachment_data}
|
||||
for product_template in self:
|
||||
product_template.attachment_count = mapped_data.get(product_template.id, 0)
|
||||
|
||||
def action_open_attachments(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': _('Digital Attachments'),
|
||||
'domain': [('res_model', '=', self._name), ('res_id', '=', self.id), ('product_downloadable', '=', True)],
|
||||
'res_model': 'ir.attachment',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'kanban,form',
|
||||
'context': "{'default_res_model': '%s','default_res_id': %d, 'default_product_downloadable': True}" % (self._name, self.id),
|
||||
'help': """
|
||||
<p class="o_view_nocontent_smiling_face">{}</p>
|
||||
<p>{}</p>
|
||||
""".format(_("Add attachments for this digital product"),
|
||||
_("The attached files are the ones that will be purchased and sent to the customer.")),
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': "Coupons, Promotions, Gift Card and Loyalty for eCommerce",
|
||||
@@ -13,12 +12,15 @@ Coupon & promotion programs can be edited in the Catalog menu of the Website app
|
||||
'depends': ['website_sale', 'website_links', 'sale_loyalty'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/sale_coupon_share_views.xml',
|
||||
|
||||
'views/loyalty_card_views.xml',
|
||||
'views/loyalty_program_views.xml',
|
||||
'views/website_sale_templates.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/snippets.xml',
|
||||
'views/website_sale_templates.xml',
|
||||
'views/website_sale_loyalty_menus.xml',
|
||||
|
||||
'wizard/coupon_share_views.xml',
|
||||
'wizard/res_config_settings_views.xml',
|
||||
],
|
||||
'demo': [
|
||||
'data/product_demo.xml',
|
||||
|
||||
@@ -1,26 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<menuitem id="menu_loyalty" name="Loyalty"
|
||||
parent="website_sale.menu_ecommerce" sequence="4"
|
||||
groups="sales_team.group_sale_manager"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_discount_loyalty_type_config"
|
||||
action="loyalty.loyalty_program_discount_loyalty_action"
|
||||
name="Discount & Loyalty"
|
||||
parent="website_sale_loyalty.menu_loyalty"
|
||||
groups="sales_team.group_sale_manager"
|
||||
sequence="50"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
id="menu_gift_ewallet_type_config"
|
||||
action="loyalty.loyalty_program_gift_ewallet_action"
|
||||
name="Gift cards & eWallet"
|
||||
parent="website_sale_loyalty.menu_loyalty"
|
||||
groups="sales_team.group_sale_manager"
|
||||
sequence="51"
|
||||
/>
|
||||
|
||||
<record id="loyalty_program_view_form_inherit_website_sale_loyalty" model="ir.ui.view">
|
||||
<field name="name">loyalty.program.view.form.inherit.website.sale.loyalty</field>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<menuitem id="menu_loyalty"
|
||||
name="Loyalty"
|
||||
parent="website_sale.menu_ecommerce"
|
||||
groups="sales_team.group_sale_manager"
|
||||
sequence="4">
|
||||
|
||||
<menuitem id="menu_discount_loyalty_type_config"
|
||||
action="loyalty.loyalty_program_discount_loyalty_action"/>
|
||||
<menuitem id="menu_gift_ewallet_type_config"
|
||||
action="loyalty.loyalty_program_gift_ewallet_action"/>
|
||||
|
||||
</menuitem>
|
||||
|
||||
</odoo>
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import sale_coupon_share
|
||||
from . import coupon_share
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from werkzeug.urls import url_encode
|
||||
@@ -7,7 +6,7 @@ from odoo import fields, models, api, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class SaleCouponShare(models.TransientModel):
|
||||
class CouponShare(models.TransientModel):
|
||||
_name = 'coupon.share'
|
||||
_description = 'Create links that apply a coupon and redirect to a specific page'
|
||||
|
||||
+10
-4
@@ -1,17 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="res_config_settings_view_form_inherit_website_sale_loyalty" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.website.sale.loyalty</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="website.res_config_settings_view_form"/>
|
||||
<field name="inherit_id" ref="website_sale.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//setting[@id='promotion_coupon_programs']" position="inside">
|
||||
<setting id="promotion_coupon_programs" position="inside">
|
||||
<div class="content-group">
|
||||
<div class="mt8" attrs="{'invisible': [('module_loyalty', '=', False)]}">
|
||||
<button name="%(loyalty.loyalty_program_discount_loyalty_action)d" icon="fa-arrow-right" type="action" string="Loyalty Programs" class="btn-link"/>
|
||||
<button name="%(loyalty.loyalty_program_discount_loyalty_action)d"
|
||||
type="action"
|
||||
string="Loyalty Programs"
|
||||
icon="fa-arrow-right"
|
||||
class="btn-link"/>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</setting>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user