odoo_dev 开发培训作业:图书管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
629B

  1. from odoo import http
  2. from odoo.addons.library_app.controllers.main import Books
  3. class BookExtended(Books): # 继承了library_app.controllers.main 里的 Books类
  4. @http.route() #如果不带参数,将会保留父类中定义的路由。但也可以为@http.route() 装饰器添加参数,来重新定义或替换类路由。
  5. def list(self, **kwargs):
  6. response = super().list(**kwargs)
  7. if kwargs.get('available'):
  8. Book = http.request.env['library.book']
  9. books = Book.search([('is_available', '=', True)])
  10. response.qcontext['books'] = books
  11. return response
上海开阖软件有限公司 沪ICP备12045867号-1