Thursday, 23 November 2023

Odoo 17 New Features

 

Odoo 17 new Features

1) Duplicate  multiple records from List view.

Please have look below screenshots

first you need to select records then click in action you can see duplicate options is there.

2) You also create invoices without click in action. In odoo17 this version they provide new button for create invoices




3) Smart button will move on top middle

Please have look below customer form.



4)  Products can select in the sale order line to the catalog view itself
  • List view you may also select easily with the keyboard using the Shift + down arrow in the list view




Friday, 1 September 2023

How to open wizard from action in Odoo

 In Odoo, to open a wizard from an action, you need to define and configure the action correctly.

Follow the steps:

1) Create Wizard Model

class MyCustomWizard(models.TransientModel): _name = 'my.custom.wizard' _description = 'My Custom Wizard Description'

# Define fields for your wizard here product_id = fields.Many2many('product.product', string='Product') product_old_price = fields.Float(string='Product Old Price') internal_ref = fields.Char(string='Product')

2) Create Wizard View

<record id="wizard_id" model="ir.ui.view">
<field name="name">confirm.wizard.form</field>
<field name="model">my.custom.wizard</field>
<field name="arch" type="xml">
<form>
               # Define fields for your wizard here
        </form>
</field>
</record>

3) Create Server action from where you need to define action


<record id="custom_product_action_server" model="ir.actions.server">
<field name="name">Open Wizard</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="product.model_product_product"/>
<field name="binding_model_id" ref="product.model_product_product"/>
<field name="state">code</field>
<field name="code">
action = model.action_open_wizard()
</field>
</record>

4) Now Define server action function in Model
def action_open_wizard(self):
product_product_ids = self.env['product.product'].browse(self._context.get('active_ids', False))
lines = []
    # This is sample code you may change your code as per your requirements
    #You need to add one2many field like line_ids in your wizard and then when you select multiple product
    #from product.product and open wizard then you may see all selected lines display in your wizard one2many
for product in product_product_ids:
vals = (0, 0, {
'product_id': product.id,
'product_old_price': product.lst_price,
'internal_ref': product.default_code,
})
lines.append(vals)
return {'type': 'ir.actions.act_window',
'name': _('Product Wizard'),
'res_model': 'my.confirm.wizard',
'target': 'new',
'view_id': self.env.ref('module_name.wizard_id').id,
'view_mode': 'form',
'context': {'default_line_ids': lines}
}

Wednesday, 23 August 2023

How To Install wkhtmltopdf 0.12.5 (with patched qt) for Odoo/Openerp/Python

 How to Install Wkhtmltopdf 0.12.5 For Odoo/Openerp 


Download the package

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb


Install the package

sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb


Fix dependencies

sudo apt install -f

Tuesday, 11 July 2023

required_if_provider In Odoo

In Odoo, the "required_if_provider" parameter is used in fields to make them required based on the selected value of another field that represents a provider.

When defining fields in an Odoo model, you can set the "required_if_provider" parameter on a field to specify that it should be required if a specific provider is selected. This parameter is typically used in combination with related fields or selection fields representing providers. 

Here's an example to illustrate the usage of "required_if_provider":

from odoo import fields, models


class MyModel(models.Model):

    _name = 'my.model'


    provider = fields.Selection([

        ('provider1', 'Provider 1'),

        ('provider2', 'Provider 2'),

        ('provider3', 'Provider 3')

    ], string='Provider')

    field1 = fields.Char(string='Field 1')

    field2 = fields.Char(string='Field 2', required_if_provider='provider1')

    field3 = fields.Char(string='Field 3', required_if_provider='provider2')


In this example, we have a model called my.model with three fields: "provider", "field1", "field2", and "field3". The "provider" field is a selection field representing different providers.

  • If the value of the "provider" field is set to "provider1", the "field2" becomes a required field, meaning that the user must provide a value for field2 to successfully save the record.

  • If the value of the "provider" field is set to "provider2", the "field3" becomes a required field, and the user must provide a value for "field3"  to save the record.

The "required_if_provider" parameter allows you to conditionally enforce field requirements based on the selected provider value, providing flexibility in data validation based on specific conditions in your Odoo models.

Wednesday, 28 June 2023

Factorial Python Program

Here's a small Python example that calculates the factorial of a given number using recursion def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) # Example usage number = 5 result = factorial(number) print("The factorial of {number} is: ",result)





Description : In this example, the factorial function takes an integer 'n' as input and calculates its factorial recursively. The base case is when 'n' is equal to 0, in which case the function returns 1. Otherwise, it multiplies 'n' by the factorial of n-1. The example then demonstrates the usage of the factorial function by calculating the factorial of 5 and printing the result. When executed, the output will be: ('The factorial of {number} is: ', 120)

Tuesday, 29 January 2019

Get all month start date and end date in python

from datetime import datetime, timedelta
import calendar


data = []
selected_start_date = datetime.strptime('2019-01-01', "%Y-%m-%d")
selected_start_date_year = selected_start_date.year
for month in range(1,13):
other_val, num_days = calendar.monthrange(int(selected_start_date_year), int(month))
month_start_date = datetime(int(selected_start_date_year), int(month), 1).strftime("%Y-%m-%d")
month_end_date = datetime(int(selected_start_date_year), int(month), num_days).strftime("%Y-%m-%d")
data.append({'start_date':month_start_date,'end_date':month_end_date})
print "data ______________",data

Wednesday, 20 June 2018

# Remove action button from tree view and form view.

# Remove action button from tree view and form view.

var Sidebar = require('web.Sidebar');

Sidebar.include({
    init : function(){
        this._super.apply(this, arguments);
        var view = this.getParent();
        var self = this;
    if (view.fields_view && view.fields_view.type === "form") {
            self.sections.splice(1, 2);
        }
        if (view.fields_view && view.fields_view.type === "tree") {
        self.sections.splice(1, 2);
        }
    },
   
});

Odoo 17 New Features

  Odoo 17 new Features 1) Duplicate  multiple records from List view. Please have look below screenshots first you need to select records th...