Browse Source

May 5 : [UPDT] Feature Updated 'commission_plan'

pull/254/head
AjmalCybro 2 years ago
parent
commit
0b1f5c45a9
  1. 2
      commission_plan/__manifest__.py
  2. 7
      commission_plan/doc/RELEASE_NOTES.md
  3. 19
      commission_plan/models/commission.py
  4. BIN
      commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-2-1.png
  5. BIN
      commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-2.png
  6. BIN
      commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-3-1.png
  7. BIN
      commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-3-2.png
  8. BIN
      commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-3.png
  9. BIN
      commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-4.png
  10. 11
      commission_plan/static/description/index.html
  11. 14
      commission_plan/views/commission.xml
  12. 42
      commission_plan/wizard/commission_report.py

2
commission_plan/__manifest__.py

@ -24,7 +24,7 @@
'description': """CRM Commission Plan for odoo15, CRM, crm commission, commission plan, crm features""", 'description': """CRM Commission Plan for odoo15, CRM, crm commission, commission plan, crm features""",
'summary': """CRM Commission Plan for odoo15""", 'summary': """CRM Commission Plan for odoo15""",
"category": 'Sales', "category": 'Sales',
"version": '15.0.1.0.0', "version": '15.0.1.0.1',
'author': 'Cybrosys Techno Solutions', 'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions',

7
commission_plan/doc/RELEASE_NOTES.md

@ -3,4 +3,9 @@
#### 18.12.2021 #### 18.12.2021
#### Version 15.0.1.0.0 #### Version 15.0.1.0.0
#### ADD #### ADD
- Initial commit for Commission Plan Module - Initial commit for Commission Plan Module
#### 26.04.2023
#### Version 15.0.1.0.1
#### UPDT
- Updated the commission amount type, added the option to use fixed amount commission.

19
commission_plan/models/commission.py

@ -41,7 +41,17 @@ class CommissionPlan(models.Model):
user_id = fields.Many2one('res.users', string='Salesperson') user_id = fields.Many2one('res.users', string='Salesperson')
product_comm_ids = fields.One2many('commission.product', 'commission_id', product_comm_ids = fields.One2many('commission.product', 'commission_id',
string="Product Wise") string="Product Wise")
currency_id = fields.Many2one("res.currency", string="Currency",
default=lambda self:
self.env.user.company_id.currency_id.id)
straight_commission_type = fields.Selection([('percentage', 'Percentage'),
('fixed', 'Fixed Amount')],
string="Amount Type",
default='percentage')
straight_commission_fixed = fields.Monetary('Commission Amount', default=0.0)
straight_commission_rate = fields.Float(string='Commission rate (%)') straight_commission_rate = fields.Float(string='Commission rate (%)')
revenue_grd_comm_ids = fields.One2many( revenue_grd_comm_ids = fields.One2many(
'commission.graduated', 'commission.graduated',
'commission_id', 'commission_id',
@ -78,6 +88,9 @@ class CommissionProduct(models.Model):
category_id = fields.Many2one('product.category', string='Product Category') category_id = fields.Many2one('product.category', string='Product Category')
product_id = fields.Many2one('product.product', string='Product', product_id = fields.Many2one('product.product', string='Product',
domain="[('categ_id', '=', category_id)]") domain="[('categ_id', '=', category_id)]")
commission_amount_type = fields.Selection([('percentage', 'Percentage'),
('fixed', 'Fixed Amount')], string="Amount Type", default='percentage')
fixed_amount = fields.Monetary('Commission Amount', default=0.0)
percentage = fields.Float(string='Rate in Percentage (%)') percentage = fields.Float(string='Rate in Percentage (%)')
amount = fields.Monetary('Maximum Commission Amount', default=0.0) amount = fields.Monetary('Maximum Commission Amount', default=0.0)
currency_id = fields.Many2one("res.currency", string="Currency", currency_id = fields.Many2one("res.currency", string="Currency",
@ -90,6 +103,12 @@ class CommissionRevenueGraduated(models.Model):
_name = 'commission.graduated' _name = 'commission.graduated'
_description = 'Commission Revenue Graduated Wise' _description = 'Commission Revenue Graduated Wise'
currency_id = fields.Many2one("res.currency", string="Currency",
default=lambda self:
self.env.user.company_id.currency_id.id)
graduated_amount_type = fields.Selection([('percentage', 'Percentage'), ('fixed', 'Fixed Amount')],
string="Amount Type", default='percentage')
graduated_fixed_amount = fields.Monetary('Commission Amount', default=0.0)
graduated_commission_rate = fields.Float(string='Commission rate (%)') graduated_commission_rate = fields.Float(string='Commission rate (%)')
amount_from = fields.Float(string="From Amount") amount_from = fields.Float(string="From Amount")
amount_to = fields.Float(string="To Amount") amount_to = fields.Float(string="To Amount")

BIN
commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-2-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

BIN
commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-3-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-3-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

BIN
commission_plan/static/description/assets/screenshots/Crm-Commission-Plan-4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 52 KiB

11
commission_plan/static/description/index.html

@ -231,7 +231,8 @@
selecting the Type the Product Wise options can be selected. Further, the Product Categories selecting the Type the Product Wise options can be selected. Further, the Product Categories
with with
respect to the respective Product Category based Commission Plan can be defined.</p> respect to the respective Product Category based Commission Plan can be defined.</p>
<img src="assets/screenshots/Crm-Commission-Plan-2.png" class="img-responsive img-thumbnail border"> <p>You can also choose the commission amount type as fixed or percentage for each product.</p>
<img src="assets/screenshots/Crm-Commission-Plan-2-1.png" class="img-responsive img-thumbnail border">
</div> </div>
<div class="mt-5"> <div class="mt-5">
<div class="d-flex mb-2" style="padding-bottom: 0.5rem !important;"> <div class="d-flex mb-2" style="padding-bottom: 0.5rem !important;">
@ -247,7 +248,11 @@
Commission. Further, the commission rate can be defined under the Straight Revenue Commission. Further, the commission rate can be defined under the Straight Revenue
Commission Commission
tab.</p> tab.</p>
<img src="assets/screenshots/Crm-Commission-Plan-3.png" class="img-responsive img-thumbnail border"> <p>The commission amount type can be chosen as fixed or percentage. You need to enter the percentage rate if you choose percentage type.</p>
<img src="assets/screenshots/Crm-Commission-Plan-3-1.png" class="img-responsive img-thumbnail border">
<p>You need to enter the fixed amount if you choose the fixed type.</p>
<img src="assets/screenshots/Crm-Commission-Plan-3-2.png" class="img-responsive img-thumbnail border">
</div> </div>
<div class="mt-5"> <div class="mt-5">
@ -257,7 +262,7 @@
<h3>Revenue-based Commission Plan: Graduated Revenue Commission Plan</h3> <h3>Revenue-based Commission Plan: Graduated Revenue Commission Plan</h3>
</div> </div>
<p>While Creating a Graduated Revenue Commission Plan the Commission type can be selected as <p>While Creating a Graduated Revenue Commission Plan the Commission type can be selected as
Graduated Commission. Further, the commission rate can be defined under the Graduated Graduated Commission. Further, the commission rate/ commission amount can be defined under the Graduated
Revenue Revenue
Commission tab.</p> Commission tab.</p>
<img src="assets/screenshots/Crm-Commission-Plan-4.png" class="img-responsive img-thumbnail border"> <img src="assets/screenshots/Crm-Commission-Plan-4.png" class="img-responsive img-thumbnail border">

14
commission_plan/views/commission.xml

@ -62,15 +62,19 @@
<tree editable="Top" create="1" multi_edit="1"> <tree editable="Top" create="1" multi_edit="1">
<field name="category_id" style="width:20%%"/> <field name="category_id" style="width:20%%"/>
<field name="product_id" style="width:20%%"/> <field name="product_id" style="width:20%%"/>
<field name="percentage" style="width:50%%"/> <field name="commission_amount_type"/>
<field name="amount" style="width:50%%"/> <field name="percentage" attrs="{'invisible' : [('commission_amount_type', '=', 'fixed')]}"/>
<field name="fixed_amount" attrs="{'invisible' : [('commission_amount_type', '!=', 'fixed')]}"/>
<field name="amount" attrs="{'invisible' : [('commission_amount_type', '=', 'fixed')]}"/>
</tree> </tree>
</field> </field>
</page> </page>
<page string="Straight Revenue Commission" attrs="{'invisible' : ['|','|',('type', '=', 'product'),('revenue_type', '=', False),('revenue_type', '=', 'graduated')]}"> <page string="Straight Revenue Commission" attrs="{'invisible' : ['|','|',('type', '=', 'product'),('revenue_type', '=', False),('revenue_type', '=', 'graduated')]}">
<group> <group>
<field name="straight_commission_type"/>
<field name="straight_commission_fixed" attrs="{'invisible' : [('straight_commission_type', '!=', 'fixed')]}"/>
<field name="straight_commission_rate" string="Commission rate (%)" <field name="straight_commission_rate" string="Commission rate (%)"
attrs="{'invisible' : ['|','|',('type', '=', 'product'),('revenue_type', '=', False),('revenue_type', '=', 'graduated')]}"/> attrs="{'invisible' : ['|','|','|',('straight_commission_type', '=', 'fixed'),('type', '=', 'product'),('revenue_type', '=', False),('revenue_type', '=', 'graduated')]}"/>
</group> </group>
</page> </page>
<page string="Graduated Revenue Commission" attrs="{'invisible' : ['|','|',('type', '=', 'product'),('revenue_type', '=', False),('revenue_type', '=', 'straight')]}"> <page string="Graduated Revenue Commission" attrs="{'invisible' : ['|','|',('type', '=', 'product'),('revenue_type', '=', False),('revenue_type', '=', 'straight')]}">
@ -79,7 +83,9 @@
<field name="sequence"/> <field name="sequence"/>
<field name="amount_from"/> <field name="amount_from"/>
<field name="amount_to"/> <field name="amount_to"/>
<field name="graduated_commission_rate"/> <field name="graduated_amount_type" widget="selection" style="max-width:200px !important;"/>
<field name="graduated_fixed_amount" style="min-width:200px !important;" attrs="{'invisible' : [('graduated_amount_type', '!=', 'fixed')]}"/>
<field name="graduated_commission_rate" style="min-width:200px !important;" attrs="{'invisible' : [('graduated_amount_type', '=', 'fixed')]}"/>
</tree> </tree>
</field> </field>
</page> </page>

42
commission_plan/wizard/commission_report.py

@ -107,20 +107,25 @@ class CommissionReportWizard(models.TransientModel):
lambda l: l.product_id == rule.product_id) lambda l: l.product_id == rule.product_id)
total_price = sum( total_price = sum(
product_order_line.mapped('price_subtotal')) product_order_line.mapped('price_subtotal'))
product_commission = (total_price * rule.percentage) / 100 if rule.commission_amount_type == 'percentage':
product_commission = (total_price * rule.percentage) / 100
elif rule.commission_amount_type == 'fixed':
product_commission = rule.fixed_amount
total_list.append(total_price) total_list.append(total_price)
user_commission_name.append(commission_id.name) user_commission_name.append(commission_id.name)
user_commission_salesperson.append(user.name) user_commission_salesperson.append(user.name)
commission_list.append(rule.amount) if ( commission_list.append(rule.amount) if (
product_commission > rule.amount) \ product_commission > rule.amount and rule.commission_amount_type == 'percentage') \
else commission_list.append(product_commission) else commission_list.append(product_commission)
if commission_id.type == 'revenue' and ( if commission_id.type == 'revenue' and (
commission_id.revenue_type == 'graduated'): commission_id.revenue_type == 'graduated'):
for rule in commission_id.revenue_grd_comm_ids: for rule in commission_id.revenue_grd_comm_ids:
if rule.amount_from <= filtered_order_lines_commission_total < rule.amount_to: if rule.amount_from <= filtered_order_lines_commission_total < rule.amount_to:
graduated_commission = (filtered_order_lines_commission_total if rule.graduated_amount_type == 'percentage':
graduated_commission = (filtered_order_lines_commission_total
* rule.graduated_commission_rate) / 100 * rule.graduated_commission_rate) / 100
elif rule.graduated_amount_type == 'fixed':
graduated_commission = rule.graduated_fixed_amount
commission_list.append(graduated_commission) commission_list.append(graduated_commission)
user_commission_name.append(commission_id.name) user_commission_name.append(commission_id.name)
user_commission_salesperson.append(user.name) user_commission_salesperson.append(user.name)
@ -128,8 +133,11 @@ class CommissionReportWizard(models.TransientModel):
if commission_id.type == 'revenue' and ( if commission_id.type == 'revenue' and (
commission_id.revenue_type == 'straight'): commission_id.revenue_type == 'straight'):
straight_commission = (filtered_order_lines_commission_total if commission_id.straight_commission_type == 'percentage':
* commission_id.straight_commission_rate) / 100 straight_commission = (filtered_order_lines_commission_total
* commission_id.straight_commission_rate) / 100
elif commission_id.straight_commission_type == 'fixed':
straight_commission = commission_id.straight_commission_fixed
commission_list.append(straight_commission) commission_list.append(straight_commission)
user_commission_name.append(commission_id.name) user_commission_name.append(commission_id.name)
user_commission_salesperson.append(user.name) user_commission_salesperson.append(user.name)
@ -177,14 +185,17 @@ class CommissionReportWizard(models.TransientModel):
lambda l: l.product_id == rules.product_id) lambda l: l.product_id == rules.product_id)
total_price = sum( total_price = sum(
product_order_line.mapped('price_subtotal')) product_order_line.mapped('price_subtotal'))
product_commission = (total_price * rules.percentage) / 100 if rules.commission_amount_type == 'percentage':
product_commission = (total_price * rules.percentage) / 100
elif rules.commission_amount_type == 'fixed':
product_commission = rules.fixed_amount
commission_total.append(total_price) commission_total.append(total_price)
commission_name.append(commissions_id.name) commission_name.append(commissions_id.name)
commission_salesperson.append(team_user.name) commission_salesperson.append(team_user.name)
commission_sales_team.append( commission_sales_team.append(
team_user.sale_team_id.name) team_user.sale_team_id.name)
commission.append(rules.amount) if ( commission.append(rules.amount) if (
product_commission > rules.amount) \ product_commission > rules.amount and rules.commission_amount_type == 'percentage') \
else commission.append(product_commission) else commission.append(product_commission)
if commissions_id.type == 'revenue' and ( if commissions_id.type == 'revenue' and (
@ -192,8 +203,12 @@ class CommissionReportWizard(models.TransientModel):
for rules in commissions_id.revenue_grd_comm_ids: for rules in commissions_id.revenue_grd_comm_ids:
if rules.amount_from <= filtered_order_lines_commission_total \ if rules.amount_from <= filtered_order_lines_commission_total \
< rules.amount_to: < rules.amount_to:
graduated_commission = (filtered_order_lines_commission_total if rules.graduated_amount_type == 'percentage':
* rules.graduated_commission_rate) / 100 graduated_commission = (filtered_order_lines_commission_total
* rules.graduated_commission_rate) / 100
elif rules.graduated_amount_type == 'fixed':
graduated_commission = rules.graduated_fixed_amount
commission.append(graduated_commission) commission.append(graduated_commission)
commission_name.append(commissions_id.name) commission_name.append(commissions_id.name)
commission_salesperson.append(team_user.name) commission_salesperson.append(team_user.name)
@ -204,8 +219,11 @@ class CommissionReportWizard(models.TransientModel):
if commissions_id.type == 'revenue' and ( if commissions_id.type == 'revenue' and (
commissions_id.revenue_type == 'straight'): commissions_id.revenue_type == 'straight'):
straight_commission = (filtered_order_lines_commission_total if commission_id.straight_commission_type == 'percentage':
* commissions_id.straight_commission_rate) / 100 straight_commission = (filtered_order_lines_commission_total
* commission_id.straight_commission_rate) / 100
elif commission_id.straight_commission_type == 'fixed':
straight_commission = commission_id.straight_commission_fixed
commission.append(straight_commission) commission.append(straight_commission)
commission_name.append(commissions_id.name) commission_name.append(commissions_id.name)
commission_salesperson.append(team_user.name) commission_salesperson.append(team_user.name)

Loading…
Cancel
Save