Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/17.0' into 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dhongu committed Jan 27, 2025
2 parents ef19930 + d039037 commit a068861
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ addon | version | maintainers | summary | price
[deltatech_queue_job](deltatech_queue_job/) | 17.0.1.0.2 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Deltatech Queue Job | Free
[deltatech_ral](deltatech_ral/) | 17.0.1.0.3 | | RAL | Free
[deltatech_reception_note](deltatech_reception_note/) | 17.0.0.1.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Batch reception note | Free
[deltatech_record_type](deltatech_record_type/) | 17.0.1.1.3 | [![VoicuStefan2001](https://github.com/VoicuStefan2001.png?size=30px)](https://github.com/VoicuStefan2001) | Manage multiple record types | Free
[deltatech_record_type](deltatech_record_type/) | 17.0.1.1.4 | [![VoicuStefan2001](https://github.com/VoicuStefan2001.png?size=30px)](https://github.com/VoicuStefan2001) | Manage multiple record types | Free
[deltatech_replenish](deltatech_replenish/) | 17.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Deltatech Replenish | Free
[deltatech_report_packaging](deltatech_report_packaging/) | 17.0.1.0.2 | [![cojocariudaniel1](https://github.com/cojocariudaniel1.png?size=30px)](https://github.com/cojocariudaniel1) [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Report Packaging | Free
[deltatech_report_prn](deltatech_report_prn/) | 17.0.1.0.4 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Raport PRN | Free
[deltatech_restricted_access](deltatech_restricted_access/) | 17.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Restricted Access | Free
[deltatech_sale](deltatech_sale/) | 17.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Sale Extension Obsolete | Free
[deltatech_sale_activity_search](deltatech_sale_activity_search/) | 17.0.0.0.0 | [![VoicuStefan2001](https://github.com/VoicuStefan2001.png?size=30px)](https://github.com/VoicuStefan2001) | Adds a field with the active activity types on that sale order | Free
[deltatech_sale_add_extra_line](deltatech_sale_add_extra_line/) | 17.0.1.0.9 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Sale Add Extra Line | Free
[deltatech_sale_commission](deltatech_sale_commission/) | 17.0.1.2.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Compute sale commission | Free
[deltatech_sale_commission](deltatech_sale_commission/) | 17.0.1.2.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Compute sale commission | Free
[deltatech_sale_contact](deltatech_sale_contact/) | 17.0.1.0.21 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Limit contacts insale order | Free
[deltatech_sale_cost_product](deltatech_sale_cost_product/) | 17.0.0.0.2 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Sale Cost on Order | Free
[deltatech_sale_feedback](deltatech_sale_feedback/) | 17.0.1.0.5 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Sale Feedback | Free
Expand Down
2 changes: 1 addition & 1 deletion deltatech_record_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Terrabit - Record Type",
"summary": "Manage multiple record types",
"version": "17.0.1.1.3",
"version": "17.0.1.1.4",
"author": "Terrabit, Voicu Stefan",
"website": "https://www.terrabit.ro",
"category": "Generic Modules/Other",
Expand Down
2 changes: 2 additions & 0 deletions deltatech_record_type/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class SaleOrder(models.Model):

def action_confirm(self):
for order in self:
if hasattr(order, "website_id") and order.website_id:
continue
if not self.env.user.has_group("deltatech_record_type.group_confirm_order_without_record_type"):
if not order.so_type:
raise exceptions.UserError(
Expand Down
3 changes: 2 additions & 1 deletion deltatech_sale_commission/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Sale Commission",
"summary": "Compute sale commission",
"version": "17.0.1.2.0",
"version": "17.0.1.2.1",
"category": "Sales",
"author": "Terrabit, Dorin Hongu",
"website": "https://www.terrabit.ro",
Expand All @@ -19,6 +19,7 @@
"wizard/commission_compute_view.xml",
"wizard/update_purchase_price_view.xml",
"views/res_config_settings_views.xml",
"views/commission_condition_view.xml",
],
"images": ["static/description/main_screenshot.png"],
"development_status": "Mature",
Expand Down
1 change: 1 addition & 0 deletions deltatech_sale_commission/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import account_invoice
from . import sale
from . import res_config_settings
from . import commission_condition
11 changes: 11 additions & 0 deletions deltatech_sale_commission/models/commission_condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo import fields, models


class SaleCommissionCondition(models.Model):
_name = "sale.commission.condition"
_description = "Commission condition"

sequence = fields.Integer(string="Sequence", default=10)
percentage = fields.Float(string="Percentage", required=True, default=0.0, digits=(12, 3))
less_than_days = fields.Integer(string="Less Than Days", required=True, default=0)
# maximum_days = fields.Integer(string="Maximum Days", required=True, default=0)
1 change: 1 addition & 0 deletions deltatech_sale_commission/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ access_sale_margin_report_user,Sale margin report,model_sale_margin_report,base.
access_commission_users,access_commission_users,model_commission_users,sales_team.group_sale_manager,1,1,1,1
access_commission_compute,access_commission_compute,model_commission_compute,base.group_user,1,1,1,1
access_commission_update_purchase_price,access_commission_update_purchase_price,model_commission_update_purchase_price,base.group_user,1,1,1,1
access_sale_commission_condition,access_sale_commission_condition,model_sale_commission_condition,base.group_user,1,1,1,1
35 changes: 35 additions & 0 deletions deltatech_sale_commission/views/commission_condition_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>


<record id="view_commission_conditions_tree" model="ir.ui.view">
<field name="name">Commission Conditions</field>
<field name="model">sale.commission.condition</field>
<field name="arch" type="xml">
<tree editable="top">
<field name="sequence" widget="handle" />
<field name="percentage" />
<field name="less_than_days" />
<!-- <field name="maximum_days" />-->
</tree>
</field>
</record>


<record id="action_commission_conditions" model="ir.actions.act_window">
<field name="name">Commission Conditions</field>
<field name="res_model">sale.commission.condition</field>
<field name="view_mode">tree</field>
</record>

<menuitem
name="Commission Conditions"
id="menu_commission_conditions"
action="action_commission_conditions"
parent="sale.menu_sale_config"
groups="sales_team.group_sale_manager"
/>



</odoo>
31 changes: 30 additions & 1 deletion deltatech_sale_commission/wizard/commission_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,36 @@ def default_get(self, fields):
def do_compute(self):
res = []
for line in self.invoice_line_ids:
value = {"commission": line.commission_computed}
commission_conditions = self.env["sale.commission.condition"].search([], order="less_than_days")
# if we don't have commission conditions, we will use the default commission
if not commission_conditions:
value = {"commission": line.commission_computed}
else:
# if the invoice is paid, we will calculate the commission based on the payment date
if line.invoice_id.payment_state == "paid":
# take the latest payment date
last_payment = sorted(
line.invoice_id.invoice_payments_widget["content"], key=lambda d: d["date"], reverse=True
)[0]
days_difference = (
fields.Date.to_date(last_payment["date"]) - line.invoice_id.invoice_date
).days # calculate the days difference between the invoice date and the payment date

if days_difference <= 0:
value = {"commission": line.commission_computed}
else:
checked = False
for condition in commission_conditions:
if (
days_difference <= condition.less_than_days
): # they are ordered by less_than_days so we will get the first condition that is less than the days difference
checked = True
value = {"commission": line.commission_computed * condition.percentage / 100}
break
if not checked: # if we didn't find a condition that is less than the days difference, we will use the default commission
value = {"commission": 0}
else:
value = {"commission": 0} # if the invoice is not paid, we will not calculate the commission
# if line.purchase_price == 0 and line.product_id:
# value['purchase_price'] = line.product_id.standard_price
invoice_line = self.env["account.move.line"].browse(line.id)
Expand Down

0 comments on commit a068861

Please sign in to comment.