Skip to content

Commit

Permalink
[IMP] *_commission: Total refactorization of the modules
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed Mar 11, 2015
1 parent 39bb020 commit 598b82b
Show file tree
Hide file tree
Showing 65 changed files with 10,685 additions and 5,505 deletions.
37 changes: 35 additions & 2 deletions hr_commission/README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
HR Commission
Commissions in HR
==================

This module links sale_commision with hr module.
This module links sale_commission with hr module. For now, it only adds another
type of agent whose commissions are not invoiced in the corresponding wizard.

Known issues / Roadmap
======================
* Add demo data.
* Restore all 6.1 functionality about linking with wages.

Credits
=======

Contributors
------------
* Pedro M. Baeza <[email protected]>

Icon
----
* http://commons.wikimedia.org/wiki/File:Percent_18e.svg
* https://openclipart.org/detail/43969/pile-of-golden-coins-by-j_alves

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
28 changes: 15 additions & 13 deletions hr_commission/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Pedro M. Baeza (<http://www.serviciosbaeza.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
Expand All @@ -17,21 +19,21 @@
##############################################################################

{
'name': 'HR commission',
'name': 'HR commissions',
'version': '1.0',
'author': 'Pexego',
"category": "Generic Modules/Sales & Purchases",
'depends': ['sale_commission', 'hr'],
'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza',
"category": "Human Resources",
'depends': [
'sale_commission',
'hr'
],
'license': 'AGPL-3',
'contributors': [
"Davide Corio <[email protected]>",
"Joao Alfredo Gama Batista <[email protected]>",
"Sandy Carter <[email protected]>",
"Giorgio Borelli <[email protected]>",
"Daniel Campos <[email protected]>",
"Pedro M. Baeza <[email protected]>",
"Ana Juaristi <[email protected]>"],
"data": ["views/sale_agent_view.xml"],
"active": True,
],
"data": [
"views/res_partner_view.xml",
],
"installable": True,
"auto_install": True,
}
37 changes: 37 additions & 0 deletions hr_commission/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_commission
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-19 08:46+0000\n"
"PO-Revision-Date: 2015-02-19 08:46+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_commission
#: code:addons/hr_commission/models/res_partner.py:47
#, python-format
msgid "There must one (and only one) employee linked to this partner. To do this, go to 'Human Resources' and check 'Employees'"
msgstr "Debe haber un (y sólo un) empleado enlazado a esta empresa. Para hacer esto, vaya a 'Recursos humanos' y compruebe la sección 'Empleados'"

#. module: hr_commission
#: field:res.partner,users:0
msgid "Users"
msgstr "Usuarios"

#. module: hr_commission
#: field:res.partner,employee:0
msgid "Employee"
msgstr "Empleado"

#. module: sale_commission
#: selection:res.partner,agent_type:0
msgid "Salesman (employee)"
msgstr "Comercial (empleado)"
21 changes: 13 additions & 8 deletions hr_commission/i18n/hr_commission.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-17 16:05+0000\n"
"PO-Revision-Date: 2015-02-17 16:05+0000\n"
"POT-Creation-Date: 2015-02-19 08:46+0000\n"
"PO-Revision-Date: 2015-02-19 08:46+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -16,17 +16,22 @@ msgstr ""
"Plural-Forms: \n"

#. module: hr_commission
#: help:sale.agent,employee_id:0
msgid "Employee associated to agent, is necessary for set an employee to settle commissions in wage."
#: code:addons/hr_commission/models/res_partner.py:47
#, python-format
msgid "There must one (and only one) employee linked to this partner. To do this, go to 'Human Resources' and check 'Employees'"
msgstr ""

#. module: hr_commission
#: field:sale.agent,employee_id:0
msgid "Employee id"
#: field:res.partner,users:0
msgid "Users"
msgstr ""

#. module: hr_commission
#: model:ir.model,name:hr_commission.model_sale_agent
msgid "Sale agent"
#: field:res.partner,employee:0
msgid "Employee"
msgstr ""

#. module: sale_commission
#: selection:res.partner,agent_type:0
msgid "Salesman (employee)"
msgstr ""
2 changes: 1 addition & 1 deletion hr_commission/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
#
##############################################################################

from . import sale_agent
from . import res_partner
55 changes: 55 additions & 0 deletions hr_commission/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2015 Avanzosc (<http://www.avanzosc.es>)
# Copyright (C) 2015 Pedro M. Baeza (<http://www.serviciosbaeza.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, exceptions, _


class ResPartner(models.Model):
"""Add some fields related to commissions"""
_inherit = "res.partner"

agent_type = fields.Selection(
selection_add=[("salesman", "Salesman (employee)")])
employee = fields.Many2one(
comodel_name="hr.employee", compute="_get_employee")
users = fields.One2many(comodel_name="res.users",
inverse_name="partner_id")

@api.one
@api.depends('users')
def _get_employee(self):
self.employee = False
if len(self.users) == 1 and len(self.users[0].employee_ids) == 1:
self.employee = self.users[0].employee_ids[0]

@api.constrains('agent_type', 'employee')
def _check_employee(self):
if self.agent_type == 'salesman' and not self.employee:
raise exceptions.ValidationError(
_("There must one (and only one) employee linked to this "
"partner. To do this, go to 'Human Resources' and check "
"'Employees'"))

@api.onchange('agent_type')
def onchange_agent_type(self):
if self.agent_type == 'salesman':
self.supplier = False
return super(ResPartner, self).onchange_agent_type()
12 changes: 0 additions & 12 deletions hr_commission/models/sale_agent.py

This file was deleted.

Binary file added hr_commission/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 598b82b

Please sign in to comment.