[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,36 +1,40 @@
|
|||
"""Fill pickup_day and pickup_date for existing group orders."""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
"""
|
||||
Fill pickup_day and pickup_date for existing group orders.
|
||||
|
||||
|
||||
This ensures that existing group orders show delivery information.
|
||||
"""
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
from odoo import SUPERUSER_ID
|
||||
from odoo import api
|
||||
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
|
||||
# Get all group orders that don't have pickup_day set
|
||||
group_orders = env['group.order'].search([('pickup_day', '=', False)])
|
||||
|
||||
group_orders = env["group.order"].search([("pickup_day", "=", False)])
|
||||
|
||||
if not group_orders:
|
||||
return
|
||||
|
||||
|
||||
# Set default values: Friday (4) and one week from now
|
||||
today = datetime.now().date()
|
||||
|
||||
|
||||
# Find Friday of next week (day 4)
|
||||
days_until_friday = (4 - today.weekday()) % 7 # 4 = Friday
|
||||
if days_until_friday == 0:
|
||||
days_until_friday = 7
|
||||
friday = today + timedelta(days=days_until_friday)
|
||||
|
||||
|
||||
for order in group_orders:
|
||||
order.write({
|
||||
'pickup_day': 4, # Friday
|
||||
'pickup_date': friday,
|
||||
'delivery_notice': 'Home delivery available.',
|
||||
})
|
||||
order.write(
|
||||
{
|
||||
"pickup_day": 4, # Friday
|
||||
"pickup_date": friday,
|
||||
"delivery_notice": "Home delivery available.",
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
# Copyright 2025 Criptomart
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from odoo import SUPERUSER_ID
|
||||
from odoo import api
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
|
|
@ -13,7 +14,7 @@ def migrate(cr, version):
|
|||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
# Obtener la compañía por defecto
|
||||
default_company = env['res.company'].search([], limit=1)
|
||||
default_company = env["res.company"].search([], limit=1)
|
||||
|
||||
if default_company:
|
||||
# Actualizar todos los registros de group.order que no tengan company_id
|
||||
|
|
@ -23,7 +24,7 @@ def migrate(cr, version):
|
|||
SET company_id = %s
|
||||
WHERE company_id IS NULL
|
||||
""",
|
||||
(default_company.id,)
|
||||
(default_company.id,),
|
||||
)
|
||||
|
||||
cr.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue