[15.0][MIG] account_move_line_sale_info: Migration to 15.0
This commit is contained in:
parent
625a2090f9
commit
6ecee22a46
@ -44,6 +44,7 @@ Images
|
|||||||
|
|
||||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||||
|
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
@ -4,14 +4,13 @@
|
|||||||
{
|
{
|
||||||
"name": "Account Move Line Sale Info",
|
"name": "Account Move Line Sale Info",
|
||||||
"summary": "Introduces the purchase order line to the journal items",
|
"summary": "Introduces the purchase order line to the journal items",
|
||||||
"version": "13.0.1.0.3",
|
"version": "15.0.1.0.0",
|
||||||
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
|
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
|
||||||
"website": "http://www.github.com/OCA/account-financial-tools",
|
"website": "https://github.com/OCA/account-financial-tools",
|
||||||
"category": "Generic",
|
"category": "Generic",
|
||||||
"depends": [
|
"depends": [
|
||||||
"account_move_line_stock_info",
|
"account_move_line_stock_info",
|
||||||
"sale_stock",
|
"sale_stock",
|
||||||
"stock_account_prepare_anglo_saxon_out_lines_hook",
|
|
||||||
],
|
],
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"data": ["security/account_security.xml", "views/account_move_view.xml"],
|
"data": ["security/account_security.xml", "views/account_move_view.xml"],
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
def post_init_hook(cr, registry):
|
def post_init_hook(cr, registry):
|
||||||
|
|
||||||
""" INIT sale references in acount move line """
|
"""INIT sale references in account move line"""
|
||||||
# FOR stock moves
|
# FOR stock moves
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"""
|
"""
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
# Copyright 2020 ForgeFlow <http://www.forgeflow.com>
|
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
|
||||||
from openupgradelib import openupgrade
|
|
||||||
|
|
||||||
_field_renames = [
|
|
||||||
("account.move.line", "account_move_line", "sale_id", "sale_order_id",),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@openupgrade.migrate()
|
|
||||||
def migrate(env, version):
|
|
||||||
openupgrade.rename_fields(env, _field_renames)
|
|
@ -5,45 +5,24 @@ from odoo import fields, models
|
|||||||
|
|
||||||
|
|
||||||
class AccountMove(models.Model):
|
class AccountMove(models.Model):
|
||||||
|
|
||||||
_inherit = "account.move"
|
_inherit = "account.move"
|
||||||
|
|
||||||
def _prepare_interim_account_line_vals(self, line, move, debit_interim_account):
|
def _stock_account_prepare_anglo_saxon_out_lines_vals(self):
|
||||||
res = super()._prepare_interim_account_line_vals(
|
res = super()._stock_account_prepare_anglo_saxon_out_lines_vals()
|
||||||
line, move, debit_interim_account
|
for i, vals in enumerate(res):
|
||||||
)
|
|
||||||
if (
|
if (
|
||||||
not res.get("move_id", False)
|
not vals.get("move_id", False)
|
||||||
or not res.get("product_id", False)
|
or not vals.get("product_id", False)
|
||||||
or not res.get("quantity", False)
|
or not vals.get("quantity", False)
|
||||||
):
|
):
|
||||||
return res
|
continue
|
||||||
am = self.env["account.move"].browse(res["move_id"])
|
am = self.env["account.move"].browse(vals["move_id"])
|
||||||
sale_line_id = am.invoice_line_ids.filtered(
|
sale_line_id = am.invoice_line_ids.filtered(
|
||||||
lambda il: il.product_id.id == res["product_id"]
|
lambda il: il.product_id.id == vals["product_id"]
|
||||||
and il.quantity == res["quantity"]
|
and il.quantity == vals["quantity"]
|
||||||
).mapped("sale_line_id")
|
).mapped("sale_line_id")
|
||||||
if sale_line_id and len(sale_line_id) == 1:
|
if sale_line_id and len(sale_line_id) == 1:
|
||||||
res["sale_line_id"] = sale_line_id.id
|
res[i]["sale_line_id"] = sale_line_id.id
|
||||||
return res
|
|
||||||
|
|
||||||
def _prepare_expense_account_line_vals(self, line, move, debit_interim_account):
|
|
||||||
res = super()._prepare_expense_account_line_vals(
|
|
||||||
line, move, debit_interim_account
|
|
||||||
)
|
|
||||||
if (
|
|
||||||
not res.get("move_id", False)
|
|
||||||
or not res.get("product_id", False)
|
|
||||||
or not res.get("quantity", False)
|
|
||||||
):
|
|
||||||
return res
|
|
||||||
am = self.env["account.move"].browse(res["move_id"])
|
|
||||||
sale_line_id = am.invoice_line_ids.filtered(
|
|
||||||
lambda il: il.product_id.id == res["product_id"]
|
|
||||||
and il.quantity == res["quantity"]
|
|
||||||
).mapped("sale_line_id")
|
|
||||||
if sale_line_id and len(sale_line_id) == 1:
|
|
||||||
res["sale_line_id"] = sale_line_id.id
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class SaleOrderLine(models.Model):
|
|||||||
result.append((line.id, name))
|
result.append((line.id, name))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _prepare_invoice_line(self):
|
def _prepare_invoice_line(self, **optional_values):
|
||||||
res = super(SaleOrderLine, self)._prepare_invoice_line()
|
res = super()._prepare_invoice_line(**optional_values)
|
||||||
res["sale_line_id"] = self.id
|
res["sale_line_id"] = self.id
|
||||||
return res
|
return res
|
||||||
|
0
account_move_line_sale_info/readme/CONFIGURE.rst
Normal file
0
account_move_line_sale_info/readme/CONFIGURE.rst
Normal file
1
account_move_line_sale_info/readme/CONTRIBUTORS.rst
Normal file
1
account_move_line_sale_info/readme/CONTRIBUTORS.rst
Normal file
@ -0,0 +1 @@
|
|||||||
|
* Aaron Henriquez <ahenriquez@forgeflow.com>
|
4
account_move_line_sale_info/readme/DESCRIPTION.rst
Normal file
4
account_move_line_sale_info/readme/DESCRIPTION.rst
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
This module will add the sale order line to journal items.
|
||||||
|
|
||||||
|
The ultimate goal is to establish the purchase order line as one of the key
|
||||||
|
fields to reconcile the Goods Delivered Not Invoiced accrual account.
|
7
account_move_line_sale_info/readme/USAGE.rst
Normal file
7
account_move_line_sale_info/readme/USAGE.rst
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
The sale order line will be automatically copied to the journal items.
|
||||||
|
|
||||||
|
* When a supplier invoice is created referencing sales orders, the
|
||||||
|
sale order line will be copied to the corresponding journal item.
|
||||||
|
|
||||||
|
* When a stock move is validated and generates a journal entry, the sale
|
||||||
|
order line is copied to the account move line.
|
@ -68,7 +68,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
|
|||||||
def _create_user(self, login, groups, company):
|
def _create_user(self, login, groups, company):
|
||||||
"""Create a user."""
|
"""Create a user."""
|
||||||
group_ids = [group.id for group in groups]
|
group_ids = [group.id for group in groups]
|
||||||
user = self.res_users_model.with_context({"no_reset_password": True}).create(
|
user = self.res_users_model.with_context(**{"no_reset_password": True}).create(
|
||||||
{
|
{
|
||||||
"name": "Test User",
|
"name": "Test User",
|
||||||
"login": login,
|
"login": login,
|
||||||
@ -198,7 +198,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
|
|||||||
}
|
}
|
||||||
payment = (
|
payment = (
|
||||||
self.env["sale.advance.payment.inv"]
|
self.env["sale.advance.payment.inv"]
|
||||||
.with_context(self.context)
|
.with_context(**self.context)
|
||||||
.create({"advance_payment_method": "delivered"})
|
.create({"advance_payment_method": "delivered"})
|
||||||
)
|
)
|
||||||
payment.create_invoices()
|
payment.create_invoices()
|
||||||
@ -217,7 +217,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
|
|||||||
def test_name_get(self):
|
def test_name_get(self):
|
||||||
sale = self._create_sale([(self.product, 1)])
|
sale = self._create_sale([(self.product, 1)])
|
||||||
so_line = sale.order_line[0]
|
so_line = sale.order_line[0]
|
||||||
name_get = so_line.with_context({"so_line_info": True}).name_get()
|
name_get = so_line.with_context(**{"so_line_info": True}).name_get()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name_get,
|
name_get,
|
||||||
[
|
[
|
||||||
@ -232,7 +232,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
name_get_no_ctx = so_line.with_context({}).name_get()
|
name_get_no_ctx = so_line.with_context(**{}).name_get()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name_get_no_ctx,
|
name_get_no_ctx,
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user