0

Previously, the quotation date field in odoo 15 wasn't visible till i removed the "group" attribute from its xml field in odoo's form view. It is visible now but unfortunately, it does not allow a user to back date the quotation date or the date of creation. i have tried working editing the the field in the form view but nothing seems to be working at this moment. Can someone please make a suggestion as to how i could get the quotation dates to back-date? This is the current code for the Quotation date field with the "group" attribute removed: <field name="date_order" nolabel="1" attrs="{'invisible': [('state', 'in', ['sale', 'done', 'cancel'])]}"/>

And the code for the group it belongs to :

<group name="order_details">
                            <field name="validity_date" attrs="{'invisible': [('state', 'in', ['sale', 'done'])]}"/>
                            <div class="o_td_label" attrs="{'invisible': [('state', 'in', ['sale', 'done', 'cancel'])]}">
                                <label for="date_order" string="Quotation Date"/>
                            </div>
                            <field name="date_order" nolabel="1"  attrs="{'invisible': [('state', 'in', ['sale', 'done', 'cancel'])]}"/>
                            <div class="o_td_label" attrs="{'invisible': [('state', 'in', ['draft', 'sent'])]}">
                                <label for="date_order" string="Order Date"/>
                            </div>
                            <field name="date_order" attrs="{'required': [('state', 'in', ['sale', 'done'])], 'invisible': [('state', 'in', ['draft', 'sent'])]}" nolabel="1"/>
                            <field name="show_update_pricelist" invisible="1"/>
                            <label for="pricelist_id" groups="product.group_product_pricelist"/>
                            <div groups="product.group_product_pricelist" class="o_row">
                                <field name="pricelist_id" options="{'no_open':True,'no_create': True}"/>
                                <button name="update_prices" type="object" string=" Update Prices" help="Recompute all prices based on this pricelist" class="btn-link mb-1 px-0" icon="fa-refresh" confirm="This will update all unit prices based on the currently set pricelist." attrs="{'invisible': ['|', ('show_update_pricelist', '=', False), ('state', 'in', ['sale', 'done','cancel'])]}"/>
                            </div>
                            <field name="currency_id" invisible="1"/>
                            <field name="tax_country_id" invisible="1"/>
                            <field name="payment_term_id" options="{'no_open':True,'no_create': True}"/>
                        </group>
Nate
  • 21
  • 1
  • 6

1 Answers1

1

Actually, after remove the group the date_order will be shown in the form and you will be able to change it and save but when you confirm the quotation the date will be updated to today date and the below method which called in action_confirm does that.

    def _prepare_confirmation_values(self):
        return {
            'state': 'sale',
            'date_order': fields.Datetime.now()
        }

You can override this method as below:

from odoo import models

class SaleOrder(models.Model):
    _inherit = "sale.order"

   def _prepare_confirmation_values(self):
        return {
            'state': 'sale'
        }
Waleed Mohsen
  • 965
  • 6
  • 8