Compare commits

..

7 Commits

Author SHA1 Message Date
Akretion Git Bot
1fc0f77dcb [BOT] add or update setup/_metapackage 2025-12-12 21:18:27 +00:00
Alexis de Lattre
705331f674 [MIG] base_mail_sender_bcc: make base_mail_sender_bcc work again ! 2025-12-12 22:18:16 +01:00
Alexis de Lattre
54025fe620 Update l10n_fr_account_profile_akretion deps 2025-12-05 14:35:27 +01:00
Alexis de Lattre
929a9418a7 [FIX] product_usability_akretion: fix 2 warnings
Fixes bug #239
2025-12-02 22:04:19 +01:00
Akretion Git Bot
cddecdf569 [BOT] add or update setup/_metapackage 2025-12-01 17:35:44 +00:00
Alexis de Lattre
17541b3369 [FIX] base_usability: ir_mail_server avoid breaking Bcc
fix code for smtp_session in inherit of send_email()
Disable module base_mail_sender_bcc that just doesn't work in v16 ; as it's a design problem, I don't plan to fix it.
2025-12-01 18:35:12 +01:00
Alexis de Lattre
a0710bc3ad [UDP] l10n_fr_account_profile_akretion: add dep on recently migrated modules 2025-11-28 09:44:49 +01:00
48 changed files with 504 additions and 1078 deletions

View File

@@ -2,7 +2,7 @@
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
from odoo import models, tools
class IrMailServer(models.Model):
@@ -25,3 +25,13 @@ class IrMailServer(models.Model):
message_id=message_id, references=references, object_id=object_id,
subtype=subtype, headers=headers,
body_alternative=body_alternative, subtype_alternative=subtype_alternative)
def _prepare_email_message(self, message, smtp_session):
validated_to = self.env.context.get('send_validated_to') or []
if message['Bcc']:
email_bcc_normalized = tools.email_normalize_all(message['Bcc'])
for email in email_bcc_normalized:
if email not in validated_to:
validated_to.append(email)
return super(IrMailServer, self.with_context(send_validated_to=validated_to))._prepare_email_message(
message, smtp_session)

View File

@@ -18,21 +18,24 @@ class IrMailServer(models.Model):
smtp_ssl_certificate=None, smtp_ssl_private_key=None,
smtp_debug=False, smtp_session=None):
# Start copy from native method
smtp = smtp_session
if not smtp:
smtp = self.connect(
if not smtp_session:
smtp_session = self.connect(
smtp_server, smtp_port, smtp_user, smtp_password, smtp_encryption,
smtp_from=message['From'], ssl_certificate=smtp_ssl_certificate, ssl_private_key=smtp_ssl_private_key,
smtp_debug=smtp_debug, mail_server_id=mail_server_id,)
smtp_from=message['From'], ssl_certificate=smtp_ssl_certificate,
ssl_private_key=smtp_ssl_private_key,
smtp_debug=smtp_debug, mail_server_id=mail_server_id)
# _prepare_email_message() will remove the Bcc field in message
# that's why we need to save it and re-inject it in message
email_bcc = message['Bcc']
smtp_from, smtp_to_list, message = self._prepare_email_message(
message, smtp)
message, smtp_session)
message['Bcc'] = email_bcc
# End copy from native method
logger.info(
"Sending email from '%s' to '%s' Cc '%s' Bcc '%s' "
"with subject '%s'",
"with subject '%s'. smtp_to_list=%s",
smtp_from, message.get('To'), message.get('Cc'),
message.get('Bcc'), message.get('Subject'))
message.get('Bcc'), message.get('Subject'), smtp_to_list)
return super().send_email(
message, mail_server_id=mail_server_id,
smtp_server=smtp_server, smtp_port=smtp_port,

View File

@@ -1,3 +1,2 @@
from . import models
from . import wizards
from . import reports

View File

@@ -4,7 +4,7 @@
{
'name': 'Commission Simple',
'version': '18.0.1.0.0',
'version': '16.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Compute commissions for salesman',
@@ -30,18 +30,19 @@ This module has been written by Alexis de Lattre from Akretion
'depends': [
'account',
'date_range',
'report_xlsx',
# this uses some related fields on account.move.line
# 'account_usability_akretion',
],
'data': [
'security/ir.model.access.csv',
'security/rule.xml',
'reports/report.xml',
'data/decimal_precision.xml',
'views/commission_profile.xml',
'views/commission_rule.xml',
'views/commission_result.xml',
'views/account_move_line.xml',
'views/res_config_settings.xml',
'wizards/commission_compute_view.xml',
],
'installable': True,
'installable': False,
}

View File

@@ -6,25 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-02 11:22+0000\n"
"PO-Revision-Date: 2025-09-02 11:23+0000\n"
"Last-Translator: Alexis de Lattre <alexis.delattre@akretion.com>\n"
"POT-Creation-Date: 2024-11-29 23:38+0000\n"
"PO-Revision-Date: 2024-11-29 23:38+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: commission_simple
#: model:ir.actions.report,print_report_name:commission_simple.commission_result_xlsx_report
msgid ""
"'commission-%s-%s' % (object.date_range_id.name.replace(' ', '_'), object."
"partner_id.name.replace(' ', '_'))"
msgstr ""
"'commission-%s-%s' % (object.date_range_id.name.replace(' ', '_'), object."
"partner_id.name.replace(' ', '_'))"
#. module: commission_simple
#: model:ir.model.constraint,message:commission_simple.constraint_commission_result_salesman_period_company_unique
msgid ""
@@ -43,13 +33,6 @@ msgstr ""
"Un vendeur doit être sélectionné lorsque le type d'affectation est "
"\"Vendeur\"."
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/models/commission_rule.py:0
#, python-format
msgid "AND"
msgstr "ET"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__message_needaction
msgid "Action Needed"
@@ -125,24 +108,13 @@ msgid "Cancel"
msgstr "Annuler"
#. module: commission_simple
#: model_terms:ir.ui.view,arch_db:commission_simple.view_move_line_form
msgid "Commission"
msgstr "Commission"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#: model:ir.model.fields,field_description:commission_simple.field_account_move_line__commission_amount
#, python-format
msgid "Commission Amount"
msgstr "Montant de la commission"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#: model:ir.model.fields,field_description:commission_simple.field_account_move_line__commission_base
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__base
#, python-format
msgid "Commission Base"
msgstr "Base de la commission"
@@ -150,14 +122,14 @@ msgstr "Base de la commission"
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__line_ids
#: model_terms:ir.ui.view,arch_db:commission_simple.commission_result_form
msgid "Commission Lines"
msgstr "Lignes de commission"
msgstr "Lignes commission"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_compute__date_range_type_id
#: model:ir.model.fields,field_description:commission_simple.field_res_company__commission_date_range_type_id
#: model:ir.model.fields,field_description:commission_simple.field_res_config_settings__commission_date_range_type_id
msgid "Commission Periodicity"
msgstr "Périodicité des commissions"
msgstr "Périodicité de commission"
#. module: commission_simple
#: model:ir.model,name:commission_simple.model_commission_profile
@@ -168,7 +140,7 @@ msgstr "Profil de commission"
#. module: commission_simple
#: model:ir.model,name:commission_simple.model_commission_profile_assignment
msgid "Commission Profile Assignment"
msgstr "Affectation des profils de commission"
msgstr "Affectation du profil de commission"
#. module: commission_simple
#: model:ir.actions.act_window,name:commission_simple.commission_profile_action
@@ -177,11 +149,8 @@ msgid "Commission Profiles"
msgstr "Profils de commission"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#: model:ir.model.fields,field_description:commission_simple.field_account_move_line__commission_rate
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__rate
#, python-format
msgid "Commission Rate"
msgstr "Taux de commission"
@@ -191,11 +160,6 @@ msgstr "Taux de commission"
msgid "Commission Result"
msgstr "État des commissions"
#. module: commission_simple
#: model:ir.model,name:commission_simple.model_report_commission_simple_report_xlsx
msgid "Commission Result XLSX"
msgstr "État des commission XLSX"
#. module: commission_simple
#: model:ir.model,name:commission_simple.model_commission_rule
msgid "Commission Rule"
@@ -220,7 +184,7 @@ msgstr "Total des commissions"
#: model:ir.ui.menu,name:commission_simple.commission_root
#: model_terms:ir.ui.view,arch_db:commission_simple.res_config_settings_view_form
msgid "Commissions"
msgstr "Commissions"
msgstr ""
#. module: commission_simple
#. odoo-python
@@ -230,13 +194,6 @@ msgid "Commissions already exist for %(period)s in company %(company)s."
msgstr ""
"Des commissions existent déjà pour %(period)s dans la société %(company)s."
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Commissions of %(partner)s for period %(period)s"
msgstr "Commissions de %(partner)s pour la période %(period)s"
#. module: commission_simple
#: model:ir.model,name:commission_simple.model_res_company
msgid "Companies"
@@ -297,37 +254,11 @@ msgstr "Créé par"
msgid "Created on"
msgstr "Créé le"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Currency"
msgstr "Devise"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Customer"
msgstr "Client"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__partner_ids
msgid "Customers"
msgstr "Clients"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/models/commission_rule.py:0
#, python-format
msgid "Customers:"
msgstr "Clients :"
#. module: commission_simple
#: model_terms:ir.ui.view,arch_db:commission_simple.commission_result_form
msgid "Disc.%"
msgstr "Rem.%"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_compute__display_name
#: model:ir.model.fields,field_description:commission_simple.field_commission_profile__display_name
@@ -341,7 +272,7 @@ msgstr "Nom affiché"
#: model:ir.model.fields.selection,name:commission_simple.selection__commission_result__state__done
#: model_terms:ir.ui.view,arch_db:commission_simple.commission_result_search
msgid "Done"
msgstr "Terminé"
msgstr "Validé"
#. module: commission_simple
#: model:ir.model.fields.selection,name:commission_simple.selection__commission_result__state__draft
@@ -350,15 +281,7 @@ msgid "Draft"
msgstr "Brouillon"
#. module: commission_simple
#: model:ir.actions.report,name:commission_simple.commission_result_xlsx_report
msgid "Détails Excel"
msgstr "Détails Excel"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__date_end
#, python-format
msgid "End Date"
msgstr "Date de fin"
@@ -368,11 +291,6 @@ msgstr "Date de fin"
msgid "End date"
msgstr "Date de fin"
#. module: commission_simple
#: model_terms:ir.ui.view,arch_db:commission_simple.commission_result_form
msgid "Excel Export"
msgstr "Export Excel"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__message_follower_ids
msgid "Followers"
@@ -389,19 +307,9 @@ msgid "Font awesome icon e.g. fa-tasks"
msgstr "Îcone font-awesome, par exemple fa-task"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Generated from Odoo on %s by %s"
msgstr "Généré à partir d'Odoo le %s par %s"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/models/commission_rule.py:0
#: model:ir.model.fields.selection,name:commission_simple.selection__commission_rule__applied_on__4_global
#, python-format
msgid "Global"
msgstr "Global"
msgstr ""
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__has_message
@@ -415,7 +323,7 @@ msgstr "A un message"
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__id
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__id
msgid "ID"
msgstr "ID"
msgstr ""
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__activity_exception_icon
@@ -442,20 +350,6 @@ msgstr "Si activé, des messages ont une erreur d'envoi."
msgid "In Payment and Paid"
msgstr "En paiement et payé"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Invoice"
msgstr "Facture"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Invoice Date"
msgstr "Date de facture"
#. module: commission_simple
#: model:ir.model.fields.selection,name:commission_simple.selection__commission_profile__trigger_type__invoice
msgid "Invoiced"
@@ -517,12 +411,7 @@ msgstr "Marge"
#. module: commission_simple
#: model_terms:ir.ui.view,arch_db:commission_simple.commission_rule_form
msgid "Match"
msgstr "Correspondance"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__apply_description
msgid "Match Criteria"
msgstr "Critères de correspondance"
msgstr ""
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_account_move_line__commission_rule_id
@@ -537,7 +426,7 @@ msgstr "Erreur d'envoi du message"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__message_ids
msgid "Messages"
msgstr "Messages"
msgstr ""
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__my_activity_date_deadline
@@ -608,18 +497,6 @@ msgstr "Payé"
msgid "Period"
msgstr "Période"
#. module: commission_simple
#: model_terms:ir.ui.view,arch_db:commission_simple.commission_result_form
msgid "Price"
msgstr "Prix"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Product"
msgstr "Produit"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__product_categ_ids
#: model:ir.model.fields.selection,name:commission_simple.selection__commission_rule__applied_on__3_product_category
@@ -631,13 +508,6 @@ msgstr "Catégories de produits"
msgid "Product Categories and Customers"
msgstr "Catégories de produits et clients"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/models/commission_rule.py:0
#, python-format
msgid "Product Categories:"
msgstr "Catégories de produits :"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_account_move_line__product_categ_id
msgid "Product Category"
@@ -654,13 +524,6 @@ msgstr "Produits"
msgid "Products and Customers"
msgstr "Produits et clients"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/models/commission_rule.py:0
#, python-format
msgid "Products:"
msgstr "Produits :"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_profile_assignment__profile_id
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__profile_id
@@ -668,13 +531,6 @@ msgstr "Produits :"
msgid "Profile"
msgstr "Profil"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Quantity"
msgstr "Quantité"
#. module: commission_simple
#: model_terms:ir.ui.view,arch_db:commission_simple.commission_result_form
#: model_terms:ir.ui.view,arch_db:commission_simple.commission_rule_tree
@@ -716,10 +572,7 @@ msgid "Sequence"
msgstr "Séquence"
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#: model:ir.model.fields,field_description:commission_simple.field_commission_rule__date_start
#, python-format
msgid "Start Date"
msgstr "Date de début"
@@ -752,13 +605,6 @@ msgstr ""
msgid "This salesman already has an assignment in this company."
msgstr "Ce vendeur a déjà une assignation dans cette société."
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Total Amount"
msgstr "Montant total"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_profile__trigger_type
msgid "Trigger"
@@ -767,20 +613,13 @@ msgstr "Déclencheur"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_profile_assignment__assign_type
msgid "Type"
msgstr "Type"
msgstr ""
#. module: commission_simple
#: model:ir.model.fields,help:commission_simple.field_commission_result__activity_exception_decoration
msgid "Type of the exception activity on record."
msgstr "Type de l'activité-alerte sur l'enregistrement."
#. module: commission_simple
#. odoo-python
#: code:addons/commission_simple/reports/commission_result_xlsx.py:0
#, python-format
msgid "Unit"
msgstr "Unité"
#. module: commission_simple
#: model:ir.model.fields,field_description:commission_simple.field_commission_result__website_message_ids
msgid "Website Messages"
@@ -797,5 +636,5 @@ msgstr "Historique des échanges sur le site Web"
#, python-format
msgid "You cannot delete commission result %s because it is in done state."
msgstr ""
"Vous ne pouvez pas supprimer l'état de commission %s parce qu'il est "
"à l'état \"terminé\"."
"Vous ne pouvez pas supprimer l'état de commission %s parce qu'il est à "
"l'état \"validé\"."

View File

@@ -1,5 +1,5 @@
from . import commission_profile
from . import commission_rule
from . import commission_result
from . import res_company
from . import account_move_line
from . import account_invoice_report

View File

@@ -1,16 +0,0 @@
# Copyright 2018-2019 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.tools import SQL
class AccountInvoiceReport(models.Model):
_inherit = 'account.invoice.report'
commission_amount = fields.Float(readonly=True)
@api.model
def _select(self) -> SQL:
return SQL("%s, line.commission_amount * account_currency_table.rate AS commission_amount", super()._select())

View File

@@ -11,7 +11,7 @@ class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
commission_result_id = fields.Many2one(
'commission.result', string='Commission Result', check_company=True, index=True)
'commission.result', string='Commission Result', check_company=True)
commission_rule_id = fields.Many2one(
'commission.rule', 'Matched Commission Rule', ondelete='restrict', check_company=True)
commission_base = fields.Monetary('Commission Base', currency_field='company_currency_id')
@@ -88,18 +88,3 @@ class AccountMoveLine(models.Model):
if float_is_zero(lvals['commission_rate'], precision_digits=rate_prec) or self.company_currency_id.is_zero(lvals['commission_base']):
return False
return lvals
def _prepare_commission_xlsx(self):
self.ensure_one()
vals = {
"inv.name": self.move_id.name,
"inv.date": self.move_id.invoice_date,
"inv.partner": self.move_id.commercial_partner_id.display_name,
"product": self.product_id and self.product_id.display_name or self.name,
"qty": self.quantity,
"uom": self.product_uom_id.name,
"commission_base": self.commission_base,
"commission_rate": self.commission_rate / 100,
"commission_amount": self.commission_amount,
}
return vals

View File

@@ -27,9 +27,6 @@ class CommissionProfile(models.Model):
('paid', 'Paid'),
('in_payment', 'In Payment and Paid'),
], default='paid', string='Trigger', required=True)
date_range_type_id = fields.Many2one(
'date.range.type', string='Commission Periodicity', ondelete='restrict',
domain="[('company_id', 'in', (False, company_id))]")
class CommissionProfileAssignment(models.Model):
@@ -103,7 +100,6 @@ class CommissionProfileAssignment(models.Model):
'profile_id': self.profile_id.id,
'date_range_id': date_range.id,
'assign_type': self.assign_type,
'assignment_id': self.id,
'company_id': self.company_id.id,
}
return vals

View File

@@ -17,8 +17,6 @@ class CommissionResult(models.Model):
readonly=True, tracking=True)
profile_id = fields.Many2one(
'commission.profile', string='Commission Profile', readonly=True, tracking=True)
assignment_id = fields.Many2one(
'commission.profile.assignment', string="Commission Profile Assignment", readonly=True)
assign_type = fields.Selection('_assign_type_selection', readonly=True, tracking=True)
company_id = fields.Many2one(
'res.company', string='Company', ondelete='cascade',
@@ -34,10 +32,7 @@ class CommissionResult(models.Model):
states={'done': [('readonly', True)]})
amount_total = fields.Monetary(
string='Commission Total', currency_field='company_currency_id',
compute='_compute_totals', store=True, tracking=True)
base_total = fields.Monetary(
string="Commission Base Total", currency_field='company_currency_id',
compute='_compute_totals', store=True, tracking=True)
compute='_compute_amount_total', store=True, tracking=True)
state = fields.Selection([
('draft', 'Draft'),
('done', 'Done'),
@@ -49,13 +44,12 @@ class CommissionResult(models.Model):
def _assign_type_selection(self):
return self.env['commission.profile.assignment']._assign_type_selection()
@api.depends('line_ids.commission_amount', 'line_ids.commission_base')
def _compute_totals(self):
rg_res = self.env['account.move.line'].read_group([('commission_result_id', 'in', self.ids)], ['commission_result_id', 'commission_amount:sum', 'commission_base:sum'], ['commission_result_id'])
mapped_data = dict([(x['commission_result_id'][0], {'amount': x['commission_amount'], 'base': x['commission_base']}) for x in rg_res])
@api.depends('line_ids.commission_amount')
def _compute_amount_total(self):
rg_res = self.env['account.move.line'].read_group([('commission_result_id', 'in', self.ids)], ['commission_result_id', 'commission_amount:sum'], ['commission_result_id'])
mapped_data = dict([(x['commission_result_id'][0], x['commission_amount']) for x in rg_res])
for rec in self:
rec.amount_total = mapped_data.get(rec.id, {}).get('amount')
rec.base_total = mapped_data.get(rec.id, {}).get('base')
rec.amount_total = mapped_data.get(rec.id, 0)
def unlink(self):
for result in self:
@@ -65,7 +59,7 @@ class CommissionResult(models.Model):
return super().unlink()
def draft2done(self):
self.filtered(lambda x: x.state == 'draft').write({'state': 'done'})
self.write({'state': 'done'})
def backtodraft(self):
self.write({'state': 'draft'})
@@ -81,7 +75,3 @@ class CommissionResult(models.Model):
'salesman_period_company_unique',
'unique(company_id, partner_id, date_range_id)',
'A commission result already exists for this salesman/agent for the same period.')]
def _prepare_xlsx_lines(self):
self.ensure_one()
return self.line_ids.sorted(key=lambda x: x.move_id.invoice_date)

View File

@@ -3,13 +3,13 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models, api, _
from odoo import fields, models, api
class CommissionRule(models.Model):
_name = 'commission.rule'
_description = 'Commission Rule'
_order = 'profile_id, applied_on, rate desc'
_order = 'profile_id, applied_on'
partner_ids = fields.Many2many(
'res.partner', string='Customers', domain=[('parent_id', '=', False)])
@@ -34,31 +34,6 @@ class CommissionRule(models.Model):
('4_global', 'Global')],
string='Apply On', default='4_global', required=True)
active = fields.Boolean(string='Active', default=True)
apply_description = fields.Html(compute='_compute_apply_description', string="Match Criteria")
_sql_constraints = [(
'rate_positive',
'CHECK(rate >= 0)',
'Rate must be positive !')]
def _compute_apply_description(self):
customer_label = "<strong>" + _("Customers:") + "</strong>"
product_label = "<strong>" + _("Products:") + "</strong>"
product_categ_label = "<strong>" + _("Product Categories:") + "</strong>"
and_label = "<strong>" + _('AND') + "</strong>"
for rule in self:
desc = False
if rule.applied_on == '0_customer_product':
desc = f"{customer_label} {', '.join([part.ref or part.name for part in rule.partner_ids])} {and_label} {product_label} {', '.join([pp.default_code or pp.name for pp in rule.product_ids])}"
elif rule.applied_on == '1_customer_product_category':
desc = f"{customer_label} {', '.join([part.ref or part.name for part in rule.partner_ids])} {and_label} {product_categ_label} {', '.join([categ.display_name for categ in rule.product_categ_ids])}"
elif rule.applied_on == '2_product':
desc = f"{product_label} {', '.join([pp.default_code or pp.name for pp in rule.product_ids])}"
elif rule.applied_on == '3_product_category':
desc = f"{product_categ_label} {', '.join([categ.display_name for categ in rule.product_categ_ids])}"
elif rule.applied_on == '4_global':
desc = _('Global')
rule.apply_description = desc
@api.model
def load_all_rules(self):
@@ -70,3 +45,8 @@ class CommissionRule(models.Model):
else:
res[rule['profile_id'][0]].append(rule)
return res
_sql_constraints = [(
'rate_positive',
'CHECK(rate >= 0)',
'Rate must be positive !')]

View File

@@ -0,0 +1,13 @@
# Copyright 2019-2024 Akretion France (https://www.akretion.com/)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResCompany(models.Model):
_inherit = 'res.company'
commission_date_range_type_id = fields.Many2one(
'date.range.type', string='Commission Periodicity', ondelete='restrict')

View File

@@ -0,0 +1,20 @@
# Copyright 2019-2024 Akretion France (https://www.akretion.com/)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResUsers(models.Model):
_inherit = 'res.users'
# TODO mon idée : déplacer ça dans une table dédiée
# company_id oblig
# partner_id (filtré... sur lien vers user ou agent petit difficulté)
# profile_id
# type agent ou user => ça donne le champ de recherche
commission_profile_id = fields.Many2one(
'commission.profile', string='Commission Profile',
company_dependent=True)

View File

@@ -1 +0,0 @@
from . import commission_result_xlsx

View File

@@ -1,112 +0,0 @@
# Copyright 2025 Akretion France (https://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, tools, Command, _
from odoo.exceptions import UserError
from datetime import datetime
from odoo.tools.misc import format_datetime
class CommissionResultXlsx(models.AbstractModel):
_name = "report.commission_simple.report_xlsx"
_inherit = "report.report_xlsx.abstract"
_description = "Commission Result XLSX"
def generate_xlsx_report(self, workbook, data, objects):
# for some strange reasons, lang is not kept in context
self = self.with_context(lang=self.env.user.lang)
result = objects[0]
sheet = workbook.add_worksheet(result.date_range_id.name)
styles = self._prepare_styles(workbook, result.company_id)
title = _("Commissions of %(partner)s for period %(period)s", partner=result.partner_id.name, period=result.date_range_id.name)
now_str = format_datetime(self.env, datetime.now())
i = 0
sheet.write(i, 0, title, styles['title'])
sheet.write(i, 5, _('Generated from Odoo on %s by %s') % (now_str, self.env.user.name), styles['regular_small'])
i += 1
sheet.write(i, 0, _('Start Date'), styles['subtitle'])
sheet.write(i, 1, result.date_start, styles['subtitle_date'])
i += 1
sheet.write(i, 0, _('End Date'), styles['subtitle'])
sheet.write(i, 1, result.date_end, styles['subtitle_date'])
i += 1
sheet.write(i, 0, _('Currency'), styles['subtitle'])
sheet.write(i, 1, result.company_id.currency_id.name, styles['subtitle'])
i += 1
sheet.write(i, 0, _('Base Total'), styles['subtitle'])
sheet.write(i, 1, result.base_total, styles['subtitle_amount'])
i += 1
sheet.write(i, 0, _('Amount Total'), styles['subtitle'])
sheet.write(i, 1, result.amount_total, styles['subtitle_amount'])
i += 3
cols = self._prepare_xlsx_cols()
coldict = {}
pos = 0
for key, label, width, style_suffix in cols:
coldict[key] = {
"label": label,
"width": width,
"pos": pos,
"style": style_suffix and f"regular_{style_suffix}" or "regular",
}
pos += 1
# header
for col_key, col_vals in coldict.items():
sheet.write(i, col_vals['pos'], col_vals['label'], styles['col_title'])
sheet.set_column(col_vals['pos'], col_vals['pos'], col_vals['width'])
# table content
for line in result._prepare_xlsx_lines():
i += 1
for col_key, value in line._prepare_commission_xlsx().items():
sheet.write(i, coldict[col_key]["pos"], value, styles[coldict[col_key]["style"]])
def _prepare_xlsx_cols(self):
cols = [ # key, label, width, style_suffix
("inv.name", _("Invoice"), 14, False),
("inv.date", _("Invoice Date"), 11, "date"),
("inv.partner", _("Customer"), 50, False),
("product", _("Product"), 35, False),
("qty", _("Quantity"), 8, "qty"),
("uom", _("Unit"), 8, False),
("commission_base", _("Commission Base"), 14, "amount"),
("commission_rate", _("Commission Rate"), 10, "rate"),
("commission_amount", _("Commission Amount"), 14, "amount"),
]
return cols
def _prepare_styles(self, workbook, company):
col_title_bg_color = '#eeeeee'
prec_qty = self.env['decimal.precision'].precision_get('Product Unit of Measure')
prec_rate = self.env['decimal.precision'].precision_get('Commission Rate')
prec_price = self.env['decimal.precision'].precision_get('Product Price')
regular_font_size = 10
date_format = "dd/mm/yyyy" # TODO depend on lang
num_format_amount = f"# ##0.{'0' * company.currency_id.decimal_places}"
num_format_qty = f"# ##0.{'0' * prec_qty}"
num_format_rate = f"""0.{'0' * prec_rate} " "%"""
num_format_price = f"# ##0.{'0' * prec_price}"
styles = {
'title': workbook.add_format({
'bold': True, 'font_size': regular_font_size + 10,
'font_color': '#003b6f'}),
'subtitle': workbook.add_format({
'bold': True, 'font_size': regular_font_size}),
'subtitle_date': workbook.add_format({
'bold': True, 'font_size': regular_font_size, 'num_format': date_format}),
'subtitle_amount': workbook.add_format({
'bold': True, 'font_size': regular_font_size, 'num_format': num_format_amount}),
'col_title': workbook.add_format({
'bold': True, 'bg_color': col_title_bg_color,
'text_wrap': True, 'font_size': regular_font_size,
'align': 'center',
}),
'regular_date': workbook.add_format({'num_format': date_format}),
'regular_amount': workbook.add_format({'num_format': num_format_amount}),
'regular_rate': workbook.add_format({'num_format': num_format_rate}),
'regular_qty': workbook.add_format({'num_format': num_format_qty}),
'regular_price': workbook.add_format({'num_format': num_format_price}),
'regular': workbook.add_format({}),
'regular_small': workbook.add_format({'font_size': regular_font_size - 2}),
}
return styles

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2025 Akretion France (https://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __manifest__.py
-->
<odoo>
<record id="commission_result_xlsx_report" model="ir.actions.report">
<field name="name">Détails Excel</field>
<field name="model">commission.result</field>
<field name="report_type">xlsx</field>
<field name="report_name">commission_simple.report_xlsx</field>
<field name="report_file">commission_simple.report_xlsx</field>
<field name="print_report_name">'commission-%s-%s' % (object.date_range_id.name.replace(' ', '_'), object.partner_id.name.replace(' ', '_'))</field>
<field name="binding_model_id" ref="model_commission_result" />
</record>
</odoo>

View File

@@ -8,4 +8,4 @@ access_commission_rule_audit,Read access on commission.rule for viewer group,mod
access_commission_result_full,Full access on commission.result to accountant,model_commission_result,account.group_account_user,1,1,1,1
access_commission_result_read,Read access on commission.result to invoicing grp,model_commission_result,account.group_account_invoice,1,0,0,0
access_commission_result_audit,Read access on commission.result to viewer grp,model_commission_result,account.group_account_readonly,1,0,0,0
access_commission_compute_full,Full access to wizard commission.compute to Accountant,model_commission_compute,account.group_account_user,1,1,1,1
access_commission_compute_full,Full access to wizard commission.compute,model_commission_compute,account.group_account_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
8 access_commission_result_full Full access on commission.result to accountant model_commission_result account.group_account_user 1 1 1 1
9 access_commission_result_read Read access on commission.result to invoicing grp model_commission_result account.group_account_invoice 1 0 0 0
10 access_commission_result_audit Read access on commission.result to viewer grp model_commission_result account.group_account_readonly 1 0 0 0
11 access_commission_compute_full Full access to wizard commission.compute to Accountant Full access to wizard commission.compute model_commission_compute account.group_account_user account.group_account_manager 1 1 1 1

View File

@@ -13,7 +13,7 @@
<field name="inherit_id" ref="account.view_move_line_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page name="commission" string="Commission" invisible="display_type != 'product'">
<page name="commission" string="Commission" attrs="{'invisible': [('display_type', '!=', 'product')]}">
<group name="commission_grp">
<field name="commission_base"/>
<label for="commission_rate"/>

View File

@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Akretion France (http://www.akretion.com)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
-->
<odoo>
<menuitem id="commission_root" name="Commissions" parent="account.menu_finance" sequence="11"/>
<menuitem id="commission_config_root" name="Commissions" parent="account.menu_finance_configuration" sequence="110"/>
<!-- PROFILE -->
<record id="commission_profile_form" model="ir.ui.view">
<field name="name">commission.profile.form</field>
<field name="model">commission.profile</field>
<field name="arch" type="xml">
<form>
<sheet>
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
<group name="main">
<field name="name"/>
<field name="active" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="trigger_type"/>
</group>
<group name="lines" string="Rules">
<field name="line_ids" nolabel="1" colspan="2"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="commission_profile_tree" model="ir.ui.view">
<field name="name">commission.profile.tree</field>
<field name="model">commission.profile</field>
<field name="arch" type="xml">
<tree>
<field name="sequence" widget="handle"/>
<field name="name" decoration-bf="1"/>
<field name="trigger_type" optional="show"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
</record>
<record id="commission_profile_action" model="ir.actions.act_window">
<field name="name">Commission Profiles</field>
<field name="res_model">commission.profile</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="commission_profile_menu" action="commission_profile_action" parent="commission_config_root" sequence="18"/>
<!-- RULE -->
<record id="commission_rule_form" model="ir.ui.view">
<field name="name">commission.rule.form</field>
<field name="model">commission.rule</field>
<field name="arch" type="xml">
<form>
<sheet>
<group name="main">
<field name="profile_id" invisible="not context.get('commission_rule_main_view')"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="company_id" invisible="1"/>
<field name="applied_on" widget="radio"/>
</group>
<group name="match" string="Match">
<field name="partner_ids" attrs="{'invisible': [('applied_on', 'not in', ('0_customer_product', '1_customer_product_category'))], 'required': [('applied_on', 'in', ('0_customer_product', '1_customer_product_category'))]}"/>
<field name="product_categ_ids" attrs="{'invisible': [('applied_on', 'not in', ('1_customer_product_category', '3_product_category'))], 'required': [('applied_on', 'in', ('1_customer_product_category', '3_product_category'))]}"/>
<field name="product_ids" attrs="{'invisible': [('applied_on', 'not in', ('0_customer_product', '2_product'))], 'required': [('applied_on', 'in', ('0_customer_product', '2_product'))]}"/>
<field name="date_start"/>
<field name="date_end"/>
</group>
<group name="compute" string="Compute">
<label for="rate"/>
<div name="rate">
<field name="rate" class="oe_inline"/> %
</div>
</group>
</sheet>
</form>
</field>
</record>
<record id="commission_rule_tree" model="ir.ui.view">
<field name="name">commission.rule.tree</field>
<field name="model">commission.rule</field>
<field name="arch" type="xml">
<tree>
<field name="profile_id" invisible="not context.get('commission_rule_main_view')"/>
<field name="applied_on"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="rate" string="Rate (%)"/>
</tree>
</field>
</record>
<record id="commission_rule_search" model="ir.ui.view">
<field name="name">commission.rule.search</field>
<field name="model">commission.rule</field>
<field name="arch" type="xml">
<search>
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
<group name="groupby">
<filter name="profile_groupby" string="Profile" context="{'group_by': 'profile_id'}"/>
</group>
</search>
</field>
</record>
<record id="commission_rule_action" model="ir.actions.act_window">
<field name="name">Commission Rules</field>
<field name="res_model">commission.rule</field>
<field name="view_mode">tree,form</field>
<field name="context">{'commission_rule_main_view': True}</field>
</record>
<menuitem id="commission_rule_menu" action="commission_rule_action" parent="commission_config_root" sequence="20"/>
<!-- RESULT -->
<record id="commission_result_form" model="ir.ui.view">
<field name="name">commission.result.form</field>
<field name="model">commission.result</field>
<field name="arch" type="xml">
<form>
<group name="main">
<group name="main-left">
<field name="partner_id"/>
<field name="profile_id" groups="account.group_account_manager"/>
<field name="company_currency_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="amount_total"/>
</group>
<group name="main-right">
<field name="date_range_id"/>
<field name="date_start"/>
<field name="date_end"/>
</group>
</group>
<group name="lines" string="Commission Lines">
<field nolabel="1" name="line_ids" colspan="2">
<tree>
<field name="move_id"/>
<field name="move_line_id"/>
<field name="base"/>
<field name="rate" string="Rate (%)"/>
<field name="amount" sum="1"/>
<field name="rule_id"/>
<field name="company_currency_id" invisible="1"/>
</tree>
</field>
</group>
</form>
</field>
</record>
<record id="commission_result_tree" model="ir.ui.view">
<field name="name">commission.result.tree</field>
<field name="model">commission.result</field>
<field name="arch" type="xml">
<tree>
<field name="date_range_id" optional="show"/>
<field name="date_start" optional="hide"/>
<field name="date_end" optional="hide"/>
<field name="partner_id"/>
<field name="profile_id" groups="account.group_account_manager"/>
<field name="company_currency_id" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="amount_total" sum="1" optional="show"/>
</tree>
</field>
</record>
<record id="commission_result_search" model="ir.ui.view">
<field name="name">commission.result.search</field>
<field name="model">commission.result</field>
<field name="arch" type="xml">
<search>
<field name="partner_id"/>
<field name="date_range_id"/>
<group name="groupby">
<filter name="partner_groupby" string="Salesman" context="{'group_by': 'partner_id'}"/>
<filter name="date_range_groupby" string="Period" context="{'group_by': 'date_range_id'}"/>
</group>
</search>
</field>
</record>
<record id="commission_result_action" model="ir.actions.act_window">
<field name="name">Commissions</field>
<field name="res_model">commission.result</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="commission_result_menu" action="commission_result_action" parent="commission_root" sequence="10"/>
</odoo>

View File

@@ -16,13 +16,12 @@
<field name="arch" type="xml">
<form>
<sheet>
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" invisible="active"/>
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
<group name="main">
<group name="main-left">
<field name="name"/>
<field name="active" invisible="1"/>
<field name="trigger_type" widget="radio"/>
<field name="date_range_type_id"/>
</group>
<group name="main-right">
<field name="company_id" invisible="1"/>
@@ -32,12 +31,12 @@
<notebook>
<page name="assignments" string="Assignments">
<field name="assign_ids">
<list editable="bottom">
<tree editable="bottom">
<field name="assign_type"/>
<field name="user_id" required="assign_type == 'user'" readonly="assign_type != 'user'"/>
<field name="user_id" attrs="{'required': [('assign_type', '=', 'user')], 'readonly': [('assign_type', '!=', 'user')]}"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="company_id" column_invisible="1"/>
</list>
<field name="company_id" invisible="1"/>
</tree>
</field>
</page>
<page name="rules" string="Rules">
@@ -49,43 +48,23 @@
</field>
</record>
<record id="commission_profile_list" model="ir.ui.view">
<field name="name">commission.profile.list</field>
<record id="commission_profile_tree" model="ir.ui.view">
<field name="name">commission.profile.tree</field>
<field name="model">commission.profile</field>
<field name="arch" type="xml">
<list>
<tree>
<field name="sequence" widget="handle"/>
<field name="name" decoration-bf="1"/>
<field name="trigger_type" optional="show" widget="badge" decoration-info="trigger_type == 'invoice'" decoration-success="trigger_type == 'paid'" decoration-warning="trigger_type == 'in_payment'"/>
<field name="date_range_type_id" optional="show"/>
<field name="trigger_type" optional="show"/>
<field name="company_id" groups="base.group_multi_company"/>
</list>
</field>
</record>
<record id="commission_profile_search" model="ir.ui.view">
<field name="model">commission.profile</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<filter string="Invoiced" name="invoice" domain="[('trigger_type', '=', 'invoice')]"/>
<filter string="Paid" name="paid" domain="[('trigger_type', '=', 'paid')]"/>
<filter string="In Payment and Paid" name="in_payment" domain="[('trigger_type', '=', 'in_payment')]"/>
<separator/>
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
<separator/>
<group name="groupby">
<filter name="date_range_type_groupby" string="Commission Periodicity" context="{'group_by': 'date_range_type_id'}"/>
</group>
</search>
</tree>
</field>
</record>
<record id="commission_profile_action" model="ir.actions.act_window">
<field name="name">Commission Profiles</field>
<field name="path">commission-profile</field>
<field name="res_model">commission.profile</field>
<field name="view_mode">list,form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="commission_profile_menu" action="commission_profile_action" parent="commission_config_root" sequence="18"/>

View File

@@ -13,9 +13,8 @@
<field name="arch" type="xml">
<form>
<header>
<button name="draft2done" type="object" invisible="state != 'draft'" string="Confirm" class="btn-primary"/>
<button name="backtodraft" type="object" invisible="state != 'done'" string="Back to Draft" confirm="Are you sure you want to go back to draft?"/>
<button name="%(commission_simple.commission_result_xlsx_report)d" type="action" string="Excel Export"/>
<button name="draft2done" type="object" states="draft" string="Confirm" class="btn-primary"/>
<button name="backtodraft" type="object" states="done" string="Back to Draft" confirm="Are you sure you want to go back to draft?"/>
<field name="state" widget="statusbar"/>
</header>
<group name="main">
@@ -24,7 +23,6 @@
<field name="date_range_id"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="base_total"/>
<field name="amount_total"/>
<field name="company_currency_id" invisible="1"/>
<field name="company_id" invisible="1"/>
@@ -36,45 +34,38 @@
</group>
</group>
<group name="lines" string="Commission Lines">
<field nolabel="1" name="line_ids" colspan="2" widget="many2many">
<list>
<field nolabel="1" name="line_ids" colspan="2">
<tree>
<field name="move_id"/>
<field name="date" optional="hide"/>
<field name="partner_id"/>
<field name="product_id"/>
<field name="product_categ_id" optional="hide"/>
<field name="name" optional="hide"/>
<field name="quantity" optional="hide"/>
<field name="product_uom_id" optional="hide" groups="uom.group_uom"/>
<field name="price_unit" string="Price" optional="hide"/>
<field name="discount" string="Disc.%" optional="hide"/>
<field name="price_subtotal" optional="hide" string="Invoiced Amount"/>
<field name="commission_base" sum="1"/>
<field name="commission_base"/>
<field name="commission_rate" string="Rate (%)"/>
<field name="commission_amount" sum="1"/>
<field name="commission_rule_id" optional="hide"/>
<field name="company_currency_id" invisible="1"/>
<field name="currency_id" invisible="1"/>
</list>
</tree>
</field>
</group>
<chatter />
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
<record id="commission_result_list" model="ir.ui.view">
<field name="name">commission.result.list</field>
<record id="commission_result_tree" model="ir.ui.view">
<field name="name">commission.result.tree</field>
<field name="model">commission.result</field>
<field name="arch" type="xml">
<list decoration-info="state == 'draft'">
<header>
<button
name="draft2done"
type="object"
string="Validate"
/>
</header>
<tree>
<field name="date_range_id" optional="show"/>
<field name="date_start" optional="hide"/>
<field name="date_end" optional="hide"/>
@@ -83,10 +74,9 @@
<field name="assign_type" optional="hide" widget="badge" decoration-warning="assign_type == 'user'"/>
<field name="company_currency_id" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="base_total" sum="1" optional="hide"/>
<field name="amount_total" sum="1" optional="show"/>
<field name="state" decoration-info="state == 'draft'" decoration-success="state == 'done'" widget="badge"/>
</list>
</tree>
</field>
</record>
@@ -113,9 +103,8 @@
<record id="commission_result_action" model="ir.actions.act_window">
<field name="name">Commissions</field>
<field name="path">commission-result</field>
<field name="res_model">commission.result</field>
<field name="view_mode">list,form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="commission_result_menu" action="commission_result_action" parent="commission_root" sequence="10"/>

View File

@@ -19,9 +19,9 @@
<field name="company_id" invisible="1"/>
</group>
<group name="match" string="Match">
<field name="partner_ids" invisible="applied_on not in ('0_customer_product', '1_customer_product_category')" required="applied_on in ('0_customer_product', '1_customer_product_category')"/>
<field name="product_categ_ids" invisible="applied_on not in ('1_customer_product_category', '3_product_category')" required="applied_on in ('1_customer_product_category', '3_product_category')"/>
<field name="product_ids" invisible="applied_on not in ('0_customer_product', '2_product')" required="applied_on in ('0_customer_product', '2_product')"/>
<field name="partner_ids" attrs="{'invisible': [('applied_on', 'not in', ('0_customer_product', '1_customer_product_category'))], 'required': [('applied_on', 'in', ('0_customer_product', '1_customer_product_category'))]}"/>
<field name="product_categ_ids" attrs="{'invisible': [('applied_on', 'not in', ('1_customer_product_category', '3_product_category'))], 'required': [('applied_on', 'in', ('1_customer_product_category', '3_product_category'))]}"/>
<field name="product_ids" attrs="{'invisible': [('applied_on', 'not in', ('0_customer_product', '2_product'))], 'required': [('applied_on', 'in', ('0_customer_product', '2_product'))]}"/>
<field name="date_start"/>
<field name="date_end"/>
</group>
@@ -37,19 +37,18 @@
</field>
</record>
<record id="commission_rule_list" model="ir.ui.view">
<field name="name">commission.rule.list</field>
<record id="commission_rule_tree" model="ir.ui.view">
<field name="name">commission.rule.tree</field>
<field name="model">commission.rule</field>
<field name="arch" type="xml">
<list>
<tree>
<field name="profile_id" invisible="not context.get('commission_rule_main_view')"/>
<field name="applied_on" widget="badge" decoration-danger="applied_on == '0_customer_product'" decoration-warning="applied_on == '1_customer_product_category'" decoration-info="applied_on == '2_product'" decoration-success="applied_on == '3_product_category'"/>
<field name="apply_description"/>
<field name="date_start" optional="show"/>
<field name="date_end" optional="show"/>
<field name="applied_on"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="rate" string="Rate (%)"/>
<field name="base" widget="badge" decoration-success="base == 'invoiced'" decoration-warning="base == 'margin'"/>
</list>
<field name="base"/>
</tree>
</field>
</record>
@@ -69,9 +68,8 @@
<record id="commission_rule_action" model="ir.actions.act_window">
<field name="name">Commission Rules</field>
<field name="path">commission-rule</field>
<field name="res_model">commission.rule</field>
<field name="view_mode">list,form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'commission_rule_main_view': True}</field>
</record>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019-2024 Akretion France (https://www.akretion.com)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">commission.res.config.settings.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='storno']" position="after">
<h2>Commissions</h2>
<div class="row mt16 o_settings_container" id="commission_simple">
<div class="col-12 col-lg-12 o_setting_box" id="commission_simple-settings">
<div class="o_setting_left_pane" />
<div class="o_setting_right_pane">
<div class="row" id="commission_date_range_type_id">
<label
for="commission_date_range_type_id"
class="col-md-5"
/>
<field name="commission_date_range_type_id" />
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019-2024 Akretion France (https://www.akretion.com)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
-->
<odoo>
<record id="view_users_form" model="ir.ui.view">
<field name="name">commission.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<group name="preferences" position="after">
<group name="commission" string="Commission" groups="account.group_account_manager">
<field name="commission_profile_id"/>
</group>
</group>
</field>
</record>
<record id="view_users_tree" model="ir.ui.view">
<field name="name">commission.res.users.tree</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_tree"/>
<field name="arch" type="xml">
<field name="login_date" position="after">
<field name="commission_profile_id" optional="hide" groups="account.group_account_manager"/>
</field>
</field>
</record>
</odoo>

View File

@@ -1 +1,2 @@
from . import commission_compute
from . import res_config_settings

View File

@@ -3,9 +3,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from odoo.exceptions import UserError
from odoo.tools.misc import format_date
import logging
logger = logging.getLogger(__name__)
@@ -14,44 +13,47 @@ class CommissionCompute(models.TransientModel):
_name = 'commission.compute'
_description = 'Compute Commissions'
company_id = fields.Many2one('res.company', required=True)
date_start = fields.Date(string="Period Start Date", required=True)
company_id = fields.Many2one('res.company', required=True, default=lambda self: self.env.company)
date_range_type_id = fields.Many2one(related='company_id.commission_date_range_type_id')
date_range_id = fields.Many2one(
'date.range', required=True, string='Period',
compute='_compute_date_range_id', store=True, precompute=True, readonly=False,
domain="[('type_id', '=', date_range_type_id)]")
date_start = fields.Date(related='date_range_id.date_start')
date_end = fields.Date(related='date_range_id.date_end')
@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
company = self.env.company
last_commission_result = self.env['commission.result'].search([
('company_id', '=', company.id),
], order='date_start desc', limit=1)
if last_commission_result:
last_start_date = last_commission_result.date_start
commissions_last_start_date = self.env['commission.result'].search([
('date_start', '=', last_start_date),
('company_id', '=', company.id),
], order="date_end asc", limit=1)
min_end_date = commissions_last_start_date.date_end
date_start = min_end_date + timedelta(1)
else:
today = fields.Date.context_today(self)
date_start = datetime(today.year, today.month, 1)
res.update({
'company_id': company.id,
'date_start': date_start,
})
return res
@api.depends('company_id')
def _compute_date_range_id(self):
for wiz in self:
date_range_id = False
company = wiz.company_id
if company and company.commission_date_range_type_id:
type_id = company.commission_date_range_type_id.id
last_commission_result = self.env['commission.result'].search([
('company_id', '=', company.id),
], order='date_end desc', limit=1)
limit_date = last_commission_result and last_commission_result.date_end or (fields.Date.context_today(self) + relativedelta(months=-2, day=31))
date_range = self.env['date.range'].search([
('company_id', 'in', (company.id, False)),
('type_id', '=', type_id),
('date_start', '>', limit_date)
], order='date_start', limit=1)
date_range_id = date_range and date_range.id or False
wiz.date_range_id = date_range_id
def run(self):
self.ensure_one()
if not self.date_start:
raise UserError(_("Missing Period Start Date."))
creso = self.env['commission.result']
existing_commissions = creso.search_read([
('date_start', '=', self.date_start),
date_range = self.date_range_id
existing_commissions = creso.search([
('date_range_id', '=', date_range.id),
('company_id', '=', self.company_id.id),
], ['assignment_id'])
exclude_assignment_ids = [x['assignment_id'][0] for x in existing_commissions if x['assignment_id']]
com_result_ids = self._core_compute(exclude_assignment_ids)
])
if existing_commissions:
raise UserError(_(
'Commissions already exist for %(period)s in company %(company)s.',
period=date_range.display_name, company=self.company_id.display_name))
com_result_ids = self._core_compute()
if not com_result_ids:
raise UserError(_('No commissions generated.'))
action = self.env['ir.actions.actions']._for_xml_id(
@@ -62,32 +64,12 @@ class CommissionCompute(models.TransientModel):
})
return action
def _core_compute(self, exclude_assignment_ids):
def _core_compute(self):
rules = self.env['commission.rule'].load_all_rules()
com_result_ids = []
assignments = self.env['commission.profile.assignment'].search(
[('company_id', '=', self.company_id.id), ('id', 'not in', exclude_assignment_ids)])
date_range_type2date_range = {}
assignments = self.env['commission.profile.assignment'].search([('company_id', '=', self.company_id.id)])
for assignment in assignments:
profile = assignment.profile_id
date_range_type = profile.date_range_type_id
if not date_range_type:
raise UserError(_("Missing commission periodicity on commission profile '%s'.") % profile.display_name)
if date_range_type not in date_range_type2date_range:
domain = [
('date_start', '=', self.date_start),
('type_id', '=', date_range_type.id),
]
date_range = self.env['date.range'].search(
domain + [('company_id', '=', self.company_id.id)], limit=1)
if not date_range:
date_range = self.env['date.range'].search(
domain + [('company_id', '=', False)], limit=1)
if not date_range:
logger.info('There is no date range with type %s starting on %s. Skipping commission generation for assignment ID %s', date_range_type.name, self.date_start, assignment.id)
continue
date_range_type2date_range[date_range_type] = date_range
com_result = assignment._generate_commission_result(date_range_type2date_range[date_range_type], rules)
com_result = assignment._generate_commission_result(self.date_range_id, rules)
if com_result:
com_result_ids.append(com_result.id)
else:

View File

@@ -15,7 +15,10 @@
<group name="main">
<field name="company_id" groups="base.group_multi_company"/>
<field name="company_id" invisible="1"/>
<field name="date_range_type_id" invisible="1"/>
<field name="date_range_id"/>
<field name="date_start"/>
<field name="date_end"/>
</group>
<footer>
<button name="run" type="object" string="Compute"
@@ -33,6 +36,6 @@
<field name="target">new</field>
</record>
<menuitem id="commission_compute_menu" action="commission_compute_action" parent="commission_root" sequence="15"/>
<menuitem id="commission_compute_menu" action="commission_compute_action" parent="commission_root" sequence="15" groups="account.group_account_user"/>
</odoo>

View File

@@ -0,0 +1,12 @@
# Copyright 2019-2024 Akretion France (https://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
commission_date_range_type_id = fields.Many2one(
related='company_id.commission_date_range_type_id', readonly=False)

View File

@@ -4,7 +4,7 @@
{
'name': 'Commission Simple Agent',
'version': '18.0.1.0.0',
'version': '16.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Glue module between commission_simple and sale_agent',
@@ -18,5 +18,5 @@
'views/commission_profile.xml',
'views/commission_result.xml',
],
'installable': True,
'installable': False,
}

View File

@@ -11,8 +11,8 @@
<field name="model">commission.profile</field>
<field name="inherit_id" ref="commission_simple.commission_profile_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='assign_ids']/list/field[@name='user_id']" position="after">
<field name="agent_id" required="assign_type == 'agent'" readonly="assign_type != 'agent'" context="{'default_agent': True}"/>
<xpath expr="//field[@name='assign_ids']/tree/field[@name='user_id']" position="after">
<field name="agent_id" attrs="{'required': [('assign_type', '=', 'agent')], 'readonly': [('assign_type', '!=', 'agent')]}"/>
</xpath>
</field>
</record>

View File

@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Akretion France (https://www.akretion.com)
Copyright 2024 Akretion France (http://www.akretion.com)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
-->
<odoo>
<record id="commission_result_list" model="ir.ui.view">
<record id="commission_result_tree" model="ir.ui.view">
<field name="model">commission.result</field>
<field name="inherit_id" ref="commission_simple.commission_result_list"/>
<field name="inherit_id" ref="commission_simple.commission_result_tree"/>
<field name="arch" type="xml">
<field name="assign_type" position="attributes">
<attribute name="decoration-danger">assign_type == 'agent'</attribute>
<attribute name="decoration-danger">assign_type == 'agent'</attribute>
</field>
</field>
</record>

View File

@@ -4,7 +4,7 @@
{
'name': 'Commission Simple Agent Purchase',
'version': '18.0.1.0.0',
'version': '16.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Glue module between commission_simple_agent and purchase',
@@ -16,8 +16,7 @@
],
'data': [
'views/commission_result.xml',
'views/commission_profile.xml',
'wizards/res_config_settings.xml',
],
'installable': True,
'installable': False,
}

View File

@@ -1,3 +1,2 @@
from . import commission_result
from . import commission_profile
from . import res_company

View File

@@ -1,20 +0,0 @@
# Copyright Akretion France (http://www.akretion.com/)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models, api, _
from odoo.exceptions import ValidationError
class CommissionProfile(models.Model):
_inherit = 'commission.profile'
commission_product_id = fields.Many2one(
'product.product', string='Specific Commission Product', ondelete='restrict',
check_company=True,
domain=[('type', '=', 'service')],
help="If not set, Odoo will use the commission product configured on the accounting "
"configuration page."
)

View File

@@ -5,7 +5,6 @@
from odoo import fields, models, _
from odoo.exceptions import UserError
from odoo.tools.misc import format_amount, formatLang
from markupsafe import Markup
class CommissionResult(models.Model):
@@ -15,34 +14,26 @@ class CommissionResult(models.Model):
def draft2done(self):
for result in self:
if result.state == "draft" and result.assign_type == 'agent':
if result.assign_type == 'agent':
if not result.purchase_id:
vals = result._prepare_purchase_order()
po = self.env['purchase.order'].create(vals)
po.message_post(body=Markup(_("Generated from commission <a href=# data-oe-model=commission.result data-oe-id=%d>%s</a>.") % (result.id, result.display_name)))
result.write({'purchase_id': po.id})
else:
po = self.purchase_id
if po.state in ('draft', 'sent', 'cancel'):
po.order_line.unlink()
po.message_post(body=Markup(_("Purchase order lines re-generated from commission <a href=# data-oe-model=commission.result data-oe-id=%d>%s</a>.") % (result.id, result.display_name)))
else:
raise UserError(_("Purchase Order %s has already been confirmed. You should cancel it first.") % po.display_name)
if po.state == 'cancel':
po.button_draft()
assert not po.order_line
# create lines
if not result.company_id.commission_product_id:
raise UserError(_("Commission product is not set on company %s.") % result.company_id.display_name)
line_vals = []
if not result.company_id.commission_po_config:
raise UserError(_(
"Purchase order configuration for commission is not set on "
"the accounting configuration page of company '%s'.")
% result.company_id.display_name)
if result.company_id.commission_po_config == 'single_line':
line_vals.append(result._prepare_purchase_order_line_single_line(po))
else:
for move_line in result.line_ids:
line_vals.append(result._prepare_purchase_order_line(move_line, po))
for move_line in result.line_ids:
line_vals.append(result._prepare_purchase_order_line(move_line, po))
po_lines = self.env['purchase.order.line'].create(line_vals)
po_lines._compute_tax_id()
return super().draft2done()
@@ -66,13 +57,7 @@ class CommissionResult(models.Model):
company_currency = move_line.company_id.currency_id
lang = self.partner_id.lang or self.env.lang
env = self.with_context(lang=lang).env
product = self.profile_id.commission_product_id or self.company_id.commission_product_id
if not product:
raise UserError(_(
"Commission product is not set on profile '%(profile)s' "
"nor on company '%(company)s'.",
profile=self.profile_id.display_name,
company=self.company_id.display_name))
product = self.company_id.commission_product_id
vals = {
'order_id': order.id,
'product_id': product.id,
@@ -83,24 +68,6 @@ class CommissionResult(models.Model):
}
return vals
def _prepare_purchase_order_line_single_line(self, order):
product = self.profile_id.commission_product_id or self.company_id.commission_product_id
if not product:
raise UserError(_(
"Commission product is not set on profile '%(profile)s' "
"nor on company '%(company)s'.",
profile=self.profile_id.display_name,
company=self.company_id.display_name))
vals = {
'order_id': order.id,
'product_id': product.id,
'name': _("Commissions for period %(period)s", period=self.date_range_id.name),
'product_qty': 1,
'product_uom': product.uom_id.id,
'price_unit': self.amount_total,
}
return vals
def unlink(self):
for result in self:
if result.purchase_id:

View File

@@ -12,7 +12,3 @@ class ResCompany(models.Model):
commission_product_id = fields.Many2one(
'product.product', string='Commission Product', ondelete='restrict', check_company=True,
domain=[('type', '=', 'service')])
commission_po_config = fields.Selection([
('single_line', 'Single Line'),
('details', 'One line per commission line'),
], default='details', string="Purchase Order Configuration")

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2025 Akretion France (https://www.akretion.com)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
-->
<odoo>
<record id="commission_profile_form" model="ir.ui.view">
<field name="model">commission.profile</field>
<field name="inherit_id" ref="commission_simple_agent.commission_profile_form"/>
<field name="arch" type="xml">
<group name="main-right" position="inside">
<field name="commission_product_id"/>
</group>
</field>
</record>
</odoo>

View File

@@ -12,7 +12,7 @@
<field name="inherit_id" ref="commission_simple.commission_result_form"/>
<field name="arch" type="xml">
<group name="main-right" position="inside">
<field name="purchase_id" invisible="assign_type != 'agent'"/>
<field name="purchase_id" attrs="{'invisible': [('assign_type', '!=', 'agent')]}"/>
</group>
</field>
</record>

View File

@@ -10,4 +10,3 @@ class ResConfigSettings(models.TransientModel):
commission_product_id = fields.Many2one(
related='company_id.commission_product_id', readonly=False)
commission_po_config = fields.Selection(related="company_id.commission_po_config", readonly=False)

View File

@@ -11,17 +11,13 @@
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">commission.res.config.settings.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="inherit_id" ref="commission_simple.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//block[@id='analytic']" position="after">
<block title="Commissions" id="commission_simple">
<setting id="commission_product" title="Commission Product">
<field name="commission_product_id" context="{'default_type': 'service', 'default_purchase_ok': True, 'default_sale_ok': False, 'default_available_in_pos': False, 'default_purchase_method': 'purchase'}"/>
</setting>
<setting id="commission_po_config" title="Purchase Order">
<field name="commission_po_config" />
</setting>
</block>
<xpath expr="//div[@id='commission_simple-settings']/div[hasclass('o_setting_right_pane')]" position="inside">
<div class="row" id="commission_product_id">
<label for="commission_product_id" class="col-md-5" />
<field name="commission_product_id" context="{'default_detailed_type': 'service', 'default_purchase_ok': True, 'default_sale_ok': False, 'default_available_in_pos': False, 'default_purchase_method': 'purchase'}"/>
</div>
</xpath>
</field>
</record>

View File

@@ -30,7 +30,7 @@
'account_financial_report', # OCA/account-financial-reporting
'account_balance_ebp_csv_export', # OCA/l10n-france
# 'l10n_fr_mis_reports', # OCA/l10n-france
# 'l10n_fr_fec_oca', # OCA/l10n-france
'l10n_fr_fec_oca', # OCA/l10n-france
### BANK STATEMENTS
'account_statement_completion_label_simple', # akretion/bank-statement-reconcile-simple
#'account_statement_completion_label_simple_sale', # akretion/bank-statement-reconcile-simple
@@ -43,9 +43,10 @@
'currency_rate_update', # OCA/currency
'currency_old_rate_notify', # OCA/currency
### INVOICE IMPORT
#'account_invoice_import_simple_pdf', # OCA/edi
#'account_invoice_import_facturx', # OCA/edi
#'l10n_fr_account_invoice_import_facturx', # OCA/l10n-france
'l10n_fr_business_document_import', # OCA/l10n-france
'account_invoice_import_simple_pdf', # OCA/edi
'account_invoice_import_ubl', # OCA/edi
'l10n_fr_account_invoice_import_facturx', # OCA/l10n-france
### OVERDUE
'account_invoice_overdue_warn', # OCA/credit-control
#'account_invoice_overdue_warn_sale', # OCA/credit-control

View File

@@ -26,7 +26,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
'author': 'Akretion',
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['product'],
"external_dependencies": {"python": ["stdnum"]},
"external_dependencies": {"python": ["python-stdnum"]},
'data': [
'views/product_supplierinfo.xml',
'views/product_pricelist.xml',

View File

@@ -1,419 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>MRP Usability</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="mrp-usability">
<h1 class="title">MRP Usability</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/akretion/odoo-usability/tree/12.0/mrp_usability"><img alt="akretion/odoo-usability" src="https://img.shields.io/badge/github-akretion%2Fodoo--usability-lightgray.png?logo=github" /></a></p>
<p>Small usability improvements on MRP:</p>
<ul class="simple">
<li>order by id desc</li>
<li>show field date_start and date_finished on mrp.production form view</li>
<li>show more fields on stock move form</li>
<li>show bom type in tree view + add group by</li>
<li>complete Manufacturing Order report with unvailable products</li>
</ul>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/akretion/odoo-usability/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/akretion/odoo-usability/issues/new?body=module:%20mrp_usability%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<p>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<p>This module is part of the <a class="reference external" href="https://github.com/akretion/odoo-usability/tree/12.0/mrp_usability">akretion/odoo-usability</a> project on GitHub.</p>
<p>You are welcome to contribute.</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -4,7 +4,7 @@
{
'name': 'Sale Agent',
'version': '18.0.1.0.0',
'version': '16.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Add agent on partner, sale order and customer invoice/refund',
@@ -19,5 +19,5 @@
"views/account_invoice_report.xml",
],
'demo': ['demo/demo.xml'],
'installable': True,
'installable': False,
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024-2025 Akretion France (https://www.akretion.com/)
Copyright 2020 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

View File

@@ -3,7 +3,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo.tools import SQL
class AccountInvoiceReport(models.Model):
@@ -12,4 +11,5 @@ class AccountInvoiceReport(models.Model):
invoice_agent_id = fields.Many2one("res.partner", string="Agent", readonly=True)
def _select(self):
return SQL("%s, move.invoice_agent_id AS invoice_agent_id", super()._select())
select_str = super()._select()
return f"{select_str}, move.invoice_agent_id AS invoice_agent_id"

View File

@@ -14,7 +14,7 @@
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='sales_purchases']//group[@name='sale']/field[@name='user_id']" name="user_id" position="after">
<field name="agent_id" invisible="parent_id"/>
<field name="agent_id" attrs="{'invisible': [('parent_id', '!=', False)]}"/>
</xpath>
<group name="misc" position="inside">
<field name="agent"/>

View File

@@ -1,6 +1,6 @@
[project]
name = "odoo-addons-akretion-odoo-usability"
version = "18.0.20251107.0"
version = "18.0.20251212.0"
dependencies = [
"odoo-addon-account_invoice_update_wizard==18.0.*",
"odoo-addon-account_usability_akretion==18.0.*",