[BKP][ADD]account_move_post_date_user

Backport module from https://github.com/OCA/account-financial-tools/pull/1822
In order to adapt it to v13.0, the `_post` method has been renamed to `post` and adapting the logic. Also, the importing on tests has been adapted.
This commit is contained in:
GuillemCForgeFlow
2024-10-28 11:17:48 +01:00
parent f691a96e1a
commit 0dcd18b7a0
5 changed files with 16 additions and 15 deletions

View File

@@ -3,12 +3,12 @@
{
"name": "Account Move Post Date User",
"summary": "Trace journal entry posting date and user.",
"version": "16.0.1.0.0",
"version": "13.0.1.0.0",
"category": "Accounting",
"website": "https://github.com/OCA/account-financial-tools",
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
"maintainers": ["JordiMForgeFlow"],
"license": "LGPL-3",
"depends": ["account",],
"depends": ["account"],
"data": ["views/account_move.xml"],
}

View File

@@ -7,20 +7,19 @@ from odoo import fields, models
class AccountMove(models.Model):
_inherit = "account.move"
def _post(self, soft=True):
res = super()._post(soft)
if res:
res.write(
{
"last_post_date": fields.Datetime.now(),
"last_post_uid": self.env.user.id,
}
)
return res
last_post_date = fields.Datetime(
string="Last Posted on", readonly=True, tracking=True
)
last_post_uid = fields.Many2one(
"res.users", string="Last Posted by", readonly=True, tracking=True
)
def post(self):
res = super().post()
self.write(
{
"last_post_date": fields.Datetime.now(),
"last_post_uid": self.env.user.id,
}
)
return res

View File

@@ -1,3 +1,4 @@
* `ForgeFlow S.L. <https://www.forgeflow.com>`__:
* Jordi Masvidal <jordi.masvidal@forgeflow.com>
* Guillem Casassas <guillem.casassas@forgeflow.com>

View File

@@ -4,7 +4,7 @@
from odoo import fields
from odoo.tests import tagged
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.addons.account.tests.account_test_savepoint import AccountTestInvoicingCommon
@tagged("post_install", "-at_install")
@@ -47,5 +47,6 @@ class TestAccountMovePostDateUser(AccountTestInvoicingCommon):
def test_account_move_post_date_user(self):
self.move.action_post()
self.assertEqual(self.move.state, "posted")
self.assertEqual(self.move.last_post_date.date(), fields.Date.today())
self.assertEqual(self.move.last_post_uid, self.env.user)

View File

@@ -1,8 +1,8 @@
<?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="name">account.move.form - account_move_post_date_user</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='accounting_info_group']" position="inside">