Files
intrastat-extrastat/intrastat_product/tests/common_sale.py

44 lines
1.3 KiB
Python

# Copyright 2021 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests import Form
from .common import IntrastatProductCommon
class IntrastatSaleCommon(IntrastatProductCommon):
"""
We define common flow:
- Customer in Netherlands
"""
@classmethod
def _init_customer(cls, vals=None):
values = {
"name": "NL Customer",
"country_id": cls.env.ref("base.nl").id,
"property_account_position_id": cls.position.id,
}
if vals is not None:
values.update(vals)
cls.customer = cls.partner_obj.create(values)
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.sale_obj = cls.env["sale.order"]
cls._init_customer()
@classmethod
def _create_sale_order(cls, vals=None):
vals = {
"partner_id": cls.customer.id,
}
sale_new = cls.sale_obj.new(vals)
sale_new.onchange_partner_id()
sale_vals = sale_new._convert_to_write(sale_new._cache)
cls.sale = cls.sale_obj.create(sale_vals)
with Form(cls.sale) as sale_form:
with sale_form.order_line.new() as line:
line.product_id = cls.product_c3po.product_variant_ids[0]
line.product_uom_qty = 3.0