19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:12 +01:00
parent 79f83631d5
commit 73afc09215
6267 changed files with 1534193 additions and 1130106 deletions

View file

@ -10,38 +10,15 @@ pip install odoo-bringout-oca-ocb-sale_mrp_margin
## Dependencies
This addon depends on:
- sale_mrp
- sale_stock_margin
## Manifest Information
- **Name**: Sale Mrp Margin
- **Version**: 0.1
- **Category**: Sales/Sales
- **License**: LGPL-3
- **Installable**: False
## Source
Based on [OCA/OCB](https://github.com/OCA/OCB) branch 16.0, addon `sale_mrp_margin`.
- Repository: https://github.com/OCA/OCB
- Branch: 19.0
- Path: addons/sale_mrp_margin
## License
This package maintains the original LGPL-3 license from the upstream Odoo project.
## Documentation
- Overview: doc/OVERVIEW.md
- Architecture: doc/ARCHITECTURE.md
- Models: doc/MODELS.md
- Controllers: doc/CONTROLLERS.md
- Wizards: doc/WIZARDS.md
- Reports: doc/REPORTS.md
- Security: doc/SECURITY.md
- Install: doc/INSTALL.md
- Usage: doc/USAGE.md
- Configuration: doc/CONFIGURATION.md
- Dependencies: doc/DEPENDENCIES.md
- Troubleshooting: doc/TROUBLESHOOTING.md
- FAQ: doc/FAQ.md
This package preserves the original LGPL-3 license.

View file

@ -1,13 +1,15 @@
[project]
name = "odoo-bringout-oca-ocb-sale_mrp_margin"
version = "16.0.0"
description = "Sale Mrp Margin - Odoo addon"
description = "Sale Mrp Margin -
Odoo addon
"
authors = [
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
]
dependencies = [
"odoo-bringout-oca-ocb-sale_mrp>=16.0.0",
"odoo-bringout-oca-ocb-sale_stock_margin>=16.0.0",
"odoo-bringout-oca-ocb-sale_mrp>=19.0.0",
"odoo-bringout-oca-ocb-sale_stock_margin>=19.0.0",
"requests>=2.25.1"
]
readme = "README.md"
@ -17,7 +19,7 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Office/Business",
]

View file

@ -5,5 +5,6 @@
'version': '0.1',
'description': 'Handle BoM prices to compute sale margin.',
'depends': ['sale_mrp', 'sale_stock_margin'],
'author': 'Odoo S.A.',
'license': 'LGPL-3',
}

View file

@ -1,15 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-06 13:32+0000\n"
"PO-Revision-Date: 2024-02-06 13:32+0000\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"

View file

@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.sale_mrp.tests import test_sale_mrp_flow
from odoo.fields import Command
from odoo.tests import common, Form
@ -50,3 +51,87 @@ class TestSaleMrpFlow(test_sale_mrp_flow.TestSaleMrpFlowCommon):
self.assertEqual(so.order_line.purchase_price, 60)
so.action_confirm()
self.assertEqual(so.order_line.purchase_price, 60)
def test_kit_cost_calculation_2(self):
""" Check that the average cost price is computed correctly after receipt validation:
Lovely KIT BOM for 10:
- 1O unit of Kit $50
- 10 units of component b $10
-> $60 per Lovely Kit
SUB KIT BOM:
- 1 units of component a 1 x $30 = $30
- 2 units of component b 2 x $10 = $20
-> $50 per SUB Kit
"""
sub_kit, kit = self._cls_create_product('Sub Kit', self.uom_unit), self._cls_create_product('Lovely Kit', self.uom_ten)
kit.uom_ids = [Command.set([self.uom_unit.id, self.uom_ten.id])]
self.product_category.property_cost_method = 'average'
self.product_category.property_valuation = 'real_time'
(kit + sub_kit + self.component_a + self.component_b).categ_id = self.product_category
self.env['mrp.bom'].create([
{
'product_tmpl_id': sub_kit.product_tmpl_id.id,
'product_qty': 1.0,
'type': 'phantom',
'bom_line_ids': [
Command.create({
'product_id': self.component_a.id,
'product_qty': 1.0,
}),
Command.create({
'product_id': self.component_b.id,
'product_qty': 2.0,
}),
],
},
{
'product_tmpl_id': kit.product_tmpl_id.id,
'product_uom_id': kit.uom_id.id,
'product_qty': 1.0,
'type': 'phantom',
'bom_line_ids': [
Command.create({
'product_id': sub_kit.id,
'product_qty': 10.0,
}),
Command.create({
'product_id': self.component_b.id,
'product_qty': 10.0,
}),
],
},
])
self.component_a.standard_price = 30
self.component_b.standard_price = 10
sub_kit.action_bom_cost()
kit.action_bom_cost()
so = self.env['sale.order'].create({
'partner_id': self.partner_a.id,
'order_line': [Command.create({
'product_id': kit.id,
'product_uom_qty': 3,
'product_uom_id': self.uom_ten.id
})]
})
self.assertEqual(so.order_line.purchase_price, 600)
so.action_confirm()
self.assertEqual(so.order_line.purchase_price, 600)
for move in so.picking_ids.move_ids:
move.quantity = move.product_uom_qty
self.assertRecordValues(so.order_line, [{'purchase_price': 600, 'qty_delivered': 0.0}])
so.picking_ids.button_validate()
self.assertEqual(so.picking_ids.state, 'done')
self.assertRecordValues(so.order_line, [{'purchase_price': 600, 'qty_delivered': 3.0}])
self.assertEqual(so.order_line.purchase_price, 600)
# create an invoice to check that the cost price on the invoice line is correct
inv_1 = so._create_invoices()
inv_1.action_post()
self.assertEqual(inv_1.state, 'posted', 'invoice should be in posted state')
# The cost price on the invoice line should be 600 * 3 = 1800
self.assertRecordValues(inv_1.line_ids, [
{'debit': 0.0, 'credit': 3.0},
{'debit': 0.0, 'credit': 0.45},
{'debit': 3.45, 'credit': 0.0},
{'debit': 0.0, 'credit': 1800},
{'debit': 1800, 'credit': 0.0},
])