Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Redirect after server action

Subscribe

Get notified when there's activity on this post

This question has been flagged
invoiceformvieworderredirect
1 Reply
3678 Views
Avatar
Hipólito Rodríguez Alvarado

I'm trying to redirect to view account.view_move_form after invoicing several POS orders and merging those invoices into one, but after the action is done it stays at POS order tree view. Here is my code:


def invoice_and_merge(self):

    partner_id = self[0].partner_id        

    account_moves = []        

    account_moves_ids = []        

    wizard = {}        

    for pedido in self:            

        if pedido.partner_id != partner_id:                

            raise UserError('Todas las facturas debes ser del mismo cliente

        account_moves.append(pedido.action_pos_order_invoice())        

    for move in account_moves:            

        account_moves_ids.append(move['res_id'])            

        factura = self.env['account.move'].search([('id', '=', move['res_id'])])

        factura.button_draft()        

    wizard['merge_type'] = 'cancel'   

    wizard['partner_id'] = partner_id.id        

    merge_invoice = self.env['sh.minv.merge.invoice.wizard'].with_context({'active_ids': account_moves_ids}).create(wizard)        

    # This is a third party app that merges serveral invoices into a new one and returns a tree view with all new invoices

    ret = merge_invoice.action_merge_invoice()        

    facturas = self.env['account.move'].search([('id','in', ret['domain'][0][2])])        

    id = 0        

    for factura in facturas:            

        if factura.name == '/':                

            self.account_move = factura                

            id = factura.id                

            factura.action_post()            

        else:                 

            factura.write({'agrupado': True})   

    # Return form view with the new invoice     

    return {            

        'name': _('Customer Invoice'),            

        'view_mode': 'form',            

        'view_id': self.env.ref('account.view_move_form').id,            

        'res_model': 'account.move',            

        'context': "{'move_type':'out_invoice'}",            

        'type': 'ir.actions.act_window',            

        'nodestroy': True,            

        'res_id': id,            

        'target': 'current'        

    }




0
Avatar
Discard
Avatar
Andres Panoso
Best Answer

You can do the following

in your server action definition:


field name="code">
            action = record.server_action_create_reverse_entry()
....


   

       


   


   


0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to hide this new column on a form view?
invoice form view column line
Avatar
Avatar
4
Mar 20
10783
Form view aligned to the left side Solved
form view
Avatar
Avatar
1
Nov 25
2556
OpenERP 7: hide Form Header for read only purpose Solved
form view
Avatar
Avatar
1
Sep 21
10286
"many2many_tags" show a refrence of the tag not the name !! Solved
form view
Avatar
Avatar
1
Jan 24
17866
how to pop up a existing module form after a button press Solved
invoice form
Avatar
Avatar
3
Mar 19
4216
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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