Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG][11.0] hr_commission: Migration to 11.0 #174

Merged
merged 3 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions hr_commission/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
==============
HR commissions
==============

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github
:target: https://github.com/OCA/commission/tree/11.0/hr_commission
:alt: OCA/commission
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/commission-11-0/commission-11-0-hr_commission
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/165/11.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

* Add demo data.
* Link settlements with wages.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/commission/issues>`_.
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
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20hr_commission%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_

* Pedro M. Baeza

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

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

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.

This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/11.0/hr_commission>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions hr_commission/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions hr_commission/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2015-2018 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html

{
'name': 'HR commissions',
'version': '11.0.1.0.0',
'author': 'Tecnativa,'
'Odoo Community Association (OCA)',
"category": "Commissions",
'depends': [
'sale_commission',
'hr'
],
'license': 'AGPL-3',
"data": [
"views/res_partner_view.xml",
],
"installable": True,
}
41 changes: 41 additions & 0 deletions hr_commission/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_commission
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-07 11:26+0000\n"
"PO-Revision-Date: 2018-08-07 11:26+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
#: model:ir.model,name:hr_commission.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: hr_commission
#: model:ir.model,name:hr_commission.model_hr_employee
#: model:ir.model.fields,field_description:hr_commission.field_res_partner_employee_id
#: model:ir.model.fields,field_description:hr_commission.field_res_users_employee_id
msgid "Employee"
msgstr "Empleado"

#. module: hr_commission
#: code:addons/hr_commission/models/res_partner.py:30
#, 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
#: code:addons/hr_commission/models/hr_employee.py:16
#, python-format
msgid "You can't remove the user, as it's linked to a commission agent."
msgstr "No puede eliminar el usuario, ya que está enlazado a un comisionista."

2 changes: 2 additions & 0 deletions hr_commission/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import hr_employee
from . import res_partner
19 changes: 19 additions & 0 deletions hr_commission/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2018 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html

from odoo import _, exceptions, models


class HrEmployee(models.Model):
_inherit = "hr.employee"

def write(self, vals):
"""Check if there's an agent linked to that employee."""
if 'user_id' in vals and not vals['user_id']:
for emp in self:
if emp.user_id.partner_id.agent_type == 'salesman':
raise exceptions.ValidationError(
_("You can't remove the user, as it's linked to "
"a commission agent.")
)
return super().write(vals)
37 changes: 37 additions & 0 deletions hr_commission/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2015-2018 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html

from odoo import _, api, fields, exceptions, models


class ResPartner(models.Model):
_inherit = "res.partner"

agent_type = fields.Selection(
selection_add=[("salesman", "Salesman (employee)")],
)
employee_id = fields.Many2one(
comodel_name="hr.employee",
compute="_compute_employee_id",
compute_sudo=True,
)

@api.depends('user_ids')
def _compute_employee_id(self):
for partner in self:
if (len(partner.user_ids) == 1 and
len(partner.user_ids[0].employee_ids) == 1):
partner.employee_id = partner.user_ids[0].employee_ids[0]

@api.constrains('agent_type')
def _check_employee(self):
if self.agent_type == 'salesman' and not self.employee_id:
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_hr_commission(self):
if self.agent_type == 'salesman':
self.supplier = False
3 changes: 3 additions & 0 deletions hr_commission/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Tecnativa <https://www.tecnativa.com>`_

* Pedro M. Baeza
2 changes: 2 additions & 0 deletions hr_commission/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
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.
2 changes: 2 additions & 0 deletions hr_commission/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Add demo data.
* Link settlements with wages.
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