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

how to call old api function in new api function(unlink)?

Subscribe

Get notified when there's activity on this post

This question has been flagged
attendancedeleteunlinkodooV8
1 Reply
5581 Views
Avatar
Uppili Arivukkannu

I want to call the old api function of hr_attendance in new api of unlink() function.

My old api code is:


def _altern_si_so(self, cr, uid, ids, context=None):

""" Alternance sign_in/sign_out check.

Previous (if exists) must be of opposite action.

Next (if exists) must be of opposite action.

"""

for att in self.browse(cr, uid, ids, context=context):

# search and browse for first previous and first next records

prev_att_ids = self.search(cr, uid, [('employee_id', '=', att.employee_id.id), ('name', '<', att.name),

('action', 'in', ('sign_in', 'sign_out'))], limit=1, order='name DESC')

next_add_ids = self.search(cr, uid, [('employee_id', '=', att.employee_id.id), ('name', '>', att.name),

('action', 'in', ('sign_in', 'sign_out'))], limit=1, order='name ASC')

prev_atts = self.browse(cr, uid, prev_att_ids, context=context)

next_atts = self.browse(cr, uid, next_add_ids, context=context)

# check for alternance, return False if at least one condition is not satisfied

if prev_atts and prev_atts[0].action == att.action:

x = self.write(cr, uid, ids, {'text': "Previous Action Is Not Valid?"})

return self.write(cr, uid, ids, {'state': True}), x

if prev_atts and prev_atts[0].action != att.action and next_atts and next_atts[0].action != att.action:

a = self.write(cr, uid, ids, {'state': False})

c = self.write(cr, uid, next_add_ids, {'state': False})

xx = self.write(cr, uid, next_add_ids, {'text': "Everything seems OK!"})

d = self.write(cr, uid, ids, {'text': "Everything seems OK!"})

return self.write(cr, uid, prev_att_ids, {'state': False}), a, c, xx, d

if next_atts and next_atts[0].action == att.action: # next exists and is same action

y = self.write(cr, uid, ids, {'text': "Next Action Is Not Valid?"})

return self.write(cr, uid, ids, {'state': True}), y

if (not prev_atts) and (not next_atts) and att.action != 'sign_in': # first attendance must be sign_in

z = self.write(cr, uid, ids, {'text': "First Action Should be Sign In!"})

return self.write(cr, uid, ids, {'state': True}), z

else:

zz = self.write(cr, uid, ids, {'text': "Everything seems OK!"})

return self.write(cr, uid, ids, {'state': False}), zz

return True

_constraints = [

(_altern_si_so, 'Error ! Sign in (resp. Sign out) must follow Sign out (resp. Sign in)', ['action'])]


This function is call by a constraint. This function will be called during the validation of imported data.

I want this function to be called in unlink() so that when delete action is performed in ORM the above old api function should be called.


How can I call this old api function in this new api  fuction

How can I achieve this?

@api.multi
def unlink(self):
#how to call the old api here
return models.Model.unlink(self
0
Avatar
Discard
Avatar
Juan Vicente Pascual
Best Answer

Try:

_altern_si_so( self.env.cr, self.env.uid, [your.ids], self.env.context))


Kind regards.

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
Confirm on delete one2many line Solved
v7 delete unlink
Avatar
Avatar
Avatar
5
Jul 20
11588
How to delete multiple values at once with function? Solved
function delete unlink
Avatar
Avatar
2
Oct 15
11809
Howto create a record in the "hr.attendance" model for various users with the web service api in python and ERPpeek?
attendance erppeek odooV8
Avatar
2
Sep 15
6482
How to delete/unlink a bank account
connection delete unlink Bank_account
Avatar
Avatar
1
Aug 24
9378
How to disable delete option from purchase order in odoo 11 Solved
purchase delete unlink odoo11
Avatar
Avatar
Avatar
2
Sep 21
4966
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