[MIG] account_move_name_sequence: Migration to 16.0
This commit is contained in:
parent
a07eeda085
commit
86eed6c1ed
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Account Move Number Sequence",
|
"name": "Account Move Number Sequence",
|
||||||
"version": "15.0.1.1.0",
|
"version": "16.0.1.0.0",
|
||||||
"category": "Accounting",
|
"category": "Accounting",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"summary": "Generate journal entry number from sequence",
|
"summary": "Generate journal entry number from sequence",
|
||||||
|
@ -67,17 +67,18 @@ class AccountJournal(models.Model):
|
|||||||
)
|
)
|
||||||
raise ValidationError(msg)
|
raise ValidationError(msg)
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
if not vals.get("sequence_id"):
|
for vals in vals_list:
|
||||||
vals["sequence_id"] = self._create_sequence(vals).id
|
if not vals.get("sequence_id"):
|
||||||
if (
|
vals["sequence_id"] = self._create_sequence(vals).id
|
||||||
vals.get("type") in ("sale", "purchase")
|
if (
|
||||||
and vals.get("refund_sequence")
|
vals.get("type") in ("sale", "purchase")
|
||||||
and not vals.get("refund_sequence_id")
|
and vals.get("refund_sequence")
|
||||||
):
|
and not vals.get("refund_sequence_id")
|
||||||
vals["refund_sequence_id"] = self._create_sequence(vals, refund=True).id
|
):
|
||||||
return super().create(vals)
|
vals["refund_sequence_id"] = self._create_sequence(vals, refund=True).id
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _prepare_sequence(self, vals, refund=False):
|
def _prepare_sequence(self, vals, refund=False):
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
* `Akretion <https://www.akretion.com>`_:
|
||||||
* Moisés López <moylop260@vauxoo.com>
|
|
||||||
* Francisco Luna <fluna@vauxoo.com>
|
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
|
||||||
|
* `Vauxoo <https://www.vauxoo.com>`_:
|
||||||
|
|
||||||
|
* Moisés López <moylop260@vauxoo.com>
|
||||||
|
* Francisco Luna <fluna@vauxoo.com>
|
||||||
|
|
||||||
|
* `Factor Libre <https://www.factorlibre.com>`_:
|
||||||
|
|
||||||
|
* Rodrigo Bonilla Martinez <rodrigo.bonilla@factorlibre.com>
|
||||||
|
@ -9,7 +9,7 @@ from datetime import datetime
|
|||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from odoo import fields
|
from odoo import fields
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.tests import tagged
|
from odoo.tests import tagged
|
||||||
from odoo.tests.common import TransactionCase
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ class TestAccountMoveNameSequence(TransactionCase):
|
|||||||
in_refund_invoice.action_post()
|
in_refund_invoice.action_post()
|
||||||
self.assertEqual(in_refund_invoice.name, move_name)
|
self.assertEqual(in_refund_invoice.name, move_name)
|
||||||
|
|
||||||
def test_remove_invoice_error(self):
|
def test_remove_invoice_error_secuence_no_grap(self):
|
||||||
invoice = self.env["account.move"].create(
|
invoice = self.env["account.move"].create(
|
||||||
{
|
{
|
||||||
"date": self.date,
|
"date": self.date,
|
||||||
@ -189,3 +189,55 @@ class TestAccountMoveNameSequence(TransactionCase):
|
|||||||
error_msg = "You cannot delete this entry, as it has already consumed a"
|
error_msg = "You cannot delete this entry, as it has already consumed a"
|
||||||
with self.assertRaisesRegex(UserError, error_msg):
|
with self.assertRaisesRegex(UserError, error_msg):
|
||||||
invoice.unlink()
|
invoice.unlink()
|
||||||
|
|
||||||
|
def test_remove_invoice_error_secuence_standard(self):
|
||||||
|
implementation = {"implementation": "standard"}
|
||||||
|
self.purchase_journal.sequence_id.write(implementation)
|
||||||
|
self.purchase_journal.refund_sequence_id.write(implementation)
|
||||||
|
in_refund_invoice = self.env["account.move"].create(
|
||||||
|
{
|
||||||
|
"journal_id": self.purchase_journal.id,
|
||||||
|
"invoice_date": self.date,
|
||||||
|
"partner_id": self.env.ref("base.res_partner_3").id,
|
||||||
|
"move_type": "in_refund",
|
||||||
|
"invoice_line_ids": [
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
"account_id": self.account1.id,
|
||||||
|
"price_unit": 42.0,
|
||||||
|
"quantity": 12,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
in_refund_invoice._compute_split_sequence()
|
||||||
|
self.assertEqual(in_refund_invoice.name, "/")
|
||||||
|
in_refund_invoice.action_post()
|
||||||
|
error_msg = "You cannot delete an item linked to a posted entry."
|
||||||
|
with self.assertRaisesRegex(UserError, error_msg):
|
||||||
|
in_refund_invoice.unlink()
|
||||||
|
in_refund_invoice.button_draft()
|
||||||
|
in_refund_invoice.button_cancel()
|
||||||
|
self.assertTrue(in_refund_invoice.unlink())
|
||||||
|
|
||||||
|
def test_journal_check_journal_sequence(self):
|
||||||
|
new_journal = self.purchase_journal.copy()
|
||||||
|
# same sequence_id and refund_sequence_id
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
new_journal.write({"refund_sequence_id": new_journal.sequence_id})
|
||||||
|
|
||||||
|
# company_id in sequence_id or refund_sequence_id to False
|
||||||
|
new_sequence_id = new_journal.sequence_id.copy({"company_id": False})
|
||||||
|
new_refund_sequence_id = new_journal.refund_sequence_id.copy(
|
||||||
|
{"company_id": False}
|
||||||
|
)
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
new_journal.write({"sequence_id": new_sequence_id.id})
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
new_journal.write({"refund_sequence_id": new_refund_sequence_id.id})
|
||||||
|
|
||||||
|
def test_constrains_date_sequence_true(self):
|
||||||
|
self.assertTrue(self.env["account.move"]._constrains_date_sequence())
|
||||||
|
@ -10,20 +10,20 @@
|
|||||||
<field name="model">account.move</field>
|
<field name="model">account.move</field>
|
||||||
<field name="inherit_id" ref="account.view_move_form" />
|
<field name="inherit_id" ref="account.view_move_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath
|
<xpath expr="//field[@name='highest_name']/.." position="attributes">
|
||||||
expr="//div[hasclass('oe_title')]/h1[hasclass('mt0')]"
|
<attribute name="invisible">1</attribute>
|
||||||
position="attributes"
|
|
||||||
>
|
|
||||||
<attribute name="attrs">{'invisible': [('name', '=', '/')]}</attribute>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath
|
<xpath
|
||||||
expr="//div[hasclass('oe_title')]//field[@name='name']"
|
expr="//div[hasclass('oe_title')]//field[@name='name']"
|
||||||
position="attributes"
|
position="attributes"
|
||||||
>
|
>
|
||||||
<attribute name="attrs">{'readonly': 1}</attribute>
|
<attribute name="attrs">{'invisible': [('name', '=', '/')]}</attribute>
|
||||||
|
<attribute name="readonly">1</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='highest_name']/.." position="attributes">
|
<xpath expr="//div[hasclass('oe_title')]//h1//span" position="attributes">
|
||||||
<attribute name="attrs">{'invisible': 1}</attribute>
|
<attribute
|
||||||
|
name="attrs"
|
||||||
|
>{'invisible': ['|', ('state', '!=', 'draft'), ('name', '!=', '/')]}</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
Loading…
Reference in New Issue
Block a user