Odoo Help


Openerp 7 calendar: end date for sale order calendar

Mathieu Stumpf
on 4/25/14, 4:22 AM 1,776 views

I'm trying to add an end date for the sale order calendar, here is the code I would expect to do the work :

<?xml version="1.0" encoding="UTF-8"?>
<!-- add the expiration_date support -->
    <record id="sale.view_sale_order_calendar" model="ir.ui.view">
        <field name="name">sale.order.calendar</field>
        <field name="model">sale.order</field>
        <field name="arch" type="xml">
            <calendar string="Sales Orders" color="state" 
                <field name="partner_id"/>
                <field name="amount_total"/>

    <record model="ir.ui.view" id="partner_axima_form_view">
        <field name="name">sale.order.form</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form" />
        <field name="arch" type="xml">

            <field name="shop_id" position="after" >
                <field name="validity_duration" 
                    on_change="onchange_validity_duration(validity_duration)" />



Where expiration_date and validity_duration is defined as follow :

class sale_order(osv.Model):
    _inherit = 'sale.order'

    def _get_validity_durations(self, cursor, user_id, context=None):

        durations = ("One week",
                     "Two weeks",
                     "Three weeks",
                     "One month",
        return list(enumerate(durations, start=1))

    _columns = {
        'validity_duration': fields.selection(
            u'Durée de validitée du devis'),

        'expiration_date' : fields.date(u"Date d’expiration",
                                            required=False, ),

    def onchange_validity_duration(self, cr, uid, ids, validity_duration=False, context=None):
        import datetime
        from dateutil.relativedelta import *
        today = datetime.date.today()
        if validity_duration in [0, False] :
            expiration_date = False
            expiration_date = today+relativedelta(weeks=+validity_duration)
        self.write(cr, uid, ids, {'expiration_date': expiration_date}, context=context)

        return {}

But looking at calendar it doesn't work, in fact it looks like the events are displayed beginning at the end date (expiration_date), and end in the same day.

Mathieu Stumpf
On 4/25/14, 10:30 AM

Here is an xml working version :

    <record id="view_sale_order_calendar" model="ir.ui.view">
        <field name="name">order.calendar</field>
        <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_sale_order_calendar" />
        <field name="arch" type="xml">
    <xpath expr="//calendar" position="attributes" >
        <attribute name="date_stop">expiration_date</attribute>

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 4/25/14, 4:22 AM
Seen: 1776 times
Last updated: 3/16/15, 8:10 AM