This question has been flagged
2 Replies
2693 Views

Hi, I am new in OpenERP's domain.

My question is : I want to show in customer view the date of his first command, may u plz help me?

This is my code, but it doesn't work :

class res_partner(osv.osv):
    _inherit = "res.partner"
        def _get_date_first_order(self, cr, uid, ids, name, partner_id, arg, context=None):
        res = {}
        for id in ids :
            cr.execute("""select
                    min(date_order)
                from
                    sale_order """,(tuple(ids),))
        return res

    _columns = {
        'customer_date_order': fields.function(_get_date_first_order, method=True, store=True, type='datetime', string='Date First order', select=1),
        }
res_partner()
Avatar
Discard
Author

anyone can help?!

Best Answer

v7: Hello, the simplest way to do this would be to go to that customer's form view, click the "Quotations and Sales" button and then sort the orders by clicking on the the Date column.

V6: go to Sales => Address Book => Customers, select a customer, then click on the "Sales" link on the right of the window. A new popup will open. You can then sort sales orders by the same method as above.

Avatar
Discard
Author

I prefer to add a field fuction in form view, but my code desn't work !!

Best Answer

Hi,

In case to see date without open any other form, add new field function type into customer and write SQL query or use search method (with order='date' and limit=1).

Email : info@acespritech.com
Skype : acespritech
Blog : acespritechblog.wordpress.com

Avatar
Discard