Browse Source

Jan 09 : [FIX] Bug Fixed 'cost_per_employee_manufacturing'

pull/299/head
RisvanaCybro 1 year ago
parent
commit
e5fd0473ec
  1. 2
      cost_per_employee_manufacturing/README.rst
  2. 3
      cost_per_employee_manufacturing/__init__.py
  3. 60
      cost_per_employee_manufacturing/__manifest__.py
  4. 2
      cost_per_employee_manufacturing/doc/RELEASE_NOTES.md
  5. 2
      cost_per_employee_manufacturing/models/__init__.py
  6. 23
      cost_per_employee_manufacturing/models/cost_per_employee.py
  7. 10
      cost_per_employee_manufacturing/models/hr_employee.py
  8. 7
      cost_per_employee_manufacturing/models/mrp_cost_structure.py
  9. 29
      cost_per_employee_manufacturing/models/mrp_production.py
  10. 15
      cost_per_employee_manufacturing/models/mrp_workcenter.py

2
cost_per_employee_manufacturing/README.rst

@ -1,4 +1,4 @@
.. image:: https://img.shields.io/badge/license-OPL--1-red.svg .. image:: https://img.shields.io/badge/licence-OPL--1-red.svg
:target: https://www.odoo.com/documentation/16.0/legal/licenses.html#odoo-apps :target: https://www.odoo.com/documentation/16.0/legal/licenses.html#odoo-apps
:alt: License: OPL-1 :alt: License: OPL-1

3
cost_per_employee_manufacturing/__init__.py

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################### ###############################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sruthi Pavithran (odoo@cybrosys.com) # Author: Sruthi Pavithran (odoo@cybrosys.com)
# #
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) # This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)

60
cost_per_employee_manufacturing/__manifest__.py

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################### ###############################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sruthi Pavithran (odoo@cybrosys.com) # Author: Sruthi Pavithran (odoo@cybrosys.com)
# #
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) # This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
@ -20,35 +19,40 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
############################################################################### ###############################################################################
{ {
'name': "Cost per Employees in Manufacturing", "name": "Cost per Employees in Manufacturing",
'version': '16.0.1.0.0', "version": "16.0.1.0.0",
'category': 'Manufacturing', "category": "Manufacturing",
'summary': """Calculate Cost per Employees in Manufacturing""", "summary": """Calculate Cost per Employees in Manufacturing""",
'description': """This module helps to Calculate Cost per Employees in "description": """This module helps to Calculate Cost per Employees in
Manufacturing.""", Manufacturing.""",
'author': 'Cybrosys Techno Solutions', "author": "Cybrosys Techno Solutions",
'company': 'Cybrosys Techno Solutions', "company": "Cybrosys Techno Solutions",
'maintainer': 'Cybrosys Techno Solutions', "maintainer": "Cybrosys Techno Solutions",
'website': "https://www.cybrosys.com", "website": "https://www.cybrosys.com",
'depends': ['base', 'mrp', 'hr', 'account_accountant', 'account', "depends": [
'mrp_subcontracting_account_enterprise'], "base",
'data': [ "mrp",
'security/ir.model.access.csv', "hr",
'views/hr_employee_views.xml', "account_accountant",
'views/mrp_workcenter_views.xml', "account",
'views/mrp_production_views.xml', "mrp_subcontracting_account_enterprise",
'views/cost_structure_report_templates.xml'
], ],
'assets': { "data": [
'web.assets_backend': [ "security/ir.model.access.csv",
'cost_per_employee_manufacturing/static/src/js/cost_per_employee.js' "views/hr_employee_views.xml",
"views/mrp_workcenter_views.xml",
"views/mrp_production_views.xml",
"views/cost_structure_report_templates.xml",
],
"assets": {
"web.assets_backend": [
"cost_per_employee_manufacturing/static/src/js/cost_per_employee.js"
] ]
}, },
'images': ['static/description/banner.jpg'], "images": ["static/description/banner.jpg"],
'license': 'AGPL-3', "license": "OPL-1",
'installable': True, "installable": True,
'auto_install': False, "auto_install": False,
'application': False, "application": False,
} }

2
cost_per_employee_manufacturing/doc/RELEASE_NOTES.md

@ -1,6 +1,6 @@
## Module <cost_per_employee_manufacturing> ## Module <cost_per_employee_manufacturing>
#### 05.01.2024 #### 09.01.2023
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD

2
cost_per_employee_manufacturing/models/__init__.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sruthi Pavithran (odoo@cybrosys.com) # Author: Sruthi Pavithran (odoo@cybrosys.com)
# #
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) # This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)

23
cost_per_employee_manufacturing/models/cost_per_employee.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sruthi Pavithran (odoo@cybrosys.com) # Author: Sruthi Pavithran (odoo@cybrosys.com)
# #
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) # This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
@ -24,15 +24,18 @@ from odoo import fields, models
class CostPerEmployee(models.Model): class CostPerEmployee(models.Model):
"""Creating new models for storing cost per employee""" """Creating new models for storing cost per employee"""
_name = 'cost.per.employee'
_name = "cost.per.employee"
_description = "Storing cost per hour of employee" _description = "Storing cost per hour of employee"
employee_id = fields.Many2one('hr.employee', employee_id = fields.Many2one(
help="Select Employees", "hr.employee", help="Select Employees", string="Employee Name"
string="Employee Name") )
cost = fields.Float(related="employee_id.hour_per_cost", cost = fields.Float(
related="employee_id.hour_per_cost",
help="Hourly cost of employee", help="Hourly cost of employee",
string="Cost") string="Cost",
mrp_workcenter_id = fields.Many2one('mrp.workcenter', )
string="Work Center", mrp_workcenter_id = fields.Many2one(
help="Select work centers") "mrp.workcenter", string="Work Center", help="Select work centers"
)

10
cost_per_employee_manufacturing/models/hr_employee.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sruthi Pavithran (odoo@cybrosys.com) # Author: Sruthi Pavithran (odoo@cybrosys.com)
# #
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) # This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
@ -24,7 +24,9 @@ from odoo import fields, models
class HrEmployee(models.Model): class HrEmployee(models.Model):
"""Adding field to hr employee""" """Adding field to hr employee"""
_inherit = 'hr.employee'
hour_per_cost = fields.Float(string='Hourly Cost', _inherit = "hr.employee"
help="Hourly cost of each employee")
hour_per_cost = fields.Float(
string="Hourly Cost", help="Hourly cost of each employee"
)

7
cost_per_employee_manufacturing/models/mrp_cost_structure.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sruthi Pavithran (odoo@cybrosys.com) # Author: Sruthi Pavithran (odoo@cybrosys.com)
# #
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) # This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
@ -24,11 +24,12 @@ from odoo import models
class MrpCostStructure(models.AbstractModel): class MrpCostStructure(models.AbstractModel):
"""Override method for adding field to cost structure report""" """Override method for adding field to cost structure report"""
_inherit = 'report.mrp_account_enterprise.mrp_cost_structure'
_inherit = "report.mrp_account_enterprise.mrp_cost_structure"
def get_lines(self, productions): def get_lines(self, productions):
"""get lines of production in cost structure report""" """get lines of production in cost structure report"""
lines = super().get_lines(productions) lines = super().get_lines(productions)
for line in lines: for line in lines:
line['cost_per_hour'] = productions.cost_per_hour line["cost_per_hour"] = productions.cost_per_hour
return lines return lines

29
cost_per_employee_manufacturing/models/mrp_production.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sruthi Pavithran (odoo@cybrosys.com) # Author: Sruthi Pavithran (odoo@cybrosys.com)
# #
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) # This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
@ -24,15 +24,20 @@ from odoo import api, fields, models
class MrpProduction(models.Model): class MrpProduction(models.Model):
"""Adding fields to mrp production""" """Adding fields to mrp production"""
_inherit = 'mrp.production'
cost_per_hour = fields.Float(compute='_compute_cost_per_hour', store=True, _inherit = "mrp.production"
cost_per_hour = fields.Float(
compute="_compute_cost_per_hour",
store=True,
string="Cost per hour", string="Cost per hour",
help="Cost per hour of production") help="Cost per hour of production",
cost = fields.Float(related='cost_per_hour', store=True, string="Cost", )
help="Cost of production") cost = fields.Float(
related="cost_per_hour", store=True, string="Cost", help="Cost of production"
)
@api.depends('workorder_ids', 'workorder_ids.duration') @api.depends("workorder_ids", "workorder_ids.duration")
def _compute_cost_per_hour(self): def _compute_cost_per_hour(self):
"""Calculate cost per hour of employee""" """Calculate cost per hour of employee"""
for record in self: for record in self:
@ -43,9 +48,13 @@ class MrpProduction(models.Model):
for work_order in record.workorder_ids: for work_order in record.workorder_ids:
work_center_employees = ( work_center_employees = (
work_order.workcenter_id.cost_per_employee_ids.mapped( work_order.workcenter_id.cost_per_employee_ids.mapped(
'employee_id.id')) "employee_id.id"
)
)
if logged_in_user in work_center_employees: if logged_in_user in work_center_employees:
cost_per = record.env['hr.employee'].browse( cost_per = (
logged_in_user).hour_per_cost * work_order.duration record.env["hr.employee"].browse(logged_in_user).hour_per_cost
* work_order.duration
)
cost.append(cost_per) cost.append(cost_per)
record.cost_per_hour = sum(cost) record.cost_per_hour = sum(cost)

15
cost_per_employee_manufacturing/models/mrp_workcenter.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sruthi Pavithran (odoo@cybrosys.com) # Author: Sruthi Pavithran (odoo@cybrosys.com)
# #
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) # This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
@ -23,10 +23,13 @@ from odoo import fields, models
class MrpWorkCenter(models.Model): class MrpWorkCenter(models.Model):
"""Adding field in mrp workcenter""" """Adding field in mrp work-center"""
_inherit = 'mrp.workcenter'
cost_per_employee_ids = fields.One2many('cost.per.employee', _inherit = "mrp.workcenter"
'mrp_workcenter_id',
cost_per_employee_ids = fields.One2many(
"cost.per.employee",
"mrp_workcenter_id",
string="Employee Cost", string="Employee Cost",
help="Cost per employee") help="Cost per employee",
)

Loading…
Cancel
Save