[16.0][MIG] account_move_line_purchase_info
This commit is contained in:
parent
68da50d2da
commit
f684695a91
@ -5,7 +5,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Account Move Line Purchase Info",
|
"name": "Account Move Line Purchase Info",
|
||||||
"summary": "Introduces the purchase order line to the journal items",
|
"summary": "Introduces the purchase order line to the journal items",
|
||||||
"version": "15.0.1.1.1",
|
"version": "16.0.1.0.0",
|
||||||
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/account-financial-tools",
|
"website": "https://github.com/OCA/account-financial-tools",
|
||||||
"category": "Generic",
|
"category": "Generic",
|
||||||
|
@ -2,18 +2,17 @@
|
|||||||
# (https://www.forgeflow.com)
|
# (https://www.forgeflow.com)
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import api, models
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
class StockMove(models.Model):
|
class StockMove(models.Model):
|
||||||
_inherit = "stock.move"
|
_inherit = "stock.move"
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _prepare_account_move_line(
|
def _prepare_account_move_line(
|
||||||
self, qty, cost, credit_account_id, debit_account_id, description
|
self, qty, cost, credit_account_id, debit_account_id, svl_id, description
|
||||||
):
|
):
|
||||||
res = super(StockMove, self)._prepare_account_move_line(
|
res = super(StockMove, self)._prepare_account_move_line(
|
||||||
qty, cost, credit_account_id, debit_account_id, description
|
qty, cost, credit_account_id, debit_account_id, svl_id, description
|
||||||
)
|
)
|
||||||
for line in res:
|
for line in res:
|
||||||
line[2]["purchase_line_id"] = self.purchase_line_id.id
|
line[2]["purchase_line_id"] = self.purchase_line_id.id
|
||||||
|
@ -14,7 +14,6 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
|||||||
cls.purchase_line_model = cls.env["purchase.order.line"]
|
cls.purchase_line_model = cls.env["purchase.order.line"]
|
||||||
cls.product_model = cls.env["product.product"]
|
cls.product_model = cls.env["product.product"]
|
||||||
cls.product_ctg_model = cls.env["product.category"]
|
cls.product_ctg_model = cls.env["product.category"]
|
||||||
cls.acc_type_model = cls.env["account.account.type"]
|
|
||||||
cls.account_model = cls.env["account.account"]
|
cls.account_model = cls.env["account.account"]
|
||||||
cls.am_model = cls.env["account.move"]
|
cls.am_model = cls.env["account.move"]
|
||||||
cls.aml_model = cls.env["account.move.line"]
|
cls.aml_model = cls.env["account.move.line"]
|
||||||
@ -28,18 +27,18 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
|||||||
cls.group_account_manager = cls.env.ref("account.group_account_manager")
|
cls.group_account_manager = cls.env.ref("account.group_account_manager")
|
||||||
|
|
||||||
# Create account for Goods Received Not Invoiced
|
# Create account for Goods Received Not Invoiced
|
||||||
acc_type = cls._create_account_type(cls, "equity", "other")
|
acc_type = "equity"
|
||||||
name = "Goods Received Not Invoiced"
|
name = "Goods Received Not Invoiced"
|
||||||
code = "grni"
|
code = "grni"
|
||||||
cls.account_grni = cls._create_account(cls, acc_type, name, code, cls.company)
|
cls.account_grni = cls._create_account(cls, acc_type, name, code, cls.company)
|
||||||
|
|
||||||
# Create account for Cost of Goods Sold
|
# Create account for Cost of Goods Sold
|
||||||
acc_type = cls._create_account_type(cls, "expense", "other")
|
acc_type = "expense"
|
||||||
name = "Cost of Goods Sold"
|
name = "Cost of Goods Sold"
|
||||||
code = "cogs"
|
code = "cogs"
|
||||||
cls.account_cogs = cls._create_account(cls, acc_type, name, code, cls.company)
|
cls.account_cogs = cls._create_account(cls, acc_type, name, code, cls.company)
|
||||||
# Create account for Inventory
|
# Create account for Inventory
|
||||||
acc_type = cls._create_account_type(cls, "asset", "other")
|
acc_type = "asset_current"
|
||||||
name = "Inventory"
|
name = "Inventory"
|
||||||
code = "inventory"
|
code = "inventory"
|
||||||
cls.account_inventory = cls._create_account(
|
cls.account_inventory = cls._create_account(
|
||||||
@ -78,19 +77,13 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
|||||||
)
|
)
|
||||||
return user.id
|
return user.id
|
||||||
|
|
||||||
def _create_account_type(self, name, a_type):
|
|
||||||
acc_type = self.acc_type_model.create(
|
|
||||||
{"name": name, "type": a_type, "internal_group": name}
|
|
||||||
)
|
|
||||||
return acc_type
|
|
||||||
|
|
||||||
def _create_account(self, acc_type, name, code, company):
|
def _create_account(self, acc_type, name, code, company):
|
||||||
"""Create an account."""
|
"""Create an account."""
|
||||||
account = self.account_model.create(
|
account = self.account_model.create(
|
||||||
{
|
{
|
||||||
"name": name,
|
"name": name,
|
||||||
"code": code,
|
"code": code,
|
||||||
"user_type_id": acc_type.id,
|
"account_type": acc_type,
|
||||||
"company_id": company.id,
|
"company_id": company.id,
|
||||||
"reconcile": True,
|
"reconcile": True,
|
||||||
}
|
}
|
||||||
@ -183,7 +176,7 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
|||||||
purchase.button_confirm()
|
purchase.button_confirm()
|
||||||
picking = purchase.picking_ids[0]
|
picking = purchase.picking_ids[0]
|
||||||
picking.action_confirm()
|
picking.action_confirm()
|
||||||
picking.move_lines.write({"quantity_done": 1.0})
|
picking.move_ids.write({"quantity_done": 1.0})
|
||||||
picking.button_validate()
|
picking.button_validate()
|
||||||
|
|
||||||
expected_balance = 1.0
|
expected_balance = 1.0
|
||||||
@ -193,12 +186,13 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase):
|
|||||||
expected_balance=expected_balance,
|
expected_balance=expected_balance,
|
||||||
)
|
)
|
||||||
|
|
||||||
f = Form(self.am_model.with_context(default_type="in_invoice"))
|
f = Form(self.am_model.with_context(default_move_type="in_invoice"))
|
||||||
f.partner_id = purchase.partner_id
|
f.partner_id = purchase.partner_id
|
||||||
f.purchase_id = purchase
|
f.invoice_date = fields.Date().today()
|
||||||
|
f.purchase_vendor_bill_id = self.env["purchase.bill.union"].browse(-purchase.id)
|
||||||
invoice = f.save()
|
invoice = f.save()
|
||||||
invoice._post()
|
invoice.action_post()
|
||||||
purchase.flush()
|
purchase.flush_model()
|
||||||
|
|
||||||
for aml in invoice.invoice_line_ids:
|
for aml in invoice.invoice_line_ids:
|
||||||
if aml.product_id == po_line.product_id and aml.move_id:
|
if aml.product_id == po_line.product_id and aml.move_id:
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
../../../../account_move_line_purchase_info
|
6
setup/account_move_line_purchase_info/setup.py
Normal file
6
setup/account_move_line_purchase_info/setup.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user