[FIX] website_sale_aplicoop: Add portal user support for sale.order creation

Portal users don't have write/create permissions on sale.order by default.
This causes errors when trying to create orders during checkout or draft save.

Changes:
- Add _get_salesperson_for_order() helper to retrieve partner's salesperson
- Use sudo() for all sale.order create() operations
- Automatically assign user_id (salesperson) when creating orders
- Use sudo() for order updates and line modifications
- Add fallback to commercial_partner_id.user_id for salesperson

This ensures orders are created with proper permissions while maintaining
traceability through the assigned salesperson.

Test coverage:
- Add test_portal_sale_order_creation.py with 3 tests
- Test portal user creates sale.order
- Test salesperson fallback logic
- Test portal user updates order lines
This commit is contained in:
snt 2026-02-21 14:09:57 +01:00
parent cf9ea887c1
commit ed8c6acd92
3 changed files with 243 additions and 28 deletions

View file

@ -11,3 +11,4 @@ from . import test_multi_company
from . import test_save_order_endpoints
from . import test_date_calculations
from . import test_pricing_with_pricelist
from . import test_portal_sale_order_creation