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

[ADD] ssi_hr_employee_stock #21

Merged
merged 3 commits into from
Mar 2, 2024
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
1 change: 1 addition & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#oca_dependencies-txt

ssi-mixin https://github.com/open-synergy/ssi-mixin.git 14.0
ssi-stock https://github.com/open-synergy/ssi-stock.git 14.0
opnsynid-hr https://github.com/open-synergy/opnsynid-hr.git 14.0
46 changes: 46 additions & 0 deletions ssi_hr_employee_stock/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. image:: https://img.shields.io/badge/licence-AGPL-3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

============================
Employee + Stock Integration
============================


Installation
============

To install this module, you need to:

1. Clone the branch 14.0 of the repository https://github.com/open-synergy/opnsynid-hr-employee
2. Add the path to this repository in your configuration (addons-path)
3. Update the module list (Must be on developer mode)
4. Go to menu *Apps -> Apps -> Main Apps*
5. Search For *Employee + Stock Integration*
6. Install the module

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

Bugs are tracked on `GitHub Issues
<https://github.com/open-synergy/opnsynid-hr-employee/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.


Credits
=======

Contributors
------------

* Andhitia Rama <[email protected]>

Maintainer
----------

.. image:: https://simetri-sinergi.id/logo.png
:alt: PT. Simetri Sinergi Indonesia
:target: https://simetri-sinergi.id

This module is maintained by the PT. Simetri Sinergi Indonesia.
5 changes: 5 additions & 0 deletions ssi_hr_employee_stock/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2024 OpenSynergy Indonesia
# Copyright 2024 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
23 changes: 23 additions & 0 deletions ssi_hr_employee_stock/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 OpenSynergy Indonesia
# Copyright 2024 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Employee + Stock Integration",
"version": "14.0.1.0.0",
"website": "https://simetri-sinergi.id",
"author": "OpenSynergy Indonesia, PT. Simetri Sinergi Indonesia",
"license": "AGPL-3",
"installable": True,
"application": False,
"auto_install": True,
"depends": [
"ssi_hr_employee",
"ssi_stock",
],
"data": [
"data/location_type_data.xml",
"views/hr_employee_views.xml",
],
"demo": [],
}
14 changes: 14 additions & 0 deletions ssi_hr_employee_stock/data/location_type_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 OpenSynergy Indonesia
Copyright 2024 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<record id="location_type_employee" model="location_type">
<field name="name">Employee</field>
<field name="code">EMPL</field>
<field name="usage">view</field>
<field name="is_warehouse_location" eval="0" />
</record>
</data>
</odoo>
7 changes: 7 additions & 0 deletions ssi_hr_employee_stock/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2024 OpenSynergy Indonesia
# Copyright 2024 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import (
hr_employee,
)
54 changes: 54 additions & 0 deletions ssi_hr_employee_stock/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2024 OpenSynergy Indonesia
# Copyright 2024 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class HrEmployeeBase(models.AbstractModel):
_name = "hr.employee.base"
_inherit = "hr.employee.base"

location_id = fields.Many2one(
string="Location",
comodel_name="stock.location",
ondelete="restrict",
)

def action_create_employee_location(self):
for record in self.sudo():
record._create_employee_location()

def action_delete_employee_location(self):
for record in self.sudo():
record._delete_employee_location()

def _create_employee_location(self):
self.ensure_one()
employee_location_type = self.env.ref(
"ssi_hr_employee_stock.location_type_employee"
)
data = {
"name": self.name,
"usage": "internal",
"type_id": employee_location_type.id,
}
location = self.env["stock.location"].create(data)
self.write(
{
"location_id": location.id,
}
)

def _delete_employee_location(self):
self.ensure_one()
location = self.location_id
if not location:
return True

self.write(
{
"location_id": False,
}
)
location.unlink()
Binary file added ssi_hr_employee_stock/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.
45 changes: 45 additions & 0 deletions ssi_hr_employee_stock/views/hr_employee_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 OpenSynergy Indonesia
Copyright 2024 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="hr_employee_view_form" model="ir.ui.view">
<field name="name">form hr.employee</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form" />
<field name="arch" type="xml">
<data>
<xpath expr="//header" position="inside">
<button
name="action_create_employee_location"
type="object"
string="Create Location"
attrs="{'invisible':[('location_id','!=',False)]}"
class="oe_highlight"
icon="fa-gears"
/>
<button
name="action_delete_employee_location"
type="object"
string="Delete Location"
attrs="{'invisible':[('location_id','=',False)]}"
class="oe_highlight"
icon="fa-eraser"
/>
</xpath>
<xpath expr="//page[last()]" position="after">
<page string="Inventory" name="inventory">
<group name="inventory_1" colspan="4" col="2">
<group name="inventory_1_1" colspan="1" col="2">
<field name="location_id" />
</group>
<group name="inventory_1_2" colspan="1" col="2">
</group>
</group>
</page>
</xpath>
</data>
</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
odoo14-addon-ssi-stock
Loading