Перейти к содержимому
Odoo Меню
  • Войти
  • Попробовать бесплатно
  • Модули
    Финансы
    • Бухгалтерия
    • Выставление счетов
    • Расходы
    • Таблицы
    • Документооборот
    • Подпись
    Продажи
    • CRM
    • Продажи
    • POS Магазин
    • POS Ресторан
    • Подписки
    • Аренда
    Вебсайты
    • Конструктор вебсайтов
    • eCommerce
    • Блог
    • Форум
    • Онлайн-чат
    • Электронное обучение
    Логистика
    • Склад
    • Производство
    • PLM
    • Закупки
    • Обслуживание
    • Качество
    Отдел кадров
    • Сотрудники
    • Подбор персонала
    • Отпуска
    • Оценка персонала
    • Реферальная программа
    • Автопарк
    Маркетинг
    • SMM
    • E-mail рассылки
    • СМС рассылки
    • Мероприятия
    • Автоматизация маркетинга
    • Опросы
    Услуги
    • Проекты
    • Табели
    • Выездной сервис
    • Поддержка
    • Планирование
    • Встречи
    Продуктивность
    • Обсуждения
    • Согласование
    • IoT
    • VoIP-телефония
    • Knowledge
    • WhatsApp
    Сторонние приложения Модуль Студия Odoo Платформа Odoo Cloud
  • Индустрии
    Розничная торговля
    • Книжный магазин
    • Магазин одежды
    • Мебельный магазин
    • Продуктовый магазин
    • Строительный магазин
    • Магазин игрушек
    Гостинично-ресторанный бизнес
    • Бар и паб
    • Ресторан
    • Фастфуд
    • Гостевой дом
    • Дистрибьютор напитков
    • Отель
    Недвижимость
    • Агентство недвижимости
    • Архитектурное бюро
    • Строительство
    • Управление недвижимостью
    • Ландшафтный дизайн
    • Товарищество собственников жилья
    Консалтинг
    • Бухгалтерская фирма
    • Партнер Odoo
    • Маркетинговое агентство
    • Юридическая фирма
    • Подбор персонала
    • Аудиторское бюро
    Производство
    • Текстиль
    • Металл
    • Мебель
    • Продукты питания
    • Пивоварня
    • Корпоративные сувениры
    Здоровье и фитнес
    • Спортивный комплекс
    • Магазин оптики
    • Фитнес-клуб
    • Велнес-центр
    • Аптека
    • Салон красоты
    Услуги
    • Специалист по бытовым услугам
    • Продажа и обслуживание IT-оборудования
    • Солнечные энергосистемы
    • Производство обуви
    • Клининг
    • Системы ОВКВ
    Прочее
    • Некоммерческая организация
    • Консалтинг в сфере устойчивого развития
    • Аренда рекламных щитов
    • Бизнес по фотосъемке
    • Прокат велосипедов
    • Реселлер программного обеспечения
    Все индустрии
  • Community
    Обучение
    • Видео уроки
    • Документация
    • Сертификация
    • Тренинг
    • Блог
    • Подкаст
    Образование и развитие
    • Образовательная программа
    • Деловая игра Scale Up!
    • Экскурсия в офис Odoo
    ПО
    • Скачать
    • Сравнить версии
    • Релизы
    Сотрудничество
    • Github
    • Форум
    • Мероприятия
    • Перевод
    • Стать партнером
    • Услуги для партнеров
    • Зарегистрировать бухгалтерскую фирму
    Услуги
    • Найти партнера
    • Найти бухгалтера
    • Встреча с экспертом
    • Услуги по внедрению
    • Отзывы клиентов
    • Поддержка
    • Обновления
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Заказать демонстрацию
  • Цены
  • Поддержка

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Бухгалтерия
  • Склад
  • PoS
  • Проекты
  • MRP
All apps
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Все посты Люди Значки
Теги (Смотреть все)
odoo accounting v14 pos v15
Об этом форуме
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Все посты Люди Значки
Теги (Смотреть все)
odoo accounting v14 pos v15
Об этом форуме
Помощь

Calling sale.order action_confirm() in a wizard (SOLVED)

Подписаться

Получайте уведомления о появлении активности в этом посте

Этот вопрос был отмечен
2 Ответы
9313 Представления
Аватар
Francesco Ballerini

EDIT 3: Damn, I have no idea how I was missing it, but it was so obvious.

I wasn't giving a specific record, that's why the method was not called properly. 

Correct solution is this:

def wizard_custom_action_confirm(self):

return {'type': 'ir.actions.act_window',
'res_model': 'my.model.name',
'view_mode': 'form',
'target': 'new',}


And then in the wizard model what I was missing was:

def btn_wizard_confirm(self):
self.env['sale.order'].browse(self.env.context.get('active_id')).action_confirm()

Of course I use much more data in my model, but basically i was missing the browse() for the identification of the record.. I usually know it but this time I was missing it for some reason.. Well it's working perfectly now, in the end I decided to use a custom button, not the original one, so I open the wizard and then in the wizard when confirm button is clicked I can simply call the action_confirm() method.


-------------------------------------------------------



Hi!

I want to achieve a custom "confirm popup" that also show some info to the user before the user confirm the Invoice into a sale order (so I can't use confirm attribute) but I can't make it work properly.  


First thing I thought was to make a function that simply returns the action that triggers the wizard, like this one 

return {'type': 'ir.actions.act_window',
'res_model': 'my.model',
'view_mode': 'form',
'target': 'new', }

and call this function in the override of action_confirm() button. Wizard is working fine by itself, but If I call it in the action_confirm() the wizard is not popping up. I'm pretty sure that I'm missing some basic programming concepts here, but can't figure out what i'm missing..


So now I'm trying another way, this allow me to trigger the Wizard but it's not working as expected aniway: 

I made another confirm button, a custom one that triggers the wizard (type=object). 

When I click on confirm button in the wizard, I call self.env['sale.order'].action_confirm().

I tried to check with debugger and I don't even think that the action_confirmed() method gets invoked, but if I override the method in my inherited sale.order model than I can call my override action_confirmed() method. So I tried to call the super() in my action_confirmed() override, but it seems that I'm not able to call the super().


Can some one please explain me what am I missing? Thank you and I hope my description is clear, I will post some code down there.


CONFIRM CUSTOM BUTTON:

def action_confirm_wizard(self):

print('action wizard')
return {'type': 'ir.actions.act_window',
'res_model': 'my.model',
'view_mode': 'form',
'target': 'new', }

action_confirm OVERRIDE:

def action_confirm(self):
self.action_confirm_wizard()
print('action_confirm')
super(SaleOrder, self).action_confirm()

And then I have the model of the wizard and the view:

wizard model:

# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import UserError

class TodoWizard(models.TransientModel):

_name = 'my.model'

def btn_confirm(self):
print('button wizard confirm order')
self.env['sale.order'].action_confirm()

def btn_2(self):
print('button wizard 2')

def btn_3(self):
    print('button wizard 3')

Thank you.


EDIT: Oh, I solved it but I still not understand why it works, I will have to study how the super() call works because I clearely didn't understand it.

I thought I had to call the wizard function before the call to the parent method because I thought all the instruction of the

parent method were executed when you make the super() call, but it wasn't working.


Instead I just put the super() at the beginning, then simply returned the dictionary with the action.act_window values values.. and it works!

The wizard pop up and suddently, only when i press the confirm button in the wizard, the parent method action_confirmed() get executed properly.

I have tried this first in my custom button, then I've tried it in the Odoo confirm button, and it works just fine.

Awsome!


So this is the code, just a little disappointing for me that I have no idea why it works this way.


def action_confirm_wizard(self):
print('action confirm wizard')
super(SaleOrder, self).action_confirm()
return {'type': 'ir.actions.act_window',
'res_model': 'my.model',
'view_mode': 'form',
'target': 'new', }


1
Аватар
Отменить
Sehrish

Hope these tips will helps: https://sites.google.com/view/thinkincode/erp/odoo

Francesco Ballerini
Автор

Thanks Sehrish, I saved your link into my favourites, there's a lot of interesting stuff in there! For now I solved by adding browse(self.env.context.get('active_id')) before method call, i wasn't specifing the record.

Аватар
Francesco Ballerini
Автор Лучший ответ

Edit 2:

I think I have another problem right now: the method action_confirm() gets executed aniway regardless of what I do in the wizard , so let's say I have this button inside the wizard:

< button

string = "Ignore"

type = "object"

name = "btn_ignore"

special = "cancel" / >


Even if it has special="cancel" the method get executed. Because the super() is called immediatly, i guess.. But as i told, if i don't call the super(SaleOrder,self).action_confirm() immediately, the method action_confirm() is not invoked..

I mean, if I call the function that returns the wizard and then I call the super() like this:

def action_confirm_wizard(self):

print('action wizard')
return {'type': 'ir.actions.act_window',
'res_model': 'my.model',
'view_mode': 'form',
            'target': 'new', }


def action_confirm(self):
self.action_confirm_wizard()
print('action_confirm')
super(SaleOrder, self).action_confirm()

The super().action_confirm() is not executed (but the print is). 

But then if i call the super() immediately and then I call the wizard, then wizard is working well and popup before the 'state' is set to Sale Order, but then I cannot prevent action_confirm() to be executed after I close the wizard. 


As I said the user is supposed to close the wizard by pressing ignore button with attribute special=cancel. It doesn't work this way, but now I don't really know how to avoid the method execution.


I think at this point I will try to make another button in my SaleOrder inherit model, so I will not override the original method.. and then I will try to call the method action_confirm() when I need it, without the super().. Hope this is working, but if you have any advide about it will be very appreciated. 

Thanks and have a good day.


1
Аватар
Отменить
Аватар
Adil Akbar
Лучший ответ

Hi, 

You can follow this link for this: https://youtu.be/oMnHpHH54QU

and following link for exact behavior: https://youtu.be/WW06SrlW4hI

Hope it helps,

Thanks

0
Аватар
Отменить
Не оставайтесь в стороне – присоединяйтесь к обсуждению!

Создайте аккаунт сегодня, чтобы получить доступ к эксклюзивным функциям и стать частью нашего замечательного сообщества!

Регистрация
Сообщество
  • Видео уроки
  • Документация
  • Форум
Открытый исходный код
  • Скачать
  • Github
  • Runbot
  • Перевод
Услуги
  • Хостинг Odoo.sh
  • Поддержка
  • Обновление
  • Индивидуальные решения по доработке
  • Образование
  • Найти бухгалтера
  • Найти партнера
  • Стать партнером
О нас
  • Наша компания
  • Активы бренда
  • Cвяжитесь с нами
  • Вакансии
  • Мероприятия
  • Подкаст
  • Блог
  • Клиенты
  • Правовые документы • Конфиденциальность
  • Безопасность
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo – это набор бизнес-модулей с открытым исходным кодом, который закроет все потребности вашей компании: CRM, E-commerce, Бухгалтерия, Склад, POS, управление проектами и др.

Odoo сочетает в себе простоту использования и полную интеграцию всех бизнес-процессов в одной системе.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now