- 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
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""Fill pickup_day and pickup_date for existing group orders."""
|
|
|
|
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 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)])
|
|
|
|
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.",
|
|
}
|
|
)
|