mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-23 00:12:02 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,100 @@
|
|||
===================
|
||||
Maintenance Account
|
||||
===================
|
||||
|
||||
..
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:56d49297cf10a1df7a32e1fb0bf4444cb2c14784d3780ac38df3056c37f60e23
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |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%2Fmaintenance-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/maintenance/tree/16.0/maintenance_account
|
||||
:alt: OCA/maintenance
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/maintenance-16-0/maintenance-16-0-maintenance_account
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/maintenance&target_branch=16.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module automatically creates the equipment when validating the purchase invoices.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use this module, you need to:
|
||||
|
||||
* Go to *Invoicing > Vendor > Bills* and create a new one with any product with the "Can be Maintenance" field checked.
|
||||
* Confirm the invoice.
|
||||
* A new equipment category linked to the product line has been created (if the product category did not already have one linked).
|
||||
* A smart-button is displayed with the equipments created (as many equipments as the quantity of product lines are created).
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/maintenance/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_account%0Aversion:%2016.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
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* César Fernández Domínguez <cesfernandez@outlook.com>
|
||||
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Víctor Martínez
|
||||
* Pedro M. Baeza
|
||||
* Carolina Fernandez
|
||||
|
||||
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.
|
||||
|
||||
.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
|
||||
:target: https://github.com/victoralmau
|
||||
:alt: victoralmau
|
||||
|
||||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-victoralmau|
|
||||
|
||||
This module is part of the `OCA/maintenance <https://github.com/OCA/maintenance/tree/16.0/maintenance_account>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import models
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Copyright 2022 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Maintenance Account",
|
||||
"version": "16.0.1.1.1",
|
||||
"category": "Maintenance",
|
||||
"website": "https://github.com/OCA/maintenance",
|
||||
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["maintenance_product", "account"],
|
||||
"installable": True,
|
||||
"data": [
|
||||
"views/maintenance_equipment_view.xml",
|
||||
"views/account_move_view.xml",
|
||||
],
|
||||
"maintainers": ["victoralmau"],
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * maintenance_account
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \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: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_category_id
|
||||
msgid "Equipment Category"
|
||||
msgstr "Kategorija opreme"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_bank_statement_line__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_payment__equipment_count
|
||||
msgid "Equipment Count"
|
||||
msgstr "Equipment Broj"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model_terms:ir.ui.view,arch_db:maintenance_account.view_move_form
|
||||
msgid "Equipment(s)"
|
||||
msgstr "Equipment(s)"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_ids
|
||||
msgid "Equipments"
|
||||
msgstr "Oprema"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_account_move
|
||||
msgid "Journal Entry"
|
||||
msgstr "Žurnal"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_account_move_line
|
||||
msgid "Journal Item"
|
||||
msgstr "Stavka žurnala"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_maintenance_equipment
|
||||
msgid "Maintenance Equipment"
|
||||
msgstr "Oprema za održavanje"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_maintenance_equipment__move_id
|
||||
msgid "Move"
|
||||
msgstr "Kretanje"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_maintenance_equipment__move_line_id
|
||||
msgid "Move line"
|
||||
msgstr "Potez line"
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * maintenance_account
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-03-30 07:30+0000\n"
|
||||
"PO-Revision-Date: 2023-07-06 20:08+0000\n"
|
||||
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: es\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 4.17\n"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_category_id
|
||||
msgid "Equipment Category"
|
||||
msgstr "Categoría de equipo"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_bank_statement_line__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_payment__equipment_count
|
||||
msgid "Equipment Count"
|
||||
msgstr "Total de equipos"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model_terms:ir.ui.view,arch_db:maintenance_account.view_move_form
|
||||
msgid "Equipment(s)"
|
||||
msgstr "Equipo(s)"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_ids
|
||||
msgid "Equipments"
|
||||
msgstr "Equipos"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_account_move
|
||||
msgid "Journal Entry"
|
||||
msgstr "Asiento contable"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_account_move_line
|
||||
msgid "Journal Item"
|
||||
msgstr "Apunte contable"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_maintenance_equipment
|
||||
msgid "Maintenance Equipment"
|
||||
msgstr "Equipo de mantenimiento"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_maintenance_equipment__move_id
|
||||
msgid "Move"
|
||||
msgstr "Asiento"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_maintenance_equipment__move_line_id
|
||||
msgid "Move line"
|
||||
msgstr "Apunte"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,help:maintenance_account.field_maintenance_equipment__move_id
|
||||
msgid "The move of this entry line."
|
||||
msgstr "El movimiento de esta línea de entrada."
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * maintenance_account
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2023-11-12 17:39+0000\n"
|
||||
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: it\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 4.17\n"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_category_id
|
||||
msgid "Equipment Category"
|
||||
msgstr "Categoria attrezzatura"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_bank_statement_line__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_payment__equipment_count
|
||||
msgid "Equipment Count"
|
||||
msgstr "Conteggio attrezzature"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model_terms:ir.ui.view,arch_db:maintenance_account.view_move_form
|
||||
msgid "Equipment(s)"
|
||||
msgstr "Attrezzatura(e)"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_ids
|
||||
msgid "Equipments"
|
||||
msgstr "Attrezzature"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_account_move
|
||||
msgid "Journal Entry"
|
||||
msgstr "Registrazione contabile"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_account_move_line
|
||||
msgid "Journal Item"
|
||||
msgstr "Movimento contabile"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_maintenance_equipment
|
||||
msgid "Maintenance Equipment"
|
||||
msgstr "Attrezzatura manutenzione"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_maintenance_equipment__move_id
|
||||
msgid "Move"
|
||||
msgstr "Movimento"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_maintenance_equipment__move_line_id
|
||||
msgid "Move line"
|
||||
msgstr "Riga movimento"
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,help:maintenance_account.field_maintenance_equipment__move_id
|
||||
msgid "The move of this entry line."
|
||||
msgstr "Il movimento per questa riga di registrazione."
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * maintenance_account
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \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: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_category_id
|
||||
msgid "Equipment Category"
|
||||
msgstr ""
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_bank_statement_line__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_count
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_payment__equipment_count
|
||||
msgid "Equipment Count"
|
||||
msgstr ""
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model_terms:ir.ui.view,arch_db:maintenance_account.view_move_form
|
||||
msgid "Equipment(s)"
|
||||
msgstr ""
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_account_move_line__equipment_ids
|
||||
msgid "Equipments"
|
||||
msgstr ""
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_account_move
|
||||
msgid "Journal Entry"
|
||||
msgstr ""
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_account_move_line
|
||||
msgid "Journal Item"
|
||||
msgstr ""
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model,name:maintenance_account.model_maintenance_equipment
|
||||
msgid "Maintenance Equipment"
|
||||
msgstr ""
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_maintenance_equipment__move_id
|
||||
msgid "Move"
|
||||
msgstr ""
|
||||
|
||||
#. module: maintenance_account
|
||||
#: model:ir.model.fields,field_description:maintenance_account.field_maintenance_equipment__move_line_id
|
||||
msgid "Move line"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
from . import account_move
|
||||
from . import maintenance_equipment
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
# Copyright 2022 Tecnativa - Víctor Martínez
|
||||
# Copyright 2024 Tecnativa - Carolina Fernandez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools import plaintext2html
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
equipment_count = fields.Integer(compute="_compute_equipment_count")
|
||||
|
||||
def _compute_equipment_count(self):
|
||||
for item in self:
|
||||
item.equipment_count = sum(item.mapped("line_ids.equipment_count"))
|
||||
|
||||
def unlink(self):
|
||||
items = self.env["maintenance.equipment"].search([("move_id", "in", self.ids)])
|
||||
items.write({"move_line_id": False, "move_id": False})
|
||||
return super().unlink()
|
||||
|
||||
def action_post(self):
|
||||
res = super().action_post()
|
||||
# Prevent error if user does not have permission to create equipments
|
||||
equipment_model = self.env["maintenance.equipment"].sudo()
|
||||
for move in self.filtered(lambda r: r.is_purchase_document()):
|
||||
for line in move.line_ids.filtered(
|
||||
lambda x: (
|
||||
not x.equipment_ids
|
||||
and x.product_id
|
||||
and x.product_id.product_tmpl_id.maintenance_ok
|
||||
)
|
||||
):
|
||||
if not line.equipment_category_id:
|
||||
line._set_equipment_category()
|
||||
# Create equipments
|
||||
limit = int(line.quantity) + 1
|
||||
vals = line._prepare_equipment_vals()
|
||||
equipment_ids = []
|
||||
for _i in range(1, limit):
|
||||
equipment = equipment_model.with_company(
|
||||
move.company_id,
|
||||
).create(vals.copy())
|
||||
equipment_ids.append((4, equipment.id))
|
||||
line.equipment_ids = equipment_ids
|
||||
return res
|
||||
|
||||
def action_view_equipments(self):
|
||||
items = self.env["maintenance.equipment"].search([("move_id", "=", self.id)])
|
||||
action_dict = self.env["ir.actions.act_window"]._for_xml_id(
|
||||
"maintenance.hr_equipment_action"
|
||||
)
|
||||
if len(items) == 1:
|
||||
res = self.env.ref("maintenance.hr_equipment_view_form", False)
|
||||
action_dict["views"] = [(res and res.id or False, "form")]
|
||||
action_dict["res_id"] = items.id
|
||||
elif items:
|
||||
action_dict["domain"] = [("id", "in", items.ids)]
|
||||
else:
|
||||
action_dict = {"type": "ir.actions.act_window_close"}
|
||||
return action_dict
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = "account.move.line"
|
||||
|
||||
equipment_category_id = fields.Many2one(
|
||||
comodel_name="maintenance.equipment.category",
|
||||
string="Equipment Category",
|
||||
compute="_compute_equipment_category_id",
|
||||
store=True,
|
||||
readonly=False,
|
||||
)
|
||||
equipment_ids = fields.Many2many(
|
||||
comodel_name="maintenance.equipment",
|
||||
string="Equipments",
|
||||
)
|
||||
equipment_count = fields.Integer(compute="_compute_equipment_count")
|
||||
|
||||
@api.depends("product_id")
|
||||
def _compute_equipment_category_id(self):
|
||||
for item in self:
|
||||
if (
|
||||
item.product_id.maintenance_ok
|
||||
and item.product_id.product_tmpl_id.categ_id.equipment_category_ids
|
||||
):
|
||||
item.equipment_category_id = fields.first(
|
||||
item.product_id.product_tmpl_id.categ_id.equipment_category_ids
|
||||
)
|
||||
else:
|
||||
item.equipment_category_id = item.equipment_category_id
|
||||
|
||||
def _compute_equipment_count(self):
|
||||
data = self.env["maintenance.equipment"].read_group(
|
||||
[("move_line_id", "in", self.ids)], ["move_line_id"], ["move_line_id"]
|
||||
)
|
||||
mapping = {x["move_line_id"][0]: x["move_line_id_count"] for x in data}
|
||||
for item in self:
|
||||
item.equipment_count = mapping.get(item.id, 0)
|
||||
|
||||
def _prepare_equipment_category_vals(self):
|
||||
categ = self.product_id.product_tmpl_id.categ_id
|
||||
return {"name": categ.name, "product_category_id": categ.id}
|
||||
|
||||
def _set_equipment_category(self):
|
||||
if not self.equipment_category_id:
|
||||
category_model = self.env["maintenance.equipment.category"].sudo()
|
||||
category = fields.first(
|
||||
self.product_id.product_tmpl_id.categ_id.equipment_category_ids
|
||||
)
|
||||
if not category:
|
||||
category = category_model.create(
|
||||
self._prepare_equipment_category_vals()
|
||||
)
|
||||
self.equipment_category_id = category.id
|
||||
|
||||
def _prepare_equipment_vals(self):
|
||||
equipment_name = self.name
|
||||
description = False
|
||||
if "\n" in self.name:
|
||||
lf_index = self.name.index("\n")
|
||||
equipment_name = self.name[:lf_index]
|
||||
description = plaintext2html(self.name[lf_index + 1 :])
|
||||
return {
|
||||
"move_line_id": self.id,
|
||||
"name": equipment_name,
|
||||
"product_id": self.product_id.id,
|
||||
"category_id": self.equipment_category_id.id,
|
||||
"assign_date": self.move_id.date,
|
||||
"effective_date": self.move_id.date,
|
||||
"partner_id": self.move_id.partner_id.id,
|
||||
"partner_ref": self.move_id.ref,
|
||||
"note": description,
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# Copyright 2022 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MaintenanceEquipment(models.Model):
|
||||
_inherit = "maintenance.equipment"
|
||||
|
||||
move_id = fields.Many2one(
|
||||
comodel_name="account.move",
|
||||
related="move_line_id.move_id",
|
||||
string="Move",
|
||||
readonly=True,
|
||||
)
|
||||
move_line_id = fields.Many2one(
|
||||
comodel_name="account.move.line",
|
||||
string="Move line",
|
||||
readonly=True,
|
||||
)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
* César Fernández Domínguez <cesfernandez@outlook.com>
|
||||
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Víctor Martínez
|
||||
* Pedro M. Baeza
|
||||
* Carolina Fernandez
|
||||
|
|
@ -0,0 +1 @@
|
|||
This module automatically creates the equipment when validating the purchase invoices.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
To use this module, you need to:
|
||||
|
||||
* Go to *Invoicing > Vendor > Bills* and create a new one with any product with the "Can be Maintenance" field checked.
|
||||
* Confirm the invoice.
|
||||
* A new equipment category linked to the product line has been created (if the product category did not already have one linked).
|
||||
* A smart-button is displayed with the equipments created (as many equipments as the quantity of product lines are created).
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
|
|
@ -0,0 +1,442 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
|
||||
<title>Maintenance Account</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
Despite the name, some widely supported CSS2 features are used.
|
||||
|
||||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: gray; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic, pre.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="maintenance-account">
|
||||
<h1 class="title">Maintenance Account</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:56d49297cf10a1df7a32e1fb0bf4444cb2c14784d3780ac38df3056c37f60e23
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/maintenance/tree/16.0/maintenance_account"><img alt="OCA/maintenance" src="https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/maintenance-16-0/maintenance-16-0-maintenance_account"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/maintenance&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module automatically creates the equipment when validating the purchase invoices.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
|
||||
<p>To use this module, you need to:</p>
|
||||
<ul class="simple">
|
||||
<li>Go to <em>Invoicing > Vendor > Bills</em> and create a new one with any product with the “Can be Maintenance” field checked.</li>
|
||||
<li>Confirm the invoice.</li>
|
||||
<li>A new equipment category linked to the product line has been created (if the product category did not already have one linked).</li>
|
||||
<li>A smart-button is displayed with the equipments created (as many equipments as the quantity of product lines are created).</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/maintenance/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_account%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Tecnativa</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>César Fernández Domínguez <<a class="reference external" href="mailto:cesfernandez@outlook.com">cesfernandez@outlook.com</a>></li>
|
||||
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
||||
<li>Víctor Martínez</li>
|
||||
<li>Pedro M. Baeza</li>
|
||||
<li>Carolina Fernandez</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||
</a>
|
||||
<p>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.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||
<p><a class="reference external image-reference" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/maintenance/tree/16.0/maintenance_account">OCA/maintenance</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
|
||||
from . import test_maintenance_account
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
# Copyright 2022-2024 Tecnativa - Víctor Martínez
|
||||
# Copyright 2024 Tecnativa - Carolina Fernandez
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
|
||||
from odoo import fields
|
||||
from odoo.tests import Form, common, new_test_user, tagged
|
||||
from odoo.tests.common import users
|
||||
|
||||
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
|
||||
|
||||
|
||||
@tagged("-at_install", "post_install")
|
||||
class TestAccountMove(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
|
||||
if not cls.env.company.chart_template_id:
|
||||
# Load a CoA if there's none in current company
|
||||
coa = cls.env.ref("l10n_generic_coa.configurable_chart_template", False)
|
||||
if not coa:
|
||||
# Load the first available CoA
|
||||
coa = cls.env["account.chart.template"].search(
|
||||
[("visible", "=", True)], limit=1
|
||||
)
|
||||
coa.try_loading(company=cls.env.company, install_demo=False)
|
||||
new_test_user(
|
||||
cls.env, login="test-account-user", groups="account.group_account_invoice"
|
||||
)
|
||||
cls.categ = cls.env["product.category"].create({"name": "Test category"})
|
||||
cls.product_a = cls.env["product.product"].create(
|
||||
{"name": "Test product A", "maintenance_ok": True, "categ_id": cls.categ.id}
|
||||
)
|
||||
cls.product_b = cls.env["product.product"].create(
|
||||
{"name": "Test product B", "categ_id": cls.categ.id}
|
||||
)
|
||||
cls.account_payable = cls.env["account.account"].create(
|
||||
{
|
||||
"name": "Test Account",
|
||||
"code": "TEST",
|
||||
"account_type": "liability_payable",
|
||||
"reconcile": True,
|
||||
}
|
||||
)
|
||||
cls.account_expense = cls.env["account.account"].create(
|
||||
{
|
||||
"name": "Test Account",
|
||||
"code": "ACC",
|
||||
"account_type": "expense",
|
||||
}
|
||||
)
|
||||
cls.journal = cls.env["account.journal"].create(
|
||||
{
|
||||
"name": "Test purchase journal",
|
||||
"type": "purchase",
|
||||
"code": "TEST-PURCHASE",
|
||||
}
|
||||
)
|
||||
cls.partner = cls.env["res.partner"].create(
|
||||
{
|
||||
"name": "Test partner",
|
||||
}
|
||||
)
|
||||
|
||||
def _create_invoice(self, move_type="in_invoice"):
|
||||
move_form = Form(
|
||||
self.env["account.move"].with_context(default_move_type=move_type)
|
||||
)
|
||||
move_form.partner_id = self.partner
|
||||
move_form.ref = "SUPPLIE-REF"
|
||||
move_form.invoice_date = fields.Date.from_string("2000-01-01")
|
||||
with move_form.invoice_line_ids.new() as line_form:
|
||||
line_form.product_id = self.product_a
|
||||
line_form.name = "Product A\nTest description product A\nB"
|
||||
line_form.quantity = 2
|
||||
with move_form.invoice_line_ids.new() as line_form:
|
||||
line_form.product_id = self.product_b
|
||||
line_form.quantity = 2
|
||||
invoice = move_form.save()
|
||||
return invoice
|
||||
|
||||
@users("test-account-user")
|
||||
def test_invoice_out_invoice_action_post_equipment_1(self):
|
||||
invoice = self._create_invoice("out_invoice")
|
||||
line_a = invoice.line_ids.filtered(lambda x: x.product_id == self.product_a)
|
||||
line_b = invoice.line_ids.filtered(lambda x: x.product_id == self.product_b)
|
||||
self.assertFalse(line_a.equipment_category_id)
|
||||
self.assertFalse(line_b.equipment_category_id)
|
||||
invoice.action_post()
|
||||
equipments = invoice.mapped("line_ids.equipment_ids")
|
||||
self.assertEqual(len(equipments), 0)
|
||||
|
||||
@users("test-account-user")
|
||||
def test_invoice_action_post_equipment_1(self):
|
||||
invoice = self._create_invoice()
|
||||
line_a = invoice.line_ids.filtered(lambda x: x.product_id == self.product_a)
|
||||
line_b = invoice.line_ids.filtered(lambda x: x.product_id == self.product_b)
|
||||
self.assertFalse(line_a.equipment_category_id)
|
||||
self.assertFalse(line_b.equipment_category_id)
|
||||
invoice.action_post()
|
||||
equipments = invoice.mapped("line_ids.equipment_ids")
|
||||
self.assertEqual(len(equipments), 2)
|
||||
self.assertTrue(line_a.equipment_category_id)
|
||||
self.assertEqual(len(line_a.equipment_ids), 2)
|
||||
self.assertEqual(len(line_b.equipment_ids), 0)
|
||||
equipment = fields.first(equipments)
|
||||
self.assertEqual(equipment.name, "Product A")
|
||||
self.assertEqual(equipment.note, "<p>Test description product A<br>B</p>")
|
||||
self.assertEqual(equipment.category_id.product_category_id, self.categ)
|
||||
self.assertEqual(equipment.assign_date, invoice.date)
|
||||
self.assertEqual(equipment.effective_date, invoice.date)
|
||||
self.assertEqual(equipment.partner_id, self.partner)
|
||||
self.assertEqual(equipment.partner_ref, invoice.ref)
|
||||
|
||||
@users("test-account-user")
|
||||
def test_invoice_action_post_equipment_1_multi_lines(self):
|
||||
self.product_b.maintenance_ok = True
|
||||
invoice = self._create_invoice()
|
||||
line_a = invoice.line_ids.filtered(lambda x: x.product_id == self.product_a)
|
||||
line_b = invoice.line_ids.filtered(lambda x: x.product_id == self.product_b)
|
||||
invoice.action_post()
|
||||
equipments = invoice.mapped("line_ids.equipment_ids")
|
||||
self.assertEqual(len(equipments.mapped("category_id")), 1)
|
||||
self.assertEqual(line_a.equipment_category_id, line_b.equipment_category_id)
|
||||
|
||||
@users("test-account-user")
|
||||
def test_invoice_action_post_equipment_2(self):
|
||||
category = (
|
||||
self.env["maintenance.equipment.category"]
|
||||
.sudo()
|
||||
.create({"name": self.categ.name, "product_category_id": self.categ.id})
|
||||
)
|
||||
invoice = self._create_invoice()
|
||||
line_a = invoice.line_ids.filtered(lambda x: x.product_id == self.product_a)
|
||||
self.assertEqual(line_a.equipment_category_id, category)
|
||||
invoice.action_post()
|
||||
equipment = fields.first(line_a.equipment_ids)
|
||||
self.assertEqual(equipment.category_id, category)
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="view_move_form" model="ir.ui.view">
|
||||
<field name="name">account.move.form</field>
|
||||
<field name="model">account.move</field>
|
||||
<field name="inherit_id" ref="account.view_move_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
|
||||
<button
|
||||
name="action_view_equipments"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-cubes"
|
||||
attrs="{'invisible': [('equipment_count', '=', 0)]}"
|
||||
groups="account.group_account_invoice"
|
||||
>
|
||||
<field
|
||||
string="Equipment(s)"
|
||||
name="equipment_count"
|
||||
widget="statinfo"
|
||||
groups="account.group_account_invoice"
|
||||
/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='invoice_line_ids']/tree/field[@name='quantity']"
|
||||
position="before"
|
||||
>
|
||||
<field
|
||||
name="equipment_category_id"
|
||||
attrs="{'column_invisible': [('parent.move_type', '!=', 'in_invoice')]}"
|
||||
optional="hide"
|
||||
groups="account.group_account_invoice"
|
||||
/>
|
||||
<field
|
||||
name="equipment_ids"
|
||||
invisible="1"
|
||||
groups="account.group_account_invoice"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//notebook//field[@name='line_ids']/tree/field[@name='date_maturity']"
|
||||
position="after"
|
||||
>
|
||||
<field
|
||||
name="equipment_category_id"
|
||||
domain="[('company_id','=', parent.company_id)]"
|
||||
optional="hide"
|
||||
groups="account.group_account_invoice"
|
||||
/>
|
||||
<field
|
||||
name="equipment_ids"
|
||||
invisible="1"
|
||||
groups="account.group_account_invoice"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="hr_equipment_view_form" model="ir.ui.view">
|
||||
<field name="name">equipment.form</field>
|
||||
<field name="model">maintenance.equipment</field>
|
||||
<field name="inherit_id" ref="maintenance.hr_equipment_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='serial_no']" position="after">
|
||||
<field name="move_id" groups="account.group_account_invoice" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue