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

[17.0][ADD] deltatech_record_type #1798

Merged
merged 1 commit into from
Oct 7, 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
56 changes: 56 additions & 0 deletions deltatech_record_type/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
======================
Terrabit - Record Type
======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b0619f4886e70796f25dc18aef1ae850aff1f1f34442032a1025ddf2c2ffd5a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-OPL--1-blue.png
:target: https://www.odoo.com/documentation/master/legal/licenses.html
:alt: License: OPL-1
.. |badge3| image:: https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github
:target: https:/dhongu/deltatech/tree/17.0/deltatech_record_type
:alt: dhongu/deltatech

|badge1| |badge2| |badge3|

Features:

- Types can be defined for records

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `Terrabit Issues <https://www.terrabit.ro/helpdesk>`_.
In case of trouble, please check there if your issue has already been reported.

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

Credits
=======

Authors
-------

* Terrabit
* Dan Stoica

Maintainers
-----------

This module is part of the `dhongu/deltatech <https:/dhongu/deltatech/tree/17.0/deltatech_record_type>`_ project on GitHub.

You are welcome to contribute.
6 changes: 6 additions & 0 deletions deltatech_record_type/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# © 2015-2021 Terrabit Solutions
# Dan Stoica <danila(@)terrabit(.)ro
# See README.rst file on addons root folder for license details


from . import models
18 changes: 18 additions & 0 deletions deltatech_record_type/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# © 2015-2021 Terrabit Solutions
# Dan Stoica <danila(@)terrabit(.)ro
# See README.rst file on addons root folder for license details


{
"name": "Terrabit - Record Type",
"summary": "Manage multiple record types",
"version": "17.0.1.0.4",
"author": "Terrabit, Dan Stoica",
"website": "https://www.terrabit.ro",
"category": "Generic Modules/Other",
"depends": ["sale", "deltatech_select_journal", "purchase"],
"license": "OPL-1",
"data": ["views/purchase_view.xml", "views/sale.xml", "security/ir.model.access.csv"],
"development_status": "Beta",
"images": ["static/description/main_screenshot.png"],
}
107 changes: 107 additions & 0 deletions deltatech_record_type/i18n/ro.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * deltatech_saleorder_type
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-31 07:00+0000\n"
"PO-Revision-Date: 2024-05-31 07:00+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: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__create_uid
msgid "Created by"
msgstr ""

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__create_date
msgid "Created on"
msgstr ""

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__display_name
msgid "Display Name"
msgstr ""

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__id
msgid "ID"
msgstr ""

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__is_default
msgid "Is Default"
msgstr ""

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__journal_id
msgid "Journal"
msgstr "Jurnal"

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type____last_update
msgid "Last Modified on"
msgstr ""

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__write_uid
msgid "Last Updated by"
msgstr ""

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__write_date
msgid "Last Updated on"
msgstr ""

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order_type__name
msgid "Name"
msgstr "Nume"

#. module: deltatech_saleorder_type
#: model_terms:ir.ui.view,arch_db:deltatech_saleorder_type.view_saleorder_type_form
#: model_terms:ir.ui.view,arch_db:deltatech_saleorder_type.view_saleorder_type_tree
msgid "Sale Order Type"
msgstr "Tip comandă vânzare"

#. module: deltatech_saleorder_type
#: model:ir.actions.act_window,name:deltatech_saleorder_type.action_saleorder_type
#: model:ir.ui.menu,name:deltatech_saleorder_type.menu_saleorder_type
msgid "Sale Order Types"
msgstr "Tipuri comenzi vânzare"

#. module: deltatech_saleorder_type
#: model:ir.model,name:deltatech_saleorder_type.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr "Factura Vânzare cu Plată în Avans"

#. module: deltatech_saleorder_type
#: model:ir.model,name:deltatech_saleorder_type.model_sale_order
msgid "Sales Order"
msgstr "Comandă de vânzare"

#. module: deltatech_saleorder_type
#: model:ir.model.fields,field_description:deltatech_saleorder_type.field_sale_order__so_type
#: model_terms:ir.ui.view,arch_db:deltatech_saleorder_type.view_saleorder_type_saleorder_filter
msgid "Type"
msgstr ""

#. module: deltatech_saleorder_type
#. odoo-python
#: code:addons/deltatech_saleorder_type/models/sale.py:0
#: code:addons/deltatech_saleorder_type/models/sale.py:0
#, python-format
msgid "You cannot have more than one default type."
msgstr "Nu puteți avea mai mult de un tip implicit."

#. module: deltatech_saleorder_type
#: model:ir.model,name:deltatech_saleorder_type.model_sale_order_type
msgid "sale.order.type"
msgstr ""
8 changes: 8 additions & 0 deletions deltatech_record_type/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# © 2015-2021 Terrabit Solutions
# Dan Stoica <danila(@)terrabit(.)ro
# See README.rst file on addons root folder for license details


from . import sale
from . import record_type
from . import purchase
22 changes: 22 additions & 0 deletions deltatech_record_type/models/purchase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See README.rst file on addons root folder for license details


from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "purchase.order"

po_type = fields.Many2one("record.type", string="Type", tracking=True)

@api.onchange("po_type")
def _check_po_type(self):
po_type_selected = self.env["record.type"].search([("id", "=", self.po_type.id), ("model", "=", "purchase")])

Check warning on line 14 in deltatech_record_type/models/purchase.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/purchase.py#L14

Added line #L14 was not covered by tests
if po_type_selected:
for default_value in po_type_selected.default_values_ids:
if default_value.field_type == "id":
self[default_value.field_name] = int(default_value.field_value)

Check warning on line 18 in deltatech_record_type/models/purchase.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/purchase.py#L18

Added line #L18 was not covered by tests
if default_value.field_type == "char":
self[default_value.field_name] = default_value.field_value

Check warning on line 20 in deltatech_record_type/models/purchase.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/purchase.py#L20

Added line #L20 was not covered by tests
if default_value.field_type == "boolean":
self[default_value.field_name] = default_value.field_value == "True"

Check warning on line 22 in deltatech_record_type/models/purchase.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/purchase.py#L22

Added line #L22 was not covered by tests
49 changes: 49 additions & 0 deletions deltatech_record_type/models/record_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError


class SaleOrderType(models.Model):
_name = "record.type"

name = fields.Char()
model = fields.Selection(
[
("sale", "Sale Order"),
("purchase", "Purchase Order"),
],
string="Model",
)
is_default = fields.Boolean()
default_values_ids = fields.One2many("record.type.default.values", "record_type_id", string="Default Values")

def write(self, vals):
if "is_default" in vals and vals.get("is_default", False):
other_types = self.env["record.type"].search(

Check warning on line 21 in deltatech_record_type/models/record_type.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/record_type.py#L21

Added line #L21 was not covered by tests
[("is_default", "=", True), ("id", "!=", self.id), ("model", "=", self.model)]
)
if other_types:
raise UserError(_("You cannot have more than one default type."))
return super().write(vals)

Check warning on line 26 in deltatech_record_type/models/record_type.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/record_type.py#L25-L26

Added lines #L25 - L26 were not covered by tests

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if "is_default" in vals and vals.get("is_default", False):
other_types = self.env["record.type"].search(

Check warning on line 32 in deltatech_record_type/models/record_type.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/record_type.py#L32

Added line #L32 was not covered by tests
[("is_default", "=", True), ("id", "!=", self.id), ("model", "=", vals.get("model"))]
)
if other_types:
raise UserError(_("You cannot have more than one default type."))
return super().create(vals_list)

Check warning on line 37 in deltatech_record_type/models/record_type.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/record_type.py#L36-L37

Added lines #L36 - L37 were not covered by tests


class SaleOrderTypeDefaultValues(models.Model):
_name = "record.type.default.values"
_description = "Sale Order Type Default Values"

field_name = fields.Char(string="Field Name", required=True)
field_value = fields.Char(string="Field Value", required=True)
field_type = fields.Selection(
[("char", "Char"), ("id", "Id"), ("boolean", "Boolean")], string="Field Type", required=True
)
record_type_id = fields.Many2one("record.type", ondelete="cascade", invisible=True)
24 changes: 24 additions & 0 deletions deltatech_record_type/models/sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# © 2015-2021 Terrabit Solutions
# Dan Stoica <danila(@)terrabit(.)ro
# See README.rst file on addons root folder for license details


from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

so_type = fields.Many2one("record.type", string="Type", tracking=True)

@api.onchange("so_type")
def _check_so_type(self):
so_type_selected = self.env["record.type"].search([("id", "=", self.so_type.id), ("model", "=", "sale")])
if so_type_selected:
for default_value in so_type_selected.default_values_ids:
if default_value.field_type == "id":
self[default_value.field_name] = int(default_value.field_value)

Check warning on line 20 in deltatech_record_type/models/sale.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/sale.py#L20

Added line #L20 was not covered by tests
if default_value.field_type == "char":
self[default_value.field_name] = default_value.field_value

Check warning on line 22 in deltatech_record_type/models/sale.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/sale.py#L22

Added line #L22 was not covered by tests
if default_value.field_type == "boolean":
self[default_value.field_name] = default_value.field_value == "True"

Check warning on line 24 in deltatech_record_type/models/sale.py

View check run for this annotation

Codecov / codecov/patch

deltatech_record_type/models/sale.py#L24

Added line #L24 was not covered by tests
3 changes: 3 additions & 0 deletions deltatech_record_type/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions deltatech_record_type/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Features:

- Types can be defined for records
3 changes: 3 additions & 0 deletions deltatech_record_type/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
deltatech_record_type.access_record_type,access_record_type,deltatech_record_type.model_record_type,base.group_user,1,1,1,1
deltatech_record_type.access_record_type_default_values,access_record_type_default_values,deltatech_record_type.model_record_type_default_values,base.group_user,1,1,1,1
Binary file added deltatech_record_type/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
Loading