mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-28 02:52:01 +02:00
Initial commit: Sale packages
This commit is contained in:
commit
14e3d26998
6469 changed files with 2479670 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from odoo.addons.sale_stock.tests.test_anglo_saxon_valuation_reconciliation import TestValuationReconciliationCommon
|
||||
from odoo.tests import tagged
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestAngloSaxonAccounting(TestValuationReconciliationCommon):
|
||||
|
||||
def test_cogs_should_use_price_from_the_right_company(self):
|
||||
"""
|
||||
Reproduce the flow of creating an invoice from a sale order with company A
|
||||
and posting the invoice with both companies selected and company B as the main.
|
||||
"""
|
||||
company_a_data = self.company_data
|
||||
company_b_data = self.company_data_2
|
||||
companies_with_b_first = company_b_data['company'] + company_a_data['company']
|
||||
product = self.test_product_delivery
|
||||
|
||||
# set different cost price for the same product in the 2 companies
|
||||
company_a_standard_price = 20.0
|
||||
product.with_company(company_a_data['company']).standard_price = company_a_standard_price
|
||||
company_b_standard_price = 10.0
|
||||
product.with_company(company_b_data['company']).standard_price = company_b_standard_price
|
||||
|
||||
# create sale order with company A in draft (by default, self.env.user.company_id is company A)
|
||||
company_a_order = self._create_sale(product, '2021-01-01')
|
||||
company_a_invoice = self._create_invoice_for_so(company_a_order, product, '2021-01-10')
|
||||
|
||||
# Post the invoice from company A with company B
|
||||
company_a_invoice.with_context(allowed_company_ids=companies_with_b_first.ids).action_post()
|
||||
|
||||
# check cost used for anglo_saxon_line is from company A
|
||||
anglo_saxon_lines = company_a_invoice.line_ids.filtered(lambda l: l.display_type == 'cogs')
|
||||
self.assertRecordValues(anglo_saxon_lines, [
|
||||
{'debit': 0.0, 'credit': company_a_standard_price},
|
||||
{'debit': company_a_standard_price, 'credit': 0.0},
|
||||
])
|
||||
Loading…
Add table
Add a link
Reference in a new issue