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
    • Artificial Intelligence
    • 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
    • Property 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
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

How to create a Duplicate button.

Subscribe

Get notified when there's activity on this post

This question has been flagged
v6.1
1 Reply
19069 Views
Avatar
Dale E. Moore

Settings, Companies, Companies, Bank Accounts does not have a duplicate button.

How would I create a push button that would duplicate a Bank Account like exists for Customers, Products, Projects, and so many other objects in OpenERP?

I've heard you "put a button on list view of o2m bank and call copy()!" Because "copy() does it all (default values + new values + translations)!" So this goes in my view.xml:

<record id="view_partner_bank_form_inherit_dale" model="ir.ui.view">
    <field name="name">Dale Bank Accounts - Journal</field>
    <field name="model">res.partner.bank</field>
    <field name="type">form</field>
    <field name="inherit_id" ref="base.view_partner_bank_form"/>
    <field name="arch" type="xml">
    <group name="bank" position="after">
    <group name="accounting" col="2" colspan="2" attrs="{'invisible': [('company_id','=', False)]}" groups="base.group_extended">
        <separator string="Duplicate" colspan="2"/>
        <button name="copy_bank" type="object" string="Duplicate"/>
    </group>
    </group>
    </field>
</record>

The button size is a bit large and I hear that "col, colspan; will adjust the size" then this goes in my bank.py:

class bank(osv.osv):
    _inherit = "res.partner.bank"

    def copy_bank(self, cr, uid, ids, context=None):
        for rec in self.browse(cr, uid, ids, context):
            self.copy(cr,uid, rec.id , {},context)
        return True
bank()

and everything works lovely.

I'd just like to move the Duplicate button up onto the same line with the Close button.

4
Avatar
Discard
Naresh Soni (nch)

Hi Dale, you should not use the reserved keyword "copy" as a name of your method. Secondly it will be nice if you can post the python code that you have written for this method.

Avatar
Parth Gajjar
Best Answer

Duplicate Button Generate Automatically

Duplicate Button will generate automatically in every form.

image description

You just need to override copy function if you want some changes in default copy function.

def copy(self, cr, uid, id, default=None, context=None):
    #your changes
    default_return_value=super("your parent class", self).copy(cr, uid, id, default, context)
    #your changes in "default_return_value"
    return default_return_value
2
Avatar
Discard
Mathieu Stumpf

I'm doing just that to prevent a constraint which doesn't allow two objects with the same name to exist for my current class. But when I try to duplicate, the constraint error rise anyway. Should I overload something in the form view to make the button call my overloaded _copy_ method?

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
Odoo – Knowledge Feature – Internal Documentation System
v6.1
Avatar
0
Apr 26
5
Odoo 17 arrêt des envois automatique
v6.1
Avatar
0
Apr 26
3
odoo invoicing Errors occurred while creating the EDI document (format: UBL BIS Billing 3.0.12): ?
v6.1
Avatar
0
Apr 26
5
눈Volaris Contacto Numero눈¿Cómo hablar con un asesor de Volaris?
v6.1
Avatar
0
Nov 25
11
Manufacturing to delivery, how are scheduled MRP operations?
v6.1
Avatar
1
Jun 24
4208
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 Svenska ภาษาไทย 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