0

I am working in odoo9. Now I needed a view that permits the user to select partner and get his sale history.

Now I created a model "sale.history" but it saves the selected data as a record in db. I really don't need this.

How can I create a view for this.

Please also see this image.

Sebin
  • 31
  • 1
  • 9

3 Answers3

1

You have two options for such views/reports.

  1. Use TransientModel instead of Model for the model inheritance. Transient model records in database will be deleted by a frequently running cron job. The email message PopUp/Wizard is a nice example for that.

  2. Write your own report (database view) for sales order. Actually there already is one report for that: Reporting/Sales/Sales Analysis. The model for that report is sale.report if you want to know, how it's done.

CZoellner
  • 13,553
  • 3
  • 25
  • 38
0

Aside from using a TransientModel (old api) or AbstractModel (new api)...you can simply set the store property of field to false, that way your field will never be persisted to the database, it will simply be a 'view field'.

class sale_history(model.Model):
    _name='sale.history'

    partner = fields.Many2one('res.partner', store=False)

The partner field will never get saved to the database

danidee
  • 9,298
  • 2
  • 35
  • 55
0

You can use store=False on the field in the model (as danidee suggested).

You can also overwrite the create method on the model.

Question - what is the purpose of the "sale.history" model? If it does not store any data at all then you may be better off creating a new view against "res.partner" rather than creating a new model.

Palza
  • 642
  • 5
  • 12