[FIX] mrp_account: reconcile AVCO kits amls
Steps to reproduce: - Create a product in KIT - The product and components must be AVCO rated. - Sell product, confirm delivery and post the invoice Bug: the journal entries are not reconciled. the lines are gouped by product but in this case the products don't match on the stock side it's the components and on the invoice it's the kit Fix: match components stock moves of kits to the kit product opw-3208169 closes odoo/odoo#133683 X-original-commit: 376e3cd31427a6715dd86af91755baca733d94ef Signed-off-by: Adrien Widart (awt) <awt@odoo.com> Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
This commit is contained in:
@@ -2234,6 +2234,57 @@ class TestSaleMrpFlow(ValuationReconciliationTestCommon):
|
||||
self.assertEqual(cogs_aml.debit, 10)
|
||||
self.assertEqual(cogs_aml.credit, 0)
|
||||
|
||||
def test_kit_avco_amls_reconciliation(self):
|
||||
self.stock_account_product_categ.property_cost_method = 'average'
|
||||
|
||||
compo01, compo02, kit = self.env['product.product'].create([{
|
||||
'name': name,
|
||||
'type': 'product',
|
||||
'standard_price': price,
|
||||
'categ_id': self.stock_account_product_categ.id,
|
||||
'invoice_policy': 'delivery',
|
||||
} for name, price in [
|
||||
('Compo 01', 10),
|
||||
('Compo 02', 20),
|
||||
('Kit', 0),
|
||||
]])
|
||||
|
||||
self.env['stock.quant']._update_available_quantity(compo01, self.company_data['default_warehouse'].lot_stock_id, 1)
|
||||
self.env['stock.quant']._update_available_quantity(compo02, self.company_data['default_warehouse'].lot_stock_id, 1)
|
||||
|
||||
self.env['mrp.bom'].create({
|
||||
'product_id': kit.id,
|
||||
'product_tmpl_id': kit.product_tmpl_id.id,
|
||||
'product_uom_id': kit.uom_id.id,
|
||||
'product_qty': 1.0,
|
||||
'type': 'phantom',
|
||||
'bom_line_ids': [
|
||||
(0, 0, {'product_id': compo01.id, 'product_qty': 1.0}),
|
||||
(0, 0, {'product_id': compo02.id, 'product_qty': 1.0}),
|
||||
],
|
||||
})
|
||||
|
||||
so = self.env['sale.order'].create({
|
||||
'partner_id': self.partner_a.id,
|
||||
'order_line': [
|
||||
(0, 0, {
|
||||
'name': kit.name,
|
||||
'product_id': kit.id,
|
||||
'product_uom_qty': 1.0,
|
||||
'product_uom': kit.uom_id.id,
|
||||
'price_unit': 5,
|
||||
'tax_id': False,
|
||||
})],
|
||||
})
|
||||
so.action_confirm()
|
||||
so.picking_ids.move_line_ids.qty_done = 1
|
||||
so.picking_ids.button_validate()
|
||||
|
||||
invoice = so._create_invoices()
|
||||
invoice.action_post()
|
||||
|
||||
self.assertEqual(len(invoice.line_ids.filtered('reconciled')), 1)
|
||||
|
||||
def test_avoid_removing_kit_bom_in_use(self):
|
||||
so = self.env['sale.order'].create({
|
||||
'partner_id': self.partner_a.id,
|
||||
|
||||
@@ -48,6 +48,8 @@ class StockMove(models.Model):
|
||||
subtype_xmlid='mail.mt_note',
|
||||
)
|
||||
|
||||
def _get_all_related_sm(self, product):
|
||||
return super()._get_all_related_sm(product) | self.filtered(lambda m: m.sale_line_id.product_id == product)
|
||||
|
||||
class ProcurementGroup(models.Model):
|
||||
_inherit = 'procurement.group'
|
||||
|
||||
Reference in New Issue
Block a user