[ADD] commission_simple, commission_simple_agent, sale_agent
3 modules backported from v16
This commit is contained in:
1
commission_simple_agent/__init__.py
Normal file
1
commission_simple_agent/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
22
commission_simple_agent/__manifest__.py
Normal file
22
commission_simple_agent/__manifest__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright 2019-2025 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).
|
||||
|
||||
{
|
||||
'name': 'Commission Simple Agent',
|
||||
'version': '14.0.1.0.0',
|
||||
'category': 'Sales',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Glue module between commission_simple and sale_agent',
|
||||
'author': 'Akretion',
|
||||
'website': 'https://github.com/akretion/odoo-usability',
|
||||
'depends': [
|
||||
'commission_simple',
|
||||
'sale_agent',
|
||||
],
|
||||
'data': [
|
||||
'views/commission_profile.xml',
|
||||
'views/commission_result.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
44
commission_simple_agent/i18n/fr.po
Normal file
44
commission_simple_agent/i18n/fr.po
Normal file
@@ -0,0 +1,44 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * commission_simple_agent
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-11-29 23:32+0000\n"
|
||||
"PO-Revision-Date: 2024-11-29 23:32+0000\n"
|
||||
"Last-Translator: Alexis de Lattre <alexis.delattre@akretion.com>\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_agent
|
||||
#. odoo-python
|
||||
#: code:addons/commission_simple_agent/models/commission_profile_assignment.py:0
|
||||
#: model:ir.model.fields,field_description:commission_simple_agent.field_commission_profile_assignment__agent_id
|
||||
#: model_terms:ir.ui.view,arch_db:commission_simple_agent.commission_result_search
|
||||
#, python-format
|
||||
msgid "Agent"
|
||||
msgstr "Agent"
|
||||
|
||||
#. module: commission_simple_agent
|
||||
#. odoo-python
|
||||
#: code:addons/commission_simple_agent/models/commission_profile_assignment.py:0
|
||||
#, python-format
|
||||
msgid "An agent must be selected when the assignment type is 'Agent'."
|
||||
msgstr ""
|
||||
"Un agent doit être sélectionné lorsque le type d'affectation est \"Agent\"."
|
||||
|
||||
#. module: commission_simple_agent
|
||||
#: model:ir.model,name:commission_simple_agent.model_commission_profile_assignment
|
||||
msgid "Commission Profile Assignment"
|
||||
msgstr "Affectation du profil de commission"
|
||||
|
||||
#. module: commission_simple_agent
|
||||
#: model:ir.model.constraint,message:commission_simple_agent.constraint_commission_profile_assignment_company_agent_uniq
|
||||
msgid "This agent already has an assignment in this company."
|
||||
msgstr "Cet agent a déjà une affectation dans cette société."
|
||||
1
commission_simple_agent/models/__init__.py
Normal file
1
commission_simple_agent/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import commission_profile_assignment
|
||||
@@ -0,0 +1,51 @@
|
||||
# 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 api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class CommissionProfileAssignment(models.Model):
|
||||
_inherit = "commission.profile.assignment"
|
||||
|
||||
agent_id = fields.Many2one(
|
||||
'res.partner', ondelete='restrict',
|
||||
compute="_compute_agent_id", store=True, readonly=False,
|
||||
domain=[('agent', '=', True)])
|
||||
|
||||
_sql_constraints = [
|
||||
(
|
||||
'company_agent_uniq',
|
||||
'unique(agent_id, company_id)',
|
||||
'This agent already has an assignment in this company.')]
|
||||
|
||||
@api.model
|
||||
def _assign_type_selection(self):
|
||||
sel = super()._assign_type_selection()
|
||||
sel.append(('agent', _('Agent')))
|
||||
return sel
|
||||
|
||||
@api.constrains('assign_type', 'agent_id')
|
||||
def _check_agent(self):
|
||||
for assignment in self:
|
||||
if assignment.assign_type == 'agent' and not assignment.agent_id:
|
||||
raise ValidationError(_("An agent must be selected when the assignment type is 'Agent'."))
|
||||
|
||||
@api.depends('assign_type')
|
||||
def _compute_agent_id(self):
|
||||
for assign in self:
|
||||
if assign.assign_type != 'agent':
|
||||
assign.agent_id = False
|
||||
|
||||
def _prepare_move_line_domain(self, date_range):
|
||||
domain = super()._prepare_move_line_domain(date_range)
|
||||
if self.assign_type == 'agent':
|
||||
domain.append(('move_id.invoice_agent_id', '=', self.agent_id.id))
|
||||
return domain
|
||||
|
||||
def _get_partner(self):
|
||||
self.ensure_one()
|
||||
if self.assign_type == 'agent':
|
||||
return self.agent_id
|
||||
return super()._get_partner()
|
||||
21
commission_simple_agent/views/commission_profile.xml
Normal file
21
commission_simple_agent/views/commission_profile.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 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="commission_profile_form" model="ir.ui.view">
|
||||
<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']/tree/field[@name='user_id']" position="after">
|
||||
<field name="agent_id" attrs="{'required': [('assign_type', '=', 'agent')], 'readonly': [('assign_type', '!=', 'agent')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
32
commission_simple_agent/views/commission_result.xml
Normal file
32
commission_simple_agent/views/commission_result.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 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="commission_result_tree" model="ir.ui.view">
|
||||
<field name="model">commission.result</field>
|
||||
<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>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record id="commission_result_search" model="ir.ui.view">
|
||||
<field name="model">commission.result</field>
|
||||
<field name="inherit_id" ref="commission_simple.commission_result_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<filter name="user" position="after">
|
||||
<filter name="agent" domain="[('assign_type', '=', 'agent')]" string="Agent"/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user