From 1437d4c7ed10f4559aba6d66627a6854f2980655 Mon Sep 17 00:00:00 2001 From: Robin Conjour Date: Wed, 11 Aug 2021 12:49:46 +0200 Subject: [PATCH 01/14] Do not drop indexes --- odoo/tools/sql.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py index 7e8f69a4168543..994259c599365c 100644 --- a/odoo/tools/sql.py +++ b/odoo/tools/sql.py @@ -199,8 +199,8 @@ def create_unique_index(cr, indexname, tablename, expressions): def drop_index(cr, indexname, tablename): """ Drop the given index if it exists. """ - cr.execute('DROP INDEX IF EXISTS "{}"'.format(indexname)) - _schema.debug("Table %r: dropped index %r", tablename, indexname) + # cr.execute('DROP INDEX IF EXISTS "{}"'.format(indexname)) + _schema.debug("Table %r: refuse drop index %r", tablename, indexname) def drop_view_if_exists(cr, viewname): cr.execute("DROP view IF EXISTS %s CASCADE" % (viewname,)) From 29d1ff9f32d1fc8a8d8eb109782b80c014cb49e6 Mon Sep 17 00:00:00 2001 From: Chris Bergman Date: Fri, 17 Sep 2021 16:57:38 +0200 Subject: [PATCH 02/14] Do not use demo data for unit tests --- .gitignore | 4 + .../tests/test_account_customer_invoice.py | 176 ++++++++++++++- .../tests/test_account_invoice_rounding.py | 68 +++++- .../tests/test_account_supplier_invoice.py | 205 +++++++++++++++++- .../test_bank_statement_reconciliation.py | 30 ++- addons/account/tests/test_payment.py | 92 +++++++- addons/account/tests/test_reconciliation.py | 69 +++++- addons/delivery/tests/test_delivery_cost.py | 169 ++++++++++++++- .../tests/test_delivery_stock_move.py | 80 ++++++- addons/purchase/tests/test_create_picking.py | 61 +++++- addons/purchase/tests/test_purchase_order.py | 61 +++++- addons/purchase/tests/test_stockvaluation.py | 64 +++++- addons/sale/tests/test_sale_common.py | 86 +++++++- addons/sale/tests/test_sale_order.py | 111 +++++++++- ...test_sale_to_invoice_and_to_be_invoiced.py | 82 ++++++- addons/sale_stock/tests/test_sale_stock.py | 123 ++++++++++- 16 files changed, 1414 insertions(+), 67 deletions(-) diff --git a/.gitignore b/.gitignore index ea844d148af37d..4ab6d3d3e8f6cd 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,7 @@ setup/win32/static/postgresql*.exe /man/ /share/ /src/ + +# running unittests +allure_results/ +htmlcov/ diff --git a/addons/account/tests/test_account_customer_invoice.py b/addons/account/tests/test_account_customer_invoice.py index 7799f70f13ced7..c69d7a6c5ba22c 100644 --- a/addons/account/tests/test_account_customer_invoice.py +++ b/addons/account/tests/test_account_customer_invoice.py @@ -18,9 +18,39 @@ def test_customer_invoice(self): # Test with that user which have rights to make Invoicing and payment and who is accountant. # Create a customer invoice self.account_invoice_obj = self.env['account.invoice'] - self.payment_term = self.env.ref('account.account_payment_term_advance') + account_payment_term_advance = self.env['account.payment.term'].create(dict( + name="30% Advance End of Following Month", + note="Payment terms: 30% Advance End of Following Month", + line_ids=[ + (5, 0), + (0, 0, {'value': 'percent', 'value_amount': 30.0, 'sequence': 400, 'days': 0, 'option': 'day_after_invoice_date'}), + (0, 0, {'value': 'balance', 'value_amount': 0.0, 'sequence': 500, 'days': 0, 'option': 'last_day_following_month'}) + ] + )) + self.payment_term = account_payment_term_advance self.journalrec = self.env['account.journal'].search([('type', '=', 'sale')])[0] - self.partner3 = self.env.ref('base.res_partner_3') + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + self.partner3 = res_partner_3 account_user_type = self.env.ref('account.data_account_type_receivable') self.ova = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_current_assets').id)], limit=1) @@ -32,10 +62,26 @@ def test_customer_invoice(self): reconcile=True, )) + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_5 = self.env['product.product'].create(dict( + name="Custom Computer (kit)", + categ_id=product_category_5.id, + standard_price=600.0, + list_price=147.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description="Custom computer shipped in kit.", + default_code="E-COM06" + )) + invoice_line_data = [ (0, 0, { - 'product_id': self.env.ref('product.product_product_5').id, + 'product_id': product_product_5.id, 'quantity': 10.0, 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, 'name': 'product test 5', @@ -106,9 +152,39 @@ def test_customer_invoice_tax(self): self.env.user.company_id.tax_calculation_rounding_method = 'round_globally' - payment_term = self.env.ref('account.account_payment_term_advance') + account_payment_term_advance = self.env['account.payment.term'].create(dict( + name="30% Advance End of Following Month", + note="Payment terms: 30% Advance End of Following Month", + line_ids=[ + (5, 0), + (0, 0, {'value': 'percent', 'value_amount': 30.0, 'sequence': 400, 'days': 0, 'option': 'day_after_invoice_date'}), + (0, 0, {'value': 'balance', 'value_amount': 0.0, 'sequence': 500, 'days': 0, 'option': 'last_day_following_month'}) + ] + )) + payment_term = account_payment_term_advance journalrec = self.env['account.journal'].search([('type', '=', 'sale')])[0] - partner3 = self.env.ref('base.res_partner_3') + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + partner3 = res_partner_3 account_id = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id tax = self.env['account.tax'].create({ @@ -118,10 +194,53 @@ def test_customer_invoice_tax(self): 'type_tax_use': 'sale', }) + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + product_product_1 = self.env['product.product'].create(dict( + name="GAP Analysis Service", + categ_id=product_category_3.id, + standard_price=20.5, + list_price=30.75, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of products to invoice based on delivery.", + invoice_policy="delivery" + )) + product_product_2 = self.env['product.product'].create(dict( + name="Support Service", + categ_id=product_category_3.id, + standard_price=25.5, + list_price=38.25, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of product to invoice based on delivery.", + invoice_policy="delivery" + )) + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_3 = self.env['product.product'].create(dict( + name="Computer SC234", + categ_id=product_category_5.id, + standard_price=450.0, + list_price=300.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="""17" LCD Monitor Processor AMD 8-Core""", + default_code="PCSC234", + invoice_policy="delivery" + )) + invoice_line_data = [ (0, 0, { - 'product_id': self.env.ref('product.product_product_1').id, + 'product_id': product_product_1.id, 'quantity': 40.0, 'account_id': account_id, 'name': 'product test 1', @@ -132,7 +251,7 @@ def test_customer_invoice_tax(self): ), (0, 0, { - 'product_id': self.env.ref('product.product_product_2').id, + 'product_id': product_product_2.id, 'quantity': 21.0, 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, 'name': 'product test 2', @@ -143,7 +262,7 @@ def test_customer_invoice_tax(self): ), (0, 0, { - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': product_product_3.id, 'quantity': 21.0, 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, 'name': 'product test 3', @@ -182,7 +301,28 @@ def test_customer_invoice_tax_refund(self): }) journalrec = self.env['account.journal'].search([('type', '=', 'sale')])[0] - partner3 = self.env.ref('base.res_partner_3') + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + partner3 = res_partner_3 account_id = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id tax = self.env['account.tax'].create({ @@ -194,10 +334,26 @@ def test_customer_invoice_tax_refund(self): 'refund_account_id': tax_refund_account.id }) + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + product_product_1 = self.env['product.product'].create(dict( + name="GAP Analysis Service", + categ_id=product_category_3.id, + standard_price=20.5, + list_price=30.75, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of products to invoice based on delivery.", + invoice_policy="delivery" + )) + invoice_line_data = [ (0, 0, { - 'product_id': self.env.ref('product.product_product_1').id, + 'product_id': product_product_1.id, 'quantity': 40.0, 'account_id': account_id, 'name': 'product test 1', diff --git a/addons/account/tests/test_account_invoice_rounding.py b/addons/account/tests/test_account_invoice_rounding.py index 9b0ef0fc9e8851..d3a701e7112503 100644 --- a/addons/account/tests/test_account_invoice_rounding.py +++ b/addons/account/tests/test_account_invoice_rounding.py @@ -31,8 +31,34 @@ def create_cash_rounding(self, rounding, method, strategy): def create_invoice(self, amount, cash_rounding_id, tax_amount=None): """ Returns an open invoice """ + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) invoice_id = self.env['account.invoice'].create({ - 'partner_id': self.env.ref("base.res_partner_2").id, + 'partner_id': res_partner_2.id, 'reference_type': 'none', 'currency_id': self.env.ref('base.USD').id, 'name': 'invoice test rounding', @@ -42,8 +68,46 @@ def create_invoice(self, amount, cash_rounding_id, tax_amount=None): }) if tax_amount: self.fixed_tax.amount = tax_amount + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + self.env['account.invoice.line'].create({ - 'product_id': self.env.ref("product.product_product_4").id, + 'product_id': product_product_4.id, 'quantity': 1, 'price_unit': amount, 'invoice_id': invoice_id.id, diff --git a/addons/account/tests/test_account_supplier_invoice.py b/addons/account/tests/test_account_supplier_invoice.py index 9d3046577d7bba..0e9ecf85717bf0 100644 --- a/addons/account/tests/test_account_supplier_invoice.py +++ b/addons/account/tests/test_account_supplier_invoice.py @@ -17,13 +17,77 @@ def test_supplier_invoice(self): invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id - invoice = self.env['account.invoice'].create({'partner_id': self.env.ref('base.res_partner_2').id, + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + invoice = self.env['account.invoice'].create({'partner_id': res_partner_2.id, 'account_id': invoice_account, 'type': 'in_invoice', }) self.assertEquals(invoice.journal_id.type, 'purchase') - self.env['account.invoice.line'].create({'product_id': self.env.ref('product.product_product_4').id, + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + self.env['account.invoice.line'].create({'product_id': product_product_4.id, 'quantity': 1.0, 'price_unit': 100.0, 'invoice_id': invoice.id, @@ -73,13 +137,77 @@ def test_supplier_invoice2(self): invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id - invoice = self.env['account.invoice'].create({'partner_id': self.env.ref('base.res_partner_2').id, + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + invoice = self.env['account.invoice'].create({'partner_id': res_partner_2.id, 'account_id': invoice_account, 'type': 'in_invoice', }) self.assertEquals(invoice.journal_id.type, 'purchase') - invoice_line = self.env['account.invoice.line'].create({'product_id': self.env.ref('product.product_product_4').id, + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + invoice_line = self.env['account.invoice.line'].create({'product_id': product_product_4.id, 'quantity': 5.0, 'price_unit': 100.0, 'invoice_id': invoice.id, @@ -121,16 +249,81 @@ def test_vendor_bill_refund(self): 'partner_id': self.env.ref('base.main_partner').id, }) + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + invoice_id = self.env['account.invoice'].create({ 'name': 'invoice test refund', 'reference_type': 'none', - 'partner_id': self.env.ref("base.res_partner_2").id, + 'partner_id': res_partner_2.id, 'account_id': invoice_account.id, 'currency_id': self.env.ref('base.USD').id, 'type': 'in_invoice', }) + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + self.env['account.invoice.line'].create({ - 'product_id': self.env.ref("product.product_product_4").id, + 'product_id': product_product_4.id, 'quantity': 1, 'price_unit': 15.0, 'invoice_id': invoice_id.id, diff --git a/addons/account/tests/test_bank_statement_reconciliation.py b/addons/account/tests/test_bank_statement_reconciliation.py index 7932b32d1fcffc..ed97ce4c931c53 100644 --- a/addons/account/tests/test_bank_statement_reconciliation.py +++ b/addons/account/tests/test_bank_statement_reconciliation.py @@ -8,7 +8,35 @@ def setUp(self): self.il_model = self.env['account.invoice.line'] self.bs_model = self.env['account.bank.statement'] self.bsl_model = self.env['account.bank.statement.line'] - self.partner_agrolait = self.env.ref("base.res_partner_2") + + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + self.partner_agrolait = res_partner_2 def test_reconciliation_proposition(self): rcv_mv_line = self.create_invoice(100) diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py index 849a882741d538..6cb4a74ea4cc29 100644 --- a/addons/account/tests/test_payment.py +++ b/addons/account/tests/test_payment.py @@ -12,15 +12,101 @@ def setUp(self): self.acc_bank_stmt_model = self.env['account.bank.statement'] self.acc_bank_stmt_line_model = self.env['account.bank.statement.line'] - self.partner_agrolait = self.env.ref("base.res_partner_2") - self.partner_china_exp = self.env.ref("base.res_partner_3") + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + self.partner_agrolait = res_partner_2 + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + self.partner_china_exp = res_partner_3 self.currency_chf_id = self.env.ref("base.CHF").id self.currency_usd_id = self.env.ref("base.USD").id self.currency_eur_id = self.env.ref("base.EUR").id company = self.env.ref('base.main_company') self.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.currency_eur_id, company.id]) - self.product = self.env.ref("product.product_product_4") + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + self.product = product_product_4 self.payment_method_manual_in = self.env.ref("account.account_payment_method_manual_in") self.payment_method_manual_out = self.env.ref("account.account_payment_method_manual_out") diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index 9b7e4edeabcd68..085519c8693a0c 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -21,7 +21,34 @@ def setUp(self): self.res_currency_model = self.registry('res.currency') self.res_currency_rate_model = self.registry('res.currency.rate') - partner_agrolait = self.env.ref("base.res_partner_2") + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + partner_agrolait = res_partner_2 self.partner_agrolait_id = partner_agrolait.id self.currency_swiss_id = self.env.ref("base.CHF").id self.currency_usd_id = self.env.ref("base.USD").id @@ -30,7 +57,45 @@ def setUp(self): self.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.currency_euro_id, company.id]) self.account_rcv = partner_agrolait.property_account_receivable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1) self.account_rsa = partner_agrolait.property_account_payable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1) - self.product = self.env.ref("product.product_product_4") + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + self.product = product_product_4 self.bank_journal_euro = self.env['account.journal'].create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'}) self.account_euro = self.bank_journal_euro.default_debit_account_id diff --git a/addons/delivery/tests/test_delivery_cost.py b/addons/delivery/tests/test_delivery_cost.py index 343443941c9554..967971349d256a 100644 --- a/addons/delivery/tests/test_delivery_cost.py +++ b/addons/delivery/tests/test_delivery_cost.py @@ -16,17 +16,171 @@ def setUp(self): self.SaleConfigSetting = self.env['res.config.settings'] self.Product = self.env['product.product'] - self.partner_18 = self.env.ref('base.res_partner_18') + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1 + )) + + res_partner_category_5 = self.env['res.partner.category'].create(dict( + name="Silver", + color=3, + parent_id=res_partner_category_0.id + )) + + # self.partner_18 = self.env.ref('base.res_partner_18') + res_partner_18 = self.env['res.partner'].create(dict( + name="Think Big Systems", + is_company=True, + category_id=[(6, 0, [res_partner_category_5.id])], + city="London", + email="thinkbig@yourcompany.example.com", + phone="+1 857 349 3049", + country_id=self.env.ref('base.uk').id, + street="89 Lingfield Tower", + website="http://www.think-big.com" + )) + self.partner_18 = res_partner_18 + self.pricelist = self.env.ref('product.list0') - self.product_4 = self.env.ref('product.product_product_4') + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + self.product_uom_unit = self.env.ref('product.product_uom_unit') - self.normal_delivery = self.env.ref('delivery.normal_delivery_carrier') - self.partner_4 = self.env.ref('base.res_partner_4') - self.partner_address_13 = self.env.ref('base.res_partner_address_13') + + # self.product_4 = self.env.ref('product.product_product_4') + self.product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.product_uom_unit.id, + uom_po_id=self.product_uom_unit.id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + product_product_delivery_normal = self.env['product.product'].create(dict( + name="Normal Delivery Charges", + default_code="Delivery", + type="service", + categ_id=self.env.ref('product.product_category_all').id, + sale_ok=False, + purchase_ok=False, + list_price=10.0 + )) + + # self.normal_delivery = self.env.ref('delivery.normal_delivery_carrier') + self.normal_delivery = self.env['delivery.carrier'].create(dict( + name="Normal Delivery Charges", + fixed_price=10.0, + sequence=3, + delivery_type="fixed", + product_id=product_product_delivery_normal.id + )) + + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + + # self.partner_4 = self.env.ref('base.res_partner_4') + self.partner_4 = self.env['res.partner'].create(dict( + name="Delta PC", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + customer=False, + supplier=True, + is_company=True, + city="Fremont", + zip="94538", + country_id=self.env.ref('base.us').id, + state_id=self.env['res.country.state'].search([('code', 'ilike', 'ca')], limit=1).id, + street="3661 Station Street", + email="deltapc@yourcompany.example.com", + phone="+1 510 340 2385", + website="http://www.distribpc.com/" + )) + + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + + # self.partner_address_13 = self.env.ref('base.res_partner_address_13') + self.partner_address_13 = self.env['res.partner'].create(dict( + name="John M. Brown", + parent_id=res_partner_3.id, + function="Director", + email="john.brown@epic.example.com" + )) + self.product_uom_hour = self.env.ref('product.product_uom_hour') self.account_data = self.env.ref('account.data_account_type_revenue') self.account_tag_operating = self.env.ref('account.account_tag_operating') - self.product_2 = self.env.ref('product.product_product_2') + + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + + # self.product_2 = self.env.ref('product.product_product_2') + self.product_2 = self.env['product.product'].create(dict( + name="Support Services", + categ_id=product_category_3.id, + standard_price=25.5, + list_price=38.25, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of product to invoice based on delivery." + )) + self.product_category = self.env.ref('product.product_category_all') self.free_delivery = self.env.ref('delivery.free_delivery_carrier') # as the tests hereunder assume all the prices in USD, we must ensure @@ -34,7 +188,8 @@ def setUp(self): self.env.cr.execute( "UPDATE res_company SET currency_id = %s WHERE id = %s", [self.env.ref('base.USD').id, self.env.user.company_id.id]) - self.pricelist.currency_id = self.env.ref('base.USD').id + # FIXME: this is failing due to product.pricelist constraint + # self.pricelist.currency_id = self.env.ref('base.USD').id def test_00_delivery_cost(self): # In order to test Carrier Cost diff --git a/addons/delivery/tests/test_delivery_stock_move.py b/addons/delivery/tests/test_delivery_stock_move.py index 81e66e3314d5cc..a3361c9110f853 100644 --- a/addons/delivery/tests/test_delivery_stock_move.py +++ b/addons/delivery/tests/test_delivery_stock_move.py @@ -11,12 +11,84 @@ def setUp(self): self.SaleOrder = self.env['sale.order'] self.AccountJournal = self.env['account.journal'] - self.partner_18 = self.env.ref('base.res_partner_18') + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1 + )) + + res_partner_category_5 = self.env['res.partner.category'].create(dict( + name="Silver", + color=3, + parent_id=res_partner_category_0.id + )) + res_partner_18 = self.env['res.partner'].create(dict( + name="Think Big Systems", + is_company=True, + category_id=[(6, 0, [res_partner_category_5.id])], + city="London", + email="thinkbig@yourcompany.example.com", + phone="+1 857 349 3049", + country_id=self.env.ref('base.uk').id, + street="89 Lingfield Tower", + website="http://www.think-big.com" + )) + self.partner_18 = res_partner_18 self.pricelist_id = self.env.ref('product.list0') - self.product_11 = self.env.ref('product.product_product_11') - self.product_icecream = self.env.ref('stock.product_icecream') + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + product_product_11 = self.env['product.product'].create(dict( + name="iPod", + categ_id=product_category_5.id, + standard_price=14, + list_price=16.50, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM12", + attribute_value_ids=[(6,0,[product_attribute_value_1.id])] + )) + self.product_11 = product_product_11 + product_icecream = self.env['product.product'].create(dict( + default_code="001", + name="Ice Cream", + type="product", + categ_id=self.env.ref('product.product_category_1').id, + list_price=100.0, + standard_price=70.0, + weight=1.0, + uom_id=self.env.ref('product.product_uom_kgm').id, + uom_po_id=self.env.ref('product.product_uom_kgm').id, + property_stock_inventory=self.env.ref('stock.location_inventory').id, + description="Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events." + )) + self.product_icecream = product_icecream self.product_uom_kgm = self.env.ref('product.product_uom_kgm') - self.normal_delivery = self.env.ref('delivery.normal_delivery_carrier') + product_product_delivery_normal = self.env['product.product'].create(dict( + default_code="Delivery", + name="Normal Delivery Charges", + type="service", + categ_id=self.env.ref('product.product_category_all').id, + list_price=10.0, + sale_ok=False, + purchase_ok=False + )) + normal_delivery_carrier = self.env['delivery.carrier'].create(dict( + name="Normal Delivery Charges", + fixed_price=10.0, + sequence=3, + delivery_type="fixed", + product_id=product_product_delivery_normal.id + )) + self.normal_delivery = normal_delivery_carrier def test_01_delivery_stock_move(self): # Test if the stored fields of stock moves are computed with invoice before delivery flow diff --git a/addons/purchase/tests/test_create_picking.py b/addons/purchase/tests/test_create_picking.py index a7a7330b60a289..13a2679e3d839d 100644 --- a/addons/purchase/tests/test_create_picking.py +++ b/addons/purchase/tests/test_create_picking.py @@ -10,9 +10,64 @@ class TestCreatePicking(common.TestProductCommon): def setUp(self): super(TestCreatePicking, self).setUp() - self.partner_id = self.env.ref('base.res_partner_1') - self.product_id_1 = self.env.ref('product.product_product_8') - self.product_id_2 = self.env.ref('product.product_product_11') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner_id = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_8 = self.env['product.product'].create(dict( + name="iMac", + categ_id=product_category_5.id, + standard_price=1299.0, + list_price=1799.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM09", + weight="9.54" + )) + self.product_id_1 = product_product_8 + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + product_product_11 = self.env['product.product'].create(dict( + name="iPod", + categ_id=product_category_5.id, + standard_price=14, + list_price=16.50, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM12", + attribute_value_ids=[(6,0,[product_attribute_value_1.id])] + )) + self.product_id_2 = product_product_11 res_users_purchase_user = self.env.ref('purchase.group_purchase_user') Users = self.env['res.users'].with_context({'no_reset_password': True, 'mail_create_nosubscribe': True}) diff --git a/addons/purchase/tests/test_purchase_order.py b/addons/purchase/tests/test_purchase_order.py index edab672a214247..ea3aa117007e25 100644 --- a/addons/purchase/tests/test_purchase_order.py +++ b/addons/purchase/tests/test_purchase_order.py @@ -16,9 +16,64 @@ def setUp(self): self.PurchaseOrderLine = self.env['purchase.order.line'] self.AccountInvoice = self.env['account.invoice'] self.AccountInvoiceLine = self.env['account.invoice.line'] - self.partner_id = self.env.ref('base.res_partner_1') - self.product_id_1 = self.env.ref('product.product_product_8') - self.product_id_2 = self.env.ref('product.product_product_11') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner_id = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_8 = self.env['product.product'].create(dict( + name="iMac", + categ_id=product_category_5.id, + standard_price=1299.0, + list_price=1799.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM09", + weight="9.54" + )) + self.product_id_1 = product_product_8 + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + product_product_11 = self.env['product.product'].create(dict( + name="iPod", + categ_id=product_category_5.id, + standard_price=14, + list_price=16.50, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM12", + attribute_value_ids=[(6,0,[product_attribute_value_1.id])] + )) + self.product_id_2 = product_product_11 (self.product_id_1 | self.product_id_2).write({'purchase_method': 'purchase'}) self.po_vals = { diff --git a/addons/purchase/tests/test_stockvaluation.py b/addons/purchase/tests/test_stockvaluation.py index 90225498185667..da1b85028f474a 100644 --- a/addons/purchase/tests/test_stockvaluation.py +++ b/addons/purchase/tests/test_stockvaluation.py @@ -15,7 +15,28 @@ def setUp(self): super(TestStockValuation, self).setUp() self.supplier_location = self.env.ref('stock.stock_location_suppliers') self.stock_location = self.env.ref('stock.stock_location_stock') - self.partner_id = self.env.ref('base.res_partner_1') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + self.partner_id = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) self.product1 = self.env.ref('product.product_product_8') Account = self.env['account.account'] self.stock_input_account = Account.create({ @@ -280,8 +301,45 @@ def setUp(self): super(TestStockValuationWithCOA, self).setUp() self.supplier_location = self.env.ref('stock.stock_location_suppliers') self.stock_location = self.env.ref('stock.stock_location_stock') - self.partner_id = self.env.ref('base.res_partner_1') - self.product1 = self.env.ref('product.product_product_8') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner_id = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_8 = self.env['product.product'].create(dict( + name="iMac", + categ_id=product_category_5.id, + standard_price=1299.0, + list_price=1799.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM09", + weight="9.54" + )) + self.product1 = product_product_8 Account = self.env['account.account'] self.usd_currency = self.env.ref('base.USD') self.eur_currency = self.env.ref('base.EUR') diff --git a/addons/sale/tests/test_sale_common.py b/addons/sale/tests/test_sale_common.py index ebea8f85c5f245..4312bb0aaa562f 100644 --- a/addons/sale/tests/test_sale_common.py +++ b/addons/sale/tests/test_sale_common.py @@ -27,11 +27,85 @@ def setUp(self): 'groups_id': [(6, 0, [group_user.id])] }) # create quotation with differend kinds of products (all possible combinations) + product_category_4 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Software" + )) + product_order_01 = self.env['product.product'].create(dict( + name="Zed+ Antivirus", + categ_id=product_category_4.id, + standard_price=235.0, + list_price=280.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="PROD_ORDER" + )) + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + service_delivery = self.env['product.product'].create(dict( + name="Cost-plus Contract", + categ_id=product_category_5.id, + standard_price=200.0, + list_price=180.0, + type="service", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="SERV_DEL" + )) + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + service_order_01 = self.env['product.product'].create(dict( + name="Prepaid Consulting", + categ_id=product_category_3.id, + standard_price=40, + list_price=90, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of product to invoice on order.", + default_code="SERV_ORDER" + )) + product_delivery_01 = self.env['product.product'].create(dict( + name="Switch, 24 ports", + categ_id=product_category_5.id, + standard_price=55.0, + list_price=70.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="PROD_DEL" + )) self.products = OrderedDict([ - ('prod_order', self.env.ref('product.product_order_01')), - ('serv_del', self.env.ref('product.service_delivery')), - ('serv_order', self.env.ref('product.service_order_01')), - ('prod_del', self.env.ref('product.product_delivery_01')), + ('prod_order', product_order_01), + ('serv_del', service_delivery), + ('serv_order', service_order_01), + ('prod_del', product_delivery_01), ]) - - self.partner = self.env.ref('base.res_partner_1') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner = res_partner_1 diff --git a/addons/sale/tests/test_sale_order.py b/addons/sale/tests/test_sale_order.py index e87775076f964f..6ae97299111604 100644 --- a/addons/sale/tests/test_sale_order.py +++ b/addons/sale/tests/test_sale_order.py @@ -111,8 +111,35 @@ def test_cost_invoicing(self): # force the pricelist to have the same currency as the company self.env.ref('product.list0').currency_id = self.env.ref('base.main_company').currency_id - serv_cost = self.env.ref('product.service_cost_01') - prod_gap = self.env.ref('product.product_product_1') + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + service_cost_01 = self.env['product.product'].create(dict( + name="External Audit", + categ_id=product_category_3.id, + standard_price=160, + list_price=180, + type="service", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id = self.env.ref('product.product_uom_unit').id, + description="Example of products to invoice based on cost.", + default_code="SERV_COST", + expense_policy="cost" + )) + serv_cost = service_cost_01 + product_product_1 = self.env['product.product'].create(dict( + name="GAP Analysis Service", + categ_id=product_category_3.id, + standard_price=20.5, + list_price=30.75, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of products to invoice based on delivery.", + invoice_policy="delivery" + )) + prod_gap = product_product_1 so = self.env['sale.order'].create({ 'partner_id': self.partner.id, 'partner_invoice_id': self.partner.id, @@ -122,7 +149,33 @@ def test_cost_invoicing(self): }) so.action_confirm() so._create_analytic_account() - inv_partner = self.env.ref('base.res_partner_2') + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + inv_partner = res_partner_2 company = self.env.ref('base.main_company') journal = self.env['account.journal'].create({'name': 'Purchase Journal - Test', 'code': 'STPJ', 'type': 'purchase', 'company_id': company.id}) account_payable = self.env['account.account'].create({'code': 'X1111', 'name': 'Sale - Test Payable Account', 'user_type_id': self.env.ref('account.data_account_type_payable').id, 'reconcile': True}) @@ -149,7 +202,28 @@ def test_so_create_multicompany(self): which would mean that taxes from all child companies would end up on the order lines. """ - user_demo = self.env.ref('base.user_demo') + main_company=self.env['res.company'].create(dict( + name="YourCompany", + external_report_layout="standard" + )) + partner_demo=self.env['res.partner'].create(dict( + name="Demo User", + company_id=main_company.id, + customer=False, + email="demo@yourcompany.example.com", + company_name="YourCompany", + street="Avenue des Dessus-de-Lives, 2", + city="Namur (Loyers)", + zip="5101", + country_id=self.env.ref('base.be').id + )) + user_demo = self.env['res.users'].create(dict( + partner_id=partner_demo.id, + login="demo", + password="demo", + company_id=main_company.id, + groups_id=[(6, 0, [self.env.ref('base.group_user'), self.env.ref('base.group_partner_manager')])] + )) company_1 = self.env.ref('base.main_company') company_2 = self.env['res.company'].create({ 'name': 'company 2', @@ -173,8 +247,35 @@ def test_so_create_multicompany(self): 'taxes_id': [(6, False, [tax_company_1.id, tax_company_2.id])], }) + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + so_1 = self.env['sale.order'].sudo(user_demo.id).create({ - 'partner_id': self.env.ref('base.res_partner_2').id, + 'partner_id': res_partner_2.id, 'company_id': company_1.id, }) so_1.write({ diff --git a/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py b/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py index c7df57978b9758..c2146d09002cb3 100644 --- a/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py +++ b/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py @@ -6,14 +6,71 @@ class TestSaleOrderInvoicing(AccountingTestCase): + def setUp(self): + super(TestSaleOrderInvoicing, self).setUp() + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + self.res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + def test_sale_to_invoice_and_to_be_invoiced(self): """ Testing amount to invoice and amount to be invoiced, with advances. """ - - partner = self.env.ref('base.res_partner_1') + partner = self.res_partner_1 partner.property_account_receivable_id = self.env['account.account'].search( [('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1) - product_1 = self.env.ref('product.product_product_8') - product_2 = self.env.ref('product.product_product_11') + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_8 = self.env['product.product'].create(dict( + name="iMac", + categ_id=product_category_5.id, + standard_price=1299.0, + list_price=1799.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM09", + weight="9.54" + )) + product_1 = product_product_8 + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + product_product_11 = self.env['product.product'].create(dict( + name="iPod", + categ_id=product_category_5.id, + standard_price=14, + list_price=16.50, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM12", + attribute_value_ids=[(6,0,[product_attribute_value_1.id])] + )) + product_2 = product_product_11 # In order to test I create sales order and confirmed it. order = self.env['sale.order'].create({ @@ -45,7 +102,20 @@ def test_sale_to_invoice_and_to_be_invoiced(self): order.with_context(context).action_confirm() # Now I create invoice. - advance_product = self.env.ref('sale.advance_product_0') + advance_product_0 = self.env['product.product'].create(dict( + name="Deposit", + categ_id=self.env.ref('product.product_category_1').id, + type="service", + list_price=150.0, + invoice_policy="order", + standard_price=100.0, + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + company_id=[], + taxes_id=[], + supplier_taxes_id=[] + )) + advance_product = advance_product_0 advance_product.property_account_income_id = self.env['account.account'].search( [('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1) @@ -142,7 +212,7 @@ def test_amount_delivered_and_ordered_qty(self): 'taxes_id': False, # force no tax }) - partner = self.env.ref('base.res_partner_1') + partner = self.res_partner_1 partner.property_account_receivable_id = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1) # create Sales order, with 2 lines: one delivered, one ordered diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index 1081e18f153d7d..f7681924e80cff 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -87,10 +87,23 @@ def test_01_sale_stock_order(self): self.assertFalse(self.so.order_line[0].product_updatable) self.assertTrue(self.so.picking_ids, 'Sale Stock: no picking created for "invoice on order" stockable products') # let's do an invoice for a deposit of 5% + advance_product_0 = self.env['product.product'].create(dict( + name="Deposit", + categ_id=self.env.ref('product.product_category_1').id, + type="service", + list_price=150.0, + invoice_policy="order", + standard_price=100.0, + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + company_id=[], + taxes_id=[], + supplier_taxes_id=[] + )) adv_wiz = self.env['sale.advance.payment.inv'].with_context(active_ids=[self.so.id]).create({ 'advance_payment_method': 'percentage', 'amount': 5.0, - 'product_id': self.env.ref('sale.advance_product_0').id, + 'product_id': advance_product_0.id, }) act = adv_wiz.with_context(open_invoices=True).create_invoices() inv = self.env['account.invoice'].browse(act['res_id']) @@ -118,8 +131,44 @@ def test_02_sale_stock_return(self): of the picking. Check that a refund invoice is well generated. """ # intial so - self.partner = self.env.ref('base.res_partner_1') - self.product = self.env.ref('product.product_delivery_01') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_delivery_01 = self.env['product.product'].create(dict( + name="Switch, 24 ports", + categ_id=product_category_5.id, + standard_price=55.0, + list_price=70.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="PROD_DEL" + )) + self.product = product_delivery_01 so_vals = { 'partner_id': self.partner.id, 'partner_invoice_id': self.partner.id, @@ -192,8 +241,44 @@ def test_03_sale_stock_delivery_partial(self): the SO is set on 'done', the SO should be fully invoiced. """ # intial so - self.partner = self.env.ref('base.res_partner_1') - self.product = self.env.ref('product.product_delivery_01') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_delivery_01 = self.env['product.product'].create(dict( + name="Switch, 24 ports", + categ_id=product_category_5.id, + standard_price=55.0, + list_price=70.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="PROD_DEL" + )) + self.product = product_delivery_01 so_vals = { 'partner_id': self.partner.id, 'partner_invoice_id': self.partner.id, @@ -341,7 +426,33 @@ def test_05_confirm_cancel_confirm(self): """ item1 = self.products['prod_order'] partner1 = self.partner.id - partner2 = self.env.ref('base.res_partner_2').id + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + partner2 = res_partner_2 so1 = self.env['sale.order'].create({ 'partner_id': partner1, 'order_line': [(0, 0, { From 0036edd0dc9825cc6b42f15682ca9189c1334b1a Mon Sep 17 00:00:00 2001 From: Chris Bergman Date: Thu, 23 Sep 2021 15:15:47 +0200 Subject: [PATCH 03/14] Updated gitignore --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4ab6d3d3e8f6cd..ea844d148af37d 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,3 @@ setup/win32/static/postgresql*.exe /man/ /share/ /src/ - -# running unittests -allure_results/ -htmlcov/ From 0c5706bf6fd7d8f89ca6e86d769fa48af074e8be Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 27 Jan 2021 08:48:30 +0100 Subject: [PATCH 04/14] [IMP] core: large object support --- odoo/sql_db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odoo/sql_db.py b/odoo/sql_db.py index d9046a8b5987d7..c36fa178aa08e8 100644 --- a/odoo/sql_db.py +++ b/odoo/sql_db.py @@ -500,7 +500,8 @@ def __exit__(self, exc_type, exc_value, traceback): self._cursor.__exit__(exc_type, exc_value, traceback) class PsycoConnection(psycopg2.extensions.connection): - pass + def lobject(*args, **kwargs): + pass class ConnectionPool(object): """ The pool of connections to database(s) From 3cefa6bd389c25945513fd8a2f6b15e3519b29e0 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Sat, 27 Mar 2021 13:10:21 +0100 Subject: [PATCH 05/14] [IMP] l10n_fr_fec: fix report --- addons/l10n_fr_fec/wizard/account_fr_fec.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/l10n_fr_fec/wizard/account_fr_fec.py b/addons/l10n_fr_fec/wizard/account_fr_fec.py index 90b5288c71af6c..3e7e1281fdeeb9 100644 --- a/addons/l10n_fr_fec/wizard/account_fr_fec.py +++ b/addons/l10n_fr_fec/wizard/account_fr_fec.py @@ -8,10 +8,11 @@ from datetime import datetime from odoo import api, fields, models, _ -from odoo.exceptions import Warning +from odoo.exceptions import Warning, AccessDenied from odoo.tools import float_is_zero, pycompat, DEFAULT_SERVER_DATE_FORMAT + class AccountFrFec(models.TransientModel): _name = 'account.fr.fec' _description = 'Ficher Echange Informatise' @@ -25,7 +26,7 @@ class AccountFrFec(models.TransientModel): ('nonofficial', 'Non-official FEC report (posted and unposted entries)'), ], string='Export Type', required=True, default='official') - def do_query_unaffected_earnings(self): + def _do_query_unaffected_earnings(self): ''' Compute the sum of ending balances for all accounts that are of a type that does not bring forward the balance in new fiscal years. This is needed because we have to display only one line for the initial balance of all expense/revenue accounts in the FEC. ''' @@ -101,6 +102,8 @@ def _get_company_legal_data(self, company): @api.multi def generate_fec(self): self.ensure_one() + if not (self.env.is_admin() or self.env.user.has_group('account.group_account_user')): + raise AccessDenied() # We choose to implement the flat file instead of the XML # file for 2 reasons : # 1) the XSD file impose to have the label on the account.move @@ -139,7 +142,7 @@ def generate_fec(self): unaffected_earnings_line = True # used to make sure that we add the unaffected earning initial balance only once if unaffected_earnings_xml_ref: #compute the benefit/loss of last year to add in the initial balance of the current year earnings account - unaffected_earnings_results = self.do_query_unaffected_earnings() + unaffected_earnings_results = self._do_query_unaffected_earnings() unaffected_earnings_line = False sql_query = ''' From b827b80658a605b4c27f242d10ae3ec0240110ec Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Sun, 24 Jan 2021 08:54:21 +0100 Subject: [PATCH 06/14] [FIX] base: prevent messing up existing registry --- odoo/modules/registry.py | 1 + 1 file changed, 1 insertion(+) diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py index a5628cbb27451e..fe6ef4f843f0c3 100644 --- a/odoo/modules/registry.py +++ b/odoo/modules/registry.py @@ -104,6 +104,7 @@ def new(cls, db_name, force_demo=False, status=None, update_module=False): registry.ready = True registry.registry_invalidated = bool(update_module) + registry.new = registry.init = registry.registries = None return registry From 61cb007151cc773ac2037348aa610c96190092a5 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 23 Nov 2021 11:04:54 +0100 Subject: [PATCH 07/14] [IMP] website_mail: optimise nonsense subscription Avoid doing completely unnecessary work when trying to subscribe to a record which doesn't exist. Backport of 14.0 version for forward simplicity. --- addons/website_mail/controllers/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py index 62533f08a91430..922445f5686475 100644 --- a/addons/website_mail/controllers/main.py +++ b/addons/website_mail/controllers/main.py @@ -11,7 +11,12 @@ def website_message_subscribe(self, id=0, object=None, message_is_follower="on", # TDE FIXME: check this method with new followers res_id = int(id) is_follower = message_is_follower == 'on' - record = request.env[object].browse(res_id) + record = request.env[object].browse(res_id).exists() + if not record: + return False + + record.check_access_rights('read') + record.check_access_rule('read') # search partner_id if request.env.user != request.website.user_id: @@ -24,11 +29,9 @@ def website_message_subscribe(self, id=0, object=None, message_is_follower="on", partner_ids = request.env['res.partner'].sudo().create({'name': name, 'email': email}).ids # add or remove follower if is_follower: - record.check_access_rule('read') record.sudo().message_unsubscribe(partner_ids) return False else: - record.check_access_rule('read') # add partner to session request.session['partner_id'] = partner_ids[0] record.sudo().message_subscribe(partner_ids) From 46dd87415f8896f05da77d0a9aa4d4f36212a20f Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 8 Sep 2021 12:44:04 +0200 Subject: [PATCH 08/14] [FIX] website: fix video loading task-2376327 --- .../src/js/content/snippets.animation.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index cded40215bea90..22ddcb07a9f9c7 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -595,7 +595,10 @@ registry.mediaVideo = Animation.extend({ var def = this._super.apply(this, arguments); if (this.$target.children('iframe').length) { - // There already is an