mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG] account_cost_centre: Migration to 15.0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016-2019 Onestein (<http://www.onestein.eu>)
|
||||
# Copyright 2016-2020 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
@@ -8,16 +8,15 @@
|
||||
"license": "AGPL-3",
|
||||
"website": "https://github.com/OCA/account-financial-tools",
|
||||
"category": "Accounting",
|
||||
"version": "12.0.1.0.0",
|
||||
"depends": ["account", "base_view_inheritance_extension"],
|
||||
"version": "15.0.1.0.0",
|
||||
"depends": ["account"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"security/account_cost_center_security.xml",
|
||||
"views/account_cost_center.xml",
|
||||
"views/account_move.xml",
|
||||
"views/account_move_line.xml",
|
||||
"views/account_invoice.xml",
|
||||
"views/account_invoice_report.xml",
|
||||
"views/account_cost_center_views.xml",
|
||||
"views/account_move_views.xml",
|
||||
"views/account_move_line_views.xml",
|
||||
"views/account_invoice_report_views.xml",
|
||||
],
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_cost_center
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 12.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: account_cost_center
|
||||
#: model:ir.model,name:account_cost_center.model_account_cost_center
|
||||
msgid "Account Cost Center"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model_terms:ir.actions.act_window,help:account_cost_center.account_cost_center_action
|
||||
msgid "Click to add a new cost center."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__code
|
||||
msgid "Code"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__company_id
|
||||
msgid "Company"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_invoice__cost_center_id
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_invoice_line__cost_center_id
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_invoice_report__cost_center_id
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_move_line__cost_center_id
|
||||
#: model_terms:ir.ui.view,arch_db:account_cost_center.view_account_invoice_report_search
|
||||
msgid "Cost Center"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.actions.act_window,name:account_cost_center.account_cost_center_action
|
||||
#: model:ir.ui.menu,name:account_cost_center.cost_center_menu
|
||||
msgid "Cost Centers"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model_terms:ir.actions.act_window,help:account_cost_center.account_cost_center_action
|
||||
msgid "Cost centers provide an extra analytic dimension"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__create_uid
|
||||
msgid "Created by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__create_date
|
||||
msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,help:account_cost_center.field_account_invoice__cost_center_id
|
||||
msgid "Default Cost Center"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model,name:account_cost_center.model_account_invoice
|
||||
msgid "Invoice"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model,name:account_cost_center.model_account_invoice_line
|
||||
msgid "Invoice Line"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model,name:account_cost_center.model_account_invoice_report
|
||||
msgid "Invoices Statistics"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model,name:account_cost_center.model_account_move_line
|
||||
msgid "Journal Item"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__write_uid
|
||||
msgid "Last Updated by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__write_date
|
||||
msgid "Last Updated on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model_terms:ir.ui.view,arch_db:account_cost_center.account_cost_center_view_search
|
||||
msgid "Name/Code"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__name
|
||||
msgid "Title"
|
||||
msgstr ""
|
||||
|
||||
@@ -11,25 +11,24 @@ msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-01-12 03:43+0000\n"
|
||||
"PO-Revision-Date: 2021-08-04 11:49+0000\n"
|
||||
"Last-Translator: Pascal GOUHIER <pascal.gouhier@copagex.fr>\n"
|
||||
"PO-Revision-Date: 2017-01-12 03:43+0000\n"
|
||||
"Last-Translator: Zwygart <zwygart@gmail.com>, 2017\n"
|
||||
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
|
||||
"Language: fr\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.3.2\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model,name:account_cost_center.model_account_cost_center
|
||||
msgid "Account Cost Center"
|
||||
msgstr "Centre de Coût"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model_terms:ir.actions.act_window,help:account_cost_center.account_cost_center_action
|
||||
msgid "Click to add a new cost center."
|
||||
msgstr "Cliquer pour ajouter un Nouveau Centre de Coût."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__code
|
||||
@@ -48,18 +47,18 @@ msgstr "Société"
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_move_line__cost_center_id
|
||||
#: model_terms:ir.ui.view,arch_db:account_cost_center.view_account_invoice_report_search
|
||||
msgid "Cost Center"
|
||||
msgstr "Centre de coût"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.actions.act_window,name:account_cost_center.account_cost_center_action
|
||||
#: model:ir.ui.menu,name:account_cost_center.cost_center_menu
|
||||
msgid "Cost Centers"
|
||||
msgstr "Centres de Coût"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model_terms:ir.actions.act_window,help:account_cost_center.account_cost_center_action
|
||||
msgid "Cost centers provide an extra analytic dimension"
|
||||
msgstr "Les centres de coût fournissent une dimension analytique supplémentaire"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__create_uid
|
||||
|
||||
@@ -12,15 +12,14 @@ msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-01-12 03:43+0000\n"
|
||||
"PO-Revision-Date: 2021-07-09 15:49+0000\n"
|
||||
"Last-Translator: Francesco Foresti <francesco.foresti@ooops404.com>\n"
|
||||
"PO-Revision-Date: 2017-01-12 03:43+0000\n"
|
||||
"Last-Translator: Andrea Cometa <a.cometa@apuliasoftware.it>, 2017\n"
|
||||
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\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.3.2\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model,name:account_cost_center.model_account_cost_center
|
||||
@@ -65,12 +64,12 @@ msgstr ""
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__create_uid
|
||||
msgid "Created by"
|
||||
msgstr "Creato da"
|
||||
msgstr "Created by"
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__create_date
|
||||
msgid "Created on"
|
||||
msgstr "Creato il"
|
||||
msgstr "Created on"
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,help:account_cost_center.field_account_invoice__cost_center_id
|
||||
@@ -116,12 +115,12 @@ msgstr "Ultima modifica il"
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__write_uid
|
||||
msgid "Last Updated by"
|
||||
msgstr "Ultimo Aggiornamento di"
|
||||
msgstr "Last Updated by"
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model:ir.model.fields,field_description:account_cost_center.field_account_cost_center__write_date
|
||||
msgid "Last Updated on"
|
||||
msgstr "Ultimo Aggiornamento il"
|
||||
msgstr "Last Updated on"
|
||||
|
||||
#. module: account_cost_center
|
||||
#: model_terms:ir.ui.view,arch_db:account_cost_center.account_cost_center_view_search
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import account_move
|
||||
from . import account_move_line
|
||||
from . import account_invoice
|
||||
from . import account_invoice_line
|
||||
from . import account_invoice_report
|
||||
from . import account_cost_center
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2015-2019 Onestein (<http://www.onestein.eu>)
|
||||
# Copyright 2015-2020 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
@@ -10,6 +10,4 @@ class AccountCostCenter(models.Model):
|
||||
|
||||
name = fields.Char(string="Title", required=True)
|
||||
code = fields.Char(required=True)
|
||||
company_id = fields.Many2one(
|
||||
"res.company", string="Company", default=lambda self: self.env.user.company_id
|
||||
)
|
||||
company_id = fields.Many2one("res.company", default=lambda self: self.env.company)
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
# Copyright 2015-2019 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
_inherit = "account.invoice"
|
||||
|
||||
cost_center_id = fields.Many2one(
|
||||
"account.cost.center",
|
||||
string="Cost Center",
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
help="Default Cost Center",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def line_get_convert(self, line, part):
|
||||
res = super(AccountInvoice, self).line_get_convert(line, part)
|
||||
if line.get("cost_center_id"):
|
||||
res["cost_center_id"] = line["cost_center_id"]
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def invoice_line_move_line_get(self):
|
||||
res = super(AccountInvoice, self).invoice_line_move_line_get()
|
||||
|
||||
for dict_data in res:
|
||||
invl_id = dict_data.get("invl_id")
|
||||
line = self.env["account.invoice.line"].browse(invl_id)
|
||||
if line.cost_center_id:
|
||||
dict_data["cost_center_id"] = line.cost_center_id.id
|
||||
|
||||
return res
|
||||
@@ -1,21 +0,0 @@
|
||||
# Copyright 2015-2019 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountInvoiceLine(models.Model):
|
||||
_inherit = "account.invoice.line"
|
||||
|
||||
@api.model
|
||||
def _default_cost_center(self):
|
||||
return self.env["account.cost.center"].browse(
|
||||
self.env.context.get("cost_center_id")
|
||||
)
|
||||
|
||||
cost_center_id = fields.Many2one(
|
||||
"account.cost.center",
|
||||
string="Cost Center",
|
||||
index=True,
|
||||
default=lambda self: self._default_cost_center(),
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2015-2019 Onestein (<http://www.onestein.eu>)
|
||||
# Copyright 2015-2020 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
@@ -7,21 +7,10 @@ from odoo import fields, models
|
||||
class AccountInvoiceReport(models.Model):
|
||||
_inherit = "account.invoice.report"
|
||||
|
||||
cost_center_id = fields.Many2one(
|
||||
"account.cost.center", string="Cost Center", readonly=True
|
||||
)
|
||||
cost_center_id = fields.Many2one("account.cost.center", readonly=True)
|
||||
|
||||
def _select(self):
|
||||
return (
|
||||
super(AccountInvoiceReport, self)._select()
|
||||
+ ", sub.cost_center_id as cost_center_id"
|
||||
+ ", line.cost_center_id as cost_center_id"
|
||||
)
|
||||
|
||||
def _sub_select(self):
|
||||
return (
|
||||
super(AccountInvoiceReport, self)._sub_select()
|
||||
+ ", ail.cost_center_id as cost_center_id"
|
||||
)
|
||||
|
||||
def _group_by(self):
|
||||
return super(AccountInvoiceReport, self)._group_by() + ", ail.cost_center_id"
|
||||
|
||||
15
account_cost_center/models/account_move.py
Normal file
15
account_cost_center/models/account_move.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# Copyright 2015-2020 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
cost_center_id = fields.Many2one(
|
||||
"account.cost.center",
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
help="Default Cost Center",
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2015-2019 Onestein (<http://www.onestein.eu>)
|
||||
# Copyright 2015-2020 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
@@ -7,6 +7,4 @@ from odoo import fields, models
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = "account.move.line"
|
||||
|
||||
cost_center_id = fields.Many2one(
|
||||
"account.cost.center", index=True, string="Cost Center"
|
||||
)
|
||||
cost_center_id = fields.Many2one("account.cost.center", index=True)
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="account_cost_center_comp_rule" model="ir.rule">
|
||||
<field name="name">Cost center multi company rule</field>
|
||||
<field
|
||||
name="model_id"
|
||||
ref="account_cost_center.model_account_cost_center"
|
||||
/>
|
||||
<field name="global" eval="True" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<odoo noupdate="1">
|
||||
<record id="account_cost_center_comp_rule" model="ir.rule">
|
||||
<field name="name">Cost center multi company rule</field>
|
||||
<field name="model_id" ref="account_cost_center.model_account_cost_center" />
|
||||
<field name="global" eval="True" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|',('company_id','=',False),('company_id', 'in', company_ids)]
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -1,92 +1,98 @@
|
||||
# Copyright 2017-2019 Onestein (<http://www.onestein.eu>)
|
||||
# Copyright 2017-2020 Onestein (<http://www.onestein.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests import common
|
||||
from odoo.tests import Form, tagged
|
||||
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
|
||||
|
||||
class TestAccountCostCenter(common.TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestAccountCostCenter, self).setUp()
|
||||
|
||||
acc_rec = self.env.ref("account.data_account_type_receivable")
|
||||
acc_exp = self.env.ref("account.data_account_type_expenses")
|
||||
self.invoice_account = (
|
||||
self.env["account.account"]
|
||||
.search([("user_type_id", "=", acc_rec.id)], limit=1)
|
||||
.id
|
||||
)
|
||||
self.invoice_line_account = (
|
||||
self.env["account.account"]
|
||||
.search([("user_type_id", "=", acc_exp.id)], limit=1)
|
||||
.id
|
||||
)
|
||||
|
||||
self.invoice1 = self.env["account.invoice"].create(
|
||||
@tagged("post_install", "-at_install")
|
||||
class TestAccountCostCenter(AccountTestInvoicingCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls, chart_template_ref=None):
|
||||
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||
cls.expenses_account = cls.env["account.account"].create(
|
||||
{
|
||||
"partner_id": self.env.ref("base.res_partner_2").id,
|
||||
"account_id": self.invoice_account,
|
||||
"type": "in_invoice",
|
||||
"user_type_id": cls.env.ref("account.data_account_type_expenses").id,
|
||||
"code": "EXPTEST",
|
||||
"name": "Test expense account",
|
||||
}
|
||||
)
|
||||
|
||||
self.line1 = self.env["account.invoice.line"].create(
|
||||
{
|
||||
"product_id": self.env.ref("product.product_product_2").id,
|
||||
"quantity": 1.0,
|
||||
"price_unit": 100.0,
|
||||
"invoice_id": self.invoice1.id,
|
||||
"name": "product that cost 100",
|
||||
"account_id": self.invoice_line_account,
|
||||
}
|
||||
)
|
||||
|
||||
self.costcenter = self.env["account.cost.center"].create(
|
||||
cls.costcenter = cls.env["account.cost.center"].create(
|
||||
{
|
||||
"name": "Cost Center Test",
|
||||
"code": "CC1",
|
||||
"company_id": self.env.user.company_id.id,
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.invoice2 = self.env["account.invoice"].create(
|
||||
{
|
||||
"partner_id": self.env.ref("base.res_partner_2").id,
|
||||
"account_id": self.invoice_account,
|
||||
"type": "in_invoice",
|
||||
"cost_center_id": self.costcenter.id,
|
||||
}
|
||||
)
|
||||
# Invoice created with tests Form
|
||||
cls.invoice1 = cls.init_invoice("in_invoice")
|
||||
|
||||
self.line2 = (
|
||||
self.env["account.invoice.line"]
|
||||
.with_context(cost_center_id=self.costcenter.id)
|
||||
# Invoice created with standard create
|
||||
cls.invoice2 = (
|
||||
cls.env["account.move"]
|
||||
.with_context(cost_center_id=cls.costcenter.id)
|
||||
.create(
|
||||
{
|
||||
"product_id": self.env.ref("product.product_product_4").id,
|
||||
"quantity": 1.0,
|
||||
"price_unit": 130.0,
|
||||
"invoice_id": self.invoice2.id,
|
||||
"name": "product that cost 130",
|
||||
"account_id": self.invoice_line_account,
|
||||
"partner_id": cls.env.ref("base.res_partner_2").id,
|
||||
"move_type": "in_invoice",
|
||||
"cost_center_id": cls.costcenter.id,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
cls.invoice2.invoice_line_ids += cls.env["account.move.line"].new(
|
||||
{
|
||||
"product_id": cls.env.ref("product.product_product_4").id,
|
||||
"quantity": 1.0,
|
||||
"price_unit": 130.0,
|
||||
"name": "product that cost 130",
|
||||
"cost_center_id": cls.costcenter.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_01_check_lines(self):
|
||||
self.assertFalse(
|
||||
self.line1.cost_center_id, "Default cost center per line not set"
|
||||
self.invoice1.invoice_line_ids.cost_center_id,
|
||||
"Default cost center per line not set",
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
(self.line2.cost_center_id == self.costcenter),
|
||||
"Default cost center per line set",
|
||||
self.assertEqual(
|
||||
self.invoice2.invoice_line_ids[0].cost_center_id, self.costcenter
|
||||
)
|
||||
|
||||
def test_02_confirm_invoice(self):
|
||||
self.invoice2.action_invoice_open()
|
||||
for move in self.invoice2.move_id.line_ids:
|
||||
cost_center = move.cost_center_id
|
||||
if move.name == "product that cost 130":
|
||||
self.assertTrue(cost_center)
|
||||
else:
|
||||
self.assertFalse(cost_center)
|
||||
def test_02_check_lines(self):
|
||||
invoice_lines = self.invoice1.invoice_line_ids
|
||||
self.assertFalse(any(line.cost_center_id for line in invoice_lines))
|
||||
|
||||
invoice_form = Form(self.invoice1)
|
||||
invoice_form.cost_center_id = self.costcenter
|
||||
with invoice_form.invoice_line_ids.new() as line:
|
||||
line.name = "Test line2"
|
||||
line.quantity = 2.0
|
||||
line.price_unit = 200.0
|
||||
line.account_id = self.expenses_account
|
||||
self.invoice1 = invoice_form.save()
|
||||
|
||||
invoice_lines = self.invoice1.invoice_line_ids
|
||||
self.assertFalse(any(line.cost_center_id for line in invoice_lines))
|
||||
self.assertTrue(any(not line.cost_center_id for line in invoice_lines))
|
||||
|
||||
def test_03_confirm_invoice(self):
|
||||
invoice_lines = self.invoice2.invoice_line_ids
|
||||
for move_line in invoice_lines:
|
||||
self.assertEqual(move_line.cost_center_id, self.costcenter)
|
||||
for move_line in self.invoice2.line_ids - invoice_lines:
|
||||
self.assertFalse(move_line.cost_center_id)
|
||||
|
||||
def test_04_search_read(self):
|
||||
expected_cost_center = self.costcenter
|
||||
|
||||
records = self.env["account.invoice.report"].sudo().search_read([])
|
||||
result = records[0].get("cost_center_id")
|
||||
|
||||
self.assertTrue(result)
|
||||
self.assertEqual(result[0], expected_cost_center.id)
|
||||
self.assertEqual(result[1], expected_cost_center.name)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- Cost Center views -->
|
||||
<!-- Account Cost Center views -->
|
||||
<record id="account_cost_center_view_form" model="ir.ui.view">
|
||||
<field name="model">account.cost.center</field>
|
||||
<field name="arch" type="xml">
|
||||
@@ -33,7 +32,6 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_cost_center_view_tree" model="ir.ui.view">
|
||||
<field name="model">account.cost.center</field>
|
||||
<field name="arch" type="xml">
|
||||
@@ -44,7 +42,6 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_cost_center_view_search" model="ir.ui.view">
|
||||
<field name="model">account.cost.center</field>
|
||||
<field name="arch" type="xml">
|
||||
@@ -57,12 +54,10 @@
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_cost_center_action" model="ir.actions.act_window">
|
||||
<field name="name">Cost Centers</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.cost.center</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="account_cost_center_view_search" />
|
||||
<field name="help" type="html">
|
||||
@@ -75,12 +70,12 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Cost Center menu-->
|
||||
<!-- Account Cost Center menu-->
|
||||
<menuitem
|
||||
id="cost_center_menu"
|
||||
id="account_cost_center_menu"
|
||||
parent="account.menu_analytic_accounting"
|
||||
action="account_cost_center_action"
|
||||
groups="account.group_account_user"
|
||||
groups="account.group_account_invoice"
|
||||
sequence="40"
|
||||
/>
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="invoice_form" model="ir.ui.view">
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="date_invoice" position="after">
|
||||
<field name="cost_center_id" />
|
||||
</field>
|
||||
<xpath
|
||||
expr="//field[@name='invoice_line_ids']/tree/field[@name='account_id']"
|
||||
position="after"
|
||||
>
|
||||
<field name="cost_center_id" />
|
||||
</xpath>
|
||||
<field name="invoice_line_ids" position="attributes">
|
||||
<attribute
|
||||
name="context"
|
||||
operation="python_dict"
|
||||
key="cost_center_id"
|
||||
>cost_center_id</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="invoice_supplier_form" model="ir.ui.view">
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_supplier_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="origin" position="after">
|
||||
<field name="cost_center_id" />
|
||||
</field>
|
||||
<xpath
|
||||
expr="//field[@name='invoice_line_ids']/tree/field[@name='account_id']"
|
||||
position="after"
|
||||
>
|
||||
<field name="cost_center_id" />
|
||||
</xpath>
|
||||
<field name="invoice_line_ids" position="attributes">
|
||||
<attribute
|
||||
name="context"
|
||||
operation="python_dict"
|
||||
key="cost_center_id"
|
||||
>cost_center_id</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_account_invoice_report_search" model="ir.ui.view">
|
||||
<field name="model">account.invoice.report</field>
|
||||
<field name="inherit_id" ref="account.view_account_invoice_report_search" />
|
||||
@@ -14,5 +13,4 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_move_line_form" model="ir.ui.view">
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="inherit_id" ref="account.view_move_line_form" />
|
||||
@@ -10,7 +9,6 @@
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_move_line_tree" model="ir.ui.view">
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="inherit_id" ref="account.view_move_line_tree" />
|
||||
@@ -21,5 +19,4 @@
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,17 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_move_form" model="ir.ui.view">
|
||||
<field name="model">account.move</field>
|
||||
<field name="inherit_id" ref="account.view_move_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath
|
||||
expr="//notebook//field[@name='line_ids']/tree/field[@name='analytic_account_id']"
|
||||
expr="//field[@name='invoice_line_ids']/tree/field[@name='account_id']"
|
||||
position="after"
|
||||
>
|
||||
<field name="cost_center_id" />
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='line_ids']/tree/field[@name='account_id']"
|
||||
position="after"
|
||||
>
|
||||
<field name="cost_center_id" />
|
||||
</xpath>
|
||||
<field name="ref" position="after">
|
||||
<field name="cost_center_id" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user