[FIX] website_sale_aplicoop: Remove redundant string= attributes and fix OCA linting warnings
- Remove redundant string= from 17 field definitions where name matches string value (W8113) - Convert @staticmethod to instance methods in selection methods for proper self.env._() access - Fix W8161 (prefer-env-translation) by using self.env._() instead of standalone _() - Fix W8301/W8115 (translation-not-lazy) by proper placement of % interpolation outside self.env._() - Remove unused imports of odoo._ from group_order.py and sale_order_extension.py - All OCA linting warnings in website_sale_aplicoop main models are now resolved Changes: - website_sale_aplicoop/models/group_order.py: 21 field definitions cleaned - website_sale_aplicoop/models/sale_order_extension.py: 5 field definitions cleaned + @staticmethod conversion - Consistent with OCA standards for addon submission
This commit is contained in:
parent
5c89795e30
commit
6fbc7b9456
73 changed files with 5386 additions and 4354 deletions
|
|
@ -1,61 +1,72 @@
|
|||
# Copyright 2025 Criptomart
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
|
||||
from odoo import _
|
||||
from odoo.http import request, route
|
||||
from odoo.addons.sale.controllers import portal as sale_portal
|
||||
import logging
|
||||
|
||||
from odoo import _
|
||||
from odoo.http import request
|
||||
from odoo.http import route
|
||||
|
||||
from odoo.addons.sale.controllers import portal as sale_portal
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CustomerPortal(sale_portal.CustomerPortal):
|
||||
'''Extend sale portal to include draft orders.'''
|
||||
"""Extend sale portal to include draft orders."""
|
||||
|
||||
def _prepare_orders_domain(self, partner):
|
||||
'''Override to include draft and done orders.'''
|
||||
"""Override to include draft and done orders."""
|
||||
return [
|
||||
('message_partner_ids', 'child_of', [partner.commercial_partner_id.id]),
|
||||
('state', 'in', ['draft', 'sale', 'done']), # Include draft orders
|
||||
("message_partner_ids", "child_of", [partner.commercial_partner_id.id]),
|
||||
("state", "in", ["draft", "sale", "done"]), # Include draft orders
|
||||
]
|
||||
|
||||
@route(['/my/orders', '/my/orders/page/<int:page>'],
|
||||
type='http', auth='user', website=True)
|
||||
@route(
|
||||
["/my/orders", "/my/orders/page/<int:page>"],
|
||||
type="http",
|
||||
auth="user",
|
||||
website=True,
|
||||
)
|
||||
def portal_my_orders(self, **kwargs):
|
||||
'''Override to add translated day names to context.'''
|
||||
"""Override to add translated day names to context."""
|
||||
# Get values from parent
|
||||
values = self._prepare_sale_portal_rendering_values(quotation_page=False, **kwargs)
|
||||
|
||||
values = self._prepare_sale_portal_rendering_values(
|
||||
quotation_page=False, **kwargs
|
||||
)
|
||||
|
||||
# Add translated day names for pickup_day display
|
||||
values['day_names'] = [
|
||||
_('Monday'),
|
||||
_('Tuesday'),
|
||||
_('Wednesday'),
|
||||
_('Thursday'),
|
||||
_('Friday'),
|
||||
_('Saturday'),
|
||||
_('Sunday'),
|
||||
values["day_names"] = [
|
||||
_("Monday"),
|
||||
_("Tuesday"),
|
||||
_("Wednesday"),
|
||||
_("Thursday"),
|
||||
_("Friday"),
|
||||
_("Saturday"),
|
||||
_("Sunday"),
|
||||
]
|
||||
|
||||
request.session['my_orders_history'] = values['orders'].ids[:100]
|
||||
|
||||
request.session["my_orders_history"] = values["orders"].ids[:100]
|
||||
return request.render("sale.portal_my_orders", values)
|
||||
|
||||
@route(['/my/orders/<int:order_id>'], type='http', auth='public', website=True)
|
||||
@route(["/my/orders/<int:order_id>"], type="http", auth="public", website=True)
|
||||
def portal_order_page(self, order_id, access_token=None, **kwargs):
|
||||
'''Override to add translated day names for order detail page.'''
|
||||
"""Override to add translated day names for order detail page."""
|
||||
# Call parent to get response
|
||||
response = super().portal_order_page(order_id, access_token=access_token, **kwargs)
|
||||
|
||||
response = super().portal_order_page(
|
||||
order_id, access_token=access_token, **kwargs
|
||||
)
|
||||
|
||||
# If it's a template render (not a redirect), add day_names to the context
|
||||
if hasattr(response, 'qcontext'):
|
||||
response.qcontext['day_names'] = [
|
||||
_('Monday'),
|
||||
_('Tuesday'),
|
||||
_('Wednesday'),
|
||||
_('Thursday'),
|
||||
_('Friday'),
|
||||
_('Saturday'),
|
||||
_('Sunday'),
|
||||
if hasattr(response, "qcontext"):
|
||||
response.qcontext["day_names"] = [
|
||||
_("Monday"),
|
||||
_("Tuesday"),
|
||||
_("Wednesday"),
|
||||
_("Thursday"),
|
||||
_("Friday"),
|
||||
_("Saturday"),
|
||||
_("Sunday"),
|
||||
]
|
||||
|
||||
|
||||
return response
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue